public ReportPDFCreator(Model.ClientReportVM objModel, string Filename, System.Windows.Controls.Grid visualObj, Grid Recomend, Grid Dun, Grid Legend, double Totalport, bool openR) { DpfName = Filename; Hat = new HatPrint(); Pcp = new PageContentPrint(); this.open = openR; _clientdetails = new string[] { "Order : " + objModel.Order, "Name : " + objModel.FIO, "Date of Birth : " + objModel.DateofBirth, "Personal Consultant Number : " + objModel.Adviser, "Status : " + objModel.Status, }; _clientsummary = objModel.AllocationCollection; this.CurrentP = visualObj; this.RecomendPort = Recomend; this.Dynamic = Dun; this.Legend = Legend; this.Totalport = Totalport; ActivesClasses = objModel.DiagrammValueCollection; }
public ClientPortfellVM() { decimal totalMarkedValueUSD = 0; //Сумма текущих стоимостей всех инструментов decimal totalUSDprifit = 0; //Сумма всех прибылей от каждого инструмента //..............<Заполнение таблицы Investment>.................... #region InvestCollection = new ObservableCollection <ToolsInvestmentDetails>(); TotalInvestCollection = new ObservableCollection <TotalInvest>(); // Actives DataTable tableInf = userDAL.GetInvestmentDetails.CurrActives(order); for (int i = 0; i < tableInf.Rows.Count; i++) // Сумма всех активов в USD , нужна для подсчета % { string _value = tableInf.Rows[i][4].ToString(); decimal _marketVUSD = Convert.ToDecimal(tableInf.Rows[i][3]); if (_value != "USD") { _marketVUSD = ValueOperation.ValueToUSD(_value, _marketVUSD); } ActiveSumm += _marketVUSD; } for (int i = 0; i < tableInf.Rows.Count; i++) { string Type = tableInf.Rows[i][6].ToString(); Type = (Type == "") ? "Alternative Invest" : Type; string _value = tableInf.Rows[i][4].ToString(); decimal _marketVUSD = Convert.ToDecimal(tableInf.Rows[i][3]); if (_value != "USD") { _marketVUSD = ValueOperation.ValueToUSD(_value, _marketVUSD); } decimal _nowQuote = QuteParse.QuoteByIsin(tableInf.Rows[i][0].ToString()); decimal _aqpr = Convert.ToDecimal(tableInf.Rows[i][1]); decimal _units = Convert.ToDecimal(tableInf.Rows[i][2]); decimal _profit = ((_units * _nowQuote) - (_units * _aqpr)); _profit = (_marketVUSD == _aqpr) ?0:_profit; InvestCollection.Add(new ToolsInvestmentDetails() { Type = Type, Isin = tableInf.Rows[i][0].ToString(), Value = _value, currentDate = (DateTime.Now.Date).ToString(), Date = tableInf.Rows[i][5].ToString(), Markedvalue = tableInf.Rows[i][3].ToString(), MarkedvalueUSD = _marketVUSD.ToString("N2"), Units = _units.ToString(), AqPr = _aqpr.ToString(), Quote = _nowQuote.ToString(), profit = _profit.ToString("N2"), Percent = ((_units * _nowQuote) / ActiveSumm * 100).ToString("N2") }); } // "Saxxxo", "IB" #region try { DataTable saxIbtable = userDAL.GetInvestmentDetails.GetInvestmentSaxoIb(Order); int roxsTable = saxIbtable.Rows.Count; InvestCollection.Add(new ToolsInvestmentDetails() { Type = "Transfer" }); if (roxsTable > 0) { for (int i = 0; i < roxsTable; i++) { InvestCollection.Add(new ToolsInvestmentDetails() { Type = saxIbtable.Rows[i][0].ToString().ToUpper(), Date = saxIbtable.Rows[i][3].ToString(), MarkedvalueUSD = saxIbtable.Rows[i][2].ToString(), Value = saxIbtable.Rows[i][1].ToString() }); } } InvestCollection.Add(new ToolsInvestmentDetails() { Type = "TOTAL RESULTS", MarkedvalueUSD = totalMarkedValueUSD.ToString("N2"), Percent = (totalMarkedValueUSD / ((Convert.ToDecimal(Cash) + totalMarkedValueUSD) / 100)).ToString("N2") + " %", profit = totalUSDprifit.ToString("N2") }); } catch (Exception ex) { // BOX.ShowError(ex.Message, ex.Source); } #endregion #endregion //.............<Заполнение таблицы Inflow>..................... #region InflowDetailsCollection = new ObservableCollection <InflowTools>(); DataTable tableIn = userDAL.GetInvestmentDetails.GetInflowDetails(order); for (int i = 0; i < tableIn.Rows.Count; i++) { InflowDetailsCollection.Add(new InflowTools() { CashAccount = tableIn.Rows[i][0].ToString(), aqprice = tableIn.Rows[i][5].ToString(), CashAccSumm = Convert.ToDecimal(tableIn.Rows[i][4]), countPaper = Convert.ToDecimal(tableIn.Rows[i][6]), date = Convert.ToDateTime(tableIn.Rows[i][7]), Isin = tableIn.Rows[i][2].ToString(), security = tableIn.Rows[i][3].ToString(), }); } #endregion //......................<Заоплнение Outflow>..................... #region WithdrawDetailsCollection = new ObservableCollection <Withdraw>(); DataTable table = userDAL.GetInvestmentDetails.OutFlow(order); for (int i = 0; i < table.Rows.Count; i++) { WithdrawDetailsCollection.Add(new Withdraw() { Summ = table.Rows[i][0].ToString(), Date = table.Rows[i][1].ToString() }); } #endregion //..............<Заполнение таблицы CELL Summary>.................... #region Collection = new ObservableCollection <ToolsInvestmentDetailsTotal>(); Collection.Add(new ToolsInvestmentDetailsTotal() { Type = "Cash Account", Balance = Cash.ToString("N2") }); Collection.Add(new ToolsInvestmentDetailsTotal() { Type = "Market value of investments", Balance = Marcet }); Collection.Add(new ToolsInvestmentDetailsTotal() { Type = "Fund Value", Balance = Found }); Collection.Add(new ToolsInvestmentDetailsTotal() { Type = "Min Cash Allocation", Balance = MINCash }); Collection.Add(new ToolsInvestmentDetailsTotal() { Type = "Encasment", Balance = Encasment }); Model.ClientReportVM report = new Model.ClientReportVM(); var tools = report.Tools; var toolstitle = report.ToolsTitle; var total = report.totallSumm; RiscDict dic = new RiscDict(); decimal totalmidCELLTV = 0; for (int i = 0; i < toolstitle.Length; i++) { if (toolstitle[i] != "leveraged_ETF") { decimal toolPrice = Convert.ToDecimal(tools.Rows[0][i]); int midd = dic.MiddCELLTV(toolstitle[i]); if (midd != 0) { var activeMidd = (toolPrice / midd) * 100; totalmidCELLTV += activeMidd; } } } decimal CELLTV = totalmidCELLTV / total; LTV = CELLTV; //Collection.Add(new ToolsInvestmentDetailsTotal() { Type= "CELLTV", Balance = (CELLTV).ToString("N2")+" %" }); #endregion }