//public TaiKhoan GetAccount(TaiKhoan account) //{ // TaiKhoan getAccount = new TaiKhoan(); // Dictionary<string, object> sqlStoredProcedureParams = new Dictionary<string, object>(); // sqlStoredProcedureParams.Add("username", account.UserName); // sqlStoredProcedureParams.Add("password", account.Password); // DataTable dt = provider.ExecuteReader("TAIKHOAN_proc_get", sqlStoredProcedureParams); // if (dt.Rows.Count == 1) // { // getAccount.UserName = dt.Rows[0]["Username"].ToString(); // getAccount.Permission = new PermissionData // { // PermissionId = dt.Rows[0]["MaPhanQuyen"].ToString(), // PermissionName = dt.Rows[0]["TenQuyen"].ToString() // }; // } // return getAccount; //} public TaiKhoan DangNhap(TaiKhoan taikhoan) { TaiKhoan getAccount = new TaiKhoan(); int param = 2; string[] names = new string[param]; Object[] values = new Object[param]; names[0] = "@UserName"; names[1] = "@Password"; values[0] = taikhoan.UserName; values[1] = taikhoan.Password; DataTable dt = db.LoadData("TAIKHOAN_proc_Login", names, values, param); if (dt.Rows.Count == 1) { getAccount.UserName = dt.Rows[0]["Username"].ToString(); getAccount.PhanQuyen = new PhanQuyen { PermissionId = dt.Rows[0]["MaPhanQuyen"].ToString(), PermissionName = dt.Rows[0]["TenQuyen"].ToString() }; } return getAccount; }
public bool Login(string user, string password) { try { taiKhoan.UserName = user; taiKhoan.Password = password; taiKhoan = taikhoanDAO.DangNhap(taiKhoan); IsLogin = true; SetPermission(); return true; } catch(Exception) { return false; } }
public List<TaiKhoan> GetAllTaiKhoan() { List<TaiKhoan> listTaiKhoan = new List<TaiKhoan>(); DataTable dt = db.LoadData("TAIKHOAN_proc_load"); foreach (DataRow row in dt.Rows) { TaiKhoan account = new TaiKhoan(); account.UserName = row["Username"].ToString(); account.Password = row["Password"].ToString(); account.PhanQuyen = new PhanQuyen() { PermissionId = row["MaPhanQuyen"].ToString(), PermissionName = row["TenQuyen"].ToString() }; listTaiKhoan.Add(account); } return listTaiKhoan; }
public int ChangePassword(TaiKhoan account) { int param = 2; string[] names = new string[param]; Object[] values = new Object[param]; names[0] = "@UserName"; names[1] = "@Password"; values[0] = account.UserName; values[1] = account.Password; return db.Update("TAIKHOAN_proc_update", names, values, param); }
//public int Logout(TaiKhoan account) //{ // TaiKhoan getAccount = new TaiKhoan(); // Dictionary<string, object> sqlStoredProcedureParams = new Dictionary<string, object>(); // sqlStoredProcedureParams.Add("username", account.UserName); // return provider.ExecuteNonQuery("TAIKHOAN_proc_logout", sqlStoredProcedureParams); //} public int AddAccount(TaiKhoan account) { int param = 3; string[] names = new string[param]; Object[] values = new Object[param]; names[0] = "@username"; names[1] = "@passWord"; names[2] = "@maPhanQuyen"; values[0] = account.UserName; values[1] = account.Password; values[2] = account.PhanQuyen.PermissionId; return db.Update("TAIKHOAN_proc_insert", names, values, param); }
public TaiKhoanBLL() { IsLogin = false; taiKhoan = new TaiKhoan(); }
public bool ThemTaikhoan(TaiKhoan tk) { try { taikhoanDAO.AddAccount(tk); return true; } catch(Exception) { return false; } }