protected MRS.Model.Account Parse(SqlDataReader Reader) { MRS.Model.Account mAccount = new MRS.Model.Account(); mAccount.Id = Convert.ToInt32(Reader[DSL.Account.ID_FIELD]); mAccount.UserName = Reader[DSL.Account.USER_NAME_FIELD].ToString().Trim(); mAccount.Password = Reader[DSL.Account.PASSWORD_FIELD].ToString().Trim(); mAccount.UserType = Reader[DSL.Account.USER_TYPE_FIELD].ToString().Trim(); mAccount.TrueName = Reader[DSL.Account.TRUE_NAME_FIELD].ToString().Trim(); return(mAccount); }
public IList <MRS.Model.Account> GetAccount() { IList <MRS.Model.Account> mAccounts = new List <MRS.Model.Account>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(ConnectionString.ConnectionStringMRS, CommandType.StoredProcedure, CommandText.SELECT_ACCOUNT, null)) { while (reader.Read()) { MRS.Model.Account mAccount = Parse(reader); mAccounts.Add(mAccount); } } return(mAccounts); }
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("用户名或密码错误"); } }
public MRS.Model.Account GetAccountByUserName(string UserName) { MRS.Model.Account account; SqlParameter username_parm = new SqlParameter(DSL.Account.USER_NAME_PARM, SqlDbType.NChar, 32); username_parm.Value = UserName; using (SqlDataReader reader = SqlHelper.ExecuteReader(ConnectionString.ConnectionStringMRS, CommandType.StoredProcedure, CommandText.SELECT_ACCOUNT_BY_USERNAME, username_parm)) { if (reader.Read()) { account = Parse(reader); } else { account = new MRS.Model.Account(); } } return(account); }