Пример #1
0
        private void BtnLogin_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var email = myContext.Users.Where(u => u.Email == TxtUserEmail.Text).FirstOrDefault();

                if ((TxtUserEmail.Text == "") || (TxtPassword.Password == ""))
                {
                    if (TxtUserEmail.Text == "")
                    {
                        MessageBox.Show("Email is Required!", "Caution", MessageBoxButton.OK);
                        TxtUserEmail.Focus();
                    }
                    else if (TxtPassword.Password == "")
                    {
                        MessageBox.Show("Password is Required!", "Caution", MessageBoxButton.OK);
                        TxtPassword.Focus();
                    }
                }
                else
                {
                    if (email != null)
                    {
                        var psw = email.Password;
                        psw = TxtPassword.Password;
                        if (TxtPassword.Password == psw)
                        {
                            MessageBox.Show("Login Successfully!", "Login Succes", MessageBoxButton.OK);
                            MainWindow dashboard = new MainWindow();
                            dashboard.Show();
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("Email and Password are wrong!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Email and Password is invalid");
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Пример #2
0
 private void BtnSubmitForgetPwd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (TxtUserEmail.Text == "")
         {
             MessageBox.Show("Email is Required", "Caution", MessageBoxButton.OK);
             TxtUserEmail.Focus();
         }
         else
         {
             var cekemail = myContext.Users.FirstOrDefault(v => v.Email == TxtUserEmail.Text);
             if (cekemail != null)
             {
                 var email = cekemail.Email;
                 if (TxtUserEmail.Text == email)
                 {
                     string newpsw   = Guid.NewGuid().ToString();
                     var    emailcek = myContext.Users.Where(s => s.Email == TxtUserEmail.Text).FirstOrDefault();
                     emailcek.Password = newpsw;
                     myContext.SaveChanges();
                     MessageBox.Show("Password has been update!");
                     Outlook._Application _app = new Outlook.Application();
                     Outlook.MailItem     mail = (Outlook.MailItem)_app.CreateItem(Outlook.OlItemType.olMailItem);
                     mail.To         = TxtUserEmail.Text;
                     mail.Subject    = "[Forgot Password]" + DateTime.Now;
                     mail.Body       = "Dear.." + TxtUserEmail.Text + "\nThis is ur new password :"******"\nDont Forget Your Password Again!";
                     mail.Importance = Outlook.OlImportance.olImportanceNormal;
                     ((Outlook._MailItem)mail).Send();
                     MessageBox.Show("Check Your Email For Your New Password", "Message", MessageBoxButton.OK);
                 }
             }
             else
             {
                 MessageBox.Show("That Email Not Registered Yet!", "Caution", MessageBoxButton.OK);
             }
         }
     }
     catch (Exception)
     {
     }
 }
        private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            TxtUserEmail.Focus();

            LblResult.Visibility = Visibility.Hidden;   // 로그인 결과를 나타내는 라벨을 숨김
        }