public List<User> GetAllUsers() { List<User> userList = new List<User>(); using (_connection) { _connection.Open(); string selectString = "SELECT * FROM SYS_USER"; command.CommandText = selectString; var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { User user = new User(); user.Username = reader["Username"].ToString(); user.IsAdmin = Convert.ToBoolean(reader["IsAdmin"]); userList.Add(user); } reader.Close(); } _connection.Close(); } return userList; }
public void DeleteUser(User usr) { using (_connection) { _connection.Open(); string deleteString = "DELETE FROM SYS_USER WHERE UserNmae = @Username"; command.CommandText = deleteString; command.Parameters.Add("@Username", usr.Username); command.ExecuteNonQuery(); _connection.Close(); } }
public LoginFormController(ILoginForm form) { _form = form; user = new User(); userDAO = new UserDAO(); }
public bool InsertUser(User usr) { try { using (_connection) { _connection.Open(); string insertString = "INSERT INTO SYS_USER(Username,Password) VALUES(@Username,@Password)"; command.CommandText = insertString; usr.Password = Sha256Encrypt(usr.Password); command.Parameters.Add("@Username", usr.Username); command.Parameters.Add("@Password", usr.Password); command.ExecuteNonQuery(); _connection.Close(); } return true; } catch { return false; } }
public void UpdatetUser(User usr) { using (_connection) { _connection.Open(); string updateString = "UPDATE SYS_USER SET UserNmae = @Username,Password = @Password"; command.CommandText = updateString; usr.Password = Sha256Encrypt(usr.Password); command.Parameters.Add("@Username", usr.Username); command.Parameters.Add("@Password", usr.Password); command.ExecuteNonQuery(); _connection.Close(); } }
public bool SuccesfullLogin(User usr) { InitConnection(); using (_connection) { _connection.Open(); string selectString = "SELECT * FROM SYS_USER WHERE Username = @Username AND Password = @Password"; command.CommandText = selectString; usr.Password = Sha256Encrypt(usr.Password); command.Parameters.Add("@Username", usr.Username); command.Parameters.Add("@Password", usr.Password); var reader = command.ExecuteReader(); if (reader.HasRows) return true; reader.Close(); _connection.Close(); } return false; }
public RegisterFormController(IRegisterForm form) { _form = form; user = new User(); userDAO = new UserDAO(); }