Ejemplo n.º 1
0
        public static DataSet DataSetTotalComptes(TotalCompte tc)
        {
            double totPointe = 0.0;
            double totaVenir = 0.0;
            double totSolde  = 0.0;

            Type      elementType = typeof(Operation);
            DataSet   ds          = new DataSet();
            DataTable t           = new DataTable("TotalComptes");

            ds.Tables.Add(t);

            t.Columns.Add("Compte", typeof(string));
            t.Columns.Add("Pointé", typeof(double));
            t.Columns.Add("A venir", typeof(double));
            t.Columns.Add("Solde", typeof(double));

            List <Compte> list = tc.Comptes;

            //go through each property on T and add each value to the table
            foreach (Compte item in list)
            {
                DataRow row          = t.NewRow();
                double  soldOpePoint = item.SoldeOperationPointee();
                double  aVenir       = item.AVenir();
                double  soldFinal    = soldOpePoint + aVenir;

                row["Compte"]  = item.Libelle;
                row["Pointé"]  = soldOpePoint;
                row["A venir"] = aVenir;
                row["Solde"]   = soldFinal;

                totPointe += soldOpePoint;
                totaVenir += aVenir;
                totSolde  += soldFinal;

                t.Rows.Add(row);
            }

            DataRow rowTot = t.NewRow();

            rowTot["Compte"]  = "Total";
            rowTot["Pointé"]  = totPointe;
            rowTot["A venir"] = totaVenir;
            rowTot["Solde"]   = totSolde;

            t.Rows.Add(rowTot);

            return(ds);
        }
Ejemplo n.º 2
0
 public static void Delete(TotalCompte tcA)
 {
     Log.Logger.Debug("Debut TotalCompte.Delete(" + tcA.Id + ")");
     try
     {
         OB ob = (OB)CallContext.GetData(KEY.OB);
         ob.ListeTotalCompte.RemoveAll((tc) => tc.Id == tcA.Id);
         CallContext.SetData(KEY.OB, ob);
     }
     catch (Exception ex)
     {
         Log.Logger.Error(ex.Message);
         throw;
     }
 }
Ejemplo n.º 3
0
        public static TotalCompte Charge(int id)
        {
            Log.Logger.Debug("Debut TotalCompte.Charge(" + id + ")");
            TotalCompte tc = new TotalCompte();

            try
            {
                OB ob = (OB)CallContext.GetData(KEY.OB);
                tc = ob.ListeTotalCompte.Where(ttc => ttc.Id == id).First();
            }
            catch (Exception ex)
            {
                Log.Logger.Error(ex.Message);
                throw;
            }
            return(tc);
        }
Ejemplo n.º 4
0
        public static TotalCompte Maj(TotalCompte tcA)
        {
            Log.Logger.Debug("Debut TotalCompte.Maj(" + tcA.Id + ")");
            try
            {
                OB          ob = (OB)CallContext.GetData(KEY.OB);
                TotalCompte tc = ob.ListeTotalCompte.Find((ttc) => ttc.Id == tcA.Id);
                tc.Libelle = tcA.Libelle;
                tc.Comptes = tcA.Comptes;

                CallContext.SetData(KEY.OB, ob);
            }
            catch (Exception ex)
            {
                Log.Logger.Error(ex.Message);
                throw;
            }
            return(tcA);
        }
Ejemplo n.º 5
0
 public static TotalCompte Sauve(TotalCompte tcA)
 {
     Log.Logger.Debug("Debut TotalCompte.Sauve(" + tcA.Libelle + ")");
     try
     {
         OB ob = (OB)CallContext.GetData(KEY.OB);
         if (ob.ListeTotalCompte == null)
         {
             ob.ListeTotalCompte = new List <TotalCompte>();
         }
         tcA.Id = ob.ListeTotalCompte.Count != 0 ? ob.ListeTotalCompte.Max(u => u.Id) + 1 : 1;
         ob.ListeTotalCompte.Add(tcA);
         CallContext.SetData(KEY.OB, ob);
     }
     catch (Exception ex)
     {
         Log.Logger.Error(ex.Message);
         throw;
     }
     return(tcA);
 }