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; using System.Linq; namespace PDFGenerator.BusinessLayer.DataSection { public class DSFD177ProfiloDiRischioAdeguatezza : IDataSection { private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); //private int _experince; //public int Experince //{ // set // { // _experince = value; // } // get // { // return _experince; // } //} public DSFD177ProfiloDiRischioAdeguatezza() { // // 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; //Aggiunta Riserva e Investimento Lungo Periodo DataRow customerRiservaInvestimentoLungoPeriodoRow; //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; /**** ATTENZIONE Forzatura Direct Banck da togliere 08032023 - Pino ***/ //querySql = "[C6MartPeriodico].PL_D_S177ProfiloDiRischio_Adeguatezza"; /**********************************************/ DataTable customerProfiloRischioDataTable = SectionManager.GetDataSection(tabelleSessione, querySql, dataThread); DataSetS177 customerProfiloRischioRecordsDataSetS177 = new DataSetS177(); if (dataThread.profiloIsAct && customerProfiloRischioDataTable.Rows.Count > 0) { int profiloRischioClienteAssegnato = Convert.ToInt32(customerProfiloRischioDataTable.Rows[0]["codiceProfilo"]); #region Creazione righe datatable Profilofinanziario // Profilo finanziario customerProfilofinanziarioDataRow = customerProfiloRischioRecordsDataSetS177.Profilofinanziario.NewRow(); customerProfilofinanziarioDataRow["Descrizione"] = "Profilo finanziario"; customerProfilofinanziarioDataRow["Valore"] = string.Format("{0} - {1}: {2}", customerProfiloRischioDataTable.Rows[0]["codiceProfilo"].ToString(), customerProfiloRischioDataTable.Rows[0]["nomeProfilo"].ToString(), customerProfiloRischioDataTable.Rows[0]["DescrizioneProfilo"].ToString()); customerProfiloRischioRecordsDataSetS177.Profilofinanziario.Rows.Add(customerProfilofinanziarioDataRow); #endregion #region Creazione righe datatable profilorischio string vara = SoglieVar.ConvOld(customerProfiloRischioDataTable.Rows[0]["varMassimo"]); if (dataThread.IsProffesionalClient && dataThread.RiskArea == 5) vara = "50,00"; //checked // VaR Massimo customerProfiloRischioDataRow = customerProfiloRischioRecordsDataSetS177.ProfiloRischio.NewRow(); customerProfiloRischioDataRow["Descrizione"] = "Rischio Mercato (VaR) massimo"; customerProfiloRischioDataRow["Valore"] = vara; customerProfiloRischioRecordsDataSetS177.ProfiloRischio.Rows.Add(customerProfiloRischioDataRow); // Rischo Credito Massimo customerProfiloRischioDataRow = customerProfiloRischioRecordsDataSetS177.ProfiloRischio.NewRow(); customerProfiloRischioDataRow["Descrizione"] = "Rischio Credito massimo"; customerProfiloRischioDataRow["Valore"] = UtilityBusinessLayer.GetRiskCreditClassName(customerProfiloRischioDataTable.Rows[0]["RiskClass"].ToString()); customerProfiloRischioRecordsDataSetS177.ProfiloRischio.Rows.Add(customerProfiloRischioDataRow); // Experince customerProfiloRischioDataRow = customerProfiloRischioRecordsDataSetS177.ProfiloRischio.NewRow(); customerProfiloRischioDataRow["Descrizione"] = "Experince"; customerProfiloRischioDataRow["Valore"] = customerProfiloRischioDataTable.Rows[0]["Experince"].ToString(); customerProfiloRischioRecordsDataSetS177.ProfiloRischio.Rows.Add(customerProfiloRischioDataRow); // MIFID2 20180706 // Descrizione grado esperienza customerProfiloRischioDataRow = customerProfiloRischioRecordsDataSetS177.ProfiloRischio.NewRow(); customerProfiloRischioDataRow["Descrizione"] = "Livello di esperienza e conoscenza in materia di investimenti"; customerProfiloRischioDataRow["Valore"] = customerProfiloRischioDataTable.Rows[0]["descrizioneEsperienza"].ToString(); customerProfiloRischioRecordsDataSetS177.ProfiloRischio.Rows.Add(customerProfiloRischioDataRow); //--MIFID2 20180405 #endregion #region Creazione righe Indicatori Riserva e Investimento lungo periodo //string queryAdeguatezza = @"[C6MartPeriodico].PL_D_S177ProfiloDiRischio_Adeguatezza"; //Questa Stored ci deve stare per forza string queryTabSessione = tabelleSessione.Where(c => c.Chiave.Contains("PL_D_FD177ProfiloDiRischio_Adeguatezza")).Select(d => d.Chiave).First().ToString(); string queryAdeguatezza = queryTabSessione.Split('|')[0]; DataTable dataLungoPeriodo = SectionManager.GetDataSection(tabelleSessione, queryAdeguatezza, dataThread); var IndicatoriAdeguatezza = new DataTable("Adeguatezza"); IndicatoriAdeguatezza.Columns.Add(new DataColumn("Descrizione", typeof(string))); IndicatoriAdeguatezza.Columns.Add(new DataColumn("Valore", typeof(string))); IndicatoriAdeguatezza.Columns.Add(new DataColumn("Descrizione1", typeof(string))); IndicatoriAdeguatezza.Columns.Add(new DataColumn("Valore1", typeof(string))); customerRiservaInvestimentoLungoPeriodoRow = IndicatoriAdeguatezza.NewRow(); customerRiservaInvestimentoLungoPeriodoRow["Descrizione"] = "Riserva"; //customerRiservaInvestimentoLungoPeriodoRow["Valore"] = $"{dataLungoPeriodo.Rows[0]["riserva"]}€"; customerRiservaInvestimentoLungoPeriodoRow["Valore"] = $"{Convert.ToDecimal(dataLungoPeriodo.Rows[0]["riserva"].ToString()).ToString("#,##0.00")}€"; customerRiservaInvestimentoLungoPeriodoRow["Descrizione1"] = "Investimento lungo periodo"; customerRiservaInvestimentoLungoPeriodoRow["Valore1"] = $"{dataLungoPeriodo.Rows[0]["investimento_l_periodo"]}%"; IndicatoriAdeguatezza.Rows.Add(customerRiservaInvestimentoLungoPeriodoRow); customerProfiloRischioRecordsDataSetS177.Tables.Add(IndicatoriAdeguatezza); #endregion #region Creazione righe datatable ProfiloDate // Data Ultimo Aggiornamento customerProfiloDateDataRow = customerProfiloRischioRecordsDataSetS177.ProfiloDate.NewRow(); // FC 09062015 // Aggiornamneto Label Descrizione //New Label Da inserire : customerProfiloDateDataRow["Descrizione"] = "Data di inizio validità del profilo"; //customerProfiloDateDataRow["Descrizione"] = "Ultimo aggiornamento questionario"; customerProfiloDateDataRow["Valore"] = string.IsNullOrEmpty(customerProfiloRischioDataTable.Rows[0]["dataInizioValidita"].ToString()) ? "-" : customerProfiloRischioDataTable.Rows[0]["dataInizioValidita"].ToString(); //customerProfiloRischioRecordsDataSetS177.ProfiloDate.Rows.Add(customerProfiloDateDataRow); //customerProfiloDateDataRow = customerProfiloRischioRecordsDataSetS177.ProfiloDate.NewRow(); customerProfiloDateDataRow["Descrizione1"] = "Data di scadenza del profilo"; customerProfiloDateDataRow["Valore1"] = string.IsNullOrEmpty(customerProfiloRischioDataTable.Rows[0]["dataScadenzaProfilo"].ToString()) ? "-" : customerProfiloRischioDataTable.Rows[0]["dataScadenzaProfilo"].ToString(); customerProfiloRischioRecordsDataSetS177.ProfiloDate.Rows.Add(customerProfiloDateDataRow); #endregion #region RISORSE FINANZIARIE decimal PatrimonioBancaFideuramCTV_netto = dataThread.PatrimonioBancaFideuramCtvAlNettoContoCorrente; CTVDataRow = customerProfiloRischioRecordsDataSetS177.Dati.NewRow(); CTVDataRow["Descrizione"] = "Risorse finanziarie"; risorseFinanziarie = PatrimonioBancaFideuramCTV_netto; CTVDataRow["Controvalore"] = formatnum.ConvertNum(PatrimonioBancaFideuramCTV_netto) + " €"; customerProfiloRischioRecordsDataSetS177.Dati.Rows.Add(CTVDataRow); #endregion #region CONTO CORRENTE CTVDataRow = customerProfiloRischioRecordsDataSetS177.Dati.NewRow(); //CTVDataRow["Descrizione"] = "Conto corrente"; CTVDataRow["Descrizione"] = "C/C a saldo negativo"; CC = dataThread.ContoCorrente; CTVDataRow["Controvalore"] = formatnum.ConvertNum(CC) + " €"; if (CC != 0) customerProfiloRischioRecordsDataSetS177.Dati.Rows.Add(CTVDataRow); #endregion #region INVESTIMENTI IN CORSO CTVDataRow = customerProfiloRischioRecordsDataSetS177.Dati.NewDatiRow(); CTVDataRow["Descrizione"] = Resource.PartiteViaggianti; investimentiInCorso = dataThread.PartiteViaggiantiInvestimento + dataThread.PartiteViaggiantiDisinvestimento; CTVDataRow["Controvalore"] = formatnum.ConvertNum(investimentiInCorso) + " €"; if (totalePartiteViaggianti != 0) customerProfiloRischioRecordsDataSetS177.Dati.Rows.Add(CTVDataRow); #endregion #region TOTALE PATRIMONIO CTVTotali = customerProfiloRischioRecordsDataSetS177.Totali.NewRow(); CTVTotali["Descrizione"] = "Totale patrimonio"; decimal totale = risorseFinanziarie + CC + investimentiInCorso; CTVTotali["Controvalore"] = formatnum.ConvertNum(totale) + " €"; customerProfiloRischioRecordsDataSetS177.Totali.Rows.Add(CTVTotali); #endregion } customerProfiloRischioDataSectionResult.DatiSezione = customerProfiloRischioRecordsDataSetS177; customerProfiloRischioDataSectionResult.Esito = customerProfiloRischioRecordsDataSetS177.ProfiloRischio.Rows.Count; return customerProfiloRischioDataSectionResult; } catch (Exception ex) { try { logger.Error(String.Concat(this.ToString()," ",ex.Message, " ", dataThread.CodiceFiscale)); } catch { } throw ex; } } #endregion } }