private void pictureBox9_Click_1(object sender, EventArgs e) { if (textBox2.Text == "" || textBox7.Text == "") { MessageBox.Show("Vous devez remplir les champs vides!", "Champs vides", MessageBoxButtons.OK); label7.ForeColor = Color.Black; label8.ForeColor = Color.Black; if (textBox2.Text == "") { label7.ForeColor = Color.Red; } if (textBox7.Text == "") { label8.ForeColor = Color.Red; } } else { pr_code = textBox2.Text; pr_quantite = Convert.ToInt16(textBox7.Text); double prix_vente_produit = 0; pr_montant = pr_quantite * prix_vente_produit; LigneDevis L = new LigneDevis(num_ligne_devis); L.ld_modifier(dv_code, pr_code, pr_quantite, pr_montant); this.lignedevisTableAdapter.Fill(this.gestioncommercialeDataSet1.lignedevis); textBox2.Text = ""; textBox7.Text = ""; panel2.Visible = false; } }
private void pictureBox9_Click(object sender, EventArgs e) { if (textBox2.Text == "" || textBox7.Text == "") { MessageBox.Show("Vous devez remplir les champs vides!", "Champs vides", MessageBoxButtons.OK); label7.ForeColor = Color.Black; label8.ForeColor = Color.Black; if (textBox2.Text == "") { label7.ForeColor = Color.Red; } if (textBox7.Text == "") { label8.ForeColor = Color.Red; } } else { //numero_ligneDevis int num_ligne_devis; if (dataGridView1.Rows.Count == 0) { num_ligne_devis = 1; } else { string MyConString = "SERVER=localhost;" + "DATABASE=gestioncommerciale;" + "UID=root;" + "PASSWORD=freedomity;"; MySqlConnection connection = new MySqlConnection(MyConString); MySqlCommand cmd = connection.CreateCommand(); cmd.CommandText = "select max(num_ligne_devis) from lignedevis"; connection.Open(); num_ligne_devis = Convert.ToInt32(cmd.ExecuteScalar()) + 1; connection.Close(); } int dv_code = Convert.ToInt16(tbCodeDevis.Text); string pr_code = textBox2.Text; int pr_quantite = Convert.ToInt16(textBox7.Text); double prix_vente_produit = 0; double pr_montant = pr_quantite * prix_vente_produit; LigneDevis L = new LigneDevis(num_ligne_devis); L.ld_modifier(dv_code, pr_code, pr_quantite, pr_montant); this.lignedevisTableAdapter.Fill(this.gestioncommercialeDataSet1.lignedevis); textBox2.Text = ""; textBox7.Text = ""; panel2.Visible = false; } }
public void SupprimerLigneDevis() { if (dataGridView1.Rows.Count == 0) { MessageBox.Show("Liste vide!", "Erreur", MessageBoxButtons.OK); } else { DialogResult rsl = MessageBox.Show("Voulez-vous vraiment supprimer ce produit de la facture?", "Supprimer Produit de la facture", MessageBoxButtons.YesNo); if (rsl == DialogResult.Yes) { int num_ligne_devis = Convert.ToInt16(dataGridView1.CurrentRow.Cells[0].Value.ToString()); LigneDevis L = new LigneDevis(num_ligne_devis); L.ld_supprimer(); this.lignedevisTableAdapter.Fill(this.gestioncommercialeDataSet1.lignedevis); } } }
private void pictureBox1_Click(object sender, EventArgs e) { try { string dv_adresse, dv_ville, dv_pays, dv_email, dv_sitew, dv_note , dv_date , dv_statut; int dv_code, cl_code, dv_cp, dv_fixe, dv_mobile, dv_fax; if (tbCodeDevis.Text == "" || tbCodeClient.Text == "") { MessageBox.Show("Veuillez remplir tous les champs nécessaires .", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); lCodeDevis.ForeColor = Color.Black; lClient.ForeColor = Color.Black; if (tbCodeDevis.Text == "") { lCodeDevis.ForeColor = Color.Red; } if (tbCodeClient.Text == "") { lClient.ForeColor = Color.Red; } } else { if (tbCP.Text == "") dv_cp = 0; else dv_cp = Convert.ToInt32(tbCP.Text); if (tbFixe.Text == "") dv_fixe = 0; else dv_fixe = Convert.ToInt32(tbFixe.Text); if (tbMobile.Text == "") dv_mobile = 0; else dv_mobile = Convert.ToInt32(tbMobile.Text); if (tbFax.Text == "") dv_fax = 0; else dv_fax = Convert.ToInt32(tbFax.Text); dv_code = Convert.ToInt16(tbCodeDevis.Text); cl_code = Convert.ToInt16(tbCodeClient.Text); dv_adresse = rtbAdresse.Text; dv_ville = tbVille.Text; dv_pays = tbPays.Text; dv_email = tbEmail.Text; dv_sitew = tbSitew.Text; dv_note = rtbNote.Text; dv_date = dtpDevis.Value.ToString("dd / MM / yyyy"); dv_statut = "Actif"; Devis dv = new Devis(dv_code, cl_code,dv_statut, dv_date, dv_adresse, dv_ville, dv_cp, dv_pays, dv_fixe, dv_mobile, dv_fax, dv_email, dv_sitew, dv_note); dv.dv_ajouter(); d.devisTableAdapter.Fill(d.gestioncommercialeDataSet1.devis); 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 lignedevis"; connection.Open(); int num = Convert.ToInt32(cmd.ExecuteScalar()); connection.Close(); if (num != 0) { cmd.CommandText = "select max(num_ligne_devis) from lignedevis;"; connection.Open(); num_ligne_devis = Convert.ToInt32(cmd.ExecuteScalar()) + 1; connection.Close(); } else { num_ligne_devis = 1; } dataGridView1.Rows[i].Cells[8].Value = num_ligne_devis; num_ligne_devis = 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); LigneDevis L = new LigneDevis(num_ligne_devis, dv_code, pr_code, pr_quantite, pr_montant); L.ld_ajouter(); } Hide(); ac.Enabled = true; } } catch(FormatException) { MessageBox.Show("Erreur!", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void pictureBox1_Click(object sender, EventArgs e) { try { string dv_adresse, dv_ville, dv_pays, dv_email, dv_sitew, dv_note, dv_date, dv_statut; int dv_code, cl_code, dv_cp, dv_fixe, dv_mobile, dv_fax; if (tbCodeDevis.Text == "" || tbCodeClient.Text == "") { MessageBox.Show("Veuillez remplir tous les champs nécessaires .", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); lCodeDevis.ForeColor = Color.Black; lClient.ForeColor = Color.Black; if (tbCodeDevis.Text == "") { lCodeDevis.ForeColor = Color.Red; } if (tbCodeClient.Text == "") { lClient.ForeColor = Color.Red; } } else { if (tbCP.Text == "") { dv_cp = 0; } else { dv_cp = Convert.ToInt32(tbCP.Text); } if (tbFixe.Text == "") { dv_fixe = 0; } else { dv_fixe = Convert.ToInt32(tbFixe.Text); } if (tbMobile.Text == "") { dv_mobile = 0; } else { dv_mobile = Convert.ToInt32(tbMobile.Text); } if (tbFax.Text == "") { dv_fax = 0; } else { dv_fax = Convert.ToInt32(tbFax.Text); } dv_code = Convert.ToInt16(tbCodeDevis.Text); cl_code = Convert.ToInt16(tbCodeClient.Text); dv_adresse = rtbAdresse.Text; dv_ville = tbVille.Text; dv_pays = tbPays.Text; dv_email = tbEmail.Text; dv_sitew = tbSitew.Text; dv_note = rtbNote.Text; dv_date = dtpDevis.Value.ToString("dd / MM / yyyy"); dv_statut = "Actif"; Devis dv = new Devis(dv_code, cl_code, dv_statut, dv_date, dv_adresse, dv_ville, dv_cp, dv_pays, dv_fixe, dv_mobile, dv_fax, dv_email, dv_sitew, dv_note); dv.dv_ajouter(); d.devisTableAdapter.Fill(d.gestioncommercialeDataSet1.devis); 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 lignedevis"; connection.Open(); int num = Convert.ToInt32(cmd.ExecuteScalar()); connection.Close(); if (num != 0) { cmd.CommandText = "select max(num_ligne_devis) from lignedevis;"; connection.Open(); num_ligne_devis = Convert.ToInt32(cmd.ExecuteScalar()) + 1; connection.Close(); } else { num_ligne_devis = 1; } dataGridView1.Rows[i].Cells[8].Value = num_ligne_devis; num_ligne_devis = 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); LigneDevis L = new LigneDevis(num_ligne_devis, dv_code, pr_code, pr_quantite, pr_montant); L.ld_ajouter(); } Hide(); ac.Enabled = true; } } catch (FormatException) { MessageBox.Show("Erreur!", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }