using System; using System.Collections.Generic; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Collections; using System.Text; using PDFGenerator.BusinessLayer.DataSection; using PDFGenerator.BusinessLayer; using PDFGenerator; /// /// Summary description for DSS10PatrimonioFinanziario /// public class DSS10PatrimonioFinanziario : IDataSection { #region IDataSection Members public StructColor toBeFound = new StructColor(); public DataSectionResult getDataSection(List tabelleSessione, string querySql, DataThread dataThread) { try { DataSectionResult dsr = new DataSectionResult(); Decimal ctvTotale = 0; DataTable dt = SectionManager.GetDataSection(tabelleSessione, querySql, dataThread); DataSetS10 ds10 = new DataSetS10(); DataRow dr; toBeFound.Tipo = "MacroAssetClass"; ds10.MacroAssetClass.Columns["Controvalore"].Caption = "Controvalore
(€)        "; ds10.MacroAssetClass.Columns["Percentuale"].Caption = "Peso
(%)"; decimal patrimonioBancaFideuramCTV = 0; decimal cc = 0; string banca = string.Empty; decimal totalePartiteViaggianti = 0; //V decimal residuo = dataThread.TotaleS57; if (dataThread.ContoCorrente < 0) residuo -= dataThread.ContoCorrente; DataRow tuplaMaggiore = null; decimal controValoreMaggiore = 0; DataRow tuplaPercMaggiore = null; decimal percMaggiore = 0; decimal residuoPerc = 100; // foreach (DataRow row in dt.Rows) { dr = ds10.MacroAssetClass.NewRow(); dr["Descrizione"] = row["assetclassname"]; //V decimal temp = Convert.ToDecimal(row["Controvalore"]); dr["Controvalore"] = temp.ToString(); if (temp > controValoreMaggiore) { controValoreMaggiore = temp; tuplaMaggiore = dr; } residuo -= temp; decimal tempPerc = Convert.ToDecimal(row["Percentuale"]); tempPerc = decimal.Round(tempPerc,2); dr["Percentuale"] = tempPerc.ToString(); if (tempPerc > percMaggiore) { percMaggiore = tempPerc; tuplaPercMaggiore = dr; } residuoPerc -= tempPerc; // if (patrimonioBancaFideuramCTV == 0) patrimonioBancaFideuramCTV = dataThread.Patrimoniobancafideuramctv; toBeFound.Codice = row["AssetClassId"].ToString(); if (cc == 0) cc = dataThread.ContoCorrente; if (banca == string.Empty) banca = (string)row["banca"]; if (totalePartiteViaggianti == 0) totalePartiteViaggianti = dataThread.PartiteViaggiantiInvestimento + dataThread.PartiteViaggiantiDisinvestimento; int foundIdx = ClsFunzioniGeneriche.findRightColors(toBeFound); dr["Red"] = ClsFunzioniGeneriche.Colors[foundIdx].Red; dr["Green"] = ClsFunzioniGeneriche.Colors[foundIdx].Green; dr["Blue"] = ClsFunzioniGeneriche.Colors[foundIdx].Blue; ctvTotale += (Decimal)row["Controvalore"]; ds10.MacroAssetClass.Rows.Add(dr); } //V ctvTotale += residuo; if (residuo != 0 && tuplaMaggiore != null) { decimal temp = Convert.ToDecimal(tuplaMaggiore["Controvalore"]); temp += residuo; tuplaMaggiore["Controvalore"] = temp.ToString(); } if (residuoPerc != 0 && tuplaPercMaggiore != null) { decimal temp = Convert.ToDecimal(tuplaPercMaggiore["Percentuale"]); temp += residuoPerc; tuplaPercMaggiore["Percentuale"] = temp.ToString(); } // DataSetS10.PatrimonioNonRappresentabileRow drPatrimonioNonRappresentabile; drPatrimonioNonRappresentabile = ds10.PatrimonioNonRappresentabile.NewPatrimonioNonRappresentabileRow(); drPatrimonioNonRappresentabile.Descrizione = Resource.PatrimonioNonRappresentabile_label; //"Patrimonio non rappresentabile"; //Arrotondamento i totali vengono presi da query differenti e avolte c'è la differenza di un decimale Decimal ctvNonRappr = dataThread.PatrimonioNonRappresentabile; if (ctvNonRappr <= 0) { drPatrimonioNonRappresentabile.ControValore = 0; ctvNonRappr = 0; } else { drPatrimonioNonRappresentabile.ControValore = ctvNonRappr; ds10.PatrimonioNonRappresentabile.Rows.Add(drPatrimonioNonRappresentabile); } DataSetS10.ContoCorrenteBancaFideuramRow drContoCorrenteBancaFideuramRow; drContoCorrenteBancaFideuramRow = ds10.ContoCorrenteBancaFideuram.NewContoCorrenteBancaFideuramRow(); drContoCorrenteBancaFideuramRow.Descrizione = "C/C a saldo negativo"; // +banca; drContoCorrenteBancaFideuramRow.ControValore = cc; if (drContoCorrenteBancaFideuramRow.ControValore < 0) ds10.ContoCorrenteBancaFideuram.Rows.Add(drContoCorrenteBancaFideuramRow); DataSetS10.ContoCorrenteBancaFideuramRow drLineaSelfRow; drLineaSelfRow = ds10.ContoCorrenteBancaFideuram.NewContoCorrenteBancaFideuramRow(); drLineaSelfRow.Descrizione = "Liquidità negativa \"Linee GP Eligo\""; drLineaSelfRow.ControValore = dataThread.TotalSelfNegCurrentAccountValue; if (drLineaSelfRow.ControValore < 0) ds10.ContoCorrenteBancaFideuram.Rows.Add(drLineaSelfRow); DataSetS10.PartiteViaggiantiRow drPartiteViaggiantiRow; drPartiteViaggiantiRow = ds10.PartiteViaggianti.NewPartiteViaggiantiRow(); drPartiteViaggiantiRow.Descrizione = Resource.PartiteViaggianti; //"Investimenti in corso"; drPartiteViaggiantiRow.ControValore = totalePartiteViaggianti; if (drPartiteViaggiantiRow.ControValore > 0) ds10.PartiteViaggianti.Rows.Add(drPartiteViaggiantiRow); bool totalePresente = true; string totRappr = "TOTALE RAPPRESENTATO"; if (drContoCorrenteBancaFideuramRow.ControValore >= 0 && drLineaSelfRow.ControValore >= 0 && drPartiteViaggiantiRow.ControValore <= 0 && ctvNonRappr == 0) { totalePresente = false; totRappr = "TOTALE"; } DataRow drTot = ds10.MacroAssetTotale.NewRow(); drTot["Totale"] = totRappr; drTot["Controvalore"] = ctvTotale; drTot["Percentuale"] = 100.00; ds10.MacroAssetTotale.Rows.Add(drTot); if(totalePresente) { DataSetS10.TotaleRow drTotale; drTotale = ds10.Totale.NewTotaleRow(); drTotale.Descrizione = "TOTALE"; //modifica luca 11/09/08 //i dati in caso di cc positivo sono già comprensivi del c/c quindi non va sommato di nuovo //drTotale.ControValore = (ctvTotale + drPatrimonioNonRappresentabile.ControValore + drContoCorrenteBancaFideuramRow.ControValore); drTotale.ControValore = (ctvTotale + ctvNonRappr); if (drContoCorrenteBancaFideuramRow.ControValore < 0) drTotale.ControValore += drContoCorrenteBancaFideuramRow.ControValore; //fine modifica luca 11/09/08 drTotale.ControValore += totalePartiteViaggianti; drTotale.ControValore += dataThread.TotalSelfNegCurrentAccountValue; ds10.Totale.Rows.Add(drTotale); } #region Risorse Percentuali Decimal valorePrecentuale = 0; DataSetS10.RisorsePercentualiRow rowRisorsePercentuali = ds10.RisorsePercentuali.NewRisorsePercentualiRow(); if (patrimonioBancaFideuramCTV == 0) rowRisorsePercentuali.ValorePercentuale = 0; else { valorePrecentuale = (ctvTotale / patrimonioBancaFideuramCTV) * 100; rowRisorsePercentuali.ValorePercentuale = System.Math.Round(valorePrecentuale, 2, MidpointRounding.ToEven); } ds10.RisorsePercentuali.AddRisorsePercentualiRow(rowRisorsePercentuali); #endregion //Normalizzo le percentuali FormatNum conv = new FormatNum(); if (dt.Rows.Count != 0) conv.NormalizePerc(ds10.MacroAssetClass, "Percentuale"); //======================================================== dsr.DatiSezione = ds10; dsr.Esito = dt.Rows.Count; if (ctvTotale == 0) dsr.Esito = 0; return dsr; } catch (Exception ex) { throw ex; } } #endregion }