Example #1
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (txtnom.Text == "" || txtprenom.Text == "" || txtadresse.Text == "" || txtville.Text == "" || comboBox1.Text == "" || txttel.Text == "" || txtemail.Text == "")
            {
                MessageBox.Show("Vous devez remplir les champs vides!", "Champs vides", MessageBoxButtons.OK);
                label2.ForeColor  = Color.Black;
                label3.ForeColor  = Color.Black;
                label4.ForeColor  = Color.Black;
                label5.ForeColor  = Color.Black;
                label6.ForeColor  = Color.Black;
                label7.ForeColor  = Color.Black;
                label8.ForeColor  = Color.Black;
                label9.ForeColor  = Color.Black;
                label10.ForeColor = Color.Black;
                label11.ForeColor = Color.Black;
                label12.ForeColor = Color.Black;
                label16.ForeColor = Color.Black;

                if (txtnom.Text == "")
                {
                    label3.ForeColor = Color.Red;
                }
                if (txtprenom.Text == "")
                {
                    label4.ForeColor = Color.Red;
                }
                if (txtcodepostal.Text == "")
                {
                    label9.ForeColor = Color.Red;
                }
                if (txtadresse.Text == "")
                {
                    label5.ForeColor = Color.Red;
                }
                if (txtville.Text == "")
                {
                    label6.ForeColor = Color.Red;
                }
                if (comboBox1.Text == "")
                {
                    label7.ForeColor = Color.Red;
                }
                if (txttel.Text == "")
                {
                    label8.ForeColor = Color.Red;
                }
                if (txtemail.Text == "")
                {
                    label10.ForeColor = Color.Red;
                }
            }
            else
            {
                Entity.Fournisseur C = new Entity.Fournisseur();

                C.idFournisseur            = int.Parse(txtcode.Text);
                C.ref_Fournisseur          = textBox2.Text;
                C.nom_Fournisseur          = txtnom.Text;
                C.prenom_Fournisseur       = txtprenom.Text;
                C.adresse_Fournisseur      = txtadresse.Text;
                C.codePostal_Fournisseur   = int.Parse(txtcodepostal.Text);
                C.ville_Fournisseur        = txtville.Text;
                C.pays_Fournisseur         = comboBox1.Text;
                C.tel_Fournisseur          = int.Parse(txttel.Text);
                C.telmobile_Fournisseur    = int.Parse(textBox1.Text);
                C.email_Fournisseur        = txtemail.Text;
                C.fax_Fournisseur          = int.Parse(txtfax.Text);
                C.siteInternet_Fournisseur = txtsite.Text;


                if (rbNouveau.Checked == true)
                {
                    C.etat_Fournisseur = "Nouveau";
                }
                else if (rbActif.Checked == true)
                {
                    C.etat_Fournisseur = "Actif";
                }
                else if (rbInactif.Checked == true)
                {
                    C.etat_Fournisseur = "Inactif";
                }

                C.note_Fournisseur = txtnotes.Text;

                DAL.DAL_Fournisseur.UpdateFournisseur(C);

                //  if (DAL.DAL_Fournisseur.UpdateFournisseur(C) == true)
                //   { MessageBox.Show("Mise à jour avec succes").ToString(); }

                //  else { MessageBox.Show("Mise à jour echouee").ToString(); }

                f.fournisseurTableAdapter.Fill(f.gestioncommercialeDataSet1.fournisseur);

                Hide();
                ac.Enabled = true;
            }
        }
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (txtcode.Text == "" || txtnom.Text == "" || txtprenom.Text == "" || txtadresse.Text == "" || txtville.Text == "" || comboBox1.Text == "" || (txttel.Text == "" && textBox1.Text=="") || txtemail.Text == "")
            {
                MessageBox.Show("Vous devez remplir les champs vides!", "Champs vides", MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
                label1.ForeColor = Color.Black;
                label2.ForeColor = Color.Black;
                label3.ForeColor = Color.Black;
                label4.ForeColor = Color.Black;
                label5.ForeColor = Color.Black;
                label6.ForeColor = Color.Black;
                label7.ForeColor = Color.Black;
                label8.ForeColor = Color.Black;
                label9.ForeColor = Color.Black;
                label10.ForeColor = Color.Black;
                label11.ForeColor = Color.Black;
                label12.ForeColor = Color.Black;
                label16.ForeColor = Color.Black;

                if (txtcode.Text == "")
                {
                    label2.ForeColor = Color.Red;
                }
                if (txtnom.Text == "")
                {
                    label3.ForeColor = Color.Red;
                }
                if (txtprenom.Text == "")
                {
                    label4.ForeColor = Color.Red;
                }
                if (txtcodepostal.Text == "")
                {
                    label9.ForeColor = Color.Red;
                }
                if (txtadresse.Text == "")
                {
                    label5.ForeColor = Color.Red;
                }
                if (txtville.Text == "")
                {
                    label6.ForeColor = Color.Red;
                }
                if (comboBox1.Text == "")
                {
                    label7.ForeColor = Color.Red;
                }
                if (txttel.Text == "" && textBox1.Text == "")
                {
                    label8.ForeColor = Color.Red;
                    label1.ForeColor = Color.Red;
                }
                if (txtemail.Text == "")
                {
                    label10.ForeColor = Color.Red;
                }
            }

            else
            {
                string etat = "Nouveau";
                int nbTr = 0;

                try
                {
                    Entity.Fournisseur C = new Entity.Fournisseur();

                    C.idFournisseur =int.Parse( txtcode.Text);
                    C.ref_Fournisseur = textBox2.Text;
                    C.nom_Fournisseur = txtnom.Text;
                    C.prenom_Fournisseur = txtprenom.Text;
                    C.adresse_Fournisseur = txtadresse.Text;
                    C.codePostal_Fournisseur = int.Parse(txtcodepostal.Text);
                    C.ville_Fournisseur = txtville.Text;
                    C.pays_Fournisseur = comboBox1.Text;
                    C.tel_Fournisseur = int.Parse(txttel.Text);
                    C.telmobile_Fournisseur = int.Parse(textBox1.Text);
                    C.email_Fournisseur = txtemail.Text;
                    C.fax_Fournisseur = int.Parse(txtfax.Text);
                    C.siteInternet_Fournisseur = txtsite.Text;
                    C.etat_Fournisseur = etat;
                    C.nb_transactions_Fournisseur = nbTr;
                    C.note_Fournisseur = txtnotes.Text;

                    DAL.DAL_Fournisseur.InsertFournisseur(C);
                }
                catch (Exception ecc)
                {
                    MessageBox.Show(ecc.ToString());
                }
                f.fournisseurTableAdapter.Fill(f.gestioncommercialeDataSet1.fournisseur);

                Hide();
                f.Enabled = true;
            }
        }
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (txtcode.Text == "" || txtnom.Text == "" || txtprenom.Text == "" || txtadresse.Text == "" || txtville.Text == "" || comboBox1.Text == "" || (txttel.Text == "" && textBox1.Text == "") || txtemail.Text == "")
            {
                MessageBox.Show("Vous devez remplir les champs vides!", "Champs vides", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                label1.ForeColor  = Color.Black;
                label2.ForeColor  = Color.Black;
                label3.ForeColor  = Color.Black;
                label4.ForeColor  = Color.Black;
                label5.ForeColor  = Color.Black;
                label6.ForeColor  = Color.Black;
                label7.ForeColor  = Color.Black;
                label8.ForeColor  = Color.Black;
                label9.ForeColor  = Color.Black;
                label10.ForeColor = Color.Black;
                label11.ForeColor = Color.Black;
                label12.ForeColor = Color.Black;
                label16.ForeColor = Color.Black;

                if (txtcode.Text == "")
                {
                    label2.ForeColor = Color.Red;
                }
                if (txtnom.Text == "")
                {
                    label3.ForeColor = Color.Red;
                }
                if (txtprenom.Text == "")
                {
                    label4.ForeColor = Color.Red;
                }
                if (txtcodepostal.Text == "")
                {
                    label9.ForeColor = Color.Red;
                }
                if (txtadresse.Text == "")
                {
                    label5.ForeColor = Color.Red;
                }
                if (txtville.Text == "")
                {
                    label6.ForeColor = Color.Red;
                }
                if (comboBox1.Text == "")
                {
                    label7.ForeColor = Color.Red;
                }
                if (txttel.Text == "" && textBox1.Text == "")
                {
                    label8.ForeColor = Color.Red;
                    label1.ForeColor = Color.Red;
                }
                if (txtemail.Text == "")
                {
                    label10.ForeColor = Color.Red;
                }
            }


            else
            {
                string etat = "Nouveau";
                int    nbTr = 0;

                try
                {
                    Entity.Fournisseur C = new Entity.Fournisseur();

                    C.idFournisseur               = int.Parse(txtcode.Text);
                    C.ref_Fournisseur             = textBox2.Text;
                    C.nom_Fournisseur             = txtnom.Text;
                    C.prenom_Fournisseur          = txtprenom.Text;
                    C.adresse_Fournisseur         = txtadresse.Text;
                    C.codePostal_Fournisseur      = int.Parse(txtcodepostal.Text);
                    C.ville_Fournisseur           = txtville.Text;
                    C.pays_Fournisseur            = comboBox1.Text;
                    C.tel_Fournisseur             = int.Parse(txttel.Text);
                    C.telmobile_Fournisseur       = int.Parse(textBox1.Text);
                    C.email_Fournisseur           = txtemail.Text;
                    C.fax_Fournisseur             = int.Parse(txtfax.Text);
                    C.siteInternet_Fournisseur    = txtsite.Text;
                    C.etat_Fournisseur            = etat;
                    C.nb_transactions_Fournisseur = nbTr;
                    C.note_Fournisseur            = txtnotes.Text;

                    DAL.DAL_Fournisseur.InsertFournisseur(C);
                }
                catch (Exception ecc)
                {
                    MessageBox.Show(ecc.ToString());
                }
                f.fournisseurTableAdapter.Fill(f.gestioncommercialeDataSet1.fournisseur);


                Hide();
                f.Enabled = true;
            }
        }
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (txtnom.Text == "" || txtprenom.Text == "" || txtadresse.Text == "" || txtville.Text == "" || comboBox1.Text == "" || txttel.Text == "" || txtemail.Text == "")
            {
                MessageBox.Show("Vous devez remplir les champs vides!", "Champs vides", MessageBoxButtons.OK);
                label2.ForeColor = Color.Black;
                label3.ForeColor = Color.Black;
                label4.ForeColor = Color.Black;
                label5.ForeColor = Color.Black;
                label6.ForeColor = Color.Black;
                label7.ForeColor = Color.Black;
                label8.ForeColor = Color.Black;
                label9.ForeColor = Color.Black;
                label10.ForeColor = Color.Black;
                label11.ForeColor = Color.Black;
                label12.ForeColor = Color.Black;
                label16.ForeColor = Color.Black;

                if (txtnom.Text == "")
                {
                    label3.ForeColor = Color.Red;
                }
                if (txtprenom.Text == "")
                {
                    label4.ForeColor = Color.Red;
                }
                if (txtcodepostal.Text == "")
                {
                    label9.ForeColor = Color.Red;
                }
                if (txtadresse.Text == "")
                {
                    label5.ForeColor = Color.Red;
                }
                if (txtville.Text == "")
                {
                    label6.ForeColor = Color.Red;
                }
                if (comboBox1.Text == "")
                {
                    label7.ForeColor = Color.Red;
                }
                if (txttel.Text == "")
                {
                    label8.ForeColor = Color.Red;
                }
                if (txtemail.Text == "")
                {
                    label10.ForeColor = Color.Red;
                }
            }
            else
            {

                Entity.Fournisseur C = new Entity.Fournisseur();

                C.idFournisseur = int.Parse(txtcode.Text);
                C.ref_Fournisseur = textBox2.Text;
                C.nom_Fournisseur = txtnom.Text;
                C.prenom_Fournisseur = txtprenom.Text;
                C.adresse_Fournisseur = txtadresse.Text;
                C.codePostal_Fournisseur = int.Parse(txtcodepostal.Text);
                C.ville_Fournisseur = txtville.Text;
                C.pays_Fournisseur = comboBox1.Text;
                C.tel_Fournisseur = int.Parse(txttel.Text);
                C.telmobile_Fournisseur = int.Parse(textBox1.Text);
                C.email_Fournisseur = txtemail.Text;
                C.fax_Fournisseur = int.Parse(txtfax.Text);
                C.siteInternet_Fournisseur = txtsite.Text;

                if (rbNouveau.Checked == true)
                {
                    C.etat_Fournisseur = "Nouveau";
                }
                else if (rbActif.Checked == true)
                {
                    C.etat_Fournisseur = "Actif";
                }
                else if (rbInactif.Checked == true)
                {
                    C.etat_Fournisseur = "Inactif";
                }

                C.note_Fournisseur = txtnotes.Text;

                DAL.DAL_Fournisseur.UpdateFournisseur(C);

              //  if (DAL.DAL_Fournisseur.UpdateFournisseur(C) == true)
             //   { MessageBox.Show("Mise à jour avec succes").ToString(); }

              //  else { MessageBox.Show("Mise à jour echouee").ToString(); }

                f.fournisseurTableAdapter.Fill(f.gestioncommercialeDataSet1.fournisseur);

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