本文整理汇总了C#中LoginModel.doLogin方法的典型用法代码示例。如果您正苦于以下问题:C# LoginModel.doLogin方法的具体用法?C# LoginModel.doLogin怎么用?C# LoginModel.doLogin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoginModel
的用法示例。
在下文中一共展示了LoginModel.doLogin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnSubmit_Click
private void btnSubmit_Click(object sender, EventArgs e)
{
if ((txtCurrentPassword.Text.Equals("")) || (txtNewPassword.Text.Equals("")))
{
MessageBox.Show("One or more fields has been left empty.");
}
else
{
//Get passwords
String passwordOld = txtCurrentPassword.Text;
String passwordNew = txtNewPassword.Text;
LoginModel loginValidateAttempt = new LoginModel();
User detailsToCheck = loginValidateAttempt.doLogin(currentUser.getUsername(), passwordOld);
//If a login attempt does not return null, the attempt was successful
if (detailsToCheck != null)
{
//If the new password is the same as the old password, we say something
if (detailsToCheck.getPassword().Equals(Encryption.calcMD5(passwordNew)))
{
MessageBox.Show("The password you entered is the same as your old password.");
}
else
{
//Then we can change the password
UserModel uModel = new UserModel();
uModel.updatePassword(passwordNew, currentUser.getUsername());
MessageBox.Show("Password successfully changed.");
this.Close();
}
}
else
{
MessageBox.Show("The password you entered does not match your current password.");
}
}
}
示例2: cmdLogin_Click
/*
* Button to attempt the login
* @AUTHOR: Andrew Davis
*/
private void cmdLogin_Click(object sender, EventArgs e)
{
// Create a LoginModel object to handle the login
LoginModel loginModel = new LoginModel();
// Get the user credentials from the form
String username = txtUsername.Text;
String password = txtPassword.Text;
// Attempt the login
User loggedIn = loginModel.doLogin(username, password);
// If it was successful, go to the Home Page
if (loggedIn != null)
{
MessageBox.Show("SUCCESS! LOGGED IN AS: " + loggedIn.getFirstName() + " " + loggedIn.getLastName());
// Create a Home Form
HomePage homeForm = new HomePage();
// Set the Current User of the HomePage to be the newly logged in user
homeForm.setCurrentUser(loggedIn);
// Show the Home Form
homeForm.Show();
// Hide the current form
this.Hide();
}
else
{
MessageBox.Show("UNSUCCESSFUL LOGIN");
// Clear the Password field
txtPassword.Text = "";
}
}