/// <summary> /// Create an new account. /// </summary> /// <param name="emId">Id of employee who use this account.</param> /// <param name="UserName">User name of this account.</param> /// <param name="password">Password of this account.</param> /// <param name="roleName">Role of this account.</param> public void CreateAccount(Guid accountId,Guid emId, String UserName, String password, String roleName) { Account newAcc = new Account(); newAcc.Account_Id = accountId; newAcc.Employee_Id = emId; newAcc.Account_UserName = UserName; newAcc.Account_Password = SecurityHelper.Instance.GetMd5Hash(password); newAcc.Role_Name = roleName; newAcc.Account_IsLocked = false; newAcc.Account_IsDelete = false; // Check Employee_Id exists // Check user name is unique if (AD.GetAccount(newAcc.Account_UserName) != null) { throw new Exception("This user name is existed."); } int result = AD.CreateAccount(newAcc); if (result == -1) { throw new Exception("An error occurred while executing this operation."); } }
/// <summary> /// Delete an account /// </summary> /// <param name="account">Account that you want to delete.</param> /// <returns>Return the number of rows affected or return -1 if occur exception.</returns> public int DeleteAccount(Account account) { return DBHelper.Instance.Delete("Account", String.Format("Account_Id = '{0}'", account.Account_Id.ToString())); }
/// <summary> /// Create new an account. /// </summary> /// <param name="account">Account that you want to create.</param> /// <returns>Return the number of rows affected or return -1 if occur exception.</returns> public int CreateAccount(Account account) { return DBHelper.Instance.Insert(account); }
/// <summary> /// Update an account. /// </summary> /// <param name="account">Account that you want to update.</param> /// <returns>Return the number of rows affected or return -1 if occur exception.</returns> public int UpdateAccount(Account account) { return DBHelper.Instance.Update(account, String.Format("Account_Id = '{0}'", account.Account_Id)); }