private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     //Semester Id validation
     if (clsValidation.ValidateForEmptiness(TxtSemesterId.Text) == false)
     {
         MessageBox.Show("Semester id is required");
     }
     else if (clsValidation.ValidateForNumeric(TxtSemesterId.Text) == false)
     {
         MessageBox.Show("Semester id is not a number");
     }
     else if (clsValidation.ValidateForLength(TxtSemesterId.Text, 5) == false)
     {
         MessageBox.Show("Semester id is not 5 digits");
     }
     //Semester Name validation
     else if (clsValidation.ValidateForEmptiness(TxtSemesterName.Text) == false)
     {
         MessageBox.Show("Semester name is required");
     }
     //Semester Duration validation
     else if (clsValidation.ValidateForEmptiness(TxtSemesterDuration.Text) == false)
     {
         MessageBox.Show("Semester duration is required");
     }
     else
     {
         int         Year              = DatePickerSemesterStartDate.SelectedDate.Value.Year;
         int         Month             = DatePickerSemesterStartDate.SelectedDate.Value.Month;
         int         Day               = DatePickerSemesterStartDate.SelectedDate.Value.Day;
         DateTime    SemesterStartDate = new DateTime(Year, Month, Day);
         clsSemester ObjSemester       = new clsSemester(int.Parse(TxtSemesterId.Text), TxtSemesterName.Text, SemesterStartDate, int.Parse(TxtSemesterDuration.Text));
         int         Semesterid        = ObjSemester.AddSemester();
         if (Semesterid == -1)
         {
             MessageBox.Show("Can't add this semester");
         }
         else
         {
             TxtSemesterId.Text = Semesterid.ToString();
         }
     }
 }
 private void btnDelete_Click(object sender, RoutedEventArgs e)
 {
     //Semester Id validation
     if (clsValidation.ValidateForEmptiness(TxtSemesterId.Text) == false)
     {
         MessageBox.Show("Semester id is required");
     }
     else if (clsValidation.ValidateForNumeric(TxtSemesterId.Text) == false)
     {
         MessageBox.Show("Semester id is not a number");
     }
     else if (clsValidation.ValidateForLength(TxtSemesterId.Text, 5) == false)
     {
         MessageBox.Show("Semester id is not 5 digits");
     }
     else
     {
         clsSemester ObjSemester = new clsSemester();
         ObjSemester.SemesterId = int.Parse(TxtSemesterId.Text);
         ObjSemester.DeleteSemester();
     }
 }
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            //Semester Id validation
            if (clsValidation.ValidateForEmptiness(TxtSemesterId.Text) == false)
            {
                MessageBox.Show("Semester id is required");
            }
            else if (clsValidation.ValidateForNumeric(TxtSemesterId.Text) == false)
            {
                MessageBox.Show("Semester id is not a number");
            }
            else if (clsValidation.ValidateForLength(TxtSemesterId.Text, 5) == false)
            {
                MessageBox.Show("Semester id is not 5 digits");
            }
            else
            {
                clsSemester ObjSemester = new clsSemester();
                ObjSemester.SemesterId = int.Parse(TxtSemesterId.Text);
                bool found = ObjSemester.SearchSemester();
                if (found)
                {
                    MessageBox.Show("Success to search this semester");
                    TxtSemesterId.Text               = ObjSemester.SemesterId.ToString();
                    TxtSemesterName.Text             = ObjSemester.SemesterName.ToString();
                    LabSemesterStartDate.Content     = ObjSemester.SemesterStartDate.ToString("dddd, dd MMMM yyyy");
                    DatePickerSemesterStartDate.Text = ObjSemester.SemesterStartDate.ToString("dd-MMMM-yyyy");
                    TxtSemesterDuration.Text         = ObjSemester.SemesterDuration.ToString();
                }
                else
                {
                    MessageBox.Show("This semester id does not exist");

                    TxtSemesterName.Text         = "";
                    TxtSemesterDuration.Text     = "";
                    LabSemesterStartDate.Content = "This semester id does not exist";
                }
            }
        }
 private void btnUpdata_Click(object sender, RoutedEventArgs e)
 {
     //Semester Id validation
     if (clsValidation.ValidateForEmptiness(TxtSemesterId.Text) == false)
     {
         MessageBox.Show("Semester id is required");
     }
     else if (clsValidation.ValidateForNumeric(TxtSemesterId.Text) == false)
     {
         MessageBox.Show("Semester id is not a number");
     }
     else if (clsValidation.ValidateForLength(TxtSemesterId.Text, 5) == false)
     {
         MessageBox.Show("Semester id is not 5 digits");
     }
     //Semester Name validation
     else if (clsValidation.ValidateForEmptiness(TxtSemesterName.Text) == false)
     {
         MessageBox.Show("Semester name is required");
     }
     //Semester Duration validation
     else if (clsValidation.ValidateForEmptiness(TxtSemesterDuration.Text) == false)
     {
         MessageBox.Show("Semester duration is required");
     }
     else
     {
         //clsTeacher objTeacher = new clsTeacher();
         //objTeacher.TeacherId = int.Parse(TxtTeacherId.Text);
         int         Year              = DatePickerSemesterStartDate.SelectedDate.Value.Year;
         int         Month             = DatePickerSemesterStartDate.SelectedDate.Value.Month;
         int         Day               = DatePickerSemesterStartDate.SelectedDate.Value.Day;
         DateTime    SemesterStartDate = new DateTime(Year, Month, Day);
         clsSemester ObjSemester       = new clsSemester(int.Parse(TxtSemesterId.Text), TxtSemesterName.Text, SemesterStartDate, int.Parse(TxtSemesterDuration.Text));
         Boolean     Flag              = ObjSemester.UpdateSemester();
     }
 }