コード例 #1
0
ファイル: Supervisor.cs プロジェクト: Jacob-Petro/4Project
 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;
 }
コード例 #2
0
ファイル: Request.cs プロジェクト: Jacob-Petro/4Project
 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;
 }
コード例 #3
0
ファイル: StudentDAO.cs プロジェクト: Jacob-Petro/4Project
        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;
        }
コード例 #4
0
ファイル: StudentDAO.cs プロジェクト: Jacob-Petro/4Project
        //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;
        }
コード例 #5
0
ファイル: Supervisor.cs プロジェクト: Jacob-Petro/4Project
 public Supervisor(int user_id, User user, Supervisor supervisor)
 {
     this.USER_ID = user_id;
       this._USER = user;
       this._SUPERVISOR = supervisor;
 }