144 lines
6.3 KiB
C#
144 lines
6.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Data;
|
|
|
|
|
|
namespace PDFGenerator.BusinessLayer.DataSection
|
|
{
|
|
class DSS140AnalisiRisparmioCharts: IDataSection
|
|
{
|
|
#region IDataSection Members
|
|
StructColor toBeFound = new StructColor();
|
|
|
|
public DataSectionResult getDataSection(List<SessionStruct> tabelleSessione, string querySql, DataThread dataThread)
|
|
{
|
|
FormatNum num = new FormatNum();
|
|
DataSectionResult dsr = new DataSectionResult();
|
|
|
|
DataTable dt = null;
|
|
|
|
dt = SectionManager.GetDataSection(tabelleSessione, querySql, dataThread);
|
|
|
|
if (dt.Rows.Count == 0) {
|
|
dsr.Esito = 0;
|
|
return dsr;
|
|
}
|
|
|
|
toBeFound.Tipo = "Classi Rischio Credito";
|
|
DataRow row;
|
|
DataView ordina = new DataView(dt);
|
|
ordina.Sort = "ordine";
|
|
DataTable tabOrdinata = ordina.ToTable();
|
|
row = tabOrdinata.Rows[0];
|
|
|
|
|
|
DataSetS140 ds140 = new DataSetS140();
|
|
ds140.RischioCredito.Columns["CounterValue"].Caption = "Controvalore (€)";
|
|
ds140.RischioCredito.Columns["Percentage"].Caption = "Peso (%)";
|
|
|
|
decimal soggettoRischioCredito = Convert.ToDecimal(row["CTV_CreditRisk"]);
|
|
decimal noSoggettoRischioCredito = Convert.ToDecimal(row["CTV_na"]);
|
|
decimal patrimonioNonRappresentabile = Convert.ToDecimal(row["CTV_Notcovered"]);
|
|
decimal scopertoCCNegativo = dataThread.TotalNegativeCurrentAccountValue;
|
|
decimal lineaSelfNeg = dataThread.TotalSelfNegCurrentAccountValue;
|
|
decimal operazioniInCorso = dataThread.PartiteViaggiantiInvestimento + dataThread.PartiteViaggiantiDisinvestimento;
|
|
decimal patrimonioTotale = soggettoRischioCredito + noSoggettoRischioCredito + patrimonioNonRappresentabile;// +scopertoCCNegativo + lineaSelfNeg + operazioniInCorso;
|
|
string nota = lineaSelfNeg<0 || operazioniInCorso !=0 || scopertoCCNegativo<0?"*":"";
|
|
//decimal PERC_DiFF = Decimal.Round(Convert.ToDecimal(row["PERC_CreditRisk"]), 2) + Decimal.Round(Convert.ToDecimal(row["PERC_na"]), 2);
|
|
|
|
#region Soggetto a Rischio Credito
|
|
DataRow dr = ds140.RischioCredito.NewRow();
|
|
dr["RiskClassName"] = "Soggetto a Rischio Credito";
|
|
dr["CounterValue"] = num.ConvertNum(soggettoRischioCredito);
|
|
dr["Percentage"] = Decimal.Round(Convert.ToDecimal(row["PERC_CreditRisk"]), 2);
|
|
dr["Red"] = 252;
|
|
dr["Green"] = 202;
|
|
dr["Blue"] = 203;
|
|
ds140.RischioCredito.Rows.Add(dr);
|
|
|
|
dr = ds140.ChartData.NewRow();
|
|
dr["Percentage"] = Decimal.Round(Convert.ToDecimal(row["PERC_CreditRisk"]), 2);
|
|
dr["Red"] = 252;
|
|
dr["Green"] = 202;
|
|
dr["Blue"] = 203;
|
|
ds140.ChartData.Rows.Add(dr);
|
|
#endregion
|
|
|
|
#region Non soggetto a Rischio Credito
|
|
dr = ds140.RischioCredito.NewRow();
|
|
dr["RiskClassName"] = "Non soggetto a Rischio Credito";
|
|
dr["CounterValue"] = num.ConvertNum(noSoggettoRischioCredito);
|
|
dr["Percentage"] = Decimal.Round(Convert.ToDecimal(row["PERC_na"]), 2);
|
|
dr["Red"] = 183;
|
|
dr["Green"] = 203;
|
|
dr["Blue"] = 227;
|
|
ds140.RischioCredito.Rows.Add(dr);
|
|
|
|
dr = ds140.ChartData.NewRow();
|
|
dr["Percentage"] = Convert.ToDecimal(row["PERC_na"]);
|
|
dr["Red"] = 183;
|
|
dr["Green"] = 203;
|
|
dr["Blue"] = 227;
|
|
ds140.ChartData.Rows.Add(dr);
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
if (patrimonioNonRappresentabile > 0)
|
|
{
|
|
#region Patrimonio complessivo
|
|
DataRow drPatrimoniocomplessivo = ds140.PatrimonioCoperto.NewRow();
|
|
drPatrimoniocomplessivo["RiskclassName"] = "Patrimonio complessivo";
|
|
drPatrimoniocomplessivo["CounterValue"] = num.ConvertNum(soggettoRischioCredito + noSoggettoRischioCredito);
|
|
drPatrimoniocomplessivo["Percentage"] = 100;
|
|
ds140.PatrimonioCoperto.Rows.Add(drPatrimoniocomplessivo);
|
|
#endregion
|
|
|
|
|
|
DataRow notCovered = ds140.PatrimonioNonCoperto.NewRow();
|
|
notCovered["RiskclassName"] = "Patrimonio non rappresentabile";
|
|
notCovered["CounterValue"] = num.ConvertNum(patrimonioNonRappresentabile);
|
|
ds140.PatrimonioNonCoperto.Rows.Add(notCovered);
|
|
}
|
|
|
|
//if (scopertoCCNegativo!=0)
|
|
//{
|
|
// DataRow notCovered = ds140.PatrimonioNonCoperto.NewRow();
|
|
// notCovered["RiskclassName"] = "Scoperto di conto corrente";
|
|
// notCovered["CounterValue"] = num.ConvertNum(scopertoCCNegativo);
|
|
// ds140.PatrimonioNonCoperto.Rows.Add(notCovered);
|
|
//}
|
|
|
|
//if (lineaSelfNeg!=0)
|
|
//{
|
|
// DataRow notCovered = ds140.PatrimonioNonCoperto.NewRow();
|
|
// notCovered["RiskclassName"] = "Liquidità GP Eligo Fondi";
|
|
// notCovered["CounterValue"] = num.ConvertNum(lineaSelfNeg);
|
|
// ds140.PatrimonioNonCoperto.Rows.Add(notCovered);
|
|
//}
|
|
|
|
//if (operazioniInCorso != 0)
|
|
//{
|
|
// DataRow notCovered = ds140.PatrimonioNonCoperto.NewRow();
|
|
// notCovered["RiskclassName"] = "Operazioni in corso";
|
|
// notCovered["CounterValue"] = num.ConvertNum(operazioniInCorso);
|
|
// ds140.PatrimonioNonCoperto.Rows.Add(notCovered);
|
|
//}
|
|
|
|
DataRow drTot = ds140.RischioCreditoTotal.NewRow();
|
|
drTot["Totale"] = "Patrimonio totale";
|
|
drTot["CounterValue"] = num.ConvertNum(patrimonioTotale) + nota;
|
|
if (patrimonioNonRappresentabile <= 0)
|
|
drTot["Percentage"] = 100;
|
|
ds140.RischioCreditoTotal.Rows.Add(drTot);
|
|
|
|
dsr.DatiSezione = ds140;
|
|
dsr.Esito = dt.Rows.Count;
|
|
return dsr;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|