コード例 #1
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            try
            {
                string  cma_adresse, cma_ville, cma_pays, cma_email, cma_sitew, cma_note, cma_date, cma_statut, cma_date_liv;
                int cma_code, fr_code, cma_cp, cma_fixe, cma_mobile, cma_fax;
                if(tbCodeCommA.Text == "" || tbCodeFourni.Text == "")
                {
                MessageBox.Show("Veuillez remplir tous les champs nécessaires .", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    lComm.ForeColor = Color.Black;
                    lFournisseur.ForeColor = Color.Black;
                if (tbCodeCommA.Text == "")
                {
                    lComm.ForeColor =Color.Red;
                }
                if (tbCodeFourni.Text == "")
                {
                    lFournisseur.ForeColor = Color.Red;
                }

                }
                else
                {
                    if (tbCP.Text == "")
                        cma_cp = 0;
                    else
                        cma_cp = Convert.ToInt32(tbCP.Text);

                    if (tbFixe.Text == "")
                        cma_fixe = 0;
                    else
                        cma_fixe = Convert.ToInt32(tbFixe.Text);

                    if (tbMobile.Text == "")
                        cma_mobile = 0;
                    else
                        cma_mobile = Convert.ToInt32(tbMobile.Text);

                    if (tbFax.Text == "")
                        cma_fax = 0;
                    else
                        cma_fax = Convert.ToInt32(tbFax.Text);

                    cma_code = Convert.ToInt32(tbCodeCommA.Text);
                    fr_code = Convert.ToInt32(tbCodeFourni.Text);
                    cma_adresse = rtbAdresse.Text;
                    cma_ville = tbVille.Text;
                    cma_pays = tbPays.Text;
                    cma_email = tbEmail.Text;
                    cma_sitew = tbSitew.Text;
                    cma_note = rtbNote.Text;
                    cma_date = dtpCommA.Value.ToString("dd / MM / yyyy");
                    cma_date_liv = dtpLiv.Value.ToString("dd / MM / yyyy");
                    cma_statut = "Active";

                    CommandeAchat cma = new CommandeAchat(cma_code, fr_code, cma_statut, cma_date, cma_date_liv, cma_adresse, cma_ville, cma_cp, cma_pays, cma_fixe, cma_mobile, cma_fax, cma_email, cma_sitew, cma_note);
                    cma.cma_ajouter();
                    ca.commandeachatTableAdapter.Fill(ca.gestioncommercialeDataSet1.commandeachat);

                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {

                        string MyConString = "SERVER=localhost;" + "DATABASE=gestioncommerciale;" + "UID=root;" + "PASSWORD=freedomity;";
                        MySqlConnection connection = new MySqlConnection(MyConString);
                        MySqlCommand cmd = connection.CreateCommand();
                        cmd.CommandText = "select count(*) from lignecommande";
                        connection.Open();
                        int num = Convert.ToInt32(cmd.ExecuteScalar());
                        connection.Close();
                        if (num != 0)
                        {
                            cmd.CommandText = "select max(num_ligne_commande) from lignecommandeachat;";
                            connection.Open();
                            num_ligne_commande = Convert.ToInt32(cmd.ExecuteScalar()) + 1;
                            connection.Close();
                        }
                        else
                        {
                            num_ligne_commande = 1;
                        }

                        dataGridView1.Rows[i].Cells[8].Value = num_ligne_commande;
                        num_ligne_commande = Convert.ToInt16(dataGridView1.Rows[i].Cells[8].Value);
                        pr_code = dataGridView1.Rows[i].Cells[1].Value.ToString();
                        pr_quantite = Convert.ToInt16(dataGridView1.Rows[i].Cells[6].Value);
                        pr_montant = Convert.ToDouble(dataGridView1.Rows[i].Cells[7].Value);

                        LigneCommandeAchat L = new LigneCommandeAchat(num_ligne_commande, cma_code, pr_code, pr_quantite, pr_montant);
                        L.lcma_ajouter();

                    }

                    Hide();
                    ac.Enabled = true;
                }
            }

            catch (FormatException)
            {
                MessageBox.Show("Erreur!", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #2
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            try
            {
                string cma_adresse, cma_ville, cma_pays, cma_email, cma_sitew, cma_note, cma_date, cma_statut, cma_date_liv;
                int    cma_code, fr_code, cma_cp, cma_fixe, cma_mobile, cma_fax;
                if (tbCodeCommA.Text == "" || tbCodeFourni.Text == "")
                {
                    MessageBox.Show("Veuillez remplir tous les champs nécessaires .", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    lComm.ForeColor        = Color.Black;
                    lFournisseur.ForeColor = Color.Black;
                    if (tbCodeCommA.Text == "")
                    {
                        lComm.ForeColor = Color.Red;
                    }
                    if (tbCodeFourni.Text == "")
                    {
                        lFournisseur.ForeColor = Color.Red;
                    }
                }
                else
                {
                    if (tbCP.Text == "")
                    {
                        cma_cp = 0;
                    }
                    else
                    {
                        cma_cp = Convert.ToInt32(tbCP.Text);
                    }

                    if (tbFixe.Text == "")
                    {
                        cma_fixe = 0;
                    }
                    else
                    {
                        cma_fixe = Convert.ToInt32(tbFixe.Text);
                    }

                    if (tbMobile.Text == "")
                    {
                        cma_mobile = 0;
                    }
                    else
                    {
                        cma_mobile = Convert.ToInt32(tbMobile.Text);
                    }

                    if (tbFax.Text == "")
                    {
                        cma_fax = 0;
                    }
                    else
                    {
                        cma_fax = Convert.ToInt32(tbFax.Text);
                    }

                    cma_code     = Convert.ToInt32(tbCodeCommA.Text);
                    fr_code      = Convert.ToInt32(tbCodeFourni.Text);
                    cma_adresse  = rtbAdresse.Text;
                    cma_ville    = tbVille.Text;
                    cma_pays     = tbPays.Text;
                    cma_email    = tbEmail.Text;
                    cma_sitew    = tbSitew.Text;
                    cma_note     = rtbNote.Text;
                    cma_date     = dtpCommA.Value.ToString("dd / MM / yyyy");
                    cma_date_liv = dtpLiv.Value.ToString("dd / MM / yyyy");
                    cma_statut   = "Active";

                    CommandeAchat cma = new CommandeAchat(cma_code, fr_code, cma_statut, cma_date, cma_date_liv, cma_adresse, cma_ville, cma_cp, cma_pays, cma_fixe, cma_mobile, cma_fax, cma_email, cma_sitew, cma_note);
                    cma.cma_ajouter();
                    ca.commandeachatTableAdapter.Fill(ca.gestioncommercialeDataSet1.commandeachat);

                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {
                        string          MyConString = "SERVER=localhost;" + "DATABASE=gestioncommerciale;" + "UID=root;" + "PASSWORD=freedomity;";
                        MySqlConnection connection  = new MySqlConnection(MyConString);
                        MySqlCommand    cmd         = connection.CreateCommand();
                        cmd.CommandText = "select count(*) from lignecommande";
                        connection.Open();
                        int num = Convert.ToInt32(cmd.ExecuteScalar());
                        connection.Close();
                        if (num != 0)
                        {
                            cmd.CommandText = "select max(num_ligne_commande) from lignecommandeachat;";
                            connection.Open();
                            num_ligne_commande = Convert.ToInt32(cmd.ExecuteScalar()) + 1;
                            connection.Close();
                        }
                        else
                        {
                            num_ligne_commande = 1;
                        }

                        dataGridView1.Rows[i].Cells[8].Value = num_ligne_commande;
                        num_ligne_commande = Convert.ToInt16(dataGridView1.Rows[i].Cells[8].Value);
                        pr_code            = dataGridView1.Rows[i].Cells[1].Value.ToString();
                        pr_quantite        = Convert.ToInt16(dataGridView1.Rows[i].Cells[6].Value);
                        pr_montant         = Convert.ToDouble(dataGridView1.Rows[i].Cells[7].Value);

                        LigneCommandeAchat L = new LigneCommandeAchat(num_ligne_commande, cma_code, pr_code, pr_quantite, pr_montant);
                        L.lcma_ajouter();
                    }

                    Hide();
                    ac.Enabled = true;
                }
            }

            catch (FormatException)
            {
                MessageBox.Show("Erreur!", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }