292 lines
15 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 System;
using System.Collections.Generic;
using Consulenza.ReportWriter.Business;
using Consulenza.ReportWriter.Business.OBJ_PDF;
using System.Data;
using Consulenza.ReportWriter.Business.Entity;
namespace Consulenza.ReportWriter.Manager.Section.Base.Proposta
{
public class P14 : Entity.Section
{
/// <summary>
/// Implementazione dell'oggetto P14. Fondi Pensione.
/// </summary>
/// <param name="environmentFacade"></param>
/// <param name="idSection"></param>
public P14(EnvironmentFacade environmentFacade, int idSection)
: base(environmentFacade, idSection)
{
try
{
Draw();
}
catch (Exception ex)
{
SectionLogger.Write("P14", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
}
}
/// <summary>
/// Disegna l'oggetto P14.
/// </summary>
protected override sealed void Draw()
{
var dsP14 = GetDataSet();
DataTable dtTabellaRiepilogo = dsP14.Tables[0];
DataTable dtTabellaDati = dsP14.Tables[1];
if (dtTabellaDati.Rows.Count <= 0) return;
#region Lista oggetti per Riepilogo (subtitle della tabella)
var sValore = string.Empty;
var listaObj = new List<ObjectPDF>();
#region etichetta1
var etichetta1 = new FormattedTextAreaPDF("Adesione con trasferimento da altra forma pensionistica:", EnvironmentFacade.RendererFacade.XLeftLimit, 250) { FontBold = true, AutoIncrementYWritable = false };
sValore = dtTabellaRiepilogo.Rows[0]["altraformapensionistica"] == DBNull.Value ? "No" : Convert.ToBoolean(dtTabellaRiepilogo.Rows[0]["altraformapensionistica"]) ? "Si" : "No";
var etichetta1_1 = new FormattedTextAreaPDF(sValore, 255, 50);
#endregion
#region etichetta2
var etichetta2 = new FormattedTextAreaPDF("Contributi programmati per la prestazione principale", EnvironmentFacade.RendererFacade.XLeftLimit, 512) { FontBold = true };
#endregion
#region etichetta3
var etichetta3 = new FormattedTextAreaPDF("Contributo dell'Aderente:", EnvironmentFacade.RendererFacade.XLeftLimit, 130) { FontBold = true, AutoIncrementYWritable = false, FontSize = 7.5F };
sValore = dtTabellaRiepilogo.Rows[0]["contributoaderente"] == DBNull.Value ? "non previsto" : Convert.ToBoolean(dtTabellaRiepilogo.Rows[0]["contributoaderente"]) == false ? "non previsto" : string.Empty;
if (sValore == string.Empty)
{
if (dtTabellaRiepilogo.Rows[0]["caimportoannuo"] != DBNull.Value)
{
sValore = string.Format("{0} Euro con rateazione {1}", Convert.ToDecimal(dtTabellaRiepilogo.Rows[0]["caimportoannuo"]).ToString("C"), DecodificaRateazione(dtTabellaRiepilogo.Rows[0]["carateazione"].ToString())); //"x.xxx,xx Euro con rateazione tipo rateazione";
}
else
{
if (dtTabellaRiepilogo.Rows[0]["caperctfr"] != DBNull.Value)
{
sValore = string.Format("{0}% della retribuzione assunta per il calcolo del TFR con rateazione {1}", Convert.ToDecimal(dtTabellaRiepilogo.Rows[0]["caperctfr"]), DecodificaRateazione(dtTabellaRiepilogo.Rows[0]["carateazione"].ToString())); // "xxx,xx% della retribuzione assunta per il calcolo del TFR con rateazione tipo ratezione";
}
else
{
if (dtTabellaRiepilogo.Rows[0]["capercirpef"] != DBNull.Value)
{
sValore = string.Format("{0}% del reddito di impresa o di lavoro autonomo dichiarato a fini IRPEF con rateazione {1}", Convert.ToDecimal(dtTabellaRiepilogo.Rows[0]["capercirpef"]), DecodificaRateazione(dtTabellaRiepilogo.Rows[0]["carateazione"].ToString())); // "xxx,xx% del reddito di impresa o di lavoro autonomo dichiarato a fini IRPEF con rateazione tipo rateazione";
}
}
}
}
var etichetta3_1 = new FormattedTextAreaPDF(sValore, 130, 500) { FontSize = 7.5F };
#endregion
#region etichetta4
var etichetta4 = new FormattedTextAreaPDF("Contributo del Datore di Lavoro:", EnvironmentFacade.RendererFacade.XLeftLimit, 155) { FontBold = true, AutoIncrementYWritable = false, FontSize = 7.5F };
sValore = dtTabellaRiepilogo.Rows[0]["contributodatore"] == DBNull.Value ? "non previsto" : Convert.ToBoolean(dtTabellaRiepilogo.Rows[0]["contributodatore"]) == false ? "non previsto" : string.Empty;
if (sValore == string.Empty)
{
if (dtTabellaRiepilogo.Rows[0]["cdimportoannuo"] != DBNull.Value)
{
sValore = string.Format("{0} Euro con rateazione {1}", Convert.ToDecimal(dtTabellaRiepilogo.Rows[0]["cdimportoannuo"]).ToString("C"), DecodificaRateazione(dtTabellaRiepilogo.Rows[0]["cdrateazione"].ToString())); // “x.xxx,xx Euro con rateazione tipo rateazione”
}
else
{
if (dtTabellaRiepilogo.Rows[0]["cdperctfr"] != DBNull.Value)
{
sValore = string.Format("{0}% della retribuzione assunta per il calcolo del TFR con rateazione {1}", Convert.ToDecimal(dtTabellaRiepilogo.Rows[0]["cdperctfr"]), DecodificaRateazione(dtTabellaRiepilogo.Rows[0]["cdrateazione"].ToString())); // - “xxx,xx% della retribuzione assunta per il calcolo del TFR con rateazione tipo ratezione
}
}
}
var etichetta4_1 = new FormattedTextAreaPDF(sValore, 155, 500) { FontSize = 7.5F };
#endregion
#region etichetta5
var etichetta5 = new FormattedTextAreaPDF("Conferimento del TFR:", EnvironmentFacade.RendererFacade.XLeftLimit, 122) { FontBold = true, AutoIncrementYWritable = false, FontSize = 7.5F };
sValore = dtTabellaRiepilogo.Rows[0]["conferimentotfr"] == DBNull.Value ? "non previsto" : Convert.ToBoolean(dtTabellaRiepilogo.Rows[0]["conferimentotfr"]) == false ? "non previsto" : string.Empty;
if (sValore == string.Empty)
{
sValore = string.Format("{0}% del TFR con rateazione {1}", Convert.ToDecimal(dtTabellaRiepilogo.Rows[0]["ctperc"]), DecodificaRateazione(dtTabellaRiepilogo.Rows[0]["ctrateazione"].ToString())); // % del TFR
}
var etichetta5_1 = new FormattedTextAreaPDF(sValore, 122, 500) { FontSize = 7.5F };
#endregion
#region etichetta6
var etichetta6 = new FormattedTextAreaPDF("Contributi versati all'adesione (€)", EnvironmentFacade.RendererFacade.XLeftLimit, 512) { FontBold = true };
#endregion
#region etichetta7
var etichetta7 = new FormattedTextAreaPDF("Contributo dellAderente:", EnvironmentFacade.RendererFacade.XLeftLimit, 135) { FontBold = true, AutoIncrementYWritable = false, FontSize = 7.5F };
sValore = dtTabellaRiepilogo.Rows[0]["contributoaderenteimporto"] == DBNull.Value ? "0,00 €" : Convert.ToDecimal(dtTabellaRiepilogo.Rows[0]["contributoaderenteimporto"]).ToString("C");
var etichetta7_1 = new FormattedTextAreaPDF(sValore, 135, 150) { AutoIncrementYWritable = false, FontSize = 7.5F };
#endregion
#region etichetta8
var etichetta8 = new FormattedTextAreaPDF("Contributo aggiuntivo dellAderente:", 310, 150) { FontBold = true, AutoIncrementYWritable = false, FontSize = 7.5F };
sValore = dtTabellaRiepilogo.Rows[0]["contributoaggiuntivoaderenteimporto"] == DBNull.Value ? "0,00 €" : Convert.ToDecimal(dtTabellaRiepilogo.Rows[0]["contributoaggiuntivoaderenteimporto"]).ToString("C");
var etichetta8_1 = new FormattedTextAreaPDF(sValore, 445, 150) { FontSize = 7.5F };
#endregion
#region etichetta9
var etichetta9 = new FormattedTextAreaPDF("Destinazione dei versamenti al Fondo Pensione", EnvironmentFacade.RendererFacade.XLeftLimit, 250) { FontBold = true };
#endregion
listaObj.Add(new SpacePDF(10));
listaObj.Add(etichetta1);
listaObj.Add(etichetta1_1);
listaObj.Add(new SpacePDF(10));
listaObj.Add(etichetta2);
listaObj.Add(etichetta3);
listaObj.Add(etichetta3_1);
listaObj.Add(etichetta4);
listaObj.Add(etichetta4_1);
listaObj.Add(etichetta5);
listaObj.Add(etichetta5_1);
listaObj.Add(new SpacePDF(10));
listaObj.Add(etichetta6);
listaObj.Add(etichetta7);
listaObj.Add(etichetta7_1);
listaObj.Add(etichetta8);
listaObj.Add(etichetta8_1);
listaObj.Add(new SpacePDF(10));
listaObj.Add(etichetta9);
#endregion
var tabella = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dtTabellaDati)
{
ID = "Tabella_P14",
SubTitleElements = listaObj,
TitleRowSpace = 5,
TitleRow = true,
TitleRowText = "ADESIONE AL FONDO PENSIONE FIDEURAM"
};
tabella.Columns.Add(new ColumnPDF("nomeprodotto", 139, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "nomeprodotto", "Nome prodotto"));
tabella.Columns.Add(new ColumnPDF("percaderentedatore", 80, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Percentuale, "percaderentedatore", "Contr. Aderente /<BR>Datore (%)"));
tabella.Columns.Add(new ColumnPDF("contr_annuo_aderente_datore", 87, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Decimale, "contr_annuo_aderente_datore", "Contr. annuo<BR>Ader. / Dat. (€)"));
tabella.Columns.Add(new ColumnPDF("tfr", 50, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Percentuale, "tfr", "TFR (%)"));
tabella.Columns.Add(new ColumnPDF("altra_forma_pensionistica", 80, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Percentuale, "altra_forma_pensionistica", "Altra forma<BR>pension. (%)"));
tabella.Columns.Add(new ColumnPDF("contributi_versati_adesione", 87, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Decimale, "contributi_versati_adesione", "Contributi versati all'adesione (€)"));
// Footer
tabella.FooterColumns.Add(new ColumnPDF("Totale", 139, HorizontalAlignmentType.Sinistra, false, true, 8, ColumnType.Testo));
tabella.FooterColumns.Add(new ColumnPDF("TotaleContrAderente", 80, HorizontalAlignmentType.Destra, false, true, 8, ColumnType.Percentuale));
tabella.FooterColumns.Add(new ColumnPDF("TotaleContrAnnuo", 87, HorizontalAlignmentType.Destra, false, true, 8, ColumnType.Decimale));
tabella.FooterColumns.Add(new ColumnPDF("TotaleTFR", 50, HorizontalAlignmentType.Destra, false, true, 8, ColumnType.Percentuale));
tabella.FooterColumns.Add(new ColumnPDF("TotaleAltraForma", 80, HorizontalAlignmentType.Destra, false, true, 8, ColumnType.Percentuale));
tabella.FooterColumns.Add(new ColumnPDF("TotaleContrVersati", 87, HorizontalAlignmentType.Destra, false, true, 8, ColumnType.Decimale));
tabella.FooterCells[0, 0].Value = "Totale";
tabella.FooterCells[1, 0].Value = Convert.ToDecimal(dtTabellaDati.Compute("Sum(percaderentedatore)", string.Empty)).ToString();
tabella.FooterCells[2, 0].Value = Convert.ToDecimal(dtTabellaDati.Compute("Sum(contr_annuo_aderente_datore)", string.Empty)).ToString();
tabella.FooterCells[3, 0].Value = Convert.ToDecimal(dtTabellaDati.Compute("Sum(tfr)", string.Empty)).ToString();
tabella.FooterCells[4, 0].Value = Convert.ToDecimal(dtTabellaDati.Compute("Sum(altra_forma_pensionistica)", string.Empty)).ToString();
tabella.FooterCells[5, 0].Value = Convert.ToDecimal(dtTabellaDati.Compute("Sum(contributi_versati_adesione)", string.Empty)).ToString();
AddElement(tabella);
AddElement(new SpacePDF(20));
}
/// <summary>
/// Recupera i dati necessari alla Section restituendo un DataTable.
/// </summary>
/// <returns></returns>
protected sealed override DataTable GetDataTable()
{
return null;
}
/// <summary>
/// Recupera i dati necessari alla Section restituendo un DataSet.
/// </summary>
/// <returns></returns>
protected sealed override DataSet GetDataSet()
{
var parametri = new List<Parametro>();
#region Definizione dei parametri
var parametro = new Parametro
{
Direction = ParameterDirection.Input,
DbType = DbType.Int64,
ParameterName = "chiaveClientePB",
Value = EnvironmentFacade.ReportEnvironment.Cliente.Chiave
};
parametri.Add(parametro);
parametro = new Parametro
{
Direction = ParameterDirection.Input,
DbType = DbType.Int32,
ParameterName = "chiaveProposta",
Value = EnvironmentFacade.ReportEnvironment.Proposta.Chiave
};
parametri.Add(parametro);
#endregion
return EnvironmentFacade.ReportEnvironment.Proposta.PropostaCBUnica ? DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_Prop_P14", parametri)
: DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaBase, "REP_Prop_P14", parametri);
}
/// <summary>
/// Decodifica il codice di rateazione passsato in input
/// </summary>
/// <param name="codificarateazione"></param>
/// <returns></returns>
private string DecodificaRateazione(string codificarateazione)
{
switch (codificarateazione.Trim().ToUpper())
{
case "A":
return "annuale";
case "B":
return "bimestale";
case "M":
return "mensile";
case "Q":
return "quadrimestrale";
case "S":
return "semestrale";
case "T":
return "trimestrale";
default:
return string.Empty;
}
}
}
}