161 lines
6.8 KiB
C#
161 lines
6.8 KiB
C#
using System;
|
|
using System.Web;
|
|
//using System.Web.Services;
|
|
//using System.Web.Services.Protocols;
|
|
using System.Text;
|
|
using System.Data;
|
|
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using PDFGenerator.BusinessLayer.DataSection;
|
|
using PDFGenerator.BusinessLayer;
|
|
using PDFGenerator;
|
|
|
|
public class DSS56PatrimonioBFAreeBisogno : IDataSection
|
|
{
|
|
#region IDataSection Members
|
|
//rispostaVaRPortafoglioType[] rispostaptfModello;
|
|
|
|
public DataSectionResult getDataSection(List<SessionStruct> tabelleSessione, string querySql, DataThread dataThread)
|
|
{
|
|
FormatNum conv = new FormatNum();
|
|
DataSectionResult dsr = new DataSectionResult();
|
|
Random rnd = new Random();
|
|
|
|
DataTable dt = new DataTable();
|
|
DataSetS56 ds56 = new DataSetS56();
|
|
|
|
if (dataThread.Patrimoniobancafideuramctv != 0)
|
|
{
|
|
dt = SectionManager.GetDataSection(tabelleSessione, querySql, dataThread);
|
|
|
|
Decimal ctvTotale = 0;
|
|
Decimal ctvCC = 0;
|
|
Decimal ctvNA = 0;
|
|
|
|
DataSetS56.PartiteViaggiantiRow drPart;
|
|
DataSetS56.TotaleAreeBisognoRow drTotAree;
|
|
DataSetS56.TotalePatrimonioRow drTotPat;
|
|
DataSetS56.PatrimonioBFAreeBisognoRow dr;
|
|
DataSetS56.ContoCorrenteRow drCc;
|
|
DataSetS56.RisorseNonAllocateRow drNa;
|
|
|
|
bool bPrimaRiga = true;
|
|
FormatNum con = new FormatNum();
|
|
ds56.PatrimonioBFAreeBisogno.Columns["Controvalore"].Caption = "Controvalore <br> € ";
|
|
|
|
drPart = ds56.PartiteViaggianti.NewPartiteViaggiantiRow();
|
|
drPart.Descrizione = Resource.PartiteViaggianti;
|
|
drPart.ControValore = dataThread.PartiteViaggiantiInvestimento + dataThread.PartiteViaggiantiDisinvestimento;
|
|
if ((Decimal)drPart.ControValore != 0)
|
|
ds56.PartiteViaggianti.Rows.Add(drPart);
|
|
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
if (bPrimaRiga)
|
|
{
|
|
//valorizzazione daatatable TotaleAreeBisogno
|
|
drTotAree = ds56.TotaleAreeBisogno.NewTotaleAreeBisognoRow();
|
|
|
|
drTotAree.DescrTotale = "TOTALE";
|
|
drTotAree.Controvalore = row["somma_controval"]== DBNull.Value ? 0 : Convert.ToDecimal(row["somma_controval"]);
|
|
drTotAree.Var = row["var_tot"]==DBNull.Value ? 0 : Convert.ToDecimal(row["var_tot"]);
|
|
if (row["copertura_totString"] != DBNull.Value)
|
|
drTotAree.GradoCopertura = row["copertura_totString"].ToString();
|
|
else
|
|
drTotAree.GradoCopertura = conv.ConvertNum(row["copertura_tot"]);
|
|
|
|
if (row["somma_controval"] == DBNull.Value)
|
|
ctvTotale += 0;
|
|
else
|
|
ctvTotale += (Decimal)row["somma_controval"];
|
|
|
|
ds56.TotaleAreeBisogno.AddTotaleAreeBisognoRow(drTotAree);
|
|
|
|
bPrimaRiga = false;
|
|
}
|
|
//nota
|
|
|
|
|
|
dr = ds56.PatrimonioBFAreeBisogno.NewPatrimonioBFAreeBisognoRow();
|
|
dr.CodiceAreaBisogno = row["needarea"].ToString();
|
|
dr.DescrAreaBisogno = row["areaname"].ToString();
|
|
dr.Controvalore = Convert.ToDecimal(row["controvalore"]);
|
|
dr.Peso = Convert.ToDecimal(row["Peso"]);
|
|
|
|
if (row["var_needareaString"] != DBNull.Value)
|
|
dr.Var = row["var_needareaString"].ToString();
|
|
else
|
|
dr.Var = row["var_needarea"] == DBNull.Value ? "0.00" : conv.ConvertNum(row["var_needarea"]);
|
|
|
|
if (row["copertura_needareaString"] != DBNull.Value)
|
|
dr.GradoCopertura = row["copertura_needareaString"].ToString();
|
|
else
|
|
dr.GradoCopertura = conv.ConvertNum(row["copertura_needarea"]);
|
|
dr.RischioRelativo = row["RischioRelativo"]== DBNull.Value ? 0 : Convert.ToDecimal(row["RischioRelativo"]);
|
|
dr.Nota = row["Nota"]==DBNull.Value ? 0 : Convert.ToInt32(row["Nota"]);
|
|
|
|
ds56.PatrimonioBFAreeBisogno.AddPatrimonioBFAreeBisognoRow(dr);
|
|
|
|
}
|
|
|
|
|
|
if (dataThread.ContoCorrente != 0)
|
|
{
|
|
drCc = ds56.ContoCorrente.NewContoCorrenteRow();
|
|
drCc.Descrizione = "Conto corrente";
|
|
drCc.Controvalore = dataThread.ContoCorrente;
|
|
ctvCC += drCc.Controvalore;
|
|
if (drCc.Controvalore != 0)
|
|
ds56.ContoCorrente.AddContoCorrenteRow(drCc);
|
|
}
|
|
|
|
if (dataThread.RisorseNonAssociate !=0)
|
|
{
|
|
drNa = ds56.RisorseNonAllocate.NewRisorseNonAllocateRow();
|
|
drNa.Descrizione = "Risorse Non Allocate";
|
|
drNa.Controvalore = Convert.ToDecimal(dataThread.RisorseNonAssociate);
|
|
ctvNA += drNa.Controvalore;
|
|
if (drNa.Controvalore != 0)
|
|
ds56.RisorseNonAllocate.AddRisorseNonAllocateRow(drNa);
|
|
}
|
|
|
|
//// Calcolo RischioRelativo = rischio relativo / rischiorelativo totale
|
|
//foreach (DataRow rwRischioRelativo in ds56.PatrimonioBFAreeBisogno.Rows)
|
|
//{
|
|
// if (rwRischioRelativo["RischioRelativo"] != null && rwRischioRelativo["RischioRelativo"] != DBNull.Value && rischioRelativoTotale != 0)
|
|
// rwRischioRelativo["RischioRelativo"] = (Convert.ToDouble(rwRischioRelativo["RischioRelativo"]) / rischioRelativoTotale) * 100;
|
|
|
|
// if (Convert.ToDouble(rwRischioRelativo["RischioRelativo"]) < 0)
|
|
// rwRischioRelativo["RischioRelativo"] = 0;
|
|
//}
|
|
|
|
|
|
if ((ctvNA + ctvCC + dataThread.PartiteViaggiantiInvestimento + dataThread.PartiteViaggiantiDisinvestimento) != 0)
|
|
{
|
|
drTotPat = ds56.TotalePatrimonio.NewTotalePatrimonioRow();
|
|
drTotPat.DescrTotale = "TOTALE PATRIMONIO";
|
|
drTotPat.Controvalore = ctvTotale + ctvCC + ctvNA + dataThread.PartiteViaggiantiInvestimento+ dataThread.PartiteViaggiantiDisinvestimento;
|
|
ds56.TotalePatrimonio.AddTotalePatrimonioRow(drTotPat);
|
|
}
|
|
|
|
//Normalizzo le percentuali
|
|
|
|
if (dt.Rows.Count != 0 && ctvTotale > 0)
|
|
{
|
|
int index = conv.NormalizePerc(ds56.PatrimonioBFAreeBisogno, "Peso");
|
|
conv.NormalizePerc(ds56.PatrimonioBFAreeBisogno, "RischioRelativo", index);
|
|
}
|
|
//========================================================
|
|
}
|
|
|
|
dsr.DatiSezione = ds56;
|
|
dsr.Esito = dt.Rows.Count;
|
|
|
|
return dsr;
|
|
}
|
|
|
|
#endregion
|
|
}
|