public ModifierCommandeAchat(CommandesAchat ca, CommandeAchat ca1,Accueil ac) { InitializeComponent(); this.ca = ca; this.ca1 = ca1; this.ac = ac; ToolTip t = new ToolTip(); t.ShowAlways = true; t.SetToolTip(tbCP, "Insertion des numéros uniquement."); t.ShowAlways = true; t.SetToolTip(tbFixe, "Insertion des numéros uniquement."); t.ShowAlways = true; t.SetToolTip(tbMobile, "Insertion des numéros uniquement."); t.ShowAlways = true; t.SetToolTip(tbFax, "Insertion des numéros uniquement."); t.ShowAlways = true; t.SetToolTip(textBox7, "Insertion des numéros uniquement."); t.ShowAlways = true; t.SetToolTip(pictureBox3, "Ajouter"); t.ShowAlways = true; t.SetToolTip(pictureBox4, "Modifier"); t.ShowAlways = true; t.SetToolTip(pictureBox5, "Supprimer"); }
public void modifier() { if (dgvCommAchat.Rows.Count == 0) { MessageBox.Show("Liste vide!", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int v_code = Convert.ToInt16(dgvCommAchat.CurrentRow.Cells[0].Value.ToString()); int v_fr_code = Convert.ToInt16(dgvCommAchat.CurrentRow.Cells[1].Value.ToString()); string v_statut = Convert.ToString(dgvCommAchat.CurrentRow.Cells[2].Value.ToString()); string v_date = Convert.ToString(dgvCommAchat.CurrentRow.Cells[3].Value.ToString()); string v_date_liv = Convert.ToString(dgvCommAchat.CurrentRow.Cells[4].Value.ToString()); string v_adresse = Convert.ToString(dgvCommAchat.CurrentRow.Cells[5].Value.ToString()); string v_ville = Convert.ToString(dgvCommAchat.CurrentRow.Cells[6].Value.ToString()); int v_cp = Convert.ToInt32(dgvCommAchat.CurrentRow.Cells[7].Value.ToString()); string v_pays = Convert.ToString(dgvCommAchat.CurrentRow.Cells[8].Value.ToString()); int v_fixe = Convert.ToInt32(dgvCommAchat.CurrentRow.Cells[9].Value.ToString()); int v_mobile = Convert.ToInt32(dgvCommAchat.CurrentRow.Cells[10].Value.ToString()); int v_fax = Convert.ToInt32(dgvCommAchat.CurrentRow.Cells[11].Value.ToString()); string v_email = Convert.ToString(dgvCommAchat.CurrentRow.Cells[12].Value.ToString()); string v_sitew = Convert.ToString(dgvCommAchat.CurrentRow.Cells[13].Value.ToString()); string v_note = Convert.ToString(dgvCommAchat.CurrentRow.Cells[14].Value.ToString()); CommandeAchat cma = new CommandeAchat(v_code, v_fr_code, v_statut, v_date, v_date_liv, v_adresse, v_ville, v_cp, v_pays, v_fixe, v_mobile, v_fax, v_email, v_sitew, v_note); ModifierCommandeAchat mca = new ModifierCommandeAchat(this, cma, ac); mca.Show(); ac.Enabled = false; } }
public ModifierCommandeAchat(CommandesAchat ca, CommandeAchat ca1, Accueil ac) { InitializeComponent(); this.ca = ca; this.ca1 = ca1; this.ac = ac; ToolTip t = new ToolTip(); t.ShowAlways = true; t.SetToolTip(tbCP, "Insertion des numéros uniquement."); t.ShowAlways = true; t.SetToolTip(tbFixe, "Insertion des numéros uniquement."); t.ShowAlways = true; t.SetToolTip(tbMobile, "Insertion des numéros uniquement."); t.ShowAlways = true; t.SetToolTip(tbFax, "Insertion des numéros uniquement."); t.ShowAlways = true; t.SetToolTip(textBox7, "Insertion des numéros uniquement."); t.ShowAlways = true; t.SetToolTip(pictureBox3, "Ajouter"); t.ShowAlways = true; t.SetToolTip(pictureBox4, "Modifier"); t.ShowAlways = true; t.SetToolTip(pictureBox5, "Supprimer"); }
public void supprimer() { if (dgvCommAchat.Rows.Count == 0) { MessageBox.Show("Liste vide!", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DialogResult result = MessageBox.Show("Voulez-vous vraiment supprimer cette commande?", "Suppression!", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { int v_code = Convert.ToInt16(dgvCommAchat.CurrentRow.Cells[0].Value.ToString()); CommandeAchat cma = new CommandeAchat(v_code); cma.cma_supprimer(); this.commandeachatTableAdapter.Fill(this.gestioncommercialeDataSet1.commandeachat); MessageBox.Show("Commande supprimée!", "Suppression", MessageBoxButtons.OK); } } }
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); } }
public void supprimer() { if (dgvCommAchat.Rows.Count == 0) MessageBox.Show("Liste vide!", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); else { DialogResult result = MessageBox.Show("Voulez-vous vraiment supprimer cette commande?", "Suppression!", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { int v_code = Convert.ToInt16(dgvCommAchat.CurrentRow.Cells[0].Value.ToString()); CommandeAchat cma = new CommandeAchat(v_code); cma.cma_supprimer(); this.commandeachatTableAdapter.Fill(this.gestioncommercialeDataSet1.commandeachat); MessageBox.Show("Commande supprimée!", "Suppression", MessageBoxButtons.OK); } } }
public void modifier() { if (dgvCommAchat.Rows.Count == 0) MessageBox.Show("Liste vide!", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); else { int v_code = Convert.ToInt16(dgvCommAchat.CurrentRow.Cells[0].Value.ToString()); int v_fr_code = Convert.ToInt16(dgvCommAchat.CurrentRow.Cells[1].Value.ToString()); string v_statut = Convert.ToString(dgvCommAchat.CurrentRow.Cells[2].Value.ToString()); string v_date = Convert.ToString(dgvCommAchat.CurrentRow.Cells[3].Value.ToString()); string v_date_liv = Convert.ToString(dgvCommAchat.CurrentRow.Cells[4].Value.ToString()); string v_adresse = Convert.ToString(dgvCommAchat.CurrentRow.Cells[5].Value.ToString()); string v_ville = Convert.ToString(dgvCommAchat.CurrentRow.Cells[6].Value.ToString()); int v_cp = Convert.ToInt32(dgvCommAchat.CurrentRow.Cells[7].Value.ToString()); string v_pays = Convert.ToString(dgvCommAchat.CurrentRow.Cells[8].Value.ToString()); int v_fixe = Convert.ToInt32(dgvCommAchat.CurrentRow.Cells[9].Value.ToString()); int v_mobile = Convert.ToInt32(dgvCommAchat.CurrentRow.Cells[10].Value.ToString()); int v_fax = Convert.ToInt32(dgvCommAchat.CurrentRow.Cells[11].Value.ToString()); string v_email = Convert.ToString(dgvCommAchat.CurrentRow.Cells[12].Value.ToString()); string v_sitew = Convert.ToString(dgvCommAchat.CurrentRow.Cells[13].Value.ToString()); string v_note = Convert.ToString(dgvCommAchat.CurrentRow.Cells[14].Value.ToString()); CommandeAchat cma = new CommandeAchat(v_code, v_fr_code, v_statut, v_date, v_date_liv, v_adresse, v_ville, v_cp, v_pays, v_fixe, v_mobile, v_fax, v_email, v_sitew, v_note); ModifierCommandeAchat mca = new ModifierCommandeAchat(this, cma,ac); mca.Show(); ac.Enabled = false; } }
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); } }