以下是引用片段:
private void btnOK_Click(object sender, System.EventArgs e)
{
// Here is to use fixed username and password
// You can check username and password from DB
if( txtUserName.Text == "Admin" && txtPassword.Text == "nopassword" )
{
// Save login user info
uiLogin.UserName = txtUserName.Text;
uiLogin.Password = txtPassword.Text;
// Set dialog result with OK
this.DialogResult = DialogResult.OK;
}
else
{
// Wrong username or password
nLoginCount++;
if( nLoginCount == MAX_LOGIN_COUNT )
// Over 3 times
this.DialogResult = DialogResult.Cancel;
else
{
MessageBox.Show( "Invalid user name and password!" );
txtUserName.Focus();
}
}
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
// Set dialog result with Cancel
this.DialogResult = DialogResult.Cancel;
}
--------------------next---------------------
阅读(198) | 评论(0) | 转发(0) |