示例#1
0
        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;
        }
示例#2
0
        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();
 }
示例#4
0
        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;
            }
        }
示例#5
0
        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();
            }
        }
示例#6
0
        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();
 }