2025-06-03 15:11:16 +02:00

291 lines
12 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using ceTe.DynamicPDF;
using ceTe.DynamicPDF.Merger;
using ceTe.DynamicPDF.PageElements;
using ceTe.DynamicPDF.Text;
using PDFGenerator.BusinessLayer;
using PDFGenerator.Presentation.Section.Tables;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using NLog;
namespace PDFGenerator.Presentation.Section
{
public class S186 : ISezione
{
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
private string _testointroduttivo;
ImportedPage page;
/// <summary>
/// Testo introduttivo della sezione.
/// </summary>
public string TestoIntroduttivo
{
get
{
return _testointroduttivo;
}
set
{
_testointroduttivo = value;
}
}
public S186()
{
//
// TODO: Add constructor logic here
//
}
#region ISezione Members
public void writeSezione(DataThread dataThread)
{
dataThread.SETDATA();
logger.Info("Inizio sezione S186 metodo writeSezione " + dataThread.CodiceFiscale);
DocumentPDF document = dataThread.DocumentPDF;
DataSet set = dataThread.Data.DatiSezione;
DatiTabella datitab = new DatiTabella();
Tabella tab = new Tabella();
float ytabella = 0; // unico incremento per la y di tutte le tabelle.
datitab.table = set.Tables["DettaglioPortafoglioSEI"];
#region Testo introduttivo Sezione S186
// Titolo della sezione
logger.Info("Testo della sezione S186" + _testointroduttivo);
if (dataThread.Rete == "W")
_testointroduttivo = _testointroduttivo.Replace("$/Banca/$", "la Società");
else
_testointroduttivo = _testointroduttivo.Replace("$/Banca/$", "la Banca");
document.setLastPos(-40);
//document.setChapterHeader(dataThread.SezioneReport.TestoIntroduttivo, 0, 520, 8);
document.setChapterHeader(_testointroduttivo, 0, 520, 8);
#endregion
#region Tabella dei Totali
DataTable dtTotali = GetTotalis(set.Tables["DettaglioPortafoglioSEI"], dataThread);
DatiTabella datitabPF = new DatiTabella();
datitabPF.table = dtTotali;
DataTable dtTotaleDettaglio = GetTotalisDettaglio(set.Tables["DettaglioPortafoglioSEI"]);
datitabPF.setY(document.getLastPos() + 10);
datitabPF.setX(document.getMargineLeft());
if (dataThread.Rete == "W")
{
datitabPF.setCell(220, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, true);
datitabPF.setCell(90, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdanaB, false);
}
else
{
datitabPF.setCell(190, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, true);
//datitabPF.setCell(90, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdanaB, true);
datitabPF.setCell(130, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdanaB, false);
}
document.InsertTable(tab.getTabella(datitabPF));
#endregion
#region Tabella di Dettaglio
string label = "Dettaglio dei prodotti finanziari/servizi di investimento/conti correnti/depositi titoli esclusi dal Portafoglio Sei";
bool notaSezioneStampata = false;
int m = (int)((float)label.Length / 135) + 2;
FormattedTextArea text = new FormattedTextArea(label, document.getMargineLeft() - 5, document.getLastPos() + 70, 500, m, new FontFamily("pipp", Globals.OpenTypeFontVerdanaB, Globals.OpenTypeFontVerdanaB, Globals.OpenTypeFontVerdanaZ, Globals.OpenTypeFontVerdanaZ), 8, false);
text.Height = text.GetRequiredHeight();
text.Style.Paragraph.Align = ceTe.DynamicPDF.TextAlign.Justify;
ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
page.Elements.Add(text);
// Disegno la tabella
Tabella tabellaDettaglio = new Tabella(document.getMargineLeft(), document.getLastPos() + 100);
tabellaDettaglio.HeaderFont = 8;
tabellaDettaglio.Header = true;
tabellaDettaglio.Datasource = datitab.table;
tabellaDettaglio.Id = "tabella_Dettaglio";
tabellaDettaglio.LineaFineTabella = true;
tabellaDettaglio.SezioneDiProvenienza = "S186";
int righeDettaglio = datitab.table.Rows.Count;
tabellaDettaglio.Colonne.Add(new Colonna("DataSottoscrizione", "Data sott.", 50, TipoAllineamento.SINISTRA, false, 7, false));
tabellaDettaglio.Colonne.Add(new Colonna("<IMAGE>", " ", 1, TipoAllineamento.DESTRA, false, 7, false, TipoColonna.IMMAGINE));
tabellaDettaglio.Colonne.Add(new Colonna("ContrattoDossier", "Contratto/Dossier ", 120, TipoAllineamento.SINISTRA, false, 7, false, TipoColonna.IMMAGINE));
tabellaDettaglio.Colonne.Add(new Colonna("Descrizione", "Descrizione", 257, TipoAllineamento.SINISTRA, false, 7, false));
tabellaDettaglio.Colonne.Add(new Colonna("Controvalore", "Controvalore (€)*", 90, TipoAllineamento.DESTRA, false, 7, false));
tabellaDettaglio.DrawMonitoraggio(datitab, document, "", true, ref notaSezioneStampata);
#endregion
#region Tabella Totale Del Dettaglio
datitab = new DatiTabella();
datitab.table = dtTotaleDettaglio;
//if (tabellaDettaglio.SaltoPaginaEffettuato)
// ytabella = tabellaDettaglio.AltezzaCella;
ytabella += tabellaDettaglio.AltezzaTabella;
// TABELLA DEI TOTALI.
float yTabellaTotali;
if (tabellaDettaglio.SaltoPaginaEffettuato)
yTabellaTotali = document.getLastPos() + tabellaDettaglio.AltezzaTabella + tabellaDettaglio.AltezzaCella + 2; //tabellaDettaglio.AltezzaTabella;
else
{
if (set.Tables["DettaglioPortafoglioSEI"].Rows.Count <= 17)
yTabellaTotali = document.getLastPos() + 100 + tabellaDettaglio.AltezzaTabella + (tabellaDettaglio.AltezzaCella + tabellaDettaglio.DimensioneLinea);
else
yTabellaTotali = document.getLastPos() + ytabella + tabellaDettaglio.AltezzaCella; // ytabella + (tabellaDettaglio.AltezzaCella * set.Tables["DettaglioPortafoglioSEI"].Rows.Count);
}
//yTabellaTotali = ytabella + (tabellaDettaglio.AltezzaCella * set.Tables["DettaglioPortafoglioSEI"].Rows.Count);
//if (tabellaDettaglio.SaltoPaginaEffettuato)
// yTabellaTotali += 25;
//Tabella tabTotali = new Tabella(document.getMargineLeft(), document.getLastPos() + yTabellaTotali + tabellaDettaglio.AltezzaCella);
Tabella tabTotali = new Tabella(document.getMargineLeft(), yTabellaTotali);
tabTotali.HeaderFont = 8;
tabTotali.Header = false;
tabTotali.SaltoPagina = false;
tabTotali.Colonne.Add(new Colonna("Descrizione", string.Empty, 373, TipoAllineamento.SINISTRA, true, 8, true));
tabTotali.Colonne.Add(new Colonna("Valore", string.Empty, 145, TipoAllineamento.DESTRA, true, 8, true));
/// disegna la tabella dei totali.
///////////////////////////////////////////////////
// Campione Simulazione Trimestrale Giugno 2024 PS 23/07/2024
///////////////////////////////////////////////////
/// INSERIMENTO NOTA : (**) Il controvalore esclude il saldo negativo dei conti correnti ( [valore negativo] € )
/// la inserisco come una label
// SE ESISTE LA RIGA NEGATIVA ALLORA INSERISCO LA NOTA:
//string notaValoreNegativo = "";
string notaTabella = "";
S148 temp = new S148();
float dim = document.getLastPos() + ytabella + tabTotali.AltezzaCella - 90;
notaTabella = temp.addNota1(document, (int)dim, dataThread, 2, false);
//notaValoreNegativo = "(**) Il controvalore esclude il saldo negativo dei conti correnti (" + ValNegativo.ToString("N2") + " € )";
//tabTotali.NotaTabella.Add(notaValoreNegativo)
//writeSezione_NotaTabella(document, notaValoreNegativo,);
tabTotali.Draw(datitab, document);
//tabellaDettaglio.DrawMonitoraggio(datitab, document, "", true, ref notaSezioneStampata);
#endregion
#region Nota
addNota(document, notaTabella);
#endregion
logger.Info("Fine sezione S186 metodo writeSezione " + dataThread.CodiceFiscale);
}
/// <summary>
/// Restituisce il valore negativo se c'è (totali prodotti esclusivi)
/// </summary>
/// <returns></returns>
// Campione Simulazione Trimestrale Giugno 2024 PS 23/07/2024
private DataTable GetTotalis(DataTable _dt, DataThread dataThread)
{
List<Totali> _listaTotali = new List<Totali>();
// PatrimonioFideuram
var itemPatrimonioFideuram = _dt.AsEnumerable().Select(s => s.Field<string>("PatrimonioFideuram")).First();
//_listaTotali.Add(new Totali()
//{
// Descrizione = "Patrimonio Fideuram (€)",
// Valore = itemPatrimonioFideuram
//});
_listaTotali.Add(new Totali()
{
Descrizione = dataThread.Rete == "F" ? "Patrimonio Fideuram (€)" : (dataThread.Rete == "S" ? "Patrimonio Sanpaolo Invest (€)" : "Patrimonio IW Private Investments (€)"),
Valore = itemPatrimonioFideuram
});
// Portafoglio SEI
var itemPortafoglioSEI = _dt.AsEnumerable().Select(s => s.Field<string>("PortafoglioSei")).First();
_listaTotali.Add(new Totali()
{
Descrizione = "Portafoglio Sei (€)",
Valore = itemPortafoglioSEI
});
/////////////////////////////////////////////////////////
// Campione Simulazione Trimestrale Giugno 2024 PS se cè un valore negativo inserire doppi asterischi PS 23/07/2024
{
foreach (Totali Desc in _listaTotali)
{
Desc.Descrizione = Desc.Descrizione + " **";
}
}
/////////////////////////////////////////////////////////
// Converto la lista in DataTable
DataTable _dtTotali = UtilityBusinessLayer.ToDataTable<Totali>(_listaTotali);
return _dtTotali;
}
private DataTable GetTotalisDettaglio(DataTable _dt)
{
List<Totali> _listaTotalDettaglio = new List<Totali>();
// PatrimonioFideuram
var itemPatrimonioFideuram = _dt.AsEnumerable().Select(s => s.Field<string>("SommaProdottiEsclusi")).First();
_listaTotalDettaglio.Add(new Totali()
{
// Campione Simulazione Trimestrale Giugno 2024 PS se cè un valore negativo inserire doppi asterischi PS 23/07/2024
Descrizione = "TOTALE PRODOTTI ESCLUSI DAL PORTAFOGLIO SEI **",
Valore = itemPatrimonioFideuram
});
// Converto la lista in DataTable
DataTable _dtTotali = UtilityBusinessLayer.ToDataTable<Totali>(_listaTotalDettaglio);
_dtTotali.TableName = "TotaleDettaglio";
return _dtTotali;
}
private void addNota(DocumentPDF doc, string notaTabella = "")
{
FormatNum con = new FormatNum();
string nota = "(*) Linformazione relativa al Controvalore fa riferimento alla data di consolidamento(per i Conti Correnti al saldo contabile).Per alcuni prodotti la valorizzazione del Controvalore può risultare non perfettamente allineata alle rendicontazioni effettuate da SGR / Compagnie Assicurative, in seguito a differenti modalità di consolidamento dati.";
if (notaTabella != null) { nota = nota + "<br>" + notaTabella; }
doc.setNotaPieDiPagina(nota);
}
#endregion
}
public class Totali
{
public string Descrizione { get; set; }
public string Valore { get; set; }
}
//public class TotaleDettaglio
//{
// public string Descrizione { get; set; }
// public string Valore { get; set; }
//}
}