private void btnAjouter_Click(object sender, EventArgs e) { if (tbQuantite.Text != "") { try { DialogResult result = MessageBox.Show("Êtes-vous sûr d'ajouter le produit " + cbProduit.Text + " en quantité " + tbQuantite.Text + " à la commande ?", "Information", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { GestionCommande.addProduit(Convert.ToInt32(tbNumero.Text), Convert.ToInt32(cbProduit.SelectedValue), Convert.ToInt32(tbQuantite.Text)); MessageBox.Show("Produit ajouté à la commande !"); refresh(); } } catch (Exception) { DialogResult result = MessageBox.Show("Le produit " + cbProduit.Text + " est déjà présent dans la commande, ajouter la nouvelle quantité ? \n Si non, l'ancienne quantité sera remplacée par la nouvelle ", "Information", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { int qte = GestionCommande.getQteProduitCommande(Convert.ToInt32(tbNumero.Text), Convert.ToInt32(cbProduit.SelectedValue)); GestionCommande.changeQteProduit(Convert.ToInt32(tbNumero.Text), Convert.ToInt32(cbProduit.SelectedValue), Convert.ToInt32(tbQuantite.Text) + qte); } else { GestionCommande.changeQteProduit(Convert.ToInt32(tbNumero.Text), Convert.ToInt32(cbProduit.SelectedValue), Convert.ToInt32(tbQuantite.Text)); } MessageBox.Show("Quantité modifiée !"); refresh(); } } }
private void frmDetailsCommande_Load(object sender, EventArgs e) { leDetailCommande = GestionCommande.getDetailsCommande(Convert.ToInt32(tbNumero.Text)); lesCategories = GestionCategorie.getAll(); lesProduits = GestionProduit.getByIdCategorie(Convert.ToInt32(cbCategorie.SelectedValue)); refresh(); }
private void btnSuivant_Click(object sender, EventArgs e) { if (position < GestionCommande.getNbCommandes() - 1) { position++; rafraichirInterface(); } }
private void btnSupprCommande_Click(object sender, EventArgs e) { DialogResult rep; rep = MessageBox.Show("Êtes-vous sûr de supprimer la commande n°" + tbNumero.Text + " ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (rep == DialogResult.Yes) { GestionCommande.del(Convert.ToInt32(tbNumero.Text)); MessageBox.Show("Commande supprimée !", "Succès", MessageBoxButtons.OK, MessageBoxIcon.Information); refreshData(); } }
public void refreshData() { lesCommandes.Clear(); cbClient.DataSource = null; cbClient.DisplayMember = null; cbClient.ValueMember = null; lesCommandes = GestionCommande.getAll(); cbClient.DataSource = GestionClient.getAll(); cbClient.DisplayMember = "NomClient"; cbClient.ValueMember = "idClient"; dgCommandes.DataSource = GestionCommande.getLesCommandesDG(); position = 0; rafraichirInterface(); }
private void refresh() { leDetailCommande.Clear(); leDetailCommande = GestionCommande.getDetailsCommande(Convert.ToInt32(tbNumero.Text)); dgProduitsCommande.DataSource = leDetailCommande; lesCategories.Clear(); lesCategories = GestionCategorie.getAll(); cbCategorie.DataSource = lesCategories; cbCategorie.DisplayMember = "LibelleCategorie"; cbCategorie.ValueMember = "idCategorie"; lesProduits.Clear(); lesProduits = GestionProduit.getByIdCategorie(Convert.ToInt32(cbCategorie.SelectedValue)); cbProduit.DataSource = lesProduits; cbProduit.DisplayMember = "LibelleProduit"; cbProduit.ValueMember = "idProduit"; }
private void btnAjoutCommande_Click(object sender, EventArgs e) { if (btnAjoutCommande.Text == "Ajouter une Commande") { btnAjoutCommande.Text = "Valider"; tbDate.Text = ""; cbClient.Text = ""; cbClient.Enabled = true; tbDate.Enabled = true; btnDernier.Enabled = false; btnPrecedent.Enabled = false; btnSuivant.Enabled = false; btnPremier.Enabled = false; btnSupprCommande.Enabled = false; btnConsulterCommande.Enabled = false; tbNumero.Text = Convert.ToString(GestionBoutique.genererClePrimaire("idCommande", "commande")); } else { if (tbNumero.Text != "" && cbClient.Text != "" && tbDate.Text != "") { GestionCommande.add(Convert.ToInt32(tbNumero.Text), tbDate.Text, Convert.ToInt32(cbClient.SelectedValue)); btnAjoutCommande.Text = "Ajouter une Commande"; MessageBox.Show("Commande ajoutée !", "Succès !", MessageBoxButtons.OK, MessageBoxIcon.Information); refreshData(); cbClient.Enabled = false; tbDate.Enabled = false; btnDernier.Enabled = true; btnPrecedent.Enabled = true; btnSuivant.Enabled = true; btnPremier.Enabled = true; btnSupprCommande.Enabled = true; btnConsulterCommande.Enabled = true; btnDernier.PerformClick(); btnConsulterCommande.PerformClick(); } else { MessageBox.Show("Erreur, un champ n'est pas ou est mal spécifié", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnDernier_Click(object sender, EventArgs e) { position = GestionCommande.getNbCommandes() - 1; rafraichirInterface(); }