private void btnSave_Click(object sender, EventArgs e)
        {
            if (!validateStudent())
            {
                return;
            }
            string message = string.Empty;

            TheStudent.StudentID = Convert.ToInt32(textBoxID.Text);
            TheStudent.Name      = textBoxName.Text;
            TheStudent.Gender    = comboBoxGender.Text;
            TheStudent.Group     = comboBoxGroup.Text;
            TheStudent.Courses   = _courseList;

            try
            {
                if (TheStudent.SerialNo > 0)
                {
                    DALStudent.Update(TheStudent);
                }
                else
                {
                    DALStudent.Insert(TheStudent);
                }

                MessageBox.Show("Record Saved Successfully");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
 protected virtual bool DoStore()
 {
     try
     {
         DALStudent student = new DALStudent();
         if (cand != null)
         {
             student.Insert(cand);
         }
         return(true);
     }
     catch
     {
         ShowMsgBox(this, "数据库读写错误");
         return(false);
     }
 }