public static void Delete(ModePaiement mpA) { Log.Logger.Debug("Debut ModePaiement.Delete(" + mpA.Id + ")"); try { OB ob = (OB)CallContext.GetData(KEY.OB); ob.ModePaiements.RemoveAll((mp) => mp.Id == mpA.Id); CallContext.SetData(KEY.OB, ob); } catch (Exception ex) { Log.Logger.Error(ex.Message); throw; } }
public static ModePaiement Charge(int id) { Log.Logger.Debug("Debut ModePaiement.Charge(" + id + ")"); ModePaiement mp = new ModePaiement(); try { OB ob = (OB)CallContext.GetData(KEY.OB); mp = ob.ModePaiements.Where(mpt => mpt.Id == id).First(); } catch (Exception ex) { Log.Logger.Error(ex.Message); throw; } return(mp); }
public static ModePaiement Sauve(ModePaiement mpA) { Log.Logger.Debug("Debut ModePaiement.Sauve(" + mpA.Libelle + ")"); try { OB ob = (OB)CallContext.GetData(KEY.OB); mpA.Id = ob.ModePaiements.Count != 0 ? ob.ModePaiements.Max(u => u.Id) + 1 : 1; ob.ModePaiements.Add(mpA); CallContext.SetData(KEY.OB, ob); } catch (Exception ex) { Log.Logger.Error(ex.Message); throw; } return(mpA); }
public static void DeletePossible(ModePaiement mpA) { Log.Logger.Debug("Debut ModePaiement.DeletePossible(" + mpA.Id + ")"); try { OB ob = (OB)CallContext.GetData(KEY.OB); List <Operation> lo = ob.Operations.Where(o => o.ModePaiement.Id == mpA.Id).ToList(); if (lo.Count != 0) { throw new Exception("Vous devez d'abord modifier vos Opérations pour qu'elles ne pointent plus sur ce Mode de Paiement."); } } catch (Exception ex) { Log.Logger.Error(ex.Message); throw; } }
public static ModePaiement Maj(ModePaiement mpA) { Log.Logger.Debug("Debut ModePaiement.Maj(" + mpA.Id + ")"); try { OB ob = (OB)CallContext.GetData(KEY.OB); ModePaiement mp = ob.ModePaiements.Find((mptemp) => mptemp.Id == mpA.Id); mp.Libelle = mpA.Libelle; mp.Type = mpA.Type; CallContext.SetData(KEY.OB, ob); } catch (Exception ex) { Log.Logger.Error(ex.Message); throw; } return(mpA); }
public static ModePaiement ChargeParNom(string nom) { Log.Logger.Debug("Debut ModePaiement.ChargeParNom(" + nom + ")"); ModePaiement mp = new ModePaiement(); try { OB ob = (OB)CallContext.GetData(KEY.OB); mp = ob.ModePaiements.Where(mpt => mpt.Libelle == nom).FirstOrDefault(); if (mp is null) { mp = new ModePaiement(); } } catch (Exception ex) { Log.Logger.Error(ex.Message); throw; } return(mp); }
public static DataSet ChargeGrilleOperationFiltre(Compte cP, bool bDate, string cbFiltreDate, DateTime txtFiltreDate, bool bModePaiement, ModePaiement mpP, bool bTiers, string txtFiltreTiers, bool bCategorie, Categorie catP, bool bMontant, string cbFiltreMontant, double txtFiltreMontant, bool bNonPointe) { Log.Logger.Debug("Debut Operations.ChargeGrilleOperationFiltre()"); DataSet retour = new DataSet(); List <Operation> lo = cP.Operations(); if (bDate) { switch (cbFiltreDate) { case KEY.COMPARAISONINFEGALE: lo = lo.Where(x => x.Date.Date <= txtFiltreDate.Date).ToList(); break; case KEY.COMPARAISONEGALE: lo = lo.Where(x => x.Date.Date == txtFiltreDate.Date).ToList(); break; case KEY.COMPARAISONSUPEGALE: lo = lo.Where(x => x.Date.Date >= txtFiltreDate.Date).ToList(); break; } } if (bModePaiement) { lo = lo.Where(x => x.ModePaiement.Id == mpP.Id).ToList(); } if (bTiers) { lo = lo.Where(x => x.Tiers == txtFiltreTiers).ToList(); } if (bCategorie) { lo = lo.Where(x => x.Categorie.Id == catP.Id).ToList(); } if (bMontant) { switch (cbFiltreMontant) { case KEY.COMPARAISONINFEGALE: lo = lo.Where(x => x.Montant <= txtFiltreMontant).ToList(); break; case KEY.COMPARAISONEGALE: lo = lo.Where(x => x.Montant == txtFiltreMontant).ToList(); break; case KEY.COMPARAISONSUPEGALE: lo = lo.Where(x => x.Montant >= txtFiltreMontant).ToList(); break; } } if (bNonPointe) { lo = lo.Where(x => x.DatePointage is null).ToList(); } return(ToDataSet(lo.OrderByDescending(x => x.Date).ToList(), cP.SoldeInitial)); }