コード例 #1
0
 private bool CheckedUser()
 {
     if (TextBoxUserName.Text.Trim().Equals(string.Empty))
     {
         TextBoxUserName.Focus();
         MessageBox.Show(this, "用户名不能为空!", "操作提示", MessageBoxButton.OK, MessageBoxImage.Warning);
         return(false);
     }
     else if (TextBoxUserPassword.Password.Trim().Equals(string.Empty))
     {
         TextBoxUserPassword.Focus();
         MessageBox.Show(this, "密码不能为空!", "操作提示", MessageBoxButton.OK, MessageBoxImage.Warning);
         return(false);
     }
     else if (TextBoxUserName.Text.Trim().Equals("260905") && TextBoxUserPassword.Password.Trim().Equals("260905"))
     {
         //分光度测试界面
         FgdTest window = new FgdTest()
         {
             ShowInTaskbar = false,
             Owner         = this
         };
         window.Show();
         return(false);
     }
     return(true);
 }
コード例 #2
0
 //账号输入框回车事件,输入完账号后按Enter键即可自动跳转到密码输入框
 private void TextBoxUserName_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
 {
     TextBoxUserPassword.Password = string.Empty;
     if (e.Key == System.Windows.Input.Key.Enter)
     {
         if (TextBoxUserName.Text.Trim().Equals(string.Empty))
         {
             TextBoxUserName.Clear();
             TextBoxUserName.Focus();
             MessageBox.Show(this, "用户名不能为空!", "操作提示", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
         else
         {
             TextBoxUserPassword.Focus();
         }
     }
 }
コード例 #3
0
 public void Login()
 {
     if (CheckedUser())
     {
         foreach (UserAccount account in Global.userAccounts)
         {
             if (account.UserName.Equals(TextBoxUserName.Text.Trim()))
             {
                 if (account.UserPassword.Equals(TextBoxUserPassword.Password))
                 {
                     _userAccount = account;
                     if (account.Create)
                     {
                         LoginDisplay window = new LoginDisplay()
                         {
                             ShowInTaskbar = false,
                             Owner         = this
                         };
                         window.ShowDialog();
                     }
                     else
                     {
                         MainWindow window = new MainWindow()
                         {
                             _userconfig   = account,
                             ShowInTaskbar = false,
                             Owner         = this
                         };
                         window.ShowDialog();
                     }
                     ClearAccount();
                 }
                 else
                 {
                     MessageBox.Show(this, "密码错误!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Error);
                     TextBoxUserPassword.Password = string.Empty;
                     TextBoxUserPassword.Focus();
                 }
                 return;
             }
         }
         MessageBox.Show(this, "用户名不存在!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Error);
         ClearAccount();
     }
 }