Пример #1
0
        public double GetValuationForDate(DateTime dt)
        {
            CListeObjetsDonnees lstValOp = Valorisations;
            CListeObjetsDonnees lstLot   = lstValOp.GetDependances("LotValorisation");

            if (lstValOp.Count == 0)
            {
                return(0);
            }
            lstLot.Tri = CLotValorisation.c_champDateLot;
            CLotValorisation lot = lstLot[0] as CLotValorisation;

            if (lot != null && lot.DateLot.Date.AddMinutes(-1) > dt)//Premier plus récent->premier
            {
                CValorisationElement val = lot.GetValorisation(this);
                if (val != null)
                {
                    return(val.Valeur);
                }
                return(0);
            }
            lstLot.InterditLectureInDB = true;
            lstLot.Filtre = new CFiltreData(CLotValorisation.c_champDateLot + "<@1",
                                            dt.Date.AddDays(1));
            lstLot.Tri = CLotValorisation.c_champDateLot;
            if (lstLot.Count > 0)
            {
                lot = lstLot[lstLot.Count - 1] as CLotValorisation;
                if (lot != null)
                {
                    CValorisationElement val = lot.GetValorisation(this);
                    if (val != null)
                    {
                        return(val.Valeur);
                    }
                }
            }
            return(0);
        }
Пример #2
0
        //------------------------------------------------------------------------
        public double GetValuationForDate(DateTime dt, CValeurUnite quantite)
        {
            CListeObjetsDonnees lstValEqpt = Valorisations;
            CListeObjetsDonnees lstLot     = lstValEqpt.GetDependances("LotValorisation");
            double fQuantite = 1;

            if (quantite != null && Unite != null)
            {
                if (quantite.IUnite == null)
                {
                    fQuantite = quantite.Valeur;
                }
                else
                {
                    fQuantite = quantite.ConvertTo(Unite.GlobalId).Valeur;
                }
            }
            if (lstValEqpt.Count == 0)
            {
                return(0);
            }
            lstLot.Tri = CLotValorisation.c_champDateLot;
            CLotValorisation lot = lstLot[0] as CLotValorisation;

            if (lot != null && lot.DateLot.Date.AddMinutes(-1) > dt)//Premier plus récent->premier
            {
                CValorisationElement val = lot.GetValorisation(this);
                if (val != null)
                {
                    return(val.Valeur * fQuantite);
                }
                return(0);
            }
            lstLot.InterditLectureInDB = true;
            lstLot.Filtre = new CFiltreData(CLotValorisation.c_champDateLot + "<@1",
                                            dt.Date.AddDays(1));
            lstLot.Tri = CLotValorisation.c_champDateLot;
            if (lstLot.Count > 0)
            {
                lot = lstLot[lstLot.Count - 1] as CLotValorisation;
                if (lot != null)
                {
                    CValorisationElement val = lot.GetValorisation(this);
                    if (val != null)
                    {
                        CValeurUnite v        = val.QuantiteEtUnite;
                        IUnite       monUnite = Unite;
                        if (v != null && monUnite != null)
                        {
                            v = v.ConvertTo(monUnite.GlobalId);
                            if (v.Valeur != 0)
                            {
                                return(val.Valeur / v.Valeur * fQuantite);
                            }
                        }
                        return(val.Valeur * fQuantite);
                    }
                }
            }
            return(0);
        }