예제 #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();
            }
        }
예제 #3
0
 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;
        }
예제 #7
0
 public RegisterFormController(IRegisterForm form)
 {
     _form = form;
     user = new User();
     userDAO = new UserDAO();
 }