private void AjouterDecaissementTransportMatierePremiere(EveReceptionMatieresPremiere recep) { ResStockMatieresPremiere matPrem = db.ResStockMatieresPremieres.FirstOrDefault(mp => mp.NomMatiere == cbxNomMatierePremiere.Text); AgeEmploye tresoriere = db.AgeEmployes.FirstOrDefault(em => em.PrenomNom == cbxTresoriere.Text); ResComptesTresorerie tres = db.ResComptesTresoreries.FirstOrDefault(tr => tr.NomCompte == cbxComptePaiement.Text); if (int.Parse(txtTransportMatierePremiere.Text) > 0 && Tresorerie.IlYaAssezDeFondsDansLeCompte(cbxComptePaiement, txtTransportMatierePremiere)) { EveDecaissement decaiss = new EveDecaissement { CodeReceptionMatierePremiere = recep.CodeReceptionMatierePremiere, Description = "Transport de " + matPrem.NomMatiere, DateDecaissement = recep.DateReception, CodeEmploye = tresoriere.CodeEmploye, CodeCompte = tres.CodeCompte, Montant = int.Parse(txtTransportMatierePremiere.Text), }; db.EveDecaissements.Add(decaiss); db.SaveChanges(); } }
private EveReceptionMatieresPremiere AjouterNouvelleAchatMatierePremiere() { ResStockMatieresPremiere matPrem = db.ResStockMatieresPremieres.FirstOrDefault(mp => mp.NomMatiere == cbxNomMatierePremiere.Text); AgeFournisseursMatieresPremiere fournMp = db.AgeFournisseursMatieresPremieres.FirstOrDefault(fmp => fmp.Nom == cbxFournisseurMPrem.Text); AgeEmploye resStocks = db.AgeEmployes.FirstOrDefault(em => em.PrenomNom == cbxRespStocks.Text); AgeEmploye tresoriere = db.AgeEmployes.FirstOrDefault(em => em.PrenomNom == cbxTresoriere.Text); ResComptesTresorerie tres = db.ResComptesTresoreries.FirstOrDefault(tr => tr.NomCompte == cbxComptePaiement.Text); EveReceptionMatieresPremiere achatMatiere = new EveReceptionMatieresPremiere { CodeMatierePremiere = matPrem.CodeMatierePremiere, DateReception = DateTime.Parse(dtpDateApprovisionnement.Text), Quantite = float.Parse(txtQuantite.Text), Montant = int.Parse(txtMontant.Text), TransportMatierePremiere = int.Parse(txtTransportMatierePremiere.Text), CodeFournisseurMatierePremiere = fournMp.CodeFournisseurMatierePremiere, CodeEmploye = resStocks.CodeEmploye, }; db.EveReceptionMatieresPremieres.Add(achatMatiere); db.SaveChanges(); return(achatMatiere); }