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 FrmEditCourseInfo_QQ254540457 : Form
    {
        public FrmEditCourseInfo_QQ254540457(String courseNumber,FrmQueryCourseInfo_QQ254540457 frmQueryCourseInfo_QQ254540457)
        {
            InitializeComponent();
            this.courseNumber = courseNumber;
            this.frmQueryCourseInfo_QQ254540457 = frmQueryCourseInfo_QQ254540457;
        }
        private CourseInfo_QQ254540457 courseInfo_QQ254540457;
        private String courseNumber;
        private FrmQueryCourseInfo_QQ254540457 frmQueryCourseInfo_QQ254540457;
        private void Btn_Update_Click(object sender, EventArgs e)
        { 
            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.EditCourseInfo_QQ254540457(courseInfo_QQ254540457))
                MessageBox.Show("课程信息更新成功!");
            else
                MessageBox.Show("课程信息更新失败!");
            frmQueryCourseInfo_QQ254540457.BindData("refresh");
            this.Close(); 
        }

        private void FrmEditCourseInfo_QQ254540457_Load(object sender, EventArgs e)
        {
            courseInfo_QQ254540457 = BLL.bllCourseInfo_QQ254540457.getSomeCourseInfo_QQ254540457(courseNumber);
            //查询所有的教师信息
            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";
            this.cb_courseTeacher.SelectedValue = courseInfo_QQ254540457.courseTeacher.ToString();
            this.txt_courseNumber.ReadOnly = true;
            this.txt_courseNumber.Text = courseInfo_QQ254540457.courseNumber;
            this.txt_courseName.Text = courseInfo_QQ254540457.courseName;
            this.txt_courseTime.Text = courseInfo_QQ254540457.courseTime;
            this.txt_coursePlace.Text = courseInfo_QQ254540457.coursePlace;
            this.txt_courseScore.Text = courseInfo_QQ254540457.courseScore.ToString();
            this.txt_courseMemo.Text = courseInfo_QQ254540457.courseMemo;
        }
    }
}
