168 lines
8.4 KiB
C#
168 lines
8.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using Consulenza.ReportWriter.Business.OBJ_PDF;
|
|
using Consulenza.ReportCommon;
|
|
using Consulenza.ReportWriter.Business;
|
|
|
|
|
|
namespace Consulenza.ReportWriter.Manager.Section.Base.Proposta
|
|
{
|
|
public class P13_B : Entity.Section
|
|
{
|
|
/// <summary>
|
|
/// Implementazione dell'oggetto P13_B. Questo oggetto è verrà stampato per tutti i TipoOperazione = CV (Conversione) raggruppati per ChiaveContratto.
|
|
/// </summary>
|
|
/// <param name="environmentFacade"></param>
|
|
/// <param name="idSection"></param>
|
|
public P13_B(EnvironmentFacade environmentFacade, int idSection)
|
|
: base(environmentFacade, idSection)
|
|
{
|
|
try
|
|
{
|
|
Draw();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SectionLogger.Write("P13_B", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Disegna l'oggetto P13_B
|
|
/// </summary>
|
|
protected override sealed void Draw()
|
|
{
|
|
var dsP13 = GetDataSet();
|
|
|
|
// E' la lista di chiavi (TipoOperazione,ChiaveContratto ) per le quali filtrare la dtTabellaDati e ripetere la stampa di questo oggetto P13_B
|
|
DataTable dtListaChiaviTabellaRiepilogo = dsP13.Tables[0].DefaultView.ToTable(true, "TipoOperazione", "ChiaveContratto");
|
|
DataRow[] rowsListaChiaviTabellaRiepilogo = dtListaChiaviTabellaRiepilogo.Select("TipoOperazione='CV'");
|
|
|
|
foreach (DataRow rowListaChiaviTabellaRiepilogo in rowsListaChiaviTabellaRiepilogo)
|
|
{
|
|
DataTable dtTabellaRiepilogo = dsP13.Tables[0];
|
|
DataRow[] rowsTabellaRiepilogo = dtTabellaRiepilogo.Select("TipoOperazione='" + rowListaChiaviTabellaRiepilogo["TipoOperazione"] + "' AND chiaveContratto=" + rowListaChiaviTabellaRiepilogo["ChiaveContratto"]);
|
|
|
|
//DataTable dtTabellaDati = dsP13.Tables[1];
|
|
DataView viewTabellaDati = dsP13.Tables[1].DefaultView;
|
|
viewTabellaDati.RowFilter = "codTipoOperazione='" + rowListaChiaviTabellaRiepilogo["TipoOperazione"] + "' AND chiaveContratto=" + rowListaChiaviTabellaRiepilogo["ChiaveContratto"];
|
|
DataTable dtTabellaDati = viewTabellaDati.ToTable();
|
|
|
|
if (rowsTabellaRiepilogo.Length <= 0) continue;
|
|
if (dtTabellaDati.Rows.Count <= 0) continue;
|
|
|
|
#region Tabella Riepilogo
|
|
|
|
var tabellaSubtitle = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, 3, 2);
|
|
tabellaSubtitle.Columns.Add(new ColumnPDF("", 174, HorizontalAlignmentType.Sinistra, false, true, 8, ColumnType.Testo));
|
|
tabellaSubtitle.Columns.Add(new ColumnPDF("", 174, HorizontalAlignmentType.Sinistra, false, true, 8, ColumnType.Testo));
|
|
tabellaSubtitle.Columns.Add(new ColumnPDF("", 174, HorizontalAlignmentType.Sinistra, false, true, 8, ColumnType.Testo));
|
|
tabellaSubtitle.Header = false;
|
|
tabellaSubtitle.Footer = false;
|
|
tabellaSubtitle.AlternateRow = false;
|
|
tabellaSubtitle.ID = "tabellaSubtitle_P13_B";
|
|
|
|
tabellaSubtitle.Cells[0, 0].Value = "Frequenza switch: " + rowsTabellaRiepilogo[0]["FrequenzaSwitch"];
|
|
tabellaSubtitle.Cells[1, 0].Value = "Durata programma: " + rowsTabellaRiepilogo[0]["DurataProgramma"];
|
|
tabellaSubtitle.Cells[2, 0].Value = "Importo programma: " + Helper.FormatCurrency(rowsTabellaRiepilogo[0]["ImportoProgramma"].ToString());
|
|
|
|
tabellaSubtitle.Cells[0, 1].Value = "Investimento iniziale: " + rowsTabellaRiepilogo[0]["InvestimentoIniziale"];
|
|
tabellaSubtitle.Cells[0, 1].ColSpan = 3;
|
|
|
|
#endregion
|
|
|
|
#region Tabella Dati
|
|
|
|
decimal totaleControvaloreAttuale = Convert.ToDecimal(dtTabellaDati.Compute("Sum(ControvaloreAttuale)", string.Empty));
|
|
decimal totaleControvaloreProspettico = Convert.ToDecimal(dtTabellaDati.Compute("Sum(ControvaloreProspettico)", string.Empty));
|
|
|
|
var tabella = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dtTabellaDati)
|
|
{
|
|
ID = "Tabella_P13_B",
|
|
SubTitleTable = tabellaSubtitle,
|
|
TitleRowSpace = 5,
|
|
TitleRow = true,
|
|
TitleRowText = rowsTabellaRiepilogo[0]["CodInterno"].ToString().Equals("KE")
|
|
? "ATTIVAZIONE DEL PROGRAMMA PERIODICO DI INVESTIMENTO SU IN PERSONA"
|
|
: "ATTIVAZIONE DEL PROGRAMMA PERIODICO DI INVESTIMENTO SU IN PRIMA PERSONA"
|
|
};
|
|
|
|
// Per TipoOperazione='CV' saranno possibili solo CodInterno = KE o KS
|
|
|
|
|
|
tabella.Columns.Add(new ColumnPDF("NomeProdotto", 223, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "NomeProdotto", "Nome prodotto"));
|
|
tabella.Columns.Add(new ColumnPDF("ControvaloreAttuale", 150, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Decimale, "ControvaloreAttuale", "Controvalore attuale (€)"));
|
|
tabella.Columns.Add(new ColumnPDF("ControvaloreProspettico", 150, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Decimale, "ControvaloreProspettico", "Controvalore prospettico (€)"));
|
|
|
|
|
|
// Footer
|
|
tabella.FooterColumns.Add(new ColumnPDF("Totale", 223, HorizontalAlignmentType.Sinistra, false, true, 8, ColumnType.Testo));
|
|
tabella.FooterColumns.Add(new ColumnPDF("TotaleControvaloreAttuale", 150, HorizontalAlignmentType.Destra, false, true, 8, ColumnType.Decimale));
|
|
tabella.FooterColumns.Add(new ColumnPDF("TotaleControvaloreProspettico", 150, HorizontalAlignmentType.Destra, false, true, 8, ColumnType.Decimale));
|
|
|
|
tabella.FooterCells[0, 0].Value = "Totale";
|
|
tabella.FooterCells[1, 0].Value = totaleControvaloreAttuale.ToString();
|
|
tabella.FooterCells[2, 0].Value = totaleControvaloreProspettico.ToString();
|
|
|
|
#region Nota PremiVersati (header della tabella)
|
|
|
|
//string[] campiAsterisco = new string[1] { "ControvaloreProspettico" }; // campi del datasource su cui aggiungere gli asterischi di rimando alla note.
|
|
|
|
//TableNotePDF notaPremiVersati = new TableNotePDF(TableNotePDF.TipologiaPosizionamento.PièDiTabella, "Totale dei premi versati in fase di sottoscrizione (prima rata + premio unico aggiuntivo)", campiAsterisco, string.Empty, TableNotePDF.TipologiaPosizionamentoAsterisco.IntestazioneTabella);
|
|
//tabella.Notes.Add(notaPremiVersati);
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
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_P13", parametri)
|
|
: DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaBase, "REP_Prop_P13", parametri);
|
|
}
|
|
}
|
|
}
|