Beispiel #1
0
        private void btnLogin_Click(object sender, EventArgs ea)
        {
            var username = txtUsername.Text;
            var password = txtPassword.Text;

            if (string.IsNullOrEmpty(username))
            {
                txtUsername.Focus();
                return;
            }
            if (string.IsNullOrEmpty(password))
            {
                txtPassword.Focus();
                return;
            }
            new Thread(() =>
            {
                btnLogin.Invoke(new Action(() =>
                {
                    var currentUser = Login(username, password);
                    if (currentUser != null)
                    {
                        CurrentUser = currentUser;
                        this.Hide();
                        var mainForm = new MainForm();
                        mainForm.Show();
                        txtUsername.Text = null;
                        txtPassword.Text = null;
                    }
                    else
                    {
                        MessageBox.Show("找不到该账号,请检查用户名或密码");
                    }
                }));

            }).Start();
        }
Beispiel #2
0
 public void Logout()
 {
     CurrentUser = null;
 }