//  [Route("buy/{id}")]
 public IActionResult Buy(string id, string quantity_input)
 {
     if (SessionHelper.GetObjectFromJson <List <Panier> >(HttpContext.Session, "cart") == null)
     {
         List <Panier> cart = new List <Panier>();
         cart.Add(new Panier {
             Produit = ProduitDAO.GetProduit(id), Quantity = int.Parse(quantity_input)
         });
         SessionHelper.SetObjectAsJson(HttpContext.Session, "cart", cart);
         SessionHelper.SetObjectAsJson(HttpContext.Session, "cartNombre", cart.Count());
         SessionHelper.SetObjectAsJson(HttpContext.Session, "cartTotal", cart.Sum(item => item.Produit.Prix * item.Quantity));
     }
     else
     {
         List <Panier> cart  = SessionHelper.GetObjectFromJson <List <Panier> >(HttpContext.Session, "cart");
         int           index = isExist(id);
         if (index != -1)
         {
             cart[index].Quantity = cart[index].Quantity + int.Parse(quantity_input);
         }
         else
         {
             cart.Add(new Panier {
                 Produit = ProduitDAO.GetProduit(id), Quantity = int.Parse(quantity_input)
             });
         }
         SessionHelper.SetObjectAsJson(HttpContext.Session, "cart", cart);
         SessionHelper.SetObjectAsJson(HttpContext.Session, "cartNombre", cart.Count());
         SessionHelper.SetObjectAsJson(HttpContext.Session, "cartTotal", cart.Sum(item => item.Produit.Prix * item.Quantity));
     }
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 2
0
        public static ProduitDAO getProduit(int id)
        {
            string       query = "SELECT * FROM produit WHERE id=" + id + ";";
            MySqlCommand cmd   = new MySqlCommand(query, DALConnection.OpenConnection());

            cmd.ExecuteNonQuery();
            MySqlDataReader reader = cmd.ExecuteReader();

            reader.Read();
            float prixVente;

            if (Convert.IsDBNull(reader[2]))
            {
                prixVente = 0;
            }
            else
            {
                prixVente = reader.GetFloat(2);
            }

            int idLot; // = ( int ) reader["idLot"];

            if (Convert.IsDBNull(reader[7]))
            {
                idLot = 0;
            }
            else
            {
                idLot = reader.GetInt32(7);
            }

            int idPhoto;

            if (Convert.IsDBNull(reader[8]))
            {
                idPhoto = 0;
            }
            else
            {
                idPhoto = reader.GetInt32(8);
            }

            int idAcheteur;

            if (Convert.IsDBNull(reader[9]))
            {
                idAcheteur = 0;
            }
            else
            {
                idAcheteur = reader.GetInt32(9);
            }

            ProduitDAO cat = new ProduitDAO(reader.GetInt32(0), reader.GetFloat(1), prixVente,
                                            reader.GetString(3), reader.GetString(4), reader.GetString(5), reader.GetString(6),
                                            idLot, idPhoto, idAcheteur, reader.GetInt32(10));

            reader.Close();
            return(cat);
        }
Ejemplo n.º 3
0
        public static ProduitViewModel getProduit(int id)
        {
            ProduitDAO       pDAO = ProduitDAO.getProduit(id);
            ProduitViewModel p    = new ProduitViewModel(pDAO.idDAO, pDAO.estimationActuelleDAO, pDAO.prixVenteDAO, pDAO.nomProduitDAO, pDAO.descriptionDAO, pDAO.artisteDAO, pDAO.styleDAO, pDAO.isVenduDAO, pDAO.idCategorieDAO, pDAO.idLotDAO, pDAO.idPhotoDAO);

            return(p);
        }
        public IActionResult produit(string codeProduit)
        {
            Produit produit = ProduitDAO.GetProduit(codeProduit);

            ViewData["Product"] = produit;
            return(View());
        }
Ejemplo n.º 5
0
        public IActionResult RechEditeur(string cat)
        {
            List <Editeur> ListeEditeur = ProduitDAO.GetListeDistinctEditeurByCat(cat);

            // List<Categorie> ListeCategories = SessionHelper.GetObjectFromJson<List<Categorie>>(HttpContext.Session, "SessionListCategorie");
            return(new JsonResult(ListeEditeur));
        }
Ejemplo n.º 6
0
 private void Txt_NumCde_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)13)
     {
         Boolean val = CommandeDAO.Existe_Commande(Txt_NumCde.Text);
         if (val)
         {
             Pan_LigC.Visible = true;
             DataTable dtlc = LigneCommandeDAO.List_LigneCommande_ParNum(Txt_NumCde.Text);
             foreach (DataRow row in dtlc.Rows)
             {
                 DataTable dtpr = ProduitDAO.List_Prod_Ref(row["Ref_Prod"].ToString());
                 Dg_Prod.Rows.Add(row["Ref_Prod"].ToString(), dtpr.Rows[0]["Desig_Prod"].ToString(), dtpr.Rows[0]["PrixV_Prod"].ToString(), row["qte"].ToString(), Convert.ToInt32(dtpr.Rows[0]["PrixV_Prod"].ToString()) * Convert.ToInt32(row["qte"].ToString()));
                 totalCde += Convert.ToInt32(dtpr.Rows[0]["PrixV_Prod"].ToString()) * Convert.ToInt32(row["qte"].ToString());
             }
             DataTable dtc = CommandeDAO.List_Com_Num(Txt_NumCde.Text);
             DataTable dt  = ClientADO.Liste_Client_ParCin(Convert.ToInt64(dtc.Rows[0]["cin_cl"].ToString()));
             Txt_cin.Text      = dt.Rows[0]["cin_cl"].ToString();
             Txt_nom.Text      = dt.Rows[0]["Nom_cl"].ToString();
             Txt_prenom.Text   = dt.Rows[0]["pren_cl"].ToString();
             Txt_vil.Text      = dt.Rows[0]["ville_cl"].ToString();
             Txt_tel.Text      = dt.Rows[0]["tel_cl"].ToString();
             Txt_TotalCde.Text = totalCde.ToString();
         }
         else
         {
             Pan_LigC.Visible = true;
         }
     }
 }
Ejemplo n.º 7
0
        private void cbxCat_SelectedIndexChanged(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            ProduitDAO pd = new ProduitDAO();

            produits = pd.FindAll();

            if (cbxCat.SelectedIndex == 0)
            {
                foreach (Produit ProductDetail in produits)
                {
                    dataGridView1.Rows.Add(ProductDetail.Id, ProductDetail.Nom, ProductDetail.Prix, ProductDetail.IdCat, ProductDetail.Description, ProductDetail.Img);
                }
            }
            else if (cbxCat.SelectedIndex > 0)
            {
                string       CategoryName = cbxCat.SelectedItem.ToString();
                CategorieDAO c            = new CategorieDAO();
                int          id           = c.ReturnCategorieID(CategoryName);
                ProduitDAO   pdao         = new ProduitDAO();
                produits = pdao.FindToCat(id);

                // int CategoryID = _DataAccess.ReturnCategoryID(CategoryName);

                foreach (Produit ProductDetail in produits)
                {
                    dataGridView1.Rows.Add(ProductDetail.Id, ProductDetail.Nom, ProductDetail.Prix, ProductDetail.IdCat, ProductDetail.Description, ProductDetail.Img);
                }
            }
        }
Ejemplo n.º 8
0
        public static ObservableCollection <ProduitDAO> selectProduits()
        {
            ObservableCollection <ProduitDAO> l = new ObservableCollection <ProduitDAO>();
            string          query  = "SELECT * FROM produit;";
            MySqlCommand    cmd    = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataReader reader = null;

            try
            {
                cmd.ExecuteNonQuery();
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    ProduitDAO p = new ProduitDAO(reader.GetInt32(0), reader.GetFloat(1), reader.GetFloat(2), reader.GetString(3), reader.GetString(4), reader.GetString(5), reader.GetString(6), reader.GetBoolean(7), reader.GetInt32(8), reader.GetInt32(9), reader.GetInt32(10));
                    l.Add(p);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Problème dans la table : {0}", e.StackTrace);
            }
            reader.Close();
            return(l);
        }
Ejemplo n.º 9
0
        void CategoryButtonClick(object sender, EventArgs e)
        {
            flPanelProd.Controls.Clear();

            Button btn = (Button)sender;

            int CategoryID = Convert.ToInt32(btn.Tag);

            ProduitDAO bd = new ProduitDAO();

            AllProduit = bd.FindToCat(CategoryID);



            foreach (Produit Product in AllProduit)
            {
                Button ProductButton = new Button();
                ProductButton.Text      = Product.Nom;
                ProductButton.Size      = new System.Drawing.Size(90, 90);
                ProductButton.ForeColor = Color.White;
                ProductButton.Cursor    = Cursors.Hand;
                ProductButton.Font      = new System.Drawing.Font(ProductButton.Font.Name, 10, FontStyle.Bold);

                MemoryStream ms = new MemoryStream(Product.Img);
                ProductButton.Image = Image.FromStream(ms);
                ProductButton.Image = new Bitmap(ProductButton.Image, ProductButton.Size);

                ProductButton.Tag = Product.Id;

                flPanelProd.Controls.Add(ProductButton);

                ProductButton.Click += ProductButton_Click;
                //ProductButton.MouseClick += ProductButton_MouseClick;
            }
        }
Ejemplo n.º 10
0
        public ActionResult FicheProduit(String id)
        {
            ActionResult retour = View();

            if (Session["UserID"] == null)
            {
                retour = RedirectToAction("Login");
            }
            else
            {
                ProduitDAO produitDao = new ProduitDAO();
                retour = RedirectToAction("AccueilCR", new { id = "Listedesproduits" });

                if (!String.IsNullOrWhiteSpace(id))
                {
                    if (Int32.TryParse(id, out int idProduit))
                    {
                        if (produitDao.Read(idProduit) != null)
                        {
                            Produit produit = produitDao.Read(idProduit);
                            ViewBag.produit = produit;
                            retour          = View();
                        }
                    }
                }
            }
            return(retour);
        }
Ejemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ProduitDAO pdao = new ProduitDAO("clone_kijiji", "root", "root");

            product.DataSource = pdao.GetAllProduit();
            product.DataBind();
        }
Ejemplo n.º 12
0
        void ProductButton_Click(object sender, EventArgs e)
        {
            Button     ProductButton = sender as Button;
            int        ProduitID     = Convert.ToInt32(ProductButton.Tag);
            ProduitDAO bd            = new ProduitDAO();
            Produit    p             = bd.Find(ProduitID);

            if (CheckProductAlreadyAdded(ProduitID))
            {
                // MessageBox.Show("Product Alraedy Exists in Datagrid view at Index : " + RowIndex);
                int     Quantity = Convert.ToInt32(dgvProd.Rows[RowIndex].Cells["qte"].Value);
                decimal Price    = Convert.ToInt32(dgvProd.Rows[RowIndex].Cells["prix"].Value);

                Quantity++;

                /////////////<Do thisssss...... Important.. Have decimal part in the total price>
                double TotalPrice = Convert.ToDouble(Quantity * Price);

                dgvProd.Rows[RowIndex].Cells["qte"].Value          = Quantity;
                dgvProd.Rows[RowIndex].Cells["totalProduit"].Value = TotalPrice;

                txtTotal.Text = CalculateTotalBill(dgvProd).ToString();
            }
            else
            {
                dgvProd.Rows.Add(ProduitID, p.Nom, p.Prix, 1, p.Prix * 1);

                txtTotal.Text = CalculateTotalBill(dgvProd).ToString();
            }
        }
Ejemplo n.º 13
0
        public static ProduitViewModel getProduit(int idProduit)
        {
            ProduitDAO       pDAO = ProduitDAO.getProduit(idProduit);
            ProduitViewModel p    = new ProduitViewModel(pDAO.id_produit, pDAO.id_lot, pDAO.prix_depart, pDAO.description, pDAO.date_vente, pDAO.estimation, pDAO.is_vendu, pDAO.prix_reserve, pDAO.region, pDAO.attribut);

            return(p);
        }
Ejemplo n.º 14
0
        public ActionResult Echantillon(int id_rdv)
        {
            ViewBag.Employe = (Employe)Session["Employe"];

            if (ViewBag.Employe != null)
            {
                ProduitDAO          produitManager          = new ProduitDAO();
                EchantillonDonneDAO echantillonDonneManager = new EchantillonDonneDAO();
                RendezVousDAO       rendezVousManager       = new RendezVousDAO();

                RendezVous rendezVous = rendezVousManager.Read(id_rdv, false);
                List <EchantillonDonne> mesEchantillonsDonnes = echantillonDonneManager.ReadAllFromRendezVous(id_rdv);
                List <Produit>          mesFamilles           = produitManager.ReadFamille();

                ViewBag.Famille          = mesFamilles;
                ViewBag.EchantillonDonne = mesEchantillonsDonnes;
                ViewBag.RendezVous       = rendezVous;

                return(View());
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Ejemplo n.º 15
0
        public string Edit()
        {
            Stream req = Request.InputStream;

            req.Seek(0, System.IO.SeekOrigin.Begin);
            string json = new StreamReader(req).ReadToEnd();

            Produit plan = null;

            try
            {
                plan = JsonConvert.DeserializeObject <Produit>(json);
                if (plan == null)
                {
                    return("Erreur");
                }

                bool result = ProduitDAO.UpdateProduit(plan);

                if (result == false)
                {
                    return("Erreur");
                }
                else
                {
                    return(JsonConvert.SerializeObject(plan));
                }
            }
            catch (Exception ex)
            {
                // Try and handle malformed POST body
                return("Erreur");
            }
        }
Ejemplo n.º 16
0
        public static void updateProduit(ProduitDAO p)
        {
            string           query       = "UPDATE produit set estimationActuelle=\"" + p.estimationActuelleDAO + "\", prixVente=\"" + p.prixVenteDAO + "\",nom=\"" + p.nomProduitDAO + "\", description=\"" + p.descriptionDAO + "\", artiste=\"" + p.artisteDAO + "\", style=\"" + p.styleDAO + "\", isVendu=\"" + p.isVenduDAO + "\", idCategorie=\"" + p.idCategorieDAO + "\", idLot=\"" + p.idLotDAO + "\", idPhoto=\"" + p.idPhotoDAO + "\" where id=" + p.idDAO + ";";
            MySqlCommand     cmd         = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd);

            cmd.ExecuteNonQuery();
        }
Ejemplo n.º 17
0
        public IActionResult Editeur(string editeur)
        {
            List <Produit> ListeProduits = ProduitDAO.GetListeFullProduitByEditeur(editeur);

            ViewData["ListeProduitsShop"] = ListeProduits;
            ViewData["ShopTitre"]         = EditeurDAO.GetEditeur(editeur);
            return(View("shop"));
        }
Ejemplo n.º 18
0
        public IActionResult RechercheDetail(string Rechcat, string edition2, string editeur2)
        {
            List <Produit> ListeProduits = ProduitDAO.RechercheProduits(Rechcat, editeur2, edition2);

            ViewData["ListeProduitsShop"] = ListeProduits;
            ViewData["ShopTitre"]         = "Recherche";
            return(View("shop"));
        }
Ejemplo n.º 19
0
        public IActionResult Recherche(string rechecheStr)
        {
            List <Produit> ListeProduits = ProduitDAO.GetListeDesProduitsByName(rechecheStr);

            ViewData["ListeProduitsShop"] = ListeProduits;
            ViewData["ShopTitre"]         = "Recherche";
            return(View("shop"));
        }
Ejemplo n.º 20
0
        public static void updateProduit(ProduitDAO p)
        {
            string           query       = "UPDATE Produit set id_lot=\"" + p.id_lot + "\", prix_depart=\"" + p.prix_depart + "\", description=\"" + p.description + "\", date_vente=\"" + p.date_vente + "\", estimation=\"" + p.estimation + "\", is_vendu=\"" + p.is_vendu + "\", prix_reserve=\"" + p.prix_reserve + "\", region=\"" + p.region + "\", attribut=\"" + p.attribut + "\" where id_produit=" + p.id_produit + ";";
            MySqlCommand     cmd         = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd);

            cmd.ExecuteNonQuery();
        }
Ejemplo n.º 21
0
        public static void insertProduit(ProduitDAO p)
        {
            int              id          = getMaxIdProduit() + 1;
            string           query       = "INSERT INTO produit VALUES (\"" + id + "\",\"" + p.estimationActuelleDAO + "\",\"" + p.prixVenteDAO + "\",\"" + p.nomProduitDAO + "\",\"" + p.descriptionDAO + "\",\"" + p.artisteDAO + "\",\"" + p.styleDAO + "\",\"" + p.isVenduDAO + "\",\"" + p.idCategorieDAO + "\",\"" + p.idLotDAO + "\",\"" + p.idPhotoDAO + "\");";
            MySqlCommand     cmd2        = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd2);

            cmd2.ExecuteNonQuery();
        }
Ejemplo n.º 22
0
        public static ProduitViewModel getProduit(int idProduit)
        {
            //todo finir l'ORM pour produit gg
            ProduitDAO       pDAO = ProduitDAO.getProduit(idProduit);
            ProduitViewModel p    = new ProduitViewModel(pDAO.idProduitDAO, pDAO.estimationProduitDAO, pDAO.prixVenteProduitDAO, pDAO.nomProduitDAO, pDAO.descriptionProduitDAO,
                                                         pDAO.artisteProduitDAO, pDAO.styleProduitDAO, pDAO.idLotProduitDAO, pDAO.idPhotoProduitDAO, pDAO.idAcheteurProduitDAO, pDAO.idVendeurProduitDAO);

            return(p);
        }
Ejemplo n.º 23
0
        public IActionResult shopping(string categorie)
        {
            string         cat           = CategorieDAO.GetCategorie(categorie);
            List <Produit> ListeProduits = ProduitDAO.GetListeFullProduitByCategorie(categorie);

            ViewData["ListeProduitsShop"] = ListeProduits;
            ViewData["ShopTitre"]         = cat;
            return(View("shop"));
        }
Ejemplo n.º 24
0
        public static void insertProduit(ProduitDAO p)
        {
            int              id          = getMaxIdProduit() + 1;
            string           query       = "INSERT INTO Produit VALUES (\"" + id + "\",\"" + p.id_lot + "\",\"" + p.prix_depart + "\",\"" + p.description + "\",\"" + p.date_vente + "\",\"" + p.estimation + "\",\"" + p.is_vendu + "\",\"" + p.prix_reserve + "\",\"" + p.region + "\",\"" + p.attribut + "\");";
            MySqlCommand     cmd2        = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd2);

            cmd2.ExecuteNonQuery();
        }
Ejemplo n.º 25
0
        //GET: Produits/Range/1/5
        public string Range(int id, int id_max)
        {
            List <Produit> p = ProduitDAO.getProduits(id, id_max);

            if (p.Count != 0)
            {
                return(JsonConvert.SerializeObject(p));
            }

            return(JsonConvert.SerializeObject("Erreur les produits en question n'existent pas"));
        }
Ejemplo n.º 26
0
        // GET: Produits/Details/5
        public string Details(int id)
        {
            Produit p = ProduitDAO.getProduit(id);

            if (p.ID != 0)
            {
                return(JsonConvert.SerializeObject(p));
            }

            return(JsonConvert.SerializeObject("Erreur le produit en question n'existe pas"));
        }
Ejemplo n.º 27
0
        private void btnConfirme_Click(object sender, EventArgs e)
        {
            EmployerDAO empd = new EmployerDAO();
            Employer    emp2 = empd.Find(user);
            DateTime    auj  = DateTime.Now.Date;
            string      d    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            DateTime    auj2 = DateTime.Parse(d);


            // Employer emp = new Employer(0,"","","","","","","","","", auj,auj,null);
            decimal total, don, ret;

            total = Convert.ToDecimal(txtTotal.Text);
            don   = Convert.ToDecimal(txtmtdonne.Text);
            ret   = Convert.ToDecimal(txtmtretourne.Text);
            metiers.Ticket m = new metiers.Ticket(idTick, emp2, total, don, ret, auj2);
            //metiers.Ticket m2 = new metiers.Ticket(emp2, total, don, ret, auj);

            TicketDAO bd = new TicketDAO();

            bd.Add(m);
            //  bd.Add2(m2);

            metiers.Ticket m2 = bd.Find(Convert.ToInt32(txtnumtick.Text));
            foreach (DataGridViewRow Row in dgvProd.Rows)
            {
                try
                {
                    LigneTicketDAO ltb             = new LigneTicketDAO();
                    int            ProductId       = Convert.ToInt32(Row.Cells["id"].Value);
                    string         ProductName     = Row.Cells["Nomproduit"].Value.ToString();
                    decimal        ProductPrice    = Convert.ToDecimal(Row.Cells["prix"].Value);
                    int            ProductQuantity = Convert.ToInt32(Row.Cells["qte"].Value);
                    decimal        ProductTotal    = Convert.ToDecimal(Row.Cells["totalProduit"].Value);
                    ProduitDAO     pb = new ProduitDAO();
                    Produit        p  = pb.Find(ProductId);
                    LigneTicket    l  = new LigneTicket(0, p, m2, ProductName, ProductQuantity, ProductPrice, ProductTotal);
                    ltb.Add(l);
                }
                catch
                {
                    //means Rows are ended
                }
            }



            new Ticket(txtTotal.Text, txtmtdonne.Text, txtmtretourne.Text).ShowDialog();
            this.Hide();
            UIEmployer f1 = new UIEmployer(user);

            f1.Show();
        }
Ejemplo n.º 28
0
        public string ProduitFromFamille(string famille)
        {
            string         response       = "";
            ProduitDAO     produitManager = new ProduitDAO();
            List <Produit> mesProduits    = produitManager.ReadNom(famille);

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            response = serializer.Serialize(mesProduits);

            return(response);
        }
Ejemplo n.º 29
0
        public static ObservableCollection <ProduitViewModel> listeProduits()
        {
            ObservableCollection <ProduitDAO>       lDAO = ProduitDAO.listeProduits();
            ObservableCollection <ProduitViewModel> l    = new ObservableCollection <ProduitViewModel>();

            foreach (ProduitDAO element in lDAO)
            {
                ProduitViewModel p = new ProduitViewModel(element.id_produit, element.id_lot, element.prix_depart, element.description, element.date_vente, element.estimation, element.is_vendu, element.prix_reserve, element.region, element.attribut);
                l.Add(p);
            }
            return(l);
        }
Ejemplo n.º 30
0
        public static ObservableCollection <ProduitViewModel> listeProduits()
        {
            ObservableCollection <ProduitDAO>       lDAO = ProduitDAO.listeProduits();
            ObservableCollection <ProduitViewModel> l    = new ObservableCollection <ProduitViewModel>();

            foreach (ProduitDAO element in lDAO)
            {
                ProduitViewModel p = new ProduitViewModel(element.idDAO, element.estimationActuelleDAO, element.prixVenteDAO, element.nomProduitDAO, element.descriptionDAO, element.artisteDAO, element.styleDAO, element.isVenduDAO, element.idCategorieDAO, element.idLotDAO, element.idPhotoDAO);
                l.Add(p);
            }
            return(l);
        }