public CashFlowCalculation GetCashFlowData(int clientId, int planId, int riskProfileId)
        {
            _clientId      = clientId;
            _planId        = planId;
            _riskProfileId = riskProfileId;

            ClientPersonalInfo clientPersonalInfo = new ClientPersonalInfo();

            PersonalInformation personalInfo = clientPersonalInfo.Get(clientId);

            fillPersonalData(personalInfo);

            _riskProfileInfo = new RiskProfileInfo();

            PlannerAssumption plannerAssumption = new PlannerAssumptionInfo().GetAll(_planId);

            if (plannerAssumption != null)
            {
                fillCashFlowFromPlannerAssumption(plannerAssumption);
            }

            IList <Income>   incomes  = new IncomeInfo().GetAll(_planId);
            IList <Expenses> expenses = new ExpensesInfo().GetAll(_planId);
            IList <Loan>     loans    = new LoanInfo().GetAll(_planId);
            IList <Goals>    goals    = new GoalsInfo().GetAll(_planId);

            fillCashFlowFromIncomes(incomes);
            fillCashFlowFromExpenses(expenses);
            fillCashFlowFromLoans(loans);
            fillCashFlowFromGoals(goals);
            return(_cashFlow);
        }
Пример #2
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            int           ID   = 1;
            BusinessPlans plan = new BusinessPlans();

            if (radioMonth.Checked)
            {
                plan.Duration = txtBusinessDuration.Text + " " + radioMonth.Text;
            }

            if (radioYears.Checked)
            {
                plan.Duration = txtBusinessDuration.Text + " " + radioYears.Text;
            }
            plan.StartDate = DateTime.ParseExact(txtStartDate.Text, "dd/MM/yyyy", enUS, DateTimeStyles.None);
            plan.EndDate   = DateTime.ParseExact(txtEndDate.Text, "dd/MM/yyyy", enUS, DateTimeStyles.None);


            DbEntities db = new DbEntities();

            foreach (var item in BusinessLists.GoalsList)
            {
                Data.Goals gl = new Data.Goals();
                gl.Name       = item.Name;
                gl.Duration   = item.Duration;
                gl.Percentage = item.Percentage;
                gl.StartDate  = DateTime.ParseExact(item.StartDate, "dd/MM/yyyy", enUS, DateTimeStyles.None);
                gl.EndDate    = DateTime.ParseExact(item.EndDate, "dd/MM/yyyy", enUS, DateTimeStyles.None);

                string[] infos = item.Info.Split(',');

                for (int i = 0; i <= infos.Length - 1; i++)
                {
                    if (infos[i] != "")
                    {
                        Data.GoalsInfo info = new GoalsInfo();
                        info.Name    = item.Name;
                        info.Goal_Id = ID;
                        info.Info    = infos[i].ToString();
                        db.GoalsInfo.Add(info);
                    }
                }
                ID++;
                db.Goals.Add(gl);
            }
            db.BusinessPlans.Add(plan);
            db.SaveChanges();
        }