Ejemplo n.º 1
0
 public string InsertLearner(Person student)
 {
     try
     {
         digitalContext = new DigitalEntities();
         digitalContext.People.Add(student);
         digitalContext.SaveChanges();
         return student.FirstName + "was successfully added";
     }
     catch (Exception ex)
     {
         return "Learner not Added" + ex.Message;
     }
 }
Ejemplo n.º 2
0
        public string InsertMentor( Person mentor)
        {
            try
            {
                digitalContext = new DigitalEntities();
                digitalContext.People.Add(mentor);
                digitalContext.SaveChanges();
                return mentor.FirstName + " " + " was successfully added";
            }
            catch (Exception ex)
            {

                return "Mentor not added" + ex.Message;
            }
        }
Ejemplo n.º 3
0
        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();
            }
        }