Beispiel #1
0
 //定义事件触发方法
 private void OnUserVerfied(UserVerifiedEventArgs e)
 {
     if (UserVerified != null)
     {
         UserVerified(this, e);
     }
 }
Beispiel #2
0
 private void login1_UserVerified(object sender, UserVerifiedEventArgs e)
 {
     if (e.Authorized)
     {
         MessageBox.Show("登录成功!");
     }
     else
     {
         MessageBox.Show("用户名或密码错误!");
     }
 }
Beispiel #3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            //验证输入
            if (String.IsNullOrEmpty(txtName.Text) || String.IsNullOrEmpty(txtPwd.Text))
            {
                MessageBox.Show("用户名和密码不能为空!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            //创建事件参数对象
            UserVerifiedEventArgs uve = new UserVerifiedEventArgs();

            //验证用户名和密码是否匹配
            if (txtName.Text == "admin" && txtPwd.Text == "123")
            {
                uve.Authorized = true;
            }
            else
            {
                uve.Authorized = false;
            }
            //触发事件
            OnUserVerfied(uve);
        }