private void Login()
        {
            if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password))
            {
                using (UnitOfWork uow = new UnitOfWork())
                {
                    var user = uow.GetRepository <UserModel>().GetAll().FirstOrDefault(x => x.Username.Equals(Username) &&
                                                                                       x.Password.Equals(Password));

                    if (user != null)
                    {
                        using (TodoMenuWindow todoMenuWindow = new TodoMenuWindow())
                        {
                            LoginWindow.Close();
                            LoginWindow.Dispose();
                            todoMenuWindow.ShowDialog();
                        }
                    }
                    else
                    {
                        MessageBox.Show("This username has already taken. Select different one.", "Username has taken", System.Windows.MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
            else
            {
                MessageBox.Show("Please fill in the required fields.");
            }
        }
Exemple #2
0
        /// <summary>
        /// 登录淘宝
        /// </summary>
        public void LoginTaoBao()
        {
            try
            {
                if (this.InvokeRequired)
                {
                    this.Invoke(new Action(LoginTaoBao), new object[] { });
                }
                else
                {
                    loginSuccess = false;

                    if (lw != null)
                    {
                        if (lw.browser != null)
                        {
                            lw.browser.Dispose();
                        }
                        lw.Dispose();
                        lw.Close();
                        lw = null;
                    }
                    lw = new LoginWindow();
                    lw.LoadSuccessHandle  += Lw_LoadSuccessHandle;
                    lw.LoginSuccessHandle += Lw_LoginSuccessHandle;
                    lw.CloseWindowHandle  += Lw_CloseWindowHandle;
                    lw.StartPosition       = FormStartPosition.CenterScreen;
                    lw.ShowDialog(this);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Exemple #3
0
 /// <summary>
 /// Remove the login screen content and controls.
 /// </summary>
 public override void Remove()
 {
     Window.Remove(imgBackground);
     Window.Remove(imgLogo);
     Window.Remove(imgPyratron);
     Window.Remove(imgGithub);
     Window.Remove(lblVersion);
     Window.Remove(wndLogin);
     wndLogin?.Dispose();
 }
 /// <summary>
 /// 登录淘宝
 /// </summary>
 public void LoginTaoBao()
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new Action(LoginTaoBao), new object[] { });
     }
     else
     {
         TimingRefreshAlimamaPage();
         if (lw != null)
         {
             lw.Dispose();
             lw.Close();
             lw = null;
         }
         lw = new TBSync.LoginWindow();
         lw.LoginSuccessHandle += Lw_LoginSuccessHandle;
         lw.CloseWindowHandle  += Lw_CloseWindowHandle;
         lw.StartPosition       = FormStartPosition.CenterScreen;
         lw.ShowDialog(this);
     }
 }