コード例 #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
ファイル: StudentDAO.cs プロジェクト: Jacob-Petro/4Project
        //add skills for the supervisor
        public Supervisor[] SearchSupervisorByUnits(string searchInput)
        {
            Unit[] unit_id = SearchUnits(searchInput);

               List<Supervisor> supervisor = new List<Supervisor>();

               for (int i = 0; i < unit_id.Length; i++)
               {
               string sql = "SELECT `skill_id`, `experience`, `user_id` FROM `super_skills` WHERE `unit_id`=" + unit_id[i].UNIT_ID;

               con = new MySqlConnection(connectionString);
               cmd = new MySqlCommand(sql, con);
               try
               {
                   con.Open();//open connection

                   MySqlDataReader _dr = cmd.ExecuteReader();
                   while (_dr.Read())
                   {
                       Supervisor s = new Supervisor((int)_dr["user_id"],unit_id[i].UNIT_NAME, LoadProfile((int)_dr["user_id"]), GetSupervisor((int)_dr["user_id"]));
                       supervisor.Add(s);
                   }
                   _dr.Close();
               }

               catch (MySqlException ex)// incase of errors catch them here
               {
                   throw new Exception(ex.Message);
               }
               finally
               {
                   con.Close();
               }
               }
               return supervisor.ToArray();
        }
コード例 #3
0
ファイル: StudentDAO.cs プロジェクト: Jacob-Petro/4Project
        // returns all the details of a supervisors details based on their profesions
        public Supervisor[] SearchSupervisorByProfession(string profession)
        {
            profession = profession.Trim();
            List<Supervisor> supervisor = new List<Supervisor>();

            if (!string.IsNullOrWhiteSpace(profession) && !string.IsNullOrEmpty(profession))
            {

                string sql = "SELECT `supervisor`.`user_id`"
                    + "FROM `supervisor` "
                    + "LEFT JOIN `users` ON(`supervisor`.`user_id`=`users`.`user_id`) "
                    + " WHERE `supervisor`.`super_profesion`LIKE '%" + profession + "%'"
                    + " AND `users`.`user_type`<>0";

                con = new MySqlConnection(connectionString);
                cmd = new MySqlCommand(sql, con);
                try
                {
                    con.Open();//open connection

                    MySqlDataReader _dr = cmd.ExecuteReader();
                    while (_dr.Read())
                    {
                        Supervisor s = new Supervisor((int)_dr["user_id"], LoadProfile((int)_dr["user_id"]), GetSupervisor((int)_dr["user_id"]));
                        supervisor.Add(s);
                    }
                    _dr.Close();
                }

                catch (MySqlException ex)// incase of errors catch them here
                {
                    throw new Exception(ex.Message);
                }
                finally
                {
                    con.Close();
                }
            }
            return supervisor.ToArray();
        }
コード例 #4
0
ファイル: StudentDAO.cs プロジェクト: Jacob-Petro/4Project
        public Supervisor GetSupervisor(int user_id)
        {
            Supervisor supervisor = new Supervisor();
            string sql = "SELECT `supervisor`.`super_id`,`supervisor`.`super_profesion`,`supervisor`.`physical_location` "
                + "FROM `supervisor` "
                + "LEFT JOIN `users` ON(`supervisor`.`user_id`=`users`.`user_id`) "
                + " WHERE `supervisor`.`user_id` =" + user_id + " AND `users`.`user_type`<>0";

             con = new MySqlConnection(connectionString);
             cmd = new MySqlCommand(sql, con);
             try
             {
             con.Open();//open connection
             MySqlDataReader _dr = cmd.ExecuteReader();
             if (_dr.Read())
             {
                 supervisor = new Supervisor(
                     (int)_dr["super_id"],
                     _dr["super_profesion"].ToString(),
                     _dr["physical_location"].ToString());
             }
             _dr.Close();
             }

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

             return supervisor;
        }
コード例 #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;
 }