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 FrmAddClassInfo : Form
    {
        public FrmAddClassInfo()
        {
            InitializeComponent();
        }

        private ClassInfo classInfo = new ClassInfo();
        private void Btn_Add_Click(object sender, EventArgs e)
        {
            if (this.txt_classNumber.Text == "")
            {
                MessageBox.Show("班级编号输入不能为空!");
                this.txt_classNumber.Focus();
                return;
            }
            classInfo.classNumber = this.txt_classNumber.Text;  //班级编号
            if (this.txt_className.Text == "")
            {
                MessageBox.Show("班级名称输入不能为空!");
                this.txt_className.Focus();
                return;
            }
            classInfo.className = this.txt_className.Text; //班级名称
            classInfo.classSpecialFieldNumber = this.cb_classSpecialFieldNumber.SelectedValue.ToString(); //所属专业
            classInfo.classBirthDate = this.dtp_classBirthDate.Value;
            classInfo.classTeacherCharge = this.txt_classTeacherCharge.Text;  //班主任
            classInfo.classTelephone = this.txt_classTelephone.Text;  //联系电话
            classInfo.classMemo = this.txt_classMemo.Text;  //附加信息
            if (BLL.bllClassInfo.AddClassInfo(classInfo))
                MessageBox.Show("班级信息添加成功!");
            else
                MessageBox.Show("班级信息添加失败!");
            this.Close(); 
        }

        private void FrmAddClassInfo_Load(object sender, EventArgs e)
        {
            //查询所有的专业信息
            DataSet specialFieldInfoDs = BLL.bllSpecialFieldInfo.getAllSpecialFieldInfo();
            this.cb_classSpecialFieldNumber.DataSource = specialFieldInfoDs.Tables[0];
            this.cb_classSpecialFieldNumber.DisplayMember = "specialFieldName";
            this.cb_classSpecialFieldNumber.ValueMember = "specialFieldNumber";
        }
    }
}
