Beispiel #1
0
        /// <summary>
        /// 添加学生学科成绩
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddCchengj_Click(object sender, EventArgs e)
        {
            //int count = groupBox1.Controls.Count;
            //string score = "";
            //for (int i = 0; i < count; i++)
            //{
            //    UserControl1 user = (UserControl1)groupBox1.Controls[i];
            //    if (user.txtExamination.Text.Trim() == "")
            //    {
            //    score="0";
            //    }
            //    else
            //    {
            //        score = user.txtExamination.Text.Trim();
            //    }

            //    exammodel.StudentID = Convert.ToInt32(this.cmbName.SelectedValue);
            //    exammodel.SubjectsID =Convert.ToInt32( user.labSubjectName.Tag);
            //    exammodel.ExamScore =Convert.ToInt32( user.txtExamination.Text);
            //    examin.AddExamination(exammodel);
            int k = this.groupBox1.Controls.Count;
            List <ExaminationModel> list = new List <ExaminationModel>(k);

            for (int i = 0; i < k; i++)
            {
                ExaminationModel exa  = new ExaminationModel();
                UserControl1     user = (UserControl1)groupBox1.Controls[i];
                exa.SubjectsID = Convert.ToInt32(user.labSubjectName.Tag);
                exa.ExamScore  = int.Parse(user.txtExamination.Text.Trim());
                exa.StudentID  = int.Parse(this.labStuID.Text);
                list.Add(exa);
            }
            int count = examin.AddExamination(k, list);

            if (count == k)
            {
                BindGrade();
                MessageBox.Show("成绩添加成功");
            }
            else
            {
                MessageBox.Show("成绩添加失败");
            }
        }