Esempio n. 1
0
        /// <summary>
        /// Va chercher les éléments des projets et le mets dans la classe
        /// approprier pour les affichers par la suite
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public List <ViewProject> viewProjet(int id)
        {
            List <ViewProject> ListVP       = new List <ViewProject>();
            Project            p            = solutiosContext.Project.Find(id);
            ProjectFollowUp    pfu          = solutiosContext.ProjectFollowUp.LastOrDefault(e => e.PfProjectId == id);
            FollowUp           follow       = solutiosContext.FollowUp.LastOrDefault(c => c.FuId == pfu.PfFollowUpId);
            List <FollowInfo>  soumission   = p.listProjectSoumission();
            List <FollowInfo>  estimation   = follow.deinfo();
            ProjectExpense     pex          = solutiosContext.ProjectExpense.LastOrDefault(c => c.PeProjectId == id);
            Expense            ex           = solutiosContext.Expense.LastOrDefault(c => c.ExpenseId == pex.PeExpenseId);
            List <ExpenseInfo> expenseInfos = ex.Listexpenses();

            for (int i = 0; i < estimation.Count; i++)
            {
                if ((soumission[i].Spending != "MargeSoumis") && (soumission[i].Spending != "MargeProjeter"))
                {
                    ViewProject vp = new ViewProject("", 0, 0, 0);
                    vp.spending         = soumission[i].Spending;
                    vp.soumission       = soumission[i].amount;
                    vp.depenceP         = estimation[i].amount;
                    vp.dépensecourrante = expenseInfos[i].amount;
                    ListVP.Add(vp);
                }
            }
            return(ListVP);
        }
Esempio n. 2
0
        /// <summary>
        /// Va chercher les éléments des dernières Projections
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public FollowUp GetLastProjection(int id)
        {
            if (solutiosContext.ProjectFollowUp.LastOrDefault(e => e.PfProjectId == id) != null)
            {
                ProjectFollowUp p = solutiosContext.ProjectFollowUp.LastOrDefault(e => e.PfProjectId == id);

                return(solutiosContext.FollowUp.LastOrDefault(c => c.FuId == p.PfFollowUpId));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Va chercher les informations pour afficher les vieux graphiques de l'historique
        /// </summary>
        /// <param name="id"></param>
        /// <param name="fuid"></param>
        /// <returns></returns>
        public ViewGraph OldGraph(int id, int fuid)
        {
            ViewGraph       vg             = new ViewGraph();
            Project         p              = solutiosContext.Project.Find(id);
            ProjectFollowUp PfollowUps     = solutiosContext.ProjectFollowUp.LastOrDefault(c => c.PfProjectId == id);
            FollowUp        follows        = solutiosContext.FollowUp.Find(fuid);
            ProjectExpense  projectExpense = solutiosContext.ProjectExpense.LastOrDefault(c => c.PeProjectId == id);
            Expense         expense        = solutiosContext.Expense.Find(projectExpense.PeExpenseId);

            List <FollowInfo>  infos   = JsonConvert.DeserializeObject <List <FollowInfo> >(follows.FuInfo);
            List <FollowInfo>  soumis  = p.listProjectSoumission();
            List <ExpenseInfo> expinfo = JsonConvert.DeserializeObject <List <ExpenseInfo> >(expense.JsonExpenseInfo);

            string end = "]";

            string projectionEX = "[";

            for (int i = 0; i < infos.Count; i++)
            {
                if ((infos[i].Spending != "MargeSoumis") && (infos[i].Spending != "MargeProjeter"))
                {
                    double depense = soumis[i].amount - expinfo[i].amount;
                    projectionEX = projectionEX + depense.ToString() + ",";
                }
            }
            projectionEX += end;

            string graphprojection = "[";

            foreach (var item in infos)
            {
                if ((item.Spending != "MargeSoumis") && (item.Spending != "MargeProjeter"))
                {
                    graphprojection = graphprojection + item.amount.ToString() + ",";
                }
            }
            graphprojection += end;

            string graphreel = "[";

            foreach (var item in expinfo)
            {
                if ((item.Spending != "MargeSoumis") && (item.Spending != "MargeProjeter"))
                {
                    graphreel = graphreel + item.amount.ToString() + ",";
                }
            }
            graphreel += end;

            string colorsoumi = "[";

            foreach (var item in soumis)
            {
                if ((item.Spending != "MargeSoumis") && (item.Spending != "MargeProjeter"))
                {
                    colorsoumi = colorsoumi + '"' + item.color + '"' + ",";
                }
            }

            colorsoumi += end;

            string colorbar        = "[";
            string colorbarexpense = "[";

            for (int i = 0; i < soumis.Count; i++)
            {
                if ((soumis[i].Spending != "MargeSoumis") && (soumis[i].Spending != "MargeProjeter"))
                {
                    if ((soumis[i].amount - expinfo[i].amount) == infos[i].amount)
                    {
                        colorbar = colorbar + '"' + "#f4b30d" + '"' + ",";
                    }
                    else if ((soumis[i].amount - expinfo[i].amount) < infos[i].amount)
                    {
                        colorbar = colorbar + '"' + "#e02d1b" + '"' + ",";
                    }
                    else if ((soumis[i].amount - expinfo[i].amount) > infos[i].amount)
                    {
                        colorbar = colorbar + '"' + "#1cc88a" + '"' + ",";
                    }

                    if (soumis[i].amount == expinfo[i].amount)
                    {
                        colorbarexpense = colorbarexpense + '"' + "#f4b30d" + '"' + ",";
                    }
                    else if (soumis[i].amount < expinfo[i].amount)
                    {
                        colorbarexpense = colorbarexpense + '"' + "#e02d1b" + '"' + ",";
                    }
                    else if (soumis[i].amount > expinfo[i].amount)
                    {
                        colorbarexpense = colorbarexpense + '"' + "#1cc88a" + '"' + ",";
                    }
                }
            }
            colorbarexpense += end;
            colorbar        += end;

            vg.soumission      = soumission(id);
            vg.soumissionColor = colorsoumi;
            vg.data            = graphprojection;
            vg.projectionEX    = projectionEX;
            vg.color           = colorbar;
            vg.dépense         = graphreel;
            vg.colordepense    = colorbarexpense;
            return(vg);
        }