Example #1
0
 private void btnSignUp_Click(object sender, RoutedEventArgs e)
 {
     using (var context = new HrDBContext()) {
         var user = new User()
         {
             UserName   = txtUserName.Text,
             FirstName  = txtFN.Text,
             LastName   = txtLN.Text,
             Position   = txtPosition.Text,
             CreateDate = DateTime.Now,
             Email      = txtEmail.Text,
             Password   = PasswordCrypt.SimpleEncrypt(txtPW.Text)
         };
         context.Users.Add(user);
         context.SaveChanges();
     }
     closeFrm();
 }
Example #2
0
        private void btnSignIn_Click(object sender, RoutedEventArgs e)
        {
            var password = PasswordCrypt.SimpleEncrypt(txtPW.Password);

            using (var context = new HrDBContext()) {
                var username = txtID.Text;
                try
                {
                    var        user = context.Users.Where(un => un.UserName == username).Where(pw => pw.Password == password).First();
                    MainWindow form = new MainWindow();
                    form.Tag = this;
                    form.Show();
                    Hide();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }