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); }
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); }
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); }