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 FrmEditCollegeInfo : Form
    {
        public FrmEditCollegeInfo(String collegeNumber,FrmQueryCollegeInfo frmQueryCollegeInfo)
        {
            InitializeComponent();
            this.collegeNumber = collegeNumber;
            this.frmQueryCollegeInfo = frmQueryCollegeInfo;
        }
        private CollegeInfo collegeInfo;
        private String collegeNumber;
        private FrmQueryCollegeInfo frmQueryCollegeInfo;
        private void Btn_Update_Click(object sender, EventArgs e)
        { 
            if (this.txt_collegeName.Text == "")
            {
                MessageBox.Show("学院名称输入不能为空!");
                this.txt_collegeName.Focus();
                return;
            }
            collegeInfo.collegeName = this.txt_collegeName.Text; //学院名称
            collegeInfo.collegeBirthDate = this.dtp_collegeBirthDate.Value;
            collegeInfo.collegeMan = this.txt_collegeMan.Text;  //院长姓名
            collegeInfo.collegeTelephone = this.txt_collegeTelephone.Text;  //联系电话
            collegeInfo.collegeMemo = this.txt_collegeMemo.Text;  //附加信息
            if (BLL.bllCollegeInfo.EditCollegeInfo(collegeInfo))
                MessageBox.Show("学院信息更新成功!");
            else
                MessageBox.Show("学院信息更新失败!");
            frmQueryCollegeInfo.BindData("refresh");
            this.Close(); 
        }

        private void FrmEditCollegeInfo_Load(object sender, EventArgs e)
        {
            collegeInfo = BLL.bllCollegeInfo.getSomeCollegeInfo(collegeNumber);
            this.txt_collegeNumber.ReadOnly = true;
            this.txt_collegeNumber.Text = collegeInfo.collegeNumber;
            this.txt_collegeName.Text = collegeInfo.collegeName;
            this.dtp_collegeBirthDate.Value = collegeInfo.collegeBirthDate;
            this.txt_collegeMan.Text = collegeInfo.collegeMan;
            this.txt_collegeTelephone.Text = collegeInfo.collegeTelephone;
            this.txt_collegeMemo.Text = collegeInfo.collegeMemo;
        }
    }
}
