public void Window_Loaded(object sender, RoutedEventArgs e)
 {
     digitalContext = new DigitalEntities();
     SignModel sign = new SignModel();
     GetMentors();
     datePicker.SelectedDate = DateTime.Now;
     cmbStudent.SelectedIndex = 1;
     cmbMentorList.SelectedIndex = 1;
     Username.Text = "Welcome ," + SessionContext.UserName;
     LoadData();
     CustomViewModel model = new CustomViewModel();
     DateTime picker = (DateTime)datePicker.SelectedDate;
     item.DataContext = model.LoadData();
 }  
        private void ValidateInput()
        {

            if(string.IsNullOrEmpty(txtFname.Text) || string.IsNullOrEmpty(txtLname.Text) || string.IsNullOrEmpty(txtUsername.Text) ||
                string.IsNullOrEmpty(txtPassword.Password) || string.IsNullOrEmpty(txtConfirm.Password))
            {
                MessageBox.Show("Required fields cannot be Empty","ERROR",MessageBoxButton.OK,MessageBoxImage.Error);
                return;
            }
            if (this.txtPassword.Password.Length < 8)
            {
                MessageBox.Show("Password must be 8 characters long", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            else if(!Regex.IsMatch(this.txtPassword.Password, @".*[0-9]+.*[0-9]+.*"))
            {
                MessageBox.Show("Password must contain atleast two numeric character", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            else if(string.Compare(txtPassword.Password,txtConfirm.Password) > 0)
            {
                MessageBox.Show("Password must match","ERROR",MessageBoxButton.OK,MessageBoxImage.Error);
                return;
            }

            else if((!Regex.IsMatch(txtUsername.Text, @"^((([\w]+\.[\w]+)+)|([\w]+))@(([\w]+\.)+)([A-Za-z]{1,3})$")))
            {
                MessageBox.Show("Email must contains, @jhb.dvt.co.za", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            else
            {
                SignModel sign = new SignModel();
                Person mentor = new Person();
                mentor.FirstName = txtFname.Text;
                mentor.LastName = txtLname.Text;
                mentor.Username = txtUsername.Text;
                mentor.Password = txtPassword.Password;
                mentor.RoleID = cmbStudentMentor.SelectedIndex + 1;
                MessageBox.Show(sign.InsertMentor(mentor));
                Login login = new Login();
                login.Show();
                this.Hide();
            }
        }
 private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         SignModel signModel = new SignModel();
         if (!Regex.IsMatch(txtHours.Text, "^((?:[0-9]|1[0-9]|2[0-3])(?:\\.\\d{1,2})?|24(?:\\.00?)?)$"))
         {
             MessageBox.Show("Invalid input for Hours");
             txtHours.Clear();
         }
         else
         {
             AttendanceMaster master = new AttendanceMaster();
             master.TrainedOn = txtTask.Text;
             master.AttendanceDate = (DateTime)datePicker.SelectedDate;
             MessageBox.Show(signModel.MasterRecord(master));
             AttendanceDetail detail = new AttendanceDetail();
             decimal hrs = decimal.Parse(txtHours.Text, CultureInfo.InvariantCulture);
             detail.HoursPerDay = hrs;                 
             detail.MasterID = master.MasterID;
             MessageBox.Show(signModel.SignRegister(detail));
             txtHours.Clear();
             txtTask.Clear();
             LoadData();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }