コード例 #1
0
        /// <summary>
        /// Initialiser
        /// </summary>
        public FajouteCdes(Commande cmd, bool modifier)
        {
            InitializeComponent();
            _cmd = cmd;

            // Actions des boutons
            this.AcceptButton = submit_button;
            submit_button.DialogResult = DialogResult.OK;
            btn_cancel.DialogResult = DialogResult.Cancel;
            ChargerDonnees();

            this.tb_nocmd.Text = _cmd.NoCommande;
            cb_novendeur.SelectedIndex = cb_novendeur.FindStringExact(cmd.Vendeur.NoVendeur);
            cb_noclient.SelectedIndex = cb_noclient.FindStringExact(cmd.Client.NoCl);
            dtp_date.Value = cmd.DateCommande;

            if (_cmd.Facture == "F")
            {
                rb_f_non.Checked = true;
                rb_f_oui.Checked = false;
            }
            else
            {
                rb_f_oui.Checked = true;
                rb_f_non.Checked = false;
            }

            if (!modifier)
            {
                tb_nocmd.Enabled = false;
                lbl_titre.Text = "Modifier une commande";
                this.Text = "Modifier une commande";
            }
            testSubmitPossible();
        }
コード例 #2
0
        /// <summary>
        /// Initialiser
        /// </summary>
        public FajouteCdes()
        {
            InitializeComponent();
            _cmd = new Commande();

            // Actions des boutons
            this.AcceptButton = submit_button;
            submit_button.DialogResult = DialogResult.OK;
            btn_cancel.DialogResult = DialogResult.Cancel;

            ChargerDonnees();
            testSubmitPossible();
        }
コード例 #3
0
        /// <summary>
        /// Affiche la liste des commandes
        /// </summary>
        private void AfficherListe()
        {
            lvcdes.Columns.Clear();
            lvcdes.Items.Clear();
            lvcdes.View = View.Details;
            lvcdes.Columns.Add("1","Numero", 100, HorizontalAlignment.Left,0);
            lvcdes.Columns.Add("2", "Numéro Vendeur", 100, HorizontalAlignment.Left,0);
            lvcdes.Columns.Add("3", "Numéro Client", 100, HorizontalAlignment.Left,0);
            lvcdes.Columns.Add("4", "Date Commande", 100, HorizontalAlignment.Left,0);
            lvcdes.Columns.Add("5", "Facture", 100, HorizontalAlignment.Left,0);

            Commande unecommande = new Commande();
            string numCde, numVend, NumCli, facture, datecde;
            ListViewItem lvitem_cde;

            try
            {
                mesCommandes = unecommande.getLesCommandes(this.tri, this.ordre);

                foreach (Commande c in mesCommandes)
                {

                    numCde = c.NoCommande;
                    // On récupère la property NoVendeur
                    numVend = c.Vendeur.NoVendeur;
                    NumCli = c.Client.NoCl;
                    datecde = c.DateCommande.ToShortDateString();
                    facture = c.Facture;
                    lvitem_cde = new ListViewItem(new string[] { numCde, numVend, NumCli, datecde, facture }, -1, Color.Black, Color.LightGray, null);
                    lvcdes.Items.Add(lvitem_cde);
                }

                if (!Numcheck.Checked) lvcdes.Columns.RemoveByKey("1");
                if (!NumVencheck.Checked) lvcdes.Columns.RemoveByKey("2");
                if (!NumClicheck.Checked) lvcdes.Columns.RemoveByKey("3");
                if (!Datecheck.Checked) lvcdes.Columns.RemoveByKey("4");
                if (!Facturecheck.Checked) lvcdes.Columns.RemoveByKey("5");
                lvcdes.FullRowSelect = true;
                lvcdes.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            }
            catch (MonException erreur)
            {
                throw erreur;
            }
        }
コード例 #4
0
 private void modifierToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Commande uneCommande = new Commande();
     Commande maCommande = uneCommande;
     List<Commande> mesCommandes;
     mesCommandes = uneCommande.getLesCommandes(this.trieur, this.organise);
     String numero = lvcdes.Items[lvcdes.SelectedIndices[0]].Text;
     foreach (Commande c in mesCommandes)
     {
         if (numero == c.NoCommande)
         {
             maCommande = c;
         }
     }
     //Si on ne trouve pas de commande équivalent a l'ajouter d'une commande
     FajouteCdes newCmd = new FajouteCdes(maCommande, false);
     DialogResult res = newCmd.ShowDialog();
     if (res == DialogResult.OK)
     {
         try
         {
             maCommande.ajouterCommande();
             MessageBox.Show("Succès de l'oppération.");
             AfficherListe();
         }
         catch (MonException excep)
         {
             MessageBox.Show(excep.MessageSysteme(), "Erreur d'ajout");
         }
     }
     
 }
コード例 #5
0
        private void supprimerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            int suprCmd;
            if (lvcdes.SelectedIndices.Count != 1)
            {
                MessageBox.Show("Veuillez Selction au moin une commande", "erreur");
            }
            else
            {
                DialogResult dr = MessageBox.Show("Confirmation avant supression", "Suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                if (dr == DialogResult.Yes)
                {
                    Commande cmd = new Commande();
                    suprCmd = Convert.ToInt32(lvcdes.FocusedItem.Text);
                    try
                    {
                        cmd.supprimerCommande(suprCmd);
                        AfficherListe();
                    }
                    catch (MonException excep)
                    {
                        MessageBox.Show(excep.MessageSysteme(), "Erreur de modification");
                    }
                }
                
            }
        }
コード例 #6
0
 private void ajouterUneCommandeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Commande cmd = new Commande();
     FajouteCdes newCmd = new FajouteCdes(cmd, true);
     DialogResult res = newCmd.ShowDialog();
     if (res == DialogResult.OK)
     {
         try
         {
             cmd.ajouterCommande();
             MessageBox.Show("Commande ajouté avec succès.");
             AfficherListe();
         }
         catch (MonException excep)
         {
             MessageBox.Show(excep.MessageSysteme(), "Erreur d'ajout");
         }
     }
 }
コード例 #7
0
 public List<Commande> getLesCommandes(String tri, String ordre)
 {
     DataTable dt;
     String mysql = "SELECT NO_COMMAND, NO_VENDEUR, NO_CLIENT, DATE_CDE, FACTURE ";
     mysql += "FROM COMMANDES ";
     mysql += "ORDER BY " + tri + " " + ordre;
     sErreurs er = new sErreurs("Erreur sur lecture des commandes", "Commande.getLesCommandes()");
     try
     {
         dt = DbInterface.Lecture(mysql, er);
         List<Commande> mesCdes = new List<Commande>();
         foreach (DataRow dataRow in dt.Rows)
         {
             Vendeur unvd = new Vendeur();
             unvd.NoVendeur = dataRow[1].ToString();
             Clientel uncli = new Clientel();
             uncli.NoCl = dataRow[2].ToString();
             Commande unecde = new Commande(dataRow[0].ToString(),
                                             ((DateTime)dataRow[3]),
                                            dataRow[4].ToString(), unvd, uncli);
             mesCdes.Add(unecde);
         }
         return mesCdes;
     }
     catch (MonException erreur)
     {
         throw erreur;
     }
 }
コード例 #8
0
        private void supprimerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int[] toDel = new int[lvcdes.SelectedIndices.Count];
            int index = 0;
            if(lvcdes.SelectedIndices.Count==0)
            {
                MessageBox.Show("Veuillez Selction une commande", "erreur");    
            }
            else
            {
                DialogResult dr = MessageBox.Show("Confirmation de la supression des commande", "Suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                if (dr == DialogResult.Yes)
                {
                    Commande cmd = new Commande();

                    foreach (ListViewItem i in lvcdes.SelectedItems)
                    {
                        toDel[index] = Convert.ToInt32(i.SubItems[0].Text);
                        index++;
                    }
                    try
                    {
                        cmd.suppCmd(toDel);
                        AfficherListe();
                    }
                    catch (MonException excep)
                    {
                        MessageBox.Show(excep.MessageSysteme(), "Erreur de modification");
                    }
                }

            }
        }
コード例 #9
0
 /// <summary>
 /// Affiche la fenêtre d'ajout d'une nouvelle commande
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ajouterToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Commande cmd = new Commande();
     FajouteCdes f = new FajouteCdes(cmd);
     DialogResult res = f.ShowDialog();
     if (res == DialogResult.OK)
     {
         try
         {
             cmd.ajouterCommande();
             MessageBox.Show("Commande ajoutée avec succès.");
             FListeCdes fliste = new FListeCdes();
             fliste.ShowDialog();
         }
         catch (MonException excep)
         {
             MessageBox.Show(excep.MessageSysteme(), "Erreur d'ajout");
         }
     }
 }