Пример #1
0
        public EmployeZoneVue findById(int id)
        {
            conn = new DB().getConn();
            EmployeZoneVue empZone = null;

            try
            {
                string query = "select * from employe_zone_vue where id=" + id;
                cmd    = new NpgsqlCommand(query, conn);
                reader = cmd.ExecuteReader();
                if (reader.Read() == true)
                {
                    empZone = new EmployeZoneVue(reader.GetInt16(0), reader.GetString(1),
                                                 reader.GetString(2));
                }
            }
            catch (Exception e)
            {
                throw new Exception("Erreur dans EmployeZoneDao=>findBydId " + e.Message);
            }
            finally
            {
                conn.Close();
                reader.Close();
            }
            return(empZone);
        }
Пример #2
0
        public List <EmployeZoneVue> getAll()
        {
            List <EmployeZoneVue> listAll = new List <EmployeZoneVue>();

            conn = new DB().getConn();
            try
            {
                string query = "select * from employe_zone_vue";
                cmd    = new NpgsqlCommand(query, conn);
                reader = cmd.ExecuteReader();
                while (reader.Read() == true)
                {
                    EmployeZoneVue employezone = new EmployeZoneVue(reader.GetInt16(0), reader.GetString(1),
                                                                    reader.GetString(2));
                    listAll.Add(employezone);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Erreur dans EmployeZoneDao->getAll" + e.Message);
            }
            finally
            {
                conn.Close();
                reader.Close();
            }
            return(listAll);
        }
Пример #3
0
        public List <EmployeZoneVue> search(EmployeZoneVue empZone)
        {
            conn = new DB().getConn();
            List <EmployeZoneVue> listAll = new List <EmployeZoneVue>();

            try
            {
                string query = "select * from employe_zone_vue when ";
                if (empZone.Employe != null)
                {
                    query += "employe =" + empZone.Employe;
                }
                if (empZone.ZoneTravail != null)
                {
                    query += " and zone_travail =" + empZone.ZoneTravail;
                }

                cmd    = new NpgsqlCommand(query, conn);
                reader = cmd.ExecuteReader();
                while (reader.Read() == true)
                {
                    EmployeZoneVue emp = new EmployeZoneVue(reader.GetInt16(0), reader.GetString(1),
                                                            reader.GetString(2));
                    listAll.Add(emp);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Erreur dans EmployeZoneDao=>search " + e.Message);
            }
            finally
            {
                conn.Close();
                reader.Close();
            }
            return(listAll);
        }