public void Supprimer() { if (AchatSelectionnee != null) { if (MessageBox.Show("Supprimer l'enregistrement ?", "Confirmer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int Iid = AchatSelectionnee.idClient; C_ClientsVoiture clTmp = new G_ClientsVoiture(chConnexion).Lire_ID(Iid); int IidVoit = AchatSelectionnee.idVoiture; //Suppression de la facture associée à la vente dans le dossier string nomFichier = clTmp.nomClient + "_" + clTmp.prenomClient + "_IDC" + Iid.ToString() + "_IDV" + IidVoit.ToString() + "_FactureAchat.txt"; string nomRepertoire = @"C:/Users/Maesm/Desktop/MAES_Maxime_projet_BD_V2/Factures_A"; string path = nomRepertoire + "/" + nomFichier; if (File.Exists(path)) { MessageBox.Show("Suppression du fichier texte associé"); File.Delete(path); } else { MessageBox.Show("Fichier texte introuvable"); } //Pour récuperer les données afin de signaler la suppression au journal des évenements //Marque C_StockVoiture tmpStock = new G_StockVoiture(chConnexion).Lire_ID(IidVoit); //On va voir dans le stock pour int IidMarque = tmpStock.idMarque; C_Marque tmpMarque = new G_Marque(chConnexion).Lire_ID(IidMarque); //Modèle int IidModele = tmpStock.idModele; C_Modele tmpModele = new G_Modele(chConnexion).Lire_ID(IidModele); //Date + prix int iId = AchatSelectionnee.idOperation; //ID opération C_AchatVente tmpAchat = new G_AchatVente(chConnexion).Lire_ID(iId); //Ajout évenements au journal de modif journal.AjoutSuppressionAchatJournal(IidVoit, tmpMarque.nomMarque, tmpModele.nomModele, Iid, clTmp.nomClient, clTmp.prenomClient, tmpAchat.dateOperation.ToShortDateString(), tmpAchat.prixOperation); //supp de l'achat dans BD avec id opération new Model.G_AchatVente(chConnexion).Supprimer(AchatSelectionnee.idOperation); //supp de la voiture achetée du stock supprimerFraisAssocieALaVoitSupp(); new G_StockVoiture(chConnexion).Supprimer(IidVoit); BcpAchats.Remove(AchatSelectionnee); } } }
//Confirmation pour l'ajout ou la modification public void Confirmer() { if (nAjout == -1) { UnAchat.IDOperation = new Model.G_AchatVente(chConnexion).Ajouter(UnAchat.IDVoiture, UnAchat.IDClient, UnAchat.Prix, UnAchat.Date, UnAchat.IDPaiement, UnAchat.Type); BcpAchats.Add(new C_AchatVente(UnAchat.IDOperation, UnAchat.IDVoiture, UnAchat.IDClient, UnAchat.Prix, UnAchat.Date, UnAchat.IDPaiement, UnAchat.Type)); } else { new Model.G_AchatVente(chConnexion).Modifier(UnAchat.IDOperation, UnAchat.IDVoiture, UnAchat.IDClient, UnAchat.Prix, UnAchat.Date, UnAchat.IDPaiement, UnAchat.Type); BcpAchats[nAjout] = new C_AchatVente(UnAchat.IDOperation, UnAchat.IDVoiture, UnAchat.IDClient, UnAchat.Prix, UnAchat.Date, UnAchat.IDPaiement, UnAchat.Type); } ActiverUneFiche = false; }
public void Modifier() { if (AchatSelectionnee != null) { C_AchatVente Tmp = new Model.G_AchatVente(chConnexion).Lire_ID(AchatSelectionnee.idOperation); UnAchat = new VM_UnAchat(); UnAchat.IDOperation = Tmp.idOperation; UnAchat.IDVoiture = Tmp.idVoiture; UnAchat.IDClient = Tmp.idClient; UnAchat.Prix = Tmp.prixOperation; UnAchat.Date = Tmp.dateOperation; UnAchat.IDPaiement = Tmp.idPaiement; UnAchat.Type = Tmp.typeOperation; nAjout = BcpAchats.IndexOf(AchatSelectionnee); ActiverUneFiche = true; } }