Example #1
0
 public static Entete One(Creneau creneau, DateTime date)
 {
     try
     {
         return EnteteDao.getOneEntete(creneau, date);
     }
     catch (Exception ex)
     {
         throw new Exception("Impossible d'atteindre l'enregistrement", ex);
     }
 }
Example #2
0
 public static List<Creneau> getListCreneau(String query)
 {
     NpgsqlConnection con = Connexion.Connection();
     try
     {
         List<Creneau> l = new List<Creneau>();
         NpgsqlCommand Lcmd = new NpgsqlCommand(query, con);
         NpgsqlDataReader lect = Lcmd.ExecuteReader();
         if (lect.HasRows)
         {
             while (lect.Read())
             {
                 Creneau a = new Creneau();
                 a.Id = Convert.ToInt64(lect["id"].ToString());
                 a.Actif = Convert.ToBoolean((lect["actif"] != null) ? (!lect["actif"].ToString().Trim().Equals("") ? lect["actif"].ToString().Trim() : "false") : "false");
                 a.DateTravail = (DateTime)((lect["date_travail"] != null) ? (!lect["date_travail"].ToString().Trim().Equals("") ? lect["date_travail"] : DateTime.Now) : DateTime.Now);
                 a.Personnel = (lect["users"] != null
                     ? (!lect["users"].ToString().Trim().Equals("")
                     ? BLL.PersonnelBll.One(Convert.ToInt64(lect["users"].ToString()))
                     : new Personnel())
                     : new Personnel());
                 a.Depot = (lect["depot"] != null
                     ? (!lect["depot"].ToString().Trim().Equals("")
                     ? BLL.DepotBll.One(Convert.ToInt64(lect["depot"].ToString()))
                     : new Depot())
                     : new Depot());
                 a.Tranche = (lect["type"] != null
                     ? (!lect["type"].ToString().Trim().Equals("")
                     ? BLL.TrancheHoraireBll.One(Convert.ToInt64(lect["type"].ToString()))
                     : new TrancheHoraire())
                     : new TrancheHoraire());
                 a.Update = true;
                 l.Add(a);
             }
             lect.Close();
         }
         return l;
     }
     catch (NpgsqlException e)
     {
         Messages.Exception(e);
         return null;
     }
     finally
     {
         Connexion.Deconnection(con);
     }
 }
Example #3
0
 public static Creneau getAjoutCreneau(Creneau 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 Entete getOneEntete(Creneau creneau, DateTime date)
 {
     NpgsqlConnection con = Connexion.Connection();
     try
     {
         String search = "select * from yvs_com_entete_doc_vente where date_entete = '" + date + "' and creneau = " + creneau.Id;
         NpgsqlCommand Lcmd = new NpgsqlCommand(search, con);
         NpgsqlDataReader lect = Lcmd.ExecuteReader();
         Entete a = new Entete();
         if (lect.HasRows)
         {
             while (lect.Read())
             {
                 a.Id = Convert.ToInt64(lect["id"].ToString());
                 a.Etat = lect["etat"].ToString();
                 a.DateEntete = Convert.ToDateTime((lect["date_entete"] != null) ? (!lect["date_entete"].ToString().Trim().Equals("") ? lect["date_entete"].ToString().Trim() : "00/00/0000") : "00/00/0000");
                 a.Creneau = (lect["creneau"] != null
                     ? (!lect["creneau"].ToString().Trim().Equals("")
                     ? BLL.CreneauBll.One(Convert.ToInt64(lect["creneau"].ToString()))
                     : new Creneau())
                     : new Creneau());
                 a.FacturesRegle = BLL.FactureBll.Liste("select * from yvs_com_doc_ventes where entete_doc = "
                     + a.Id + " and type_doc = '" + Constantes.TYPE_FV + "' and statut = '" + Constantes.ETAT_REGLE + "'");
                 foreach (Facture f in a.FacturesRegle)
                 {
                     a.Montant += f.MontantTTC;
                 }
                 a.FacturesEnAttente = BLL.FactureBll.Liste("select * from yvs_com_doc_ventes where entete_doc = "
                     + a.Id + " and type_doc = '" + Constantes.TYPE_FV + "' and statut = '" + Constantes.ETAT_EN_ATTENTE + "'");
                 foreach (Facture f in a.FacturesEnAttente)
                 {
                     a.Montant += f.MontantTTC;
                 }
                 a.FacturesEnCours = BLL.FactureBll.Liste("select * from yvs_com_doc_ventes where entete_doc = "
                     + a.Id + " and type_doc = '" + Constantes.TYPE_FV + "' and statut = '" + Constantes.ETAT_EN_COURS + "'");
                 foreach (Facture f in a.FacturesEnCours)
                 {
                     a.Montant += f.MontantTTC;
                 }
                 a.Commandes = BLL.FactureBll.Liste("select * from yvs_com_doc_ventes where entete_doc = "
                     + a.Id + " and type_doc = '" + Constantes.TYPE_BCV + "' and statut = '" + Constantes.ETAT_VALIDE + "'");
                 foreach (Facture f in a.Commandes)
                 {
                     a.Montant += f.MontantAvance;
                 }
                 a.Update = true;
             }
             lect.Close();
         }
         return a;
     }
     catch (NpgsqlException e)
     {
         Messages.Exception(e);
         return null;
     }
     finally
     {
         Connexion.Deconnection(con);
     }
 }
Example #5
0
 public static bool getUpdateCreneau(Creneau 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 #6
0
 public static Creneau getOneCreneau(Personnel pers, DateTime date, DateTime heureDebut, DateTime heureFin)
 {
     NpgsqlConnection con = Connexion.Connection();
     try
     {
         String search = "select c.id as id, c.date_travail as date_travail, c.users as users, c.actif actif, h.depot as depot, h.type as type"
             + " from yvs_com_creneau_horaire_users c "
             + " inner join yvs_com_creneau_horaire h on c.creneau = h.id"
             + " inner join yvs_com_type_creneau_horaire t on h.type = t.id"
             + " where c.users = " + pers.Id + " and c.date_travail ='" + date + "' and t.heure_debut = '" + heureDebut + "' and t.heure_fin = '" + heureFin + "'";
         NpgsqlCommand Lcmd = new NpgsqlCommand(search, con);
         NpgsqlDataReader lect = Lcmd.ExecuteReader();
         Creneau a = new Creneau();
         if (lect.HasRows)
         {
             while (lect.Read())
             {
                 a.Id = Convert.ToInt64(lect["id"].ToString());
                 a.Actif = Convert.ToBoolean((lect["actif"] != null) ? (!lect["actif"].ToString().Trim().Equals("") ? lect["actif"].ToString().Trim() : "false") : "false");
                 a.DateTravail = (DateTime)((lect["date_travail"] != null) ? (!lect["date_travail"].ToString().Trim().Equals("") ? lect["date_travail"] : DateTime.Now) : DateTime.Now);
                 a.Personnel = (lect["users"] != null
                     ? (!lect["users"].ToString().Trim().Equals("")
                     ? BLL.PersonnelBll.One(Convert.ToInt64(lect["users"].ToString()))
                     : new Personnel())
                     : new Personnel());
                 a.Depot = (lect["depot"] != null
                     ? (!lect["depot"].ToString().Trim().Equals("")
                     ? BLL.DepotBll.One(Convert.ToInt64(lect["depot"].ToString()))
                     : new Depot())
                     : new Depot());
                 a.Tranche = (lect["type"] != null
                     ? (!lect["type"].ToString().Trim().Equals("")
                     ? BLL.TrancheHoraireBll.One(Convert.ToInt64(lect["type"].ToString()))
                     : new TrancheHoraire())
                     : new TrancheHoraire());
                 a.Update = true;
             }
             lect.Close();
         }
         return a;
     }
     catch (NpgsqlException e)
     {
         Messages.Exception(e);
         return null;
     }
     finally
     {
         Connexion.Deconnection(con);
     }
 }
Example #7
0
 public CreneauBll(Creneau unCreneau)
 {
     creneau = unCreneau;
 }