Beispiel #1
0
        public static LoginHandler.User SearchBlockData(User username)
        {
            LoginHandler.User user = username;
            try
            {
                conn.Open();
                //parametroi sto query
                searchCommand = new OleDbCommand(@"SELECT * FROM [Blocked] WHERE User_id=?", conn);
                searchCommand.Parameters.AddWithValue("@p1", user.userID);
                searchReader = searchCommand.ExecuteReader();

                while (searchReader.Read())
                {
                    //set profile data
                    user.blockID     = searchReader.GetInt32(0);
                    user.reason      = searchReader.GetString(2);
                    user.blockedDays = searchReader.GetInt32(3);
                    user.isBlocked   = searchReader.GetBoolean(4);
                }
                searchReader.Close();
                conn.Close();
                return(user);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                conn.Close();
            }
            return(new LoginHandler.User());
        }
Beispiel #2
0
 public static bool UpdateUserData(User username)
 {
     LoginHandler.User user = username;
     try
     {
         conn.Open();
         //parametroi sto query
         searchCommand = new OleDbCommand(@"Update [User] Set Email = ?,First_name = ?,Last_name = ? Where User_id = ?;", conn);
         //searchCommand.Parameters.AddWithValue("@p1", user.username);
         searchCommand.Parameters.AddWithValue("@p1", user.email);
         searchCommand.Parameters.AddWithValue("@p2", user.name);
         searchCommand.Parameters.AddWithValue("@p3", user.surname);
         searchCommand.Parameters.AddWithValue("@p4", user.userID);
         searchReader = searchCommand.ExecuteReader();
         int countRow = 0;
         while (searchReader.Read())
         {
             countRow++;
         }
         Console.WriteLine("Records found: " + countRow);
         searchReader.Close();
         conn.Close();
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         conn.Close();
         return(false);
     }
 }
Beispiel #3
0
 public static LoginHandler.User SearchAccountData(string username)
 {
     LoginHandler.User user = new LoginHandler.User();
     try
     {
         conn.Open();
         //parametroi sto query
         searchCommand = new OleDbCommand(@"SELECT * FROM [User] WHERE Username=?", conn);
         searchCommand.Parameters.AddWithValue("@p1", username);
         searchReader = searchCommand.ExecuteReader();
         int countRow = 0;
         while (searchReader.Read())
         {
             //set profile data
             user.userID   = searchReader.GetInt32(0);
             user.username = searchReader.GetString(1);
             user.role     = searchReader.GetString(3);
             user.email    = searchReader.GetString(4);
             user.name     = searchReader.GetString(5);
             user.surname  = searchReader.GetString(6);
             countRow++;
         }
         Console.WriteLine("Records found: " + countRow);
         searchReader.Close();
         conn.Close();
         return(user);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         conn.Close();
     }
     return(new LoginHandler.User());
 }
Beispiel #4
0
        private void LoadUserFields()
        {
            if (!String.IsNullOrWhiteSpace(SearchIDBox.Text))
            {
                warningLabel.Visible = false;
                LoginHandler.User user = DBConnection.SearchAccountData(SearchIDBox.Text);
                if (user.name != null)
                {
                    warningLabel.Visible = false;

                    UserIDBox.Text   = "" + user.userID;
                    RoleBox.Text     = user.role;
                    NameBox.Text     = user.name;
                    LastNameBox.Text = user.surname;
                    EmailBox.Text    = user.email;
                    user             = DBConnection.SearchBlockData(user);
                    if (user.reason != null)
                    {
                        BlockData.blockID = user.blockID;
                        BlockData.reason  = user.reason;
                        BlockData.days    = user.blockedDays;
                        BlockData.blocked = user.isBlocked;
                        if (BlockData.blocked)
                        {
                            BlockButton.Text = "Unblock";
                        }
                    }
                    else
                    {
                        BlockData.blockID = 0;
                        BlockData.reason  = "";
                        BlockData.days    = 0;
                        BlockButton.Text  = "Block";
                    }
                }
                else
                {
                    warningLabel.Text    = "This user does not exist.";
                    warningLabel.Visible = true;
                }
            }
            else
            {
                warningLabel.Text    = "Please input a username.";
                warningLabel.Visible = true;
            }
        }