public static bool Authenticate(string UserName, string Password, string UserType) { bool result = false; Account daAccount = new Account(); MRS.Model.Account account = new MRS.Model.Account(); account = daAccount.GetAccountByUserName(UserName); if (account.UserName != string.Empty) { if (account.UserName == UserName && account.Password == Password && account.UserType == UserType) { result = true; } } return(result); }
public static bool ChangePassword(string UserName, string OldPassword, string NewPassword) { bool result = false; Account daAccount = new Account(); MRS.Model.Account account = new MRS.Model.Account(); account = daAccount.GetAccountByUserName(UserName); if (account.UserName != string.Empty) { if (account.UserName == UserName && account.Password == OldPassword) { daAccount.UpdateAccount(account.Id, account.UserName, NewPassword, account.UserType, account.TrueName); result = true; } } return(result); }
private void btnLogin_Click(object sender, EventArgs e) { string UserType = BLL.UserType.Accountant.ToString(); switch (cbUserType.SelectedIndex) { case 0: UserType = BLL.UserType.Accountant.ToString(); break; case 1: UserType = BLL.UserType.Cashier.ToString(); break; case 2: UserType = BLL.UserType.Administrator.ToString(); break; } if (Authentication.Authenticate(tbUserName.Text, tbPassword.Text, UserType)) { MRS.Model.Account account = new MRS.Model.Account(); account = bllAccount.GetAccountByUserName(tbUserName.Text); switch (UserType) { case "Accountant": //mrModule.Show(); //mrModule.ShowAccountant(account.TrueName); mrBxMain.Show(); mrBxMain.WindowState = FormWindowState.Maximized; mrBxMain.ShowAccountant(account.TrueName); break; case "Cashier": cuMain.Show(); cuMain.ShowCashier(account.TrueName); break; case "Administrator": settingMain.Show(); break; } this.Visible = false; } else { MessageBox.Show("用户名或密码错误"); } }