Exemple #1
0
        public DevisElements(string _nomFichier, decimal _totalTable)
        {
            this.dateCreation = DateTime.Now.ToShortDateString();
            this.dateVersion  = DateTime.Now.ToShortDateString();
            this.numVersion   = 1.0m;
            this.numEdition   = 1;
            this.nomFichier   = _nomFichier;
            this.totalTable   = _totalTable;
            DateTime firstOfTheMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

            this.dateDebut      = firstOfTheMonth.ToLongDateString();
            this.livraisonFinal = firstOfTheMonth.AddMonths(1).AddDays(-1).ToLongDateString();

            //Calculs des factu CDP et DT
            using (DevisEntities cont = new DevisEntities())
            {
                //Atttention ta base est pourrie pense a changer les labels pour les finaux
                decimal cdp = cont.Tarification.Where(s => s.Type == "CDP").Select(s => s.Tar5).First();
                decimal dt  = cont.Tarification.Where(s => s.Type == "Directeur").Select(s => s.Tar5).First();
                this.facturationCDP  = 20 * cdp;
                this.facturationDT   = 7 * dt;
                this.estimationDTCDP = this.facturationDT + this.facturationCDP;
            }
            this.totalCumule = this.estimationDTCDP + this.totalTable;
        }
        public void updateValue(bool isAmo)
        {
            using (DevisEntities cont = new DevisEntities())
            {
                Ressource res = cont.Ressource.Where(x => x.Initial == initials).Include(x => x.Tarification_Ressource).FirstOrDefault();
                if (res != null)
                {
                    List <long>  typeId     = res.Tarification_Ressource.Select(x => x.FK_Tarification).ToList();
                    Tarification tar        = cont.Tarification.Where(x => typeId.Contains(x.ID) && x.IsAmo == isAmo).FirstOrDefault();
                    decimal      dailyValue = this.value != null?Math.Round(Convert.ToDecimal(this.value / 7), 2) : 0;

                    dailyValue = getDecimalPart(dailyValue);

                    this.value = Math.Round(dailyValue * (res.Niveau == 3 ? (decimal)tar.Tar3 : (decimal)tar.Tar5), 2);
                }
            }
        }
        public Facturation(string initials, bool isAmo, long type)
        {
            using (DevisEntities cont = new DevisEntities())
            {
                Ressource res = cont.Ressource.Where(x => x.Initial == initials).FirstOrDefault();
                if (res != null)
                {
                    List <long>  typeId = res.Tarification_Ressource.Select(x => x.FK_Tarification).ToList();
                    Tarification tar    = cont.Tarification.Where(x => typeId.Contains(x.ID) && x.IsAmo == isAmo).FirstOrDefault();
                    if (tar != null)
                    {
                        this.initials = res.Initial;
                        decimal dailyValue = this.value != null?Math.Round(Convert.ToDecimal(this.value / 7), 2) : 0;

                        this.value = Math.Round(dailyValue * (res.Niveau == 3 ? (decimal)tar.Tar3 : (decimal)tar.Tar5), 2);
                    }
                }
            }
        }