// FOR SUBMIT BUTTON
 public void checkEmptyAndSave()
 {
     if (StudentNameText.Text.Length <= 2)
     {
         this.ShowMessageAsync("Empty", "Student Name Box is empty!");
         StudentNameText.Focus();
     }
     else if (DOBText.Text.Length < 8)
     {
         this.ShowMessageAsync("Empty or Missing", "DOB is empty!");
         DOBText.Focus();
     }
     else if (FatherCNICText.Text.Length <= 2)
     {
         this.ShowMessageAsync("Empty", "Father CNIC Box is empty!");
         FatherCNICText.Focus();
     }
     //else if (HomeAddressText.Text.Length <= 2)
     //{
     //    this.ShowMessageAsync("Empty", "Address Box is empty!");
     //    HomeAddressText.Focus();
     //}
     else if (EmergencyText.Text.Length <= 2)
     {
         this.ShowMessageAsync("Empty", "Mobile Number Box is empty!");
         EmergencyText.Focus();
     }
     else
     {
         saveNewStudent();
     }
 }
 public void clearAll()
 {
     formBay.Source = birthCertificate.Source = studentImage.Source = null;
     totalKids.Text = "";
     StudentNameText.Clear();
     PlaceOfBirthText.Clear();
     FirstLanguageText.Clear();
     FatherNameText.Clear();
     FatherCNICText.Clear();
     MotherNameText.Clear();
     MotherCNICText.Clear();
     HomeAddressText.Clear();
     PhoneText.Clear();
     EmergencyText.Clear();
     MobileText.Clear();
     FatherOccupationText.Clear();
     FatherDesignation.Clear();
     FatherAdress.Clear();
     MotherOccupationText.Clear();
     MotherDesignation.Clear();
     MotherAddress.Clear();
     GuardianNameText.Clear();
     RelationText.Clear();
     GuardianAddress.Clear();
     PreviousSchoolText.Clear();
     FromToText.Clear();
     ReasonText.Clear();
 }
 // FOR UPDATE BUTTON
 public void emptyBoxes()
 {
     if (StudentNameText.Text.Length <= 2)
     {
         this.ShowMessageAsync("Empty", "Student Name Box is empty!");
         StudentNameText.Focus();
     }
     else if (DOBText.Text.Length < 8)
     {
         this.ShowMessageAsync("Empty or Missing", "DOB is empty!");
         DOBText.Focus();
     }
     else if (FatherCNICText.Text.Length <= 2)
     {
         this.ShowMessageAsync("Empty", "Father CNIC Box is empty!");
         FatherCNICText.Focus();
     }
     //else if (HomeAddressText.Text.Length <= 2)
     //{
     //    this.ShowMessageAsync("Empty", "Address Box is empty!");
     //    HomeAddressText.Focus();
     //}
     else if (EmergencyText.Text.Length <= 2)
     {
         this.ShowMessageAsync("Empty", "Mobile Number Box is empty!");
         EmergencyText.Focus();
     }
     else
     {
         try
         {
             //3. Mark entity as modified
             context.Entry(search).State = System.Data.Entity.EntityState.Modified;
             context.SaveChanges();
             this.ShowMessageAsync("Student Updated", "Student updated successfully");
             clearAll();
             nextAdmission();
             UpdateButton.Visibility = Visibility.Hidden;
             SubmitButton.Visibility = Visibility.Visible;
             Grade.SelectedIndex     = 0;
             onLoad();
         }
         catch (DbEntityValidationException err)
         {
             foreach (var eve in err.EntityValidationErrors)
             {
                 Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                   eve.Entry.Entity.GetType().Name, eve.Entry.State);
                 foreach (var ve in eve.ValidationErrors)
                 {
                     Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                       ve.PropertyName, ve.ErrorMessage);
                 }
             }
         }
     }
 }