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

        private SpecialFieldInfo specialFieldInfo = new SpecialFieldInfo();
        private void Btn_Add_Click(object sender, EventArgs e)
        {
            if (this.txt_specialFieldNumber.Text == "")
            {
                MessageBox.Show("专业编号输入不能为空!");
                this.txt_specialFieldNumber.Focus();
                return;
            }
            specialFieldInfo.specialFieldNumber = this.txt_specialFieldNumber.Text;  //专业编号
            if (this.txt_specialFieldName.Text == "")
            {
                MessageBox.Show("专业名称输入不能为空!");
                this.txt_specialFieldName.Focus();
                return;
            }
            specialFieldInfo.specialFieldName = this.txt_specialFieldName.Text; //专业名称
            specialFieldInfo.specialCollegeNumber = this.cb_specialCollegeNumber.SelectedValue.ToString(); //所在学院
            specialFieldInfo.specialBirthDate = this.dtp_specialBirthDate.Value;
            specialFieldInfo.specialMan = this.txt_specialMan.Text;  //联系人
            specialFieldInfo.specialTelephone = this.txt_specialTelephone.Text;  //联系电话
            specialFieldInfo.specialMemo = this.txt_specialMemo.Text;  //附加信息
            if (BLL.bllSpecialFieldInfo.AddSpecialFieldInfo(specialFieldInfo))
                MessageBox.Show("专业信息添加成功!");
            else
                MessageBox.Show("专业信息添加失败!");
            this.Close(); 
        }

        private void FrmAddSpecialFieldInfo_Load(object sender, EventArgs e)
        {
            //查询所有的学院信息
            DataSet collegeInfoDs = BLL.bllCollegeInfo.getAllCollegeInfo();
            this.cb_specialCollegeNumber.DataSource = collegeInfoDs.Tables[0];
            this.cb_specialCollegeNumber.DisplayMember = "collegeName";
            this.cb_specialCollegeNumber.ValueMember = "collegeNumber";
        }
    }
}
