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 FrmEditSpecialFieldInfo : Form
    {
        public FrmEditSpecialFieldInfo(String specialFieldNumber,FrmQuerySpecialFieldInfo frmQuerySpecialFieldInfo)
        {
            InitializeComponent();
            this.specialFieldNumber = specialFieldNumber;
            this.frmQuerySpecialFieldInfo = frmQuerySpecialFieldInfo;
        }
        private SpecialFieldInfo specialFieldInfo;
        private String specialFieldNumber;
        private FrmQuerySpecialFieldInfo frmQuerySpecialFieldInfo;
        private void Btn_Update_Click(object sender, EventArgs e)
        { 
            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.EditSpecialFieldInfo(specialFieldInfo))
                MessageBox.Show("专业信息更新成功!");
            else
                MessageBox.Show("专业信息更新失败!");
            frmQuerySpecialFieldInfo.BindData("refresh");
            this.Close(); 
        }

        private void FrmEditSpecialFieldInfo_Load(object sender, EventArgs e)
        {
            specialFieldInfo = BLL.bllSpecialFieldInfo.getSomeSpecialFieldInfo(specialFieldNumber);
            //查询所有的学院信息
            DataSet collegeInfoDs = BLL.bllCollegeInfo.getAllCollegeInfo();
            this.cb_specialCollegeNumber.DataSource = collegeInfoDs.Tables[0];
            this.cb_specialCollegeNumber.DisplayMember = "collegeName";
            this.cb_specialCollegeNumber.ValueMember = "collegeNumber";
            this.cb_specialCollegeNumber.SelectedValue = specialFieldInfo.specialCollegeNumber.ToString();
            this.txt_specialFieldNumber.ReadOnly = true;
            this.txt_specialFieldNumber.Text = specialFieldInfo.specialFieldNumber;
            this.txt_specialFieldName.Text = specialFieldInfo.specialFieldName;
            this.dtp_specialBirthDate.Value = specialFieldInfo.specialBirthDate;
            this.txt_specialMan.Text = specialFieldInfo.specialMan;
            this.txt_specialTelephone.Text = specialFieldInfo.specialTelephone;
            this.txt_specialMemo.Text = specialFieldInfo.specialMemo;
        }
    }
}
