117 lines
4.6 KiB
C#
117 lines
4.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Consulenza.ReportWriter.Business.OBJ_PDF;
|
|
using System.Data;
|
|
using Consulenza.ReportWriter.Business;
|
|
|
|
namespace Consulenza.ReportWriter.Manager.Section.Base.Proposta
|
|
{
|
|
public class P1 : Entity.Section
|
|
{
|
|
|
|
public P1(EnvironmentFacade environmentFacade, int idSection)
|
|
: base(environmentFacade, idSection)
|
|
{
|
|
try
|
|
{
|
|
Draw();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SectionLogger.Write("P1", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Disegna l'oggetto P1
|
|
/// </summary>
|
|
protected override sealed void Draw()
|
|
{
|
|
var dtP1 = GetDataTable();
|
|
decimal controvaloreTotale = 0;
|
|
|
|
if (dtP1.Rows.Count > 0)
|
|
{
|
|
var controvaloreAggiuntivo = Convert.ToDecimal(dtP1.Compute("Sum(Ctv)", "classeOrdine<3"));
|
|
var controvaloreInDetrazione = Convert.ToDecimal(dtP1.Compute("Sum(Ctv)", "classeOrdine=3"));
|
|
controvaloreTotale = controvaloreAggiuntivo - controvaloreInDetrazione;
|
|
|
|
|
|
#region Disegno della tabella P1
|
|
|
|
#region Dettaglio
|
|
|
|
var tabella = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dtP1) { ID = "P1" };
|
|
tabella.Columns.Add(new ColumnPDF("TipologiaOperazione", 150, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Descrizione", "Tipologia operazione"));
|
|
tabella.Columns.Add(new ColumnPDF("Immagine", 150, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Immagine, string.Empty, string.Empty));
|
|
tabella.Columns.Add(new ColumnPDF("Controvalore", 223, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Decimale, "Ctv", "Controvalore (€)"));
|
|
tabella.Columns[1].ScaleColumnTypeImage = 0.14F;
|
|
tabella.Columns[1].DeltaYContent = 5;
|
|
|
|
tabella.Cells[1, 0].Value = "proposta.P1.immagineA.gif";
|
|
tabella.Cells[1, 1].Value = "proposta.P1.immagineB.gif";
|
|
tabella.Cells[1, 2].Value = "proposta.P1.immagineC.gif";
|
|
|
|
#endregion
|
|
|
|
#region Footer
|
|
|
|
tabella.FooterColumns.Add(new ColumnPDF("SaldoOperazioni", 150, HorizontalAlignmentType.Sinistra, false, true, 8, ColumnType.Testo));
|
|
tabella.FooterColumns.Add(new ColumnPDF("Immagine", 150, HorizontalAlignmentType.Sinistra, false, true, 8, ColumnType.Immagine, string.Empty, string.Empty));
|
|
tabella.FooterColumns.Add(new ColumnPDF("Controvalore", 223, HorizontalAlignmentType.Destra, false, true, 8, ColumnType.Testo));
|
|
tabella.FooterColumns[1].ScaleColumnTypeImage = 0.14F;
|
|
|
|
|
|
|
|
tabella.FooterCells[0, 0].Value = "Saldo operazioni";
|
|
tabella.FooterCells[1, 0].Value = "proposta.P1.immagineApBmC.gif";
|
|
|
|
tabella.FooterCells[2, 0].Value = controvaloreTotale > 0 ?
|
|
string.Format("+{0}", string.Format("{0:N}", controvaloreTotale)) :
|
|
string.Format("{0:N}", controvaloreTotale);
|
|
|
|
#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()
|
|
{
|
|
var parametri = new List<Parametro>();
|
|
|
|
#region Definizione dei parametri
|
|
|
|
var 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.ExecuteDataTableStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_Prop_P1", parametri)
|
|
: DataAccess.ExecuteDataTableStoredProcedure(DBProvider.SqlServerConsulenzaBase, "REP_Prop_P1", parametri);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recupera i dati necessari alla Section restituendo un DataSet.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected sealed override DataSet GetDataSet()
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|