Esempio n. 1
0
        public EmployeVue findById(int id)
        {
            conn = new DB().getConn();
            EmployeVue employe = null;

            try
            {
                string query = "select * from employe_vue where id=" + id;
                cmd    = new NpgsqlCommand(query, conn);
                reader = cmd.ExecuteReader();
                if (reader.Read() == true)
                {
                    employe = new EmployeVue(reader.GetInt16(0), reader.GetString(1),
                                             reader.GetString(2), reader.GetInt32(3), reader.GetString(4), reader.GetString(5),
                                             reader.GetString(6), reader.GetString(7));
                }
            }
            catch (Exception e)
            {
                throw new Exception("Erreur dans EmployeDao=>findBydId " + e.Message);
            }
            finally
            {
                conn.Close();
                reader.Close();
            }
            return(employe);
        }
Esempio n. 2
0
        public List <EmployeVue> getAll()
        {
            List <EmployeVue> listAll = new List <EmployeVue>();

            conn = new DB().getConn();
            try
            {
                string query = "select * from employe_vue";
                cmd    = new NpgsqlCommand(query, conn);
                reader = cmd.ExecuteReader();
                while (reader.Read() == true)
                {
                    EmployeVue employe = new EmployeVue(reader.GetInt16(0), reader.GetString(1),
                                                        reader.GetString(2), reader.GetInt32(3), reader.GetString(4), reader.GetString(5),
                                                        reader.GetString(6), reader.GetString(7));
                    listAll.Add(employe);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Erreur dans EmployeDao->getAll" + e.Message);
            }
            finally
            {
                conn.Close();
                reader.Close();
            }
            return(listAll);
        }
Esempio n. 3
0
        //INSERT LIVRAISON
        public ActionResult Livraison(int empStock, int employe, int quantite,
                                      int resteNonVendu, string dateLivraison, int pointDeVente)
        {
            //Insertion livraison

            livraisonCarteService = new LivraisonCarteService();
            empStockService       = new EmployeStockService();
            empService            = new EmployeService();

            Employe        emp          = new Employe(employe);
            PointDeVente   pointVente   = new PointDeVente(pointDeVente);
            EmployeStock   employeStock = new EmployeStock(empStock);
            DateTime       date         = DateTime.Parse(dateLivraison);
            LivraisonCarte livCarte     = new LivraisonCarte(employeStock, quantite, resteNonVendu,
                                                             date, pointVente);

            livraisonCarteService.insert(livCarte);

            //Update stock
            EmployeStockVue emplStock = empStockService.findById(empStock);

            Debug.WriteLine("Emp stock update " + emplStock.Stock + "-" + empStock);
            int          stockUpdate    = emplStock.Stock - quantite;
            EmployeStock empStockUpdate = new EmployeStock(emplStock.Id, stockUpdate);

            empStockService.update(empStockUpdate);

            //GET ALL STOCK

            EmployeVue             empl    = empService.findById(employe);
            List <EmployeStockVue> listAll = empStockService.search(new EmployeStockVue(empl.Nom, emp.Prenom));

            ViewBag.listStock = listAll;
            return(View());
        }
Esempio n. 4
0
        public List <EmployeVue> search(Employe employe)
        {
            conn = new DB().getConn();
            List <EmployeVue> listAll = new List <EmployeVue>();

            try
            {
                string query = "select * from employe_vue where 1<2 ";
                if (employe.Nom != null)
                {
                    query += " and nom =" + employe.Nom;
                }
                if (employe.Prenom != null)
                {
                    query += " and prenom =" + employe.Prenom;
                }
                if (employe.Age != 0)
                {
                    query += " and age =" + employe.Age;
                }
                if (employe.Sexe != null)
                {
                    query += " and sexe =" + employe.Sexe;
                }
                if (employe.Email != null)
                {
                    query += " and email =" + employe.Email;
                }
                if (employe.Contact != null)
                {
                    query += " and contact =" + employe.Contact;
                }
                if (employe.TypeEmploye != null)
                {
                    query += " and type_employe = '" + employe.TypeEmploye.Libelle + "'";
                }
                cmd    = new NpgsqlCommand(query, conn);
                reader = cmd.ExecuteReader();
                while (reader.Read() == true)
                {
                    EmployeVue c = new EmployeVue(reader.GetInt32(0), reader.GetString(1),
                                                  reader.GetString(2), reader.GetInt16(3), reader.GetString(4), reader.GetString(5),
                                                  reader.GetString(6), reader.GetString(7));
                    listAll.Add(c);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Erreur dans EmployeDao=>search " + e.Message);
            }
            finally
            {
                conn.Close();
                reader.Close();
            }
            return(listAll);
        }
Esempio n. 5
0
        public ActionResult Index(int id)
        {
            empStockService     = new EmployeStockService();
            empService          = new EmployeService();
            pointDeVenteService = new PointDeVenteService();

            List <EmployeVue>      listEmploye      = empService.getAll();
            List <PointDeVenteVue> listPointDeVente = pointDeVenteService.getAll();

            ViewBag.listEmploye    = listEmploye;
            ViewBag.listPointVente = listPointDeVente;

            EmployeVue             emp     = empService.findById(id);
            List <EmployeStockVue> listAll = empStockService.search(new EmployeStockVue(emp.Nom, emp.Prenom));

            ViewBag.listStock = listAll;
            return(View());
        }
Esempio n. 6
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());
        }