Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
0
 private void Txt_NumCde_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (Convert.ToInt32(e.KeyChar) == 13)
     {
         if (!string.IsNullOrEmpty(Txt_NumCde.Text))
         {
             int      numCmd = int.Parse(Txt_NumCde.Text);
             Commande cmd    = CommandeADO.Recherche_Commande_Num_Cde(numCmd);
             if (cmd != null)
             {
                 cmdSelected = cmd;
                 Client cl = ClientADO.Recherche_cin(cmd.CIN_Cl);
                 if (cl != null)
                 {
                     clSelected = cl;
                     setClientFields(cl);
                 }
                 else
                 {
                     MessageBox.Show("Client introuvable");
                 }
             }
             else
             {
                 Nouv_Cde_Click(sender, e);
             }
         }
         else
         {
             MessageBox.Show("Entrer numero de commande");
         }
     }
 }
Ejemplo n.º 3
0
 private void Nouv_Lig_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(Txt_NumCde.Text))
     {
         Commande cmd = CommandeADO.Recherche_Commande_Num_Cde(int.Parse(Txt_NumCde.Text));
         if (cmd != null)
         {
             if (!string.IsNullOrEmpty(Txt_Qte.Text))
             {
                 FListe_Prod fc = new FListe_Prod();
                 fc.ShowDialog();
                 if (FListe_Prod.produit != null)
                 {
                     prSelected = FListe_Prod.produit;
                     if (prSelected != null)
                     {
                         LigneCommande lc = new LigneCommande
                         {
                             NumCde  = cmd.Num_Cde,
                             RefProd = prSelected.Ref_Prod,
                             Qte     = int.Parse(Txt_Qte.Text)
                         };
                         LigneCommandeADO.Inserer(lc);
                         Affiche_Ligne_Commande();
                         Vider_Clt_Click(sender, e);
                         Vider_Cde_Click(sender, e);
                         lcSelected  = null;
                         prSelected  = null;
                         cmdSelected = null;
                         clSelected  = null;
                         MessageBox.Show("Ligne Commande inserer");
                     }
                     else
                     {
                         MessageBox.Show("Sélectionner un produit");
                     }
                 }
                 else
                 {
                     MessageBox.Show("Sélectionner un produit");
                 }
             }
             else
             {
                 MessageBox.Show("Inserer une qunatité");
             }
         }
         else
         {
             MessageBox.Show("Inserer une commande");
         }
     }
     else
     {
         MessageBox.Show("Inserer une commande");
     }
 }
Ejemplo n.º 4
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();
            }
        }
Ejemplo n.º 5
0
 private void Nouv_Cde_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(Txt_NumCde.Text))
     {
         MessageBox.Show("Numero commande invalid");
     }
     else if (string.IsNullOrEmpty(Date_Cde.Value.Date.ToString()))
     {
         MessageBox.Show("Date commande invalid");
     }
     else
     {
         int      numCmd   = int.Parse(Txt_NumCde.Text);
         DateTime dteCmd   = Date_Cde.Value.Date;
         Commande commande = CommandeADO.Recherche_Commande_Num_Cde(numCmd);
         if (commande != null)
         {
             cmdSelected      = commande;
             Pan_LigC.Visible = true;
             Txt_NumCde.Text  = commande.Num_Cde.ToString();
             Date_Cde.Value   = commande.Date_Cde;
             Client client = ClientADO.Recherche_cin(commande.CIN_Cl);
             if (client != null)
             {
                 setClientFields(client);
                 clSelected = client;
             }
         }
         else
         {
             if (string.IsNullOrEmpty(Txt_Cin.Text))
             {
                 MessageBox.Show("CIN client invalid");
             }
             else
             {
                 int    cin = int.Parse(Txt_Cin.Text);
                 Client cl  = ClientADO.Recherche_cin(cin);
                 if (cl != null)
                 {
                     setClientFields(cl);
                     clSelected = cl;
                     Commande cmd = new Commande
                     {
                         Num_Cde  = numCmd,
                         Date_Cde = dteCmd,
                         CIN_Cl   = cin,
                     };
                     CommandeADO.Inserer(cmd);
                     Pan_LigC.Visible = true;
                     cmdSelected      = cmd;
                     MessageBox.Show("Commande inserer");
                 }
                 else
                 {
                     MessageBox.Show("Client introuvable");
                 }
             }
         }
     }
 }