Example #1
0
        public static TrancheHoraire getOneById(int id)
        {
            TrancheHoraire   bean    = new TrancheHoraire();
            NpgsqlConnection connect = new Connexion().Connection();

            try
            {
                string query = "select * from yvs_grh_tranche_horaire where id =" + id + ";";
                using (NpgsqlCommand Lcmd = new NpgsqlCommand(query, connect))
                    using (NpgsqlDataReader lect = Lcmd.ExecuteReader())
                    {
                        if (lect.HasRows)
                        {
                            while (lect.Read())
                            {
                                bean = Return(lect);
                            }
                        }
                    }
                return(bean);
            }
            catch (Exception ex)
            {
                Messages.Exception("TrancheHoraire (getOneById) ", ex);
                return(bean);
            }
            finally
            {
                Connexion.Close(connect);
            }
        }
Example #2
0
        private static TrancheHoraire Return(NpgsqlDataReader lect)
        {
            TrancheHoraire bean = new TrancheHoraire();

            try
            {
                bean.Id          = Convert.ToInt32(lect["id"].ToString());
                bean.Societe     = Convert.ToInt32(lect["societe"].ToString());
                bean.HeureDebut  = (DateTime)((lect["heure_debut"] != null) ? (!lect["heure_debut"].ToString().Trim().Equals("") ? lect["heure_debut"] : DateTime.Now) : DateTime.Now);
                bean.HeureFin    = (DateTime)((lect["heure_fin"] != null) ? (!lect["heure_fin"].ToString().Trim().Equals("") ? lect["heure_fin"] : 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.TypeJournee = lect["type_journee"].ToString();
                bean.Titre       = lect["titre"].ToString();
            }
            catch (Exception ex)
            {
                Messages.Exception(ex);
            }
            return(bean);
        }
Example #3
0
        public static TrancheHoraire getAjoutTrancheHoraire(TrancheHoraire a)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                string        insert = "";
                NpgsqlCommand cmd    = new NpgsqlCommand(insert, con);
                cmd.ExecuteNonQuery();
                a.Id = getCurrent();
                return(a);
            }
            catch
            {
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Example #4
0
        public static bool getUpdateTrancheHoraire(TrancheHoraire a)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                string        update = "";
                NpgsqlCommand Ucmd   = new NpgsqlCommand(update, con);
                Ucmd.ExecuteNonQuery();
                return(true);
            }
            catch (Exception e)
            {
                Messages.Exception(e);
                return(false);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Example #5
0
        public static List <TrancheHoraire> getListTrancheHoraire(String query)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                List <TrancheHoraire> l    = new List <TrancheHoraire>();
                NpgsqlCommand         Lcmd = new NpgsqlCommand(query, con);
                NpgsqlDataReader      lect = Lcmd.ExecuteReader();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        TrancheHoraire a = new TrancheHoraire();
                        a.Id         = Convert.ToInt64(lect["id"].ToString());
                        a.Reference  = lect["reference"].ToString();
                        a.Critere    = lect["critere"].ToString();
                        a.HeureDebut = Convert.ToDateTime((lect["heure_debut"] != null) ? (!lect["heure_debut"].ToString().Trim().Equals("") ? lect["heure_debut"].ToString().Trim() : "00:00:0000") : "00:00:0000");
                        a.HeureFin   = Convert.ToDateTime((lect["heure_fin"] != null) ? (!lect["heure_fin"].ToString().Trim().Equals("") ? lect["heure_fin"].ToString().Trim() : "00:00:0000") : "00:00:0000");
                        a.Actif      = Convert.ToBoolean((lect["actif"] != null) ? (!lect["actif"].ToString().Trim().Equals("") ? lect["actif"].ToString().Trim() : "false") : "false");
                        a.Update     = true;
                        l.Add(a);
                    }
                    lect.Close();
                }
                return(l);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Example #6
0
        public static TrancheHoraire getOneTrancheHoraire(long id)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                String           search = "select * from yvs_com_type_creneau_horaire where id = " + id + "";
                NpgsqlCommand    Lcmd   = new NpgsqlCommand(search, con);
                NpgsqlDataReader lect   = Lcmd.ExecuteReader();
                TrancheHoraire   a      = new TrancheHoraire();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        a.Id         = Convert.ToInt64(lect["id"].ToString());
                        a.Reference  = lect["reference"].ToString();
                        a.Critere    = lect["critere"].ToString();
                        a.HeureDebut = Convert.ToDateTime((lect["heure_debut"] != null) ? (!lect["heure_debut"].ToString().Trim().Equals("") ? lect["heure_debut"].ToString().Trim() : "00:00:0000") : "00:00:0000");
                        a.HeureFin   = Convert.ToDateTime((lect["heure_fin"] != null) ? (!lect["heure_fin"].ToString().Trim().Equals("") ? lect["heure_fin"].ToString().Trim() : "00:00:0000") : "00:00:0000");
                        a.Actif      = Convert.ToBoolean((lect["actif"] != null) ? (!lect["actif"].ToString().Trim().Equals("") ? lect["actif"].ToString().Trim() : "false") : "false");
                        a.Update     = true;
                    }
                    lect.Close();
                }
                return(a);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
 public TrancheHoraireBll(TrancheHoraire unTrancheHoraire)
 {
     tranche = unTrancheHoraire;
 }