public void remove(DistributionCarte carte)
 {
     try
     {
         distributionDAO.remove(carte);
     }
     catch (Exception e)
     {
         throw new Exception("Erreur dans DistributionCarteService => remove:" + e.Message);
     }
 }
 public void insert(DistributionCarte distribCarte)
 {
     try
     {
         distributionDAO.insert(distribCarte);
     }
     catch (Exception e)
     {
         throw new Exception("Erreur dans DistributionCarteService => insert:" + e.Message);
     }
 }
Esempio n. 3
0
 public void remove(DistributionCarte dcarte)
 {
     conn = new DB().getConn();
     try
     {
         string query = "delete * from distribution_carte where id = " + dcarte.Id;
         cmd = new NpgsqlCommand(query, conn);
         cmd.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         throw new Exception("Erreur dans distributionCarte=>remove " + e.Message);
     }
     finally
     {
         conn.Close();
     }
 }
Esempio n. 4
0
        // Add card
        public ActionResult InsertCard(int carte, int employe, int quantite, string date)
        {
            //instanciation des services
            distribCarteService      = new DistributionCarteService();
            empStockService          = new EmployeStockService();
            empService               = new EmployeService();
            carteService             = new CarteService();
            employeStockHistoService = new EmployeStockHistoService();

            //instanciation objet depuis argument
            Carte      c        = new Carte(carte);
            Employe    emp      = new Employe(employe);
            DateTime   dateTime = DateTime.Parse(date);
            EmployeVue employee = empService.findById(employe);
            Carte      cartee   = carteService.findById(carte);

            //instanciation distribution carte
            DistributionCarte carteDist = new DistributionCarte(c, emp, quantite, dateTime);

            //Recherche du stock de l'employe actuelle
            EmployeStockVue empStockActu = new EmployeStockVue();

            empStockActu.Carte = cartee.Libelle;
            empStockActu.Nom   = employee.Nom;
            List <EmployeStockVue> listEmpStockActu = empStockService.search(empStockActu);

            //insertion de la distribution
            distribCarteService.insert(carteDist);

            //mise a jour du stock du coursier
            int stock = listEmpStockActu[0].Stock + quantite;

            empStockService.update(new EmployeStock(employe, stock, carte));

            //insertion du nouveau stock du coursier
            employeStockHistoService.insert(new EmployeStockHisto(employe, quantite, carte));

            //Recherche liste carte distribue
            List <DistributionCarteVue> listCarteDistr = distribCarteService.getAll();

            ViewBag.ListCarteDistr = listCarteDistr;
            return(View());
        }
Esempio n. 5
0
 public void insert(DistributionCarte dcarte)
 {
     conn = new DB().getConn();
     try
     {
         string query = "insert into distribution_carte (id, carte, employe, quantite, date) values"
                        + " (nextval('seq_distribution_carte')," + dcarte.Carte.Id + "," + dcarte.Employe.Id + ")";
         cmd = new NpgsqlCommand(query, conn);
         cmd.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         throw new Exception("Erreur dans DistributionCarteDao=>insert" + e.Message);
     }
     finally
     {
         conn.Close();
     }
 }