Esempio n. 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;
 }
Esempio n. 2
0
        //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();
        }
Esempio n. 3
0
        // 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();
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
 public Supervisor(int user_id, User user, Supervisor supervisor)
 {
     this.USER_ID = user_id;
       this._USER = user;
       this._SUPERVISOR = supervisor;
 }