Пример #1
0
        public PointDeVenteVue findById(int id)
        {
            conn = new DB().getConn();
            PointDeVenteVue pVente = null;

            try
            {
                string query = "select * from point_de_vente_vue where id=" + id;
                cmd    = new NpgsqlCommand(query, conn);
                reader = cmd.ExecuteReader();
                if (reader.Read() == true)
                {
                    pVente = new PointDeVenteVue(reader.GetInt16(0), reader.GetString(1),
                                                 reader.GetString(3), reader.GetString(4), reader.GetString(5), reader.GetString(6));
                }
            }
            catch (Exception e)
            {
                throw new Exception("Erreur dans PointDeVenteDao=>findBydId " + e.Message);
            }
            finally
            {
                conn.Close();
                reader.Close();
            }
            return(pVente);
        }
Пример #2
0
        public List <PointDeVenteVue> getAll()
        {
            List <PointDeVenteVue> listAll = new List <PointDeVenteVue>();

            conn = new DB().getConn();
            try
            {
                string query = "select * from point_de_vente_vue";
                cmd    = new NpgsqlCommand(query, conn);
                reader = cmd.ExecuteReader();
                while (reader.Read() == true)
                {
                    PointDeVenteVue pvente = new PointDeVenteVue(reader.GetInt16(0), reader.GetString(1),
                                                                 reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5));
                    listAll.Add(pvente);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Erreur dans PointDeVenteDao->getAll" + e.Message);
            }
            finally
            {
                conn.Close();
                reader.Close();
            }
            return(listAll);
        }
Пример #3
0
        public List <PointDeVenteVue> search(PointDeVenteVue pVente)
        {
            conn = new DB().getConn();
            List <PointDeVenteVue> listAll = new List <PointDeVenteVue>();

            try
            {
                string query = "select * from point_de_vente_vue where 1<2";
                if (pVente.ZoneDeTravail != null)
                {
                    query += "zone_de_travail ='" + pVente.ZoneDeTravail + "'";
                }
                if (pVente.Libelle != null)
                {
                    query += " and libelle ='" + pVente.Libelle + "'";
                }
                if (pVente.Latitude != null)
                {
                    query += " and latitude =" + pVente.Latitude;
                }
                if (pVente.Longitude != null)
                {
                    query += " and longitude =" + pVente.Longitude;
                }
                if (pVente.Responsable != null)
                {
                    query += " and responsable = '" + pVente.Responsable + "'";
                }
                Debug.WriteLine(query);
                cmd    = new NpgsqlCommand(query, conn);
                reader = cmd.ExecuteReader();
                while (reader.Read() == true)
                {
                    PointDeVenteVue pv = new PointDeVenteVue(reader.GetInt16(0), reader.GetString(1),
                                                             reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5));
                    listAll.Add(pv);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Erreur dans PointDeVenteDAO=>search " + e.Message);
            }
            finally
            {
                conn.Close();
                reader.Close();
            }
            Debug.WriteLine("listAll count:" + listAll.Count);
            return(listAll);
        }
Пример #4
0
        public List <PointDeVenteVue> search(PointDeVenteVue pointVente)
        {
            List <PointDeVenteVue> listPointDeVente;

            try
            {
                listPointDeVente = pointDeVenteDAO.search(pointVente);
            }
            catch (Exception e)
            {
                throw new Exception("Erreur dans PointDeVenteService => search:" + e.Message + e.StackTrace);
            }
            return(listPointDeVente);
        }
Пример #5
0
        //
        // GET: /PointDeVente/

        public ActionResult Index(int id, string utilisateur)
        {
            //Initiation service
            pointVenteService        = new PointDeVenteService();
            livraisonCarteVueService = new LivraisonCartePVVueService();

            PointDeVenteVue pointDeVente = new PointDeVenteVue(utilisateur);

            List <PointDeVenteVue> listPointDeVente = pointVenteService.search(pointDeVente);
            LivraisonCartePVVue    livraison        = new LivraisonCartePVVue(listPointDeVente[0].Libelle);

            List <LivraisonCartePVVue> listLivraison = new LivraisonCartePVVueDAO().search(livraison);

            ViewBag.ListeLivraison = listLivraison;

            return(View());
        }
Пример #6
0
        public List <PointDeVenteVue> search(PointDeVente pVente)
        {
            conn = new DB().getConn();
            List <PointDeVenteVue> listAll = new List <PointDeVenteVue>();

            try
            {
                string query = "select * from livraison_carte_vue when ";
                if (pVente.ZoneDeTravail != null)
                {
                    query += "zone_de_travail =" + pVente.ZoneDeTravail;
                }
                if (pVente.Libelle != null)
                {
                    query += " and libelle =" + pVente.Libelle;
                }
                if (pVente.Latitude != null)
                {
                    query += " and latitude =" + pVente.Latitude;
                }
                if (pVente.Longitude != null)
                {
                    query += " and longitude =" + pVente.Longitude;
                }

                cmd    = new NpgsqlCommand(query, conn);
                reader = cmd.ExecuteReader();
                while (reader.Read() == true)
                {
                    PointDeVenteVue pv = new PointDeVenteVue(reader.GetInt16(0), reader.GetString(1),
                                                             reader.GetString(3), reader.GetString(4), reader.GetString(5));
                    listAll.Add(pv);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Erreur dans LivraisonCarteDao=>search " + e.Message);
            }
            finally
            {
                conn.Close();
                reader.Close();
            }
            return(listAll);
        }
Пример #7
0
        public ActionResult VenteCarte(int livraison, int quantite, string pointDeVente, string date_vente)
        {
            //insertion vente carte
            venteCarteService = new VenteCarteService();
            pointVenteService = new PointDeVenteService();

            LivraisonCarte         liv        = new LivraisonCarte(livraison);
            PointDeVenteVue        pv         = new PointDeVenteVue(0, pointDeVente);
            List <PointDeVenteVue> listPV     = new PointDeVenteDAO().search(pv);
            PointDeVente           pointVente = new PointDeVente(listPV[0].Id);

            DateTime   date  = DateTime.Parse(date_vente);
            VenteCarte vente = new VenteCarte(liv, quantite, pointVente, date);

            venteCarteService.insert(vente);

            return(new EmptyResult());
        }
Пример #8
0
 public void remove(PointDeVenteVue carte)
 {
     conn = new DB().getConn();
     try
     {
         string query = "delete * from point_de_vente where id = " + carte.Id;
         cmd = new NpgsqlCommand(query, conn);
         cmd.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         throw new Exception("Erreur dans PointDeVenteDao=>remove " + e.Message);
     }
     finally
     {
         conn.Close();
     }
 }