Пример #1
0
 public static List<Remise> getListRemise(String query)
 {
     NpgsqlConnection con = Connexion.Connection();
     try
     {
         List<Remise> l = new List<Remise>();
         NpgsqlCommand Lcmd = new NpgsqlCommand(query, con);
         NpgsqlDataReader lect = Lcmd.ExecuteReader();
         if (lect.HasRows)
         {
             while (lect.Read())
             {
                 Remise a = new Remise();
                 a.Id = Convert.ToInt64(lect["id"].ToString());
                 a.Reference = lect["reference"].ToString();
                 a.BaseRemise = lect["base_remise"].ToString();
                 a.Permanent = Convert.ToBoolean((lect["permanent"] != null) ? (!lect["permanent"].ToString().Trim().Equals("") ? lect["permanent"].ToString().Trim() : "false") : "false");
                 a.Grilles = BLL.GrilleRemiseBll.Liste("SELECT * FROM yvs_com_grille_remise WHERE remise =" + a.Id);
                 a.Update = true;
                 l.Add(a);
             }
             lect.Close();
         }
         return l;
     }
     catch (NpgsqlException e)
     {
         Messages.Exception(e);
         return null;
     }
     finally
     {
         Connexion.Deconnection(con);
     }
 }
Пример #2
0
 public static Remise getAjoutRemise(Remise 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);
     }
 }
Пример #3
0
 private static double MontantRemise(Remise r, double quantite, double montant)
 {
     double remise = 0;
     if (r != null)
     {
         switch (r.BaseRemise)
         {
             case Constantes.BASE_CA:
                 foreach (GrilleRabais g in r.Grilles)
                 {
                     if (g.Maximal >= montant && montant >= g.Minimal)
                     {
                         switch (g.Nature)
                         {
                             case Constantes.NATURE_MTANT:
                                 remise = g.Montant;
                                 break;
                             case Constantes.NATURE_TAUX:
                                 remise = (montant * g.Montant) / 100;
                                 break;
                             default:
                                 break;
                         }
                         break;
                     }
                 }
                 break;
             case Constantes.BASE_QTE:
                 foreach (GrilleRabais g in r.Grilles)
                 {
                     if (g.Maximal >= quantite && quantite >= g.Minimal)
                     {
                         switch (g.Nature)
                         {
                             case Constantes.NATURE_MTANT:
                                 remise = g.Montant;
                                 break;
                             case Constantes.NATURE_TAUX:
                                 remise = (montant * g.Montant) / 100;
                                 break;
                             default:
                                 break;
                         }
                         break;
                     }
                 }
                 break;
             default:
                 remise = 0;
                 break;
         }
     }
     return remise;
 }
Пример #4
0
 public static Remise getOneRemise(long id)
 {
     NpgsqlConnection con = Connexion.Connection();
     try
     {
         String search = "select * from yvs_com_remise where id = " + id + "";
         NpgsqlCommand Lcmd = new NpgsqlCommand(search, con);
         NpgsqlDataReader lect = Lcmd.ExecuteReader();
         Remise a = new Remise();
         if (lect.HasRows)
         {
             while (lect.Read())
             {
                 a.Id = Convert.ToInt64(lect["id"].ToString());
                 a.Reference = lect["reference"].ToString();
                 a.BaseRemise = lect["base_remise"].ToString();
                 a.Permanent = Convert.ToBoolean((lect["permanent"] != null) ? (!lect["permanent"].ToString().Trim().Equals("") ? lect["permanent"].ToString().Trim() : "false") : "false");
                 a.Grilles = BLL.GrilleRemiseBll.Liste("SELECT * FROM yvs_com_grille_remise WHERE remise =" + a.Id);
             }
             a.Update = true;
             lect.Close();
         }
         return a;
     }
     catch (NpgsqlException e)
     {
         Messages.Exception(e);
         return null;
     }
     finally
     {
         Connexion.Deconnection(con);
     }
 }
Пример #5
0
 public static bool getUpdateRemise(Remise 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);
     }
 }
Пример #6
0
 public RemiseBll(Remise unRemise)
 {
     remise = unRemise;
 }