private void Rechercher_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(Txt_Ref.Text))
     {
         bool prdExist = ProduitADO.Existe_Produit(int.Parse(Txt_Ref.Text));
         if (prdExist != null)
         {
             Dg_Prod.DataSource = ProduitADO.Liste_Ref(int.Parse(Txt_Ref.Text));
         }
         else
         {
             MessageBox.Show("Produit inexistant");
         }
     }
     else if (!string.IsNullOrEmpty(Txt_Desig.Text))
     {
         Dg_Prod.DataSource = ProduitADO.Liste_Desig(Txt_Desig.Text);
     }
     else if (!string.IsNullOrEmpty(Cmb_Categ.Text))
     {
         Dg_Prod.DataSource = ProduitADO.Liste_Categ_Prod(Cmb_Categ.Text);
     }
     else
     {
         Dg_Prod.DataSource = ProduitADO.Liste_Produit();
     }
 }
Example #2
0
        private void Dg_Prod_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int           index = e.RowIndex;
            int           refe  = int.Parse(Dg_Prod.Rows[index].Cells[0].Value.ToString());
            String        desig = Dg_Prod.Rows[index].Cells[1].Value.ToString();
            int           prix  = int.Parse(Dg_Prod.Rows[index].Cells[2].Value.ToString());
            int           qte   = int.Parse(Dg_Prod.Rows[index].Cells[3].Value.ToString());
            int           total = int.Parse(Dg_Prod.Rows[index].Cells[4].Value.ToString());
            LigneCommande lc    = LigneCommandeADO.LigneCommande(refe);

            if (lc != null)
            {
                lcSelected   = lc;
                Txt_Qte.Text = lc.Qte.ToString();
                Commande cmd = CommandeADO.Recherche_Commande_Num_Cde(lc.NumCde);
                if (cmd != null)
                {
                    cmdSelected     = cmd;
                    Txt_NumCde.Text = cmd.Num_Cde.ToString();
                    Date_Cde.Text   = cmd.Date_Cde.ToString();
                    Client client = ClientADO.Recherche_cin(cmd.CIN_Cl);
                    if (client != null)
                    {
                        setClientFields(client);
                        clSelected = client;
                    }
                }
                Produit pr = ProduitADO.Recherche_Ref(lc.RefProd);
                if (pr != null)
                {
                    prSelected = pr;
                }
            }
        }
 private void Vider_Click(object sender, EventArgs e)
 {
     Txt_Ref.Clear();
     Txt_Desig.Clear();
     if (!string.IsNullOrEmpty(Cmb_Categ.Text))
     {
         Cmb_Categ.SelectedIndex = -1;
     }
     Dg_Prod.DataSource = ProduitADO.Liste_Produit();
 }
 private void Cmb_Categ_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(Cmb_Categ.Text))
     {
         Dg_Prod.DataSource = ProduitADO.Liste_Categ_Prod(Cmb_Categ.Text);
     }
     else
     {
         Dg_Prod.DataSource = ProduitADO.Liste_Produit();
     }
 }
        private void Btn_Enregistrer_Click(object sender, EventArgs e)
        {
            int    refe  = int.Parse(Txt_Ref.Text);
            String desig = Txt_Desig.Text;
            String categ = Cmb_Categ.Text;
            int    prix  = int.Parse(Txt_Prix.Text);
            int    qte   = int.Parse(Txt_Qte.Text);

            if (string.IsNullOrEmpty(refe.ToString()))
            {
                MessageBox.Show("Ref produit invalid");
            }
            else if (string.IsNullOrEmpty(desig))
            {
                MessageBox.Show("Designatation produit invalid");
            }
            else if (string.IsNullOrEmpty(categ))
            {
                MessageBox.Show("Choisir une categorie");
            }
            else if (string.IsNullOrEmpty(prix.ToString()))
            {
                MessageBox.Show("Prix produit invalid");
            }
            else if (string.IsNullOrEmpty(qte.ToString()))
            {
                MessageBox.Show("Quantité produit invalid");
            }
            else
            {
                Produit produit = new Produit
                {
                    Ref_Prod   = refe,
                    Desig_Prod = desig,
                    Categ_Prod = categ,
                    PrixV_Prod = prix,
                    Qte_Stock  = qte
                };
                if (FListe_Prod.TypeOP.Equals('M'))
                {
                    ProduitADO.Modifier(produit);
                }
                else
                {
                    ProduitADO.Inserer(produit);
                }
                this.form.loadGrid();
                this.Close();
            }
        }
 private void Supprimer_Click(object sender, EventArgs e)
 {
     if (produit != null)
     {
         DialogResult dialogResult = MessageBox.Show("Vous été sur de supprimer ce produit?", "Supprimer", MessageBoxButtons.YesNo);
         if (dialogResult == DialogResult.Yes)
         {
             ProduitADO.Supprimer(produit.Ref_Prod);
             this.produitTableAdapter.Fill(this.bd_ClientDataSet.Produit);
         }
         else if (dialogResult == DialogResult.No)
         {
             //do something else
         }
     }
     else
     {
         MessageBox.Show("Selectionné un produit!");
     }
 }
Example #7
0
        private void Affiche_Ligne_Commande()
        {
            Txt_TotCde.Clear();
            Dg_Prod.Rows.Clear();
            List <LigneCommande> ligneCmd = LigneCommandeADO.Liste_LigneCommande();

            if (ligneCmd != null)
            {
                long totalCmds = 0;
                foreach (LigneCommande lc in ligneCmd)
                {
                    Produit  pd  = ProduitADO.Recherche_Ref(lc.RefProd);
                    Commande cmd = CommandeADO.Recherche_Commande_Num_Cde(lc.NumCde);
                    // Ref ligcmd | design | prix | quantité | total
                    long totalCmd = pd.PrixV_Prod * lc.Qte;
                    totalCmds += totalCmd;
                    Dg_Prod.Rows.Add(cmd.Num_Cde, pd.Desig_Prod, pd.PrixV_Prod, lc.Qte, totalCmd);
                }
                Txt_TotCde.Text = totalCmds.ToString();
            }
        }