Example #1
0
 public Supervisor(int user_id,string unit_name, User user, Supervisor supervisor)
 {
     this.USER_ID = user_id;
       this.UNIT_NAME = unit_name;
       this._USER = user;
       this._SUPERVISOR = supervisor;
 }
Example #2
0
 public Request(int req_id, int super_id, User load_profile, string is_accepted, string comments)
 {
     this.REQ_ID = req_id;
     this.LOAD_PROFILE = load_profile;
     this.SUPER_ID = super_id;
     this.COMMENTS = comments;
     this.IS_ACCEPTED = is_accepted;
 }
Example #3
0
        public User Login(string username, string password)
        {
            User u = new User();
            //preventing sql injection by triming whitesapces and empty strings
            if ((!string.IsNullOrWhiteSpace(username) && !string.IsNullOrEmpty(username))
                && (!string.IsNullOrWhiteSpace(password) && !string.IsNullOrEmpty(password)))
            {
                string sql = "SELECT * FROM `users` WHERE `user_email`='" + username + "' AND `user_password`='" + password + "'";//select the user email and password and compare the two if they match.
                con = new MySqlConnection(connectionString);
                cmd = new MySqlCommand(sql, con);
                try
                {
                    con.Open();//open connection
                    dr = cmd.ExecuteReader();
                    if (dr.Read())
                    {//returning user details like id name,email and type
                        u = new User((int)dr["user_id"], dr["user_name"].ToString(), dr["user_email"].ToString(), (int)dr["user_type"]);
                    }
                    else
                    {
                        //return "Inavid Username or Password!";
                    }
                }

                catch (MySqlException ex)// incase of errors catch them here
                {
                    throw new Exception(ex.Message);
                }
                finally
                {
                    con.Close();
                }
            }
            else
            {
                u = null;
            }

            return u;
        }
Example #4
0
        //loads the general details of the user from user table in the database
        public User LoadProfile(int user_id)
        {
            User user = null;
               string sql = "SELECT  `user_national_id`, `user_name`, `user_gender`, `user_dob`, `user_email`, `phone_number`  FROM `users` WHERE `user_id`="+user_id;
            con = new MySqlConnection(connectionString);
            cmd = new MySqlCommand(sql, con);
            try
            {
                con.Open();//open connection
                MySqlDataReader _dr = cmd.ExecuteReader();
                if (_dr.Read())
                {
                    user = new User(
                        _dr["user_national_id"].ToString(),
                        _dr["user_name"].ToString(),
                        _dr["user_gender"].ToString(),
                        _dr["user_dob"].ToString(),
                        _dr["user_email"].ToString(),
                        _dr["phone_number"].ToString());
                }
                _dr.Close();
            }

            catch (MySqlException ex)// incase of errors catch them here
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                con.Close();
            }

            return user;
        }
Example #5
0
 public Supervisor(int user_id, User user, Supervisor supervisor)
 {
     this.USER_ID = user_id;
       this._USER = user;
       this._SUPERVISOR = supervisor;
 }