public static JoursOuvres getOneById(int id) { JoursOuvres bean = new JoursOuvres(); NpgsqlConnection connect = new Connexion().Connection(); try { string query = "select * from yvs_jours_ouvres where id =" + id + ";"; NpgsqlCommand Lcmd = new NpgsqlCommand(query, connect); NpgsqlDataReader lect = Lcmd.ExecuteReader(); if (lect.HasRows) { while (lect.Read()) { bean = Return(lect); } } return(bean); } catch (Exception ex) { Messages.Exception("JoursOuvres (getOneById) ", ex); return(bean); } finally { Connexion.Close(connect); } }
public static JoursOuvres getOneByCalendier(Calendrier calendrier, string jour, string adresse) { JoursOuvres bean = new JoursOuvres(); NpgsqlConnection connect = new Connexion().Connection(adresse); try { string query = "select * from yvs_jours_ouvres where calendrier =" + calendrier.Id + " and upper(jour) = upper('" + jour + "') limit 1;"; NpgsqlCommand Lcmd = new NpgsqlCommand(query, connect); NpgsqlDataReader lect = Lcmd.ExecuteReader(); if (lect.HasRows) { while (lect.Read()) { bean = Return(lect); } } return(bean); } catch (Exception ex) { Messages.Exception("JoursOuvres (getOneByCalendier) ", ex); return(bean); } finally { Connexion.Close(connect); } }
public static Planning getPlanningForJoursOuvres(JoursOuvres jour, DateTime date) { try { return(PlanningDAO.setPlanning(jour, date)); } catch (Exception ex) { throw new Exception(ex.Message); } }
private static JoursOuvres Return(NpgsqlDataReader lect) { JoursOuvres bean = new JoursOuvres(); bean.Id = Convert.ToInt32(lect["id"].ToString()); bean.Jour = lect["jour"].ToString(); bean.HeureDebutTravail = (DateTime)((lect["heure_debut_travail"] != null) ? (!lect["heure_debut_travail"].ToString().Trim().Equals("") ? lect["heure_debut_travail"] : DateTime.Now) : DateTime.Now); bean.HeureFinTravail = (DateTime)((lect["heure_fin_travail"] != null) ? (!lect["heure_fin_travail"].ToString().Trim().Equals("") ? lect["heure_fin_travail"] : DateTime.Now) : DateTime.Now); bean.DureePause = (DateTime)((lect["duree_pause"] != null) ? (!lect["duree_pause"].ToString().Trim().Equals("") ? lect["duree_pause"] : DateTime.Now) : DateTime.Now); bean.HeureDebutPause = (DateTime)((lect["heure_debut_pause"] != null) ? (!lect["heure_debut_pause"].ToString().Trim().Equals("") ? lect["heure_debut_pause"] : DateTime.Now) : DateTime.Now); bean.HeureFinPause = (DateTime)((lect["heure_fin_pause"] != null) ? (!lect["heure_fin_pause"].ToString().Trim().Equals("") ? lect["heure_fin_pause"] : DateTime.Now) : DateTime.Now); bean.Ouvrable = (Boolean)((lect["ouvrable"] != null) ? (!lect["ouvrable"].ToString().Trim().Equals("") ? lect["ouvrable"] : false) : false); bean.Calendrier = Convert.ToInt32(lect["calendrier"].ToString()); return(bean); }
public static Planning setPlanning(JoursOuvres jour, DateTime date) { Planning bean = new Planning(); if (jour != null) { bean.Id = jour.Id; bean.DateDebut = date; DateTime d = new DateTime(date.Year, date.Month, date.Day, jour.HeureDebutTravail.Hour, jour.HeureDebutTravail.Minute, jour.HeureDebutTravail.Second); bean.DateFin = Utils.GetTimeStamp(d, jour.HeureFinTravail); bean.DureePause = jour.DureePause; bean.HeureDebut = jour.HeureDebutTravail; bean.HeureFin = jour.HeureFinTravail; bean.Supplementaire = !jour.Ouvrable; } return(bean); }