using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

using Model;

namespace LoginFrame
{
    public partial class FrmAddCourseInfo_QQ254540457 : Form
    {
        public FrmAddCourseInfo_QQ254540457()
        {
            InitializeComponent();
        }

        private CourseInfo_QQ254540457 courseInfo_QQ254540457 = new CourseInfo_QQ254540457();
        private void Btn_Add_Click(object sender, EventArgs e)
        {
            if (this.txt_courseNumber.Text == "")
            {
                MessageBox.Show("课程编号输入不能为空!");
                this.txt_courseNumber.Focus();
                return;
            }
            courseInfo_QQ254540457.courseNumber = this.txt_courseNumber.Text;  //课程编号
            if (this.txt_courseName.Text == "")
            {
                MessageBox.Show("课程名称输入不能为空!");
                this.txt_courseName.Focus();
                return;
            }
            courseInfo_QQ254540457.courseName = this.txt_courseName.Text; //课程名称
            courseInfo_QQ254540457.courseTeacher = this.cb_courseTeacher.SelectedValue.ToString(); //上课老师
            courseInfo_QQ254540457.courseTime = this.txt_courseTime.Text;  //上课时间
            courseInfo_QQ254540457.coursePlace = this.txt_coursePlace.Text;  //上课地点
            try
            {
                courseInfo_QQ254540457.courseScore = Convert.ToSingle(this.txt_courseScore.Text);  //课程学分
            }
            catch
            {
                MessageBox.Show("课程学分请输入正确的格式!");
                this.txt_courseScore.SelectAll();
                this.txt_courseScore.Focus();
                return;
            }
            courseInfo_QQ254540457.courseMemo = this.txt_courseMemo.Text;  //附加信息
            if (BLL.bllCourseInfo_QQ254540457.AddCourseInfo_QQ254540457(courseInfo_QQ254540457))
                MessageBox.Show("课程信息添加成功!");
            else
                MessageBox.Show("课程信息添加失败!");
            this.Close(); 
        }

        private void FrmAddCourseInfo_QQ254540457_Load(object sender, EventArgs e)
        {
            //查询所有的教师信息
            DataSet teacher_QQ287307421Ds = BLL.bllTeacher_QQ287307421.getAllTeacher_QQ287307421();
            this.cb_courseTeacher.DataSource = teacher_QQ287307421Ds.Tables[0];
            this.cb_courseTeacher.DisplayMember = "teacherName";
            this.cb_courseTeacher.ValueMember = "teacherNumber";
        }
    }
}
