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 FrmEditStudentSelectCourseInfo : Form
    {
        public FrmEditStudentSelectCourseInfo(int selectId,FrmQueryStudentSelectCourseInfo frmQueryStudentSelectCourseInfo)
        {
            InitializeComponent();
            this.selectId = selectId;
            this.frmQueryStudentSelectCourseInfo = frmQueryStudentSelectCourseInfo;
        }
        private StudentSelectCourseInfo studentSelectCourseInfo;
        private int selectId;
        private FrmQueryStudentSelectCourseInfo frmQueryStudentSelectCourseInfo;
        private void Btn_Update_Click(object sender, EventArgs e)
        { 
            studentSelectCourseInfo.studentNumber = this.cb_studentNumber.SelectedValue.ToString(); //学生对象
            studentSelectCourseInfo.courseNumber = this.cb_courseNumber.SelectedValue.ToString(); //课程对象
            if (BLL.bllStudentSelectCourseInfo.EditStudentSelectCourseInfo(studentSelectCourseInfo))
                MessageBox.Show("选课信息更新成功!");
            else
                MessageBox.Show("选课信息更新失败!");
            frmQueryStudentSelectCourseInfo.BindData("refresh");
            this.Close(); 
        }

        private void FrmEditStudentSelectCourseInfo_Load(object sender, EventArgs e)
        {
            studentSelectCourseInfo = BLL.bllStudentSelectCourseInfo.getSomeStudentSelectCourseInfo(selectId);
            //查询所有的学生信息
            DataSet student_QQ287307421Ds = BLL.bllStudent_QQ287307421.getAllStudent_QQ287307421();
            this.cb_studentNumber.DataSource = student_QQ287307421Ds.Tables[0];
            this.cb_studentNumber.DisplayMember = "studentName";
            this.cb_studentNumber.ValueMember = "studentNumber";
            this.cb_studentNumber.SelectedValue = studentSelectCourseInfo.studentNumber.ToString();
            //查询所有的课程信息
            DataSet courseInfo_QQ254540457Ds = BLL.bllCourseInfo_QQ254540457.getAllCourseInfo_QQ254540457();
            this.cb_courseNumber.DataSource = courseInfo_QQ254540457Ds.Tables[0];
            this.cb_courseNumber.DisplayMember = "courseName";
            this.cb_courseNumber.ValueMember = "courseNumber";
            this.cb_courseNumber.SelectedValue = studentSelectCourseInfo.courseNumber.ToString();
            this.txt_selectId.ReadOnly = true;
            this.txt_selectId.Text = studentSelectCourseInfo.selectId.ToString();
        }
    }
}
