예제 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var email = myContext.Suppliers.Where(Q => Q.Email.Contains(txtEmail.Text)).SingleOrDefault();

            if (email == null)
            {
                lblStatus.Content = "Sorry! Please enter existing email";
                txtEmail.Focus();
                return;
            }
            Guid guid = Guid.NewGuid();

            SendEmail(email.Email, guid);
            email.Newpass  = 1;
            email.Password = BCrypt.Net.BCrypt.HashString(guid.ToString(), 12);
            myContext.SaveChanges();
            MessageBox.Show("Password has been sent to " + email.Email);

            login login = new login();

            Close();
            login.Show();
        }
예제 #2
0
        private void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            var hasbcrypt = BCrypt.Net.BCrypt.HashPassword(pwReg.Password, 13);
            var regis     = myContext.Suppliers.Where(I => I.Email.ToString().Contains(txtEmailReg.Text)).SingleOrDefault();

            if (regis != null)
            {
                MessageBox.Show("Email has been registered. Please use another email.");
                txtEmailReg.Focus();
            }
            else
            {
                {
                    MessageBoxResult result = MessageBox.Show("Do you want to save this data?",
                                                              "Confirmation",
                                                              MessageBoxButton.YesNo,
                                                              MessageBoxImage.Question);
                    if (result == MessageBoxResult.Yes)
                    {
                        var input = new Supplier()
                        {
                            Name     = txtSNameReg.Text,
                            Email    = txtEmailReg.Text,
                            Password = hasbcrypt,
                            JoinDate = dateJoinDate.SelectedDate.Value
                        };
                        myContext.Suppliers.Add(input);
                        myContext.SaveChanges();
                    }
                }
                MessageBox.Show("You have Registered successfully.");
                Reset();
                login login = new login();
                login.Show();
                this.Close();
            }
        }