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 FrmEditScoreInfo : Form
    {
        public FrmEditScoreInfo(int scoreId,FrmQueryScoreInfo frmQueryScoreInfo)
        {
            InitializeComponent();
            this.scoreId = scoreId;
            this.frmQueryScoreInfo = frmQueryScoreInfo;
        }
        private ScoreInfo scoreInfo;
        private int scoreId;
        private FrmQueryScoreInfo frmQueryScoreInfo;
        private void Btn_Update_Click(object sender, EventArgs e)
        { 
            scoreInfo.studentNumber = this.cb_studentNumber.SelectedValue.ToString(); //学生对象
            scoreInfo.courseNumber = this.cb_courseNumber.SelectedValue.ToString(); //课程对象
            try
            {
                scoreInfo.scoreValue = Convert.ToSingle(this.txt_scoreValue.Text);  //成绩得分
            }
            catch
            {
                MessageBox.Show("成绩得分请输入正确的格式!");
                this.txt_scoreValue.SelectAll();
                this.txt_scoreValue.Focus();
                return;
            }
            scoreInfo.studentEvaluate = this.txt_studentEvaluate.Text;  //学生评价
            if (BLL.bllScoreInfo.EditScoreInfo(scoreInfo))
                MessageBox.Show("成绩信息更新成功!");
            else
                MessageBox.Show("成绩信息更新失败!");
            frmQueryScoreInfo.BindData("refresh");
            this.Close(); 
        }

        private void FrmEditScoreInfo_Load(object sender, EventArgs e)
        {
            scoreInfo = BLL.bllScoreInfo.getSomeScoreInfo(scoreId);
            //查询所有的学生信息
            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 = scoreInfo.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 = scoreInfo.courseNumber.ToString();
            this.txt_scoreId.ReadOnly = true;
            this.txt_scoreId.Text = scoreInfo.scoreId.ToString();
            this.txt_scoreValue.Text = scoreInfo.scoreValue.ToString();
            this.txt_studentEvaluate.Text = scoreInfo.studentEvaluate;
        }
    }
}
