Ejemplo n.º 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            currentStudent             = currentStudent ?? new StudentModel();
            currentStudent.StudentId   = int.Parse(maskedStdId.Text);
            currentStudent.StudentName = txtName.Text;
            currentStudent.Course      = cmbCourse.SelectedItem.ToString();
            currentStudent.Picture     = pbStudentImage.Image;


            if (rbFirst.Checked)
            {
                currentStudent.Year = 1;
            }

            if (rbSecond.Checked)
            {
                currentStudent.Year = 2;
            }
            if (rbThird.Checked)
            {
                currentStudent.Year = 3;
            }
            if (rbFour.Checked)
            {
                currentStudent.Year = 4;
            }

            bool updated = false;

            if (currentStudent.Id == 0)
            {
                updated = studentTable.InsertStudent(currentStudent);
            }
            else
            {
                updated = studentTable.UpdateStudent(currentStudent);
            }

            if (updated)
            {
                MessageBox.Show(" Information Added successfully...");
                resetForm();
            }
            else
            {
                MessageBox.Show("Some Error Occurred.");
            }
        }