public void forUpdate(int val)
 {
     try
     {
         search = context.EmployeeTables.Find(val);
         if (search.Gender == "Male")
         {
             MaleRadioButton.IsChecked = true;
         }
         else
         {
             FemaleRadioButton.IsChecked = true;
         }
         employeeName.Text       = search.Name;
         employeeFatherName.Text = search.FatherName;
         CNIC.Text             = search.CNIC;
         HomeAddressText.Text  = search.Adress;
         primaryContact.Text   = search.PrimaryContact;
         secondaryContact.Text = search.SecondaryContact;
         subject.Text          = search.Subject;
         joinedOn.Text         = search.JoinedOn.ToString("dd/MM/yyyy");
         qualification.Text    = search.Qualifications;
         age.Text = search.Age.ToString();
     }
     catch (Exception err)
     {
         this.ShowMessageAsync("Doesn't not Exits!", "The Student does not exits in the database with this Employee ID "
                               + val + " . Please enter a valid Employee ID.");
         Console.WriteLine(err.ToString());
     }
 }
        private void saveButtonClick(object sender, RoutedEventArgs e)
        {
            string Gender = null;

            if (MaleRadioButton.IsChecked == true)
            {
                Gender = "Male";
            }
            else
            {
                Gender = "Female";
            }

            DateTime      join  = DateTime.ParseExact(joinedOn.Text.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
            EmployeeTable modal = new EmployeeTable();

            modal.Name             = employeeName.Text.ToString();
            modal.FatherName       = employeeFatherName.Text.ToString();
            modal.Age              = int.Parse(age.Text.ToString());
            modal.Subject          = subject.Text.ToString();
            modal.CNIC             = CNIC.Text.ToString();
            modal.PrimaryContact   = primaryContact.Text.ToString();
            modal.SecondaryContact = secondaryContact.Text.ToString();
            modal.Qualifications   = qualification.Text.ToString();
            modal.JoinedOn         = join;
            modal.Adress           = HomeAddressText.Text.ToString();
            modal.Gender           = Gender;
            try
            {
                context.EmployeeTables.Add(modal);
                context.SaveChanges();
            }
            catch (DbEntityValidationException err)
            {
                this.ShowMessageAsync("Error", "A field is empty");
                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);
                    }
                }
            }
            this.ShowMessageAsync("Done!", "Employee added");
            clearAll();
            load();
        }