using System;
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 PDFGenerator.BusinessLayer.DataSection;
using PDFGenerator.BusinessLayer;
using System.Collections.Generic;
namespace PDFGenerator.BusinessLayer.DataSection
{
class DSS151ProfiloDiRischio : IDataSection
{
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
//private int _experince;
//public int Experince
//{
// set
// {
// _experince = value;
// }
// get
// {
// return _experince;
// }
//}
public DSS151ProfiloDiRischio()
{
//
// TODO: Add constructor logic here
//
}
#region IDataSection Members
///
/// Implement the getDataSection function of the interface IDataSection.
///
///
/// Sql Statment to be executed to return the Profile Risk of the certain customer in a certain network
///
/// Data Table to be shown in the report
public DataSectionResult getDataSection(List tabelleSessione, string querySql, DataThread dataThread)
{
try
{
DataSectionResult customerProfiloRischioDataSectionResult = new DataSectionResult();
//Random rnd = new Random();
DataRow customerProfiloRischioDataRow;
DataRow customerProfilofinanziarioDataRow;
DataRow customerProfiloDateDataRow;
//S93 Data moved to S95
DataRow CTVDataRow;
DataRow CTVTotali;
decimal risorseFinanziarie = 0;
decimal CC = 0;
decimal investimentiInCorso = 0;
FormatNum formatnum = new FormatNum();
decimal totalePartiteViaggianti = dataThread.PartiteViaggiantiInvestimento + dataThread.PartiteViaggiantiDisinvestimento;
DataTable customerProfiloRischioDataTable = SectionManager.GetDataSection(tabelleSessione, querySql, dataThread);
DataSetS151 customerProfiloRischioRecordsDataSetS151 = new DataSetS151();
if (dataThread.profiloIsAct && customerProfiloRischioDataTable.Rows.Count > 0)
{
int profiloRischioClienteAssegnato = Convert.ToInt32(customerProfiloRischioDataTable.Rows[0]["codiceProfilo"]);
#region Creazione righe datatable Profilofinanziario
// Profilo finanziario
customerProfilofinanziarioDataRow = customerProfiloRischioRecordsDataSetS151.Profilofinanziario.NewRow();
customerProfilofinanziarioDataRow["Descrizione"] = "Profilo finanziario";
customerProfilofinanziarioDataRow["Valore"] = customerProfiloRischioDataTable.Rows[0]["codiceProfilo"].ToString() + " " + customerProfiloRischioDataTable.Rows[0]["nomeProfilo"].ToString();
customerProfiloRischioRecordsDataSetS151.Profilofinanziario.Rows.Add(customerProfilofinanziarioDataRow);
#endregion
#region Creazione righe datatable profilorischio
// VaR Massimo
customerProfiloRischioDataRow = customerProfiloRischioRecordsDataSetS151.ProfiloRischio.NewRow();
customerProfiloRischioDataRow["Descrizione"] = "Rischio Mercato (VaR) massimo";
customerProfiloRischioDataRow["Valore"] = SoglieVar.ConvOld(customerProfiloRischioDataTable.Rows[0]["varMassimo"]);
customerProfiloRischioRecordsDataSetS151.ProfiloRischio.Rows.Add(customerProfiloRischioDataRow);
// Rischo Credito Massimo
customerProfiloRischioDataRow = customerProfiloRischioRecordsDataSetS151.ProfiloRischio.NewRow();
customerProfiloRischioDataRow["Descrizione"] = "Rischio Credito massimo";
customerProfiloRischioDataRow["Valore"] = UtilityBusinessLayer.GetRiskCreditClassName(customerProfiloRischioDataTable.Rows[0]["RiskClass"].ToString());
customerProfiloRischioRecordsDataSetS151.ProfiloRischio.Rows.Add(customerProfiloRischioDataRow);
// Experince
customerProfiloRischioDataRow = customerProfiloRischioRecordsDataSetS151.ProfiloRischio.NewRow();
customerProfiloRischioDataRow["Descrizione"] = "Experince";
customerProfiloRischioDataRow["Valore"] = customerProfiloRischioDataTable.Rows[0]["Experince"].ToString();
customerProfiloRischioRecordsDataSetS151.ProfiloRischio.Rows.Add(customerProfiloRischioDataRow);
#endregion
#region Creazione righe datatable ProfiloDate
// Data Ultimo Aggiornamento
customerProfiloDateDataRow = customerProfiloRischioRecordsDataSetS151.ProfiloDate.NewRow();
// FC 09062015
// Aggiornamneto Label Descrizione
//New Label Da inserire :
customerProfiloDateDataRow["Descrizione"] = "Data inizio validità profilo";
//customerProfiloDateDataRow["Descrizione"] = "Ultimo aggiornamento questionario";
customerProfiloDateDataRow["Valore"] = customerProfiloRischioDataTable.Rows[0]["dataInizioValidita"].ToString();
customerProfiloRischioRecordsDataSetS151.ProfiloDate.Rows.Add(customerProfiloDateDataRow);
#endregion
#region RISORSE FINANZIARIE
decimal PatrimonioBancaFideuramCTV_netto = dataThread.PatrimonioBancaFideuramCtvAlNettoContoCorrente;
CTVDataRow = customerProfiloRischioRecordsDataSetS151.Dati.NewRow();
CTVDataRow["Descrizione"] = "Risorse finanziarie";
risorseFinanziarie = PatrimonioBancaFideuramCTV_netto;
CTVDataRow["Controvalore"] = formatnum.ConvertNum(PatrimonioBancaFideuramCTV_netto) + " €";
customerProfiloRischioRecordsDataSetS151.Dati.Rows.Add(CTVDataRow);
#endregion
#region CONTO CORRENTE
CTVDataRow = customerProfiloRischioRecordsDataSetS151.Dati.NewRow();
//CTVDataRow["Descrizione"] = "Conto corrente";
CTVDataRow["Descrizione"] = "C/C a saldo negativo";
CC = dataThread.ContoCorrente;
CTVDataRow["Controvalore"] = formatnum.ConvertNum(CC) + " €";
if (CC != 0)
customerProfiloRischioRecordsDataSetS151.Dati.Rows.Add(CTVDataRow);
#endregion
#region INVESTIMENTI IN CORSO
CTVDataRow = customerProfiloRischioRecordsDataSetS151.Dati.NewDatiRow();
CTVDataRow["Descrizione"] = Resource.PartiteViaggianti;
investimentiInCorso = dataThread.PartiteViaggiantiInvestimento + dataThread.PartiteViaggiantiDisinvestimento;
CTVDataRow["Controvalore"] = formatnum.ConvertNum(investimentiInCorso) + " €";
if (totalePartiteViaggianti != 0)
customerProfiloRischioRecordsDataSetS151.Dati.Rows.Add(CTVDataRow);
#endregion
#region TOTALE PATRIMONIO
CTVTotali = customerProfiloRischioRecordsDataSetS151.Totali.NewRow();
CTVTotali["Descrizione"] = "Totale patrimonio";
decimal totale = risorseFinanziarie + CC + investimentiInCorso;
CTVTotali["Controvalore"] = formatnum.ConvertNum(totale) + " €";
customerProfiloRischioRecordsDataSetS151.Totali.Rows.Add(CTVTotali);
#endregion
}
customerProfiloRischioDataSectionResult.DatiSezione = customerProfiloRischioRecordsDataSetS151;
customerProfiloRischioDataSectionResult.Esito = customerProfiloRischioRecordsDataSetS151.ProfiloRischio.Rows.Count;
return customerProfiloRischioDataSectionResult;
}
catch (Exception ex)
{
try {
logger.Error(String.Concat(ex.Message, " ", dataThread.CodiceFiscale));
}
catch { }
throw ex;
}
}
#endregion
}
}