private void btnSearch_Click(object sender, RoutedEventArgs e)
 {
     //Student Id validation
     if (clsValidation.ValidateForEmptiness(TxtStudentId.Text) == false)
     {
         MessageBox.Show("Student id is required");
     }
     else if (clsValidation.ValidateForNumeric(TxtStudentId.Text) == false)
     {
         MessageBox.Show("Student id is not a number");
     }
     else if (clsValidation.ValidateForLength(TxtStudentId.Text, 5) == false)
     {
         MessageBox.Show("Student id is not 5 digits");
     }
     else
     {
         clsStudent ObjStudent = new clsStudent();
         ObjStudent.StudentId = int.Parse(TxtStudentId.Text);
         bool found = ObjStudent.SearchStudent();
         if (found)
         {
             MessageBox.Show("Success to search this Student");
             TxtStudentId.Text        = ObjStudent.StudentId.ToString();
             TxtPassword.Password     = ObjStudent.Password.ToString();
             TxtStudentName.Text      = ObjStudent.StudentName.ToString();
             LabStudentGender.Content = ObjStudent.StudentGender.ToString();
             if ("Male".Equals(ObjStudent.StudentGender))
             {
                 RadioMale.IsChecked = true;
             }
             else
             {
                 RadioFemale.IsChecked = true;
             }
             TxtStudentMobile.Text  = ObjStudent.StudentMobile.ToString();
             TxtStudentEmail.Text   = ObjStudent.StudentEmail.ToString();
             TxtStudentAddress.Text = ObjStudent.StudentAddress.ToString();
             //LabStudentDOB.Content = objStudent.StudentDOB.Year + "-" + objStudent.StudentDOB.Month + "-" + objStudent.StudentDOB.Day;
             LabStudentDOB.Content     = ObjStudent.StudentDOB.ToString("dddd, dd MMMM yyyy");
             DatePickerStudentDOB.Text = ObjStudent.StudentDOB.ToString("dd-MMMM-yyyy");
         }
         else
         {
             MessageBox.Show("This Student id does not exist");
             TxtStudentId.Text        = "";
             TxtPassword.Password     = "";
             TxtStudentName.Text      = "";
             RadioMale.IsChecked      = true;
             RadioMale.IsChecked      = false;
             LabStudentGender.Content = "";
             TxtStudentMobile.Text    = "";
             TxtStudentEmail.Text     = "";
             TxtStudentAddress.Text   = "";
             LabStudentDOB.Content    = "This Student id does not exist";
             //DatePickerStudentDOB.Text = objStudent.StudentDOB.ToString("dd-MMMM-yyyy");
         }
     }
 }
 private void btnDelete_Click(object sender, RoutedEventArgs e)
 {
     //Student Id validation
     if (clsValidation.ValidateForEmptiness(TxtStudentId.Text) == false)
     {
         MessageBox.Show("Student id is required");
     }
     else if (clsValidation.ValidateForNumeric(TxtStudentId.Text) == false)
     {
         MessageBox.Show("Student id is not a number");
     }
     else if (clsValidation.ValidateForLength(TxtStudentId.Text, 5) == false)
     {
         MessageBox.Show("Student id is not 5 digits");
     }
     else
     {
         clsStudent ObjStudent = new clsStudent();
         ObjStudent.StudentId = int.Parse(TxtStudentId.Text);
         ObjStudent.DeleteStudent();
     }
 }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            //Student Id validation
            if (clsValidation.ValidateForEmptiness(TxtStudentId.Text) == false)
            {
                MessageBox.Show("Student id is required");
            }
            else if (clsValidation.ValidateForNumeric(TxtStudentId.Text) == false)
            {
                MessageBox.Show("Student id is not a number");
            }
            else if (clsValidation.ValidateForLength(TxtStudentId.Text, 5) == false)
            {
                MessageBox.Show("Student id is not 5 digits");
            }
            //Student Name validation
            else if (clsValidation.ValidateForEmptiness(TxtStudentName.Text) == false)
            {
                MessageBox.Show("Student name is required");
            }
            //Student Password validation
            else if (clsValidation.ValidateForEmptiness(TxtPassword.Password) == false)
            {
                MessageBox.Show("Student password is required");
            }
            //Student Mobile validation
            else if (clsValidation.ValidateForEmptiness(TxtStudentMobile.Text) == false)
            {
                MessageBox.Show("Student mobile is required");
            }
            //Student Email validation
            else if (clsValidation.ValidateForEmptiness(TxtStudentEmail.Text) == false)
            {
                MessageBox.Show("Student email is required");
            }
            //Student Address validation
            else if (clsValidation.ValidateForEmptiness(TxtStudentAddress.Text) == false)
            {
                MessageBox.Show("Student address is required");
            }
            //Student DOB validation
            else if (clsValidation.ValidateForEmptiness(DatePickerStudentDOB.Text) == false)
            {
                MessageBox.Show("Student DOB is required");
            }
            else
            {
                String StudentGender = "";
                if (RadioMale.IsChecked == true)
                {
                    StudentGender = "Male";
                }
                else
                {
                    StudentGender = "Female";
                }

                int        Year       = DatePickerStudentDOB.SelectedDate.Value.Year;
                int        Month      = DatePickerStudentDOB.SelectedDate.Value.Month;
                int        Day        = DatePickerStudentDOB.SelectedDate.Value.Day;
                DateTime   StudentDOB = new DateTime(Year, Month, Day);
                clsStudent ObjStudent = new clsStudent(int.Parse(TxtStudentId.Text), TxtPassword.Password, TxtStudentName.Text, StudentGender, TxtStudentMobile.Text, TxtStudentEmail.Text, TxtStudentAddress.Text, StudentDOB);
                int        Studentid  = ObjStudent.AddStudent();
                if (Studentid == -1)
                {
                    MessageBox.Show("Can't add this Student");
                }
                else
                {
                    TxtStudentId.Text = Studentid.ToString();
                }
            }
        }