using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using ceTe.DynamicPDF.Text;
using ceTe.DynamicPDF;
using PDFGenerator.Presentation.Section;
using PDFGenerator;
using PDFGenerator.Presentation.Section.Tables;
using PDFGenerator.Presentation.Section.Charts;
using PDFGenerator.BusinessLayer;
using PDFGenerator.BusinessLayer.DataSection;
///
/// Summary description for S57BIS
///
///
public class S57BIS : ISezione
{
string Titolo = string.Empty;
string _testotitolo;
string _testointroduttivo;
///
/// Testo introduttivo della sezione.
///
public string TestoIntroduttivo
{
get
{
return _testointroduttivo;
}
set
{
_testointroduttivo = value;
}
}
///
/// Testo del titolo della sezione.
///
public string TestoTitolo
{
get
{
return _testotitolo;
}
set
{
_testotitolo = value;
}
}
public void setTitolo(string label)
{
Titolo = label;
}
public S57BIS()
{
//
// TODO: Add constructor logic here
//
}
public void writeSezione(DataThread dataThread)
{
DocumentPDF document = dataThread.DocumentPDF;
DatiTabella datitab = new DatiTabella();
DataSetS57BIS set = (DataSetS57BIS)dataThread.Data.DatiSezione;
bool _mostracolonnacopertura = false;
#region Resulset- Verifica disegno colonna "copertura"
datitab.table = set.Tables["ResultSet"];
_mostracolonnacopertura = Convert.ToBoolean(datitab.table.Rows[0][0]);
#endregion
//calcola se entra nella pagina altrimenti aggiunge una nuova pagina. In questa sezione il # di righe è fissato
//devo considerare lo spazio dell'header- ora lo aggiungo manualmente
if (document.checkMargin(300))
document.addPage();
ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
//aggiorna l'indice, titolo e header sezione
if (dataThread.TipoReport.ToUpper() == "DIAGNOSI")
document.setSezTitoloDiagnosi(_testotitolo);
else
document.setSezTitolo(_testotitolo);
document.setSezHeader(_testointroduttivo);
#region Piramide
//disegno la parte della piramide
Piramide modello = new Piramide();
modello.writeSezione(document);
#endregion
#region Tabella a destra della piramide
// disegno la tabella a destra della piramide.
#region datasource tabella
//setta la datatable
datitab.table = set.Tables["GraficoPiramide"];
DataView view = new DataView(datitab.table);
view.RowFilter = "";
datitab.table = view.ToTable(false, "Controvalore", "Rischio", "Copertura");
#endregion
Tabella tabella = new Tabella();
if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tabella.HeaderFont = 8;
tabella.LineeTabella = false;
tabella.Y = document.getLastPos();
tabella.X = 210;
tabella.Header = true;
tabella.SaltoPagina = false;
tabella.Datasource = datitab.table;
tabella.AltezzaCella = 30;
if (_mostracolonnacopertura)
{
//
tabella.Colonne.Add(new Colonna("Controvalore", "Controvalore (€)", 70, TipoAllineamento.DESTRA, false, 8, false));
tabella.Colonne.Add(new Colonna("Rischio", "Rischio
(VaR %)", 50, TipoAllineamento.DESTRA, false, 8, false));
tabella.Colonne.Add(new Colonna("Copertura", "Copertura
(%)", 60, TipoAllineamento.DESTRA, false, 8, false));
}
else
{
tabella.Colonne.Add(new Colonna("Controvalore", "Controvalore (€)", 100, TipoAllineamento.DESTRA, false, 8, false));
tabella.Colonne.Add(new Colonna("Rischio", "Rischio
(VaR %)", 80, TipoAllineamento.DESTRA, false, 8, false));
}
tabella.Draw(datitab, document);
#endregion
#region Grafico a Farfalla
//Grafico a farfalla
DatiGrafico dati = new DatiGrafico();
dati.dataTab = set.Tables["GraficoFarfalla"];
dati.setHeight(188);
dati.setWidth(163);
dati.ActLabelSeries();
IstoFarfalla farfalla = new IstoFarfalla();
document.InsertGrafico(farfalla.getGrafico(dati), 400, document.getLastPos() + 14);
// header del grafico
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Piramide Modello", tabella.X + 190, tabella.Y - 5, 120, 10, Globals.OpenTypeFontVerdanaB, 8, ceTe.DynamicPDF.TextAlign.Left));
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Piramide Attuale", tabella.X + 275, tabella.Y - 5, 120, 10, Globals.OpenTypeFontVerdanaB, 8, ceTe.DynamicPDF.TextAlign.Left));
//footer del grafico
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(tabella.X + 190, tabella.Y + 173, 163, 23, 0, new RgbColor(232, 236, 237)));
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(" 100% 50% 0% 50% 100%", tabella.X + 190, tabella.Y + 179, 320, 10, Globals.OpenTypeFontVerdana, 7, ceTe.DynamicPDF.TextAlign.Left));
#endregion
// 21-2-2011 MZ:
// If the customer has only allocated resources the financial resources will equal to them only
// and the same if the user has non allocated resources only the financial resources will equal to them only so if each of allocated or un allocated equal zero,
// we didn’t draw both of them and we draw the financial resources only.
// But there is a special case as well that we didn’t draw the financial resources as well in the case above if the customer doesn’t have negative bank account and doesn’t have Operazioni in corso as
// then the financial resources will be equal to the “TOTALE PATRIMONIO”
#region Tabella per il Totale delle Risorse Allocate
// disegno la tabella per il Totale delle Risorse Allocate
#region datasource tabellaRisorseAllocate
//setta la datatable
datitab = new DatiTabella();
datitab.table = set.Tables["RisorseAllocate"];
#endregion
Tabella tabellaRisorseAllocate = new Tabella();
if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tabellaRisorseAllocate.HeaderFont = 8;
tabellaRisorseAllocate.X = document.getMargineLeft();
tabellaRisorseAllocate.Y = document.getLastPos() + tabella.AltezzaTabella + 40;
tabellaRisorseAllocate.SaltoPagina = false;
tabellaRisorseAllocate.Datasource = datitab.table;
tabellaRisorseAllocate.Colonne.Add(new Colonna("Descrizione", "", 170, TipoAllineamento.SINISTRA, false, 8, true));
if (_mostracolonnacopertura)
{
tabellaRisorseAllocate.Colonne.Add(new Colonna("Controvalore", "", 74, TipoAllineamento.DESTRA, false, 8, true));
tabellaRisorseAllocate.Colonne.Add(new Colonna("Rischio", "", 48, TipoAllineamento.DESTRA, false, 8, true));
tabellaRisorseAllocate.Colonne.Add(new Colonna("Copertura", "", 58, TipoAllineamento.DESTRA, false, 8, true));
}
else
{
tabellaRisorseAllocate.Colonne.Add(new Colonna("Controvalore", "", 100, TipoAllineamento.DESTRA, false, 8, true));
tabellaRisorseAllocate.Colonne.Add(new Colonna("Rischio", "", 80, TipoAllineamento.DESTRA, false, 8, true));
}
// 21-02-2011 MZ: Draw the Risorse Allocate row if the customer has un allocated resources as well
if (set.Tables["RisorseNonAllocate"].Rows.Count > 0)
tabellaRisorseAllocate.Draw(datitab, document);
#endregion
#region Tabella per il Totale delle Risorse non Allocate
// disegno la tabella per il Totale delle Risorse Allocate
#region datasource tabellaRisorseAllocate
//setta la datatable
datitab = new DatiTabella();
datitab.table = set.Tables["RisorseNonAllocate"];
#endregion
Tabella tabellaRisorseNonAllocate = new Tabella();
if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tabellaRisorseNonAllocate.HeaderFont = 8;
tabellaRisorseNonAllocate.X = document.getMargineLeft();
tabellaRisorseNonAllocate.Y = document.getLastPos() + tabella.AltezzaTabella + tabellaRisorseAllocate.AltezzaTabella + 40;
tabellaRisorseNonAllocate.SaltoPagina = false;
tabellaRisorseNonAllocate.Datasource = datitab.table;
tabellaRisorseNonAllocate.Colonne.Add(new Colonna("Descrizione", "", 170, TipoAllineamento.SINISTRA, false, 8, false));
if (_mostracolonnacopertura)
{
tabellaRisorseNonAllocate.Colonne.Add(new Colonna("Controvalore", "", 74, TipoAllineamento.DESTRA, false, 8, false));
tabellaRisorseNonAllocate.Colonne.Add(new Colonna("Rischio", "", 48, TipoAllineamento.DESTRA, false, 8, false));
tabellaRisorseNonAllocate.Colonne.Add(new Colonna("Copertura", "", 58, TipoAllineamento.DESTRA, false, 8, false));
}
else
{
tabellaRisorseNonAllocate.Colonne.Add(new Colonna("Controvalore", "", 100, TipoAllineamento.DESTRA, false, 8, false));
tabellaRisorseNonAllocate.Colonne.Add(new Colonna("Rischio", "", 80, TipoAllineamento.DESTRA, false, 8, false));
}
// 21-02-2011 MZ: Draw the un allocated resources row if the customer has allocated resources as well
if (set.Tables["RisorseNonAllocate"].Rows.Count > 0)
tabellaRisorseNonAllocate.Draw(datitab, document);
#endregion
#region Tabella per il Totale delle Risorse Finanaziarie
// disegno la tabella per il Totale delle Risorse Finanaziarie
#region datasource tabellaRisorseFinanaziarie
//setta la datatable
datitab = new DatiTabella();
datitab.table = set.Tables["RisorseFinanziarie"];
#endregion
Tabella tabellaRisorseFinanaziarie = new Tabella();
if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tabellaRisorseFinanaziarie.HeaderFont = 8;
tabellaRisorseFinanaziarie.X = document.getMargineLeft();
tabellaRisorseFinanaziarie.Y = document.getLastPos() + tabella.AltezzaTabella + tabellaRisorseAllocate.AltezzaTabella + tabellaRisorseNonAllocate.AltezzaTabella + 40;
tabellaRisorseFinanaziarie.SaltoPagina = false;
tabellaRisorseFinanaziarie.Datasource = datitab.table;
tabellaRisorseFinanaziarie.Colonne.Add(new Colonna("Descrizione", "", 170, TipoAllineamento.SINISTRA, false, 8, true));
if (_mostracolonnacopertura)
{
tabellaRisorseFinanaziarie.Colonne.Add(new Colonna("Controvalore", "", 74, TipoAllineamento.DESTRA, false, 8, true));
tabellaRisorseFinanaziarie.Colonne.Add(new Colonna("Rischio", "", 48, TipoAllineamento.DESTRA, false, 8, true));
tabellaRisorseFinanaziarie.Colonne.Add(new Colonna("Copertura", "", 58, TipoAllineamento.DESTRA, false, 8, true));
}
else
{
tabellaRisorseFinanaziarie.Colonne.Add(new Colonna("Controvalore", "", 100, TipoAllineamento.DESTRA, false, 8, true));
tabellaRisorseFinanaziarie.Colonne.Add(new Colonna("Rischio", "", 80, TipoAllineamento.DESTRA, false, 8, true));
}
// 21-02-2011 MZ: Draw the financial resources row if the customer doesn't have un allocated resources or allocated resources but has negative bank account or has Operazioni in corso
// OR draw it if the customer has both un allocated resources and allocated resources and has negative bank account well or has Operazioni in corso as well
if (
((set.Tables["RisorseAllocate"].Rows.Count == 0 || set.Tables["RisorseNonAllocate"].Rows.Count == 0) && set.Tables["PartiteViaggianti"].Rows.Count > 0) || ((set.Tables["RisorseAllocate"].Rows.Count == 0 || set.Tables["RisorseNonAllocate"].Rows.Count == 0) && dataThread.TotalNegativeCurrentAccountValue < 0)
||
((set.Tables["RisorseAllocate"].Rows.Count > 0 && set.Tables["RisorseNonAllocate"].Rows.Count > 0 && set.Tables["PartiteViaggianti"].Rows.Count > 0) || (set.Tables["RisorseAllocate"].Rows.Count > 0 && set.Tables["RisorseNonAllocate"].Rows.Count > 0 && dataThread.TotalNegativeCurrentAccountValue < 0))
)
tabellaRisorseFinanaziarie.Draw(datitab, document);
#endregion
#region Tabella per il Conto Corrente
// disegno la tabella per il Conto Corrente
#region datasource tabellaContoCorrente
//setta la datatable
datitab = new DatiTabella();
datitab.table = set.Tables["ContoCorrente"];
#endregion
Tabella tabellaContoCorrente = new Tabella();
if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tabellaContoCorrente.HeaderFont = 8;
// 21-02-2011 MZ: Draw the row Conto Corrente if the customer has negative bank account.
if (dataThread.TotalNegativeCurrentAccountValue < 0)
{
tabellaContoCorrente.X = document.getMargineLeft();
tabellaContoCorrente.Y = document.getLastPos() + tabella.AltezzaTabella + tabellaRisorseAllocate.AltezzaTabella + tabellaRisorseNonAllocate.AltezzaTabella + tabellaRisorseFinanaziarie.AltezzaTabella + 40;
tabellaContoCorrente.SaltoPagina = false;
tabellaContoCorrente.Datasource = datitab.table;
tabellaContoCorrente.Colonne.Add(new Colonna("Descrizione", "", 170, TipoAllineamento.SINISTRA, false, 8, false));
if (_mostracolonnacopertura)
{
tabellaContoCorrente.Colonne.Add(new Colonna("Controvalore", "", 74, TipoAllineamento.DESTRA, false, 8, false));
tabellaContoCorrente.Colonne.Add(new Colonna("Rischio", "", 48, TipoAllineamento.DESTRA, false, 8, false));
tabellaContoCorrente.Colonne.Add(new Colonna("Copertura", "", 58, TipoAllineamento.DESTRA, false, 8, false));
}
else
{
tabellaContoCorrente.Colonne.Add(new Colonna("Controvalore", "", 100, TipoAllineamento.DESTRA, false, 8, false));
tabellaContoCorrente.Colonne.Add(new Colonna("Rischio", "", 80, TipoAllineamento.DESTRA, false, 8, false));
}
tabellaContoCorrente.Draw(datitab, document);
}
#endregion
#region Tabella per gli Investimenti in corso o Partite Viaggianti
// disegno la tabella per gli Investimenti in corso o Partite Viaggianti
#region datasource tabellaPartiteViaggianti
//setta la datatable
datitab = new DatiTabella();
datitab.table = set.Tables["PartiteViaggianti"];
#endregion
Tabella tabellaPartiteViaggianti = new Tabella();
if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tabellaPartiteViaggianti.HeaderFont = 8;
// Draw the Operazioni in corso row if the customer has Operazioni in corso.
if (datitab.table.Rows.Count > 0)
{
tabellaPartiteViaggianti.X = document.getMargineLeft();
tabellaPartiteViaggianti.Y = document.getLastPos() + tabella.AltezzaTabella + tabellaRisorseAllocate.AltezzaTabella + tabellaRisorseNonAllocate.AltezzaTabella + tabellaRisorseFinanaziarie.AltezzaTabella + tabellaContoCorrente.AltezzaTabella + 40;
tabellaPartiteViaggianti.SaltoPagina = false;
tabellaPartiteViaggianti.Datasource = datitab.table;
tabellaPartiteViaggianti.Colonne.Add(new Colonna("Descrizione", "", 170, TipoAllineamento.SINISTRA, false, 8, false));
if (_mostracolonnacopertura)
tabellaPartiteViaggianti.Colonne.Add(new Colonna("Controvalore", "", 74, TipoAllineamento.DESTRA, false, 8, false));
else
tabellaPartiteViaggianti.Colonne.Add(new Colonna("Controvalore", "", 100, TipoAllineamento.DESTRA, false, 8, false));
tabellaPartiteViaggianti.Draw(datitab, document);
}
#endregion
#region Tabella per il Totale Patrimonio
// disegno la tabella per il Totale Patrimonio
#region datasource tabellaTotalePatrimonio
//setta la datatable
datitab = new DatiTabella();
datitab.table = set.Tables["TotalePatrimonio"];
#endregion
Tabella tabellaTotalePatrimonio = new Tabella();
if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tabellaTotalePatrimonio.HeaderFont = 8;
tabellaTotalePatrimonio.X = document.getMargineLeft();
tabellaTotalePatrimonio.Y = document.getLastPos() + tabella.AltezzaTabella + tabellaRisorseAllocate.AltezzaTabella + tabellaRisorseNonAllocate.AltezzaTabella + tabellaRisorseFinanaziarie.AltezzaTabella + tabellaContoCorrente.AltezzaTabella + tabellaPartiteViaggianti.AltezzaTabella + 40;
tabellaTotalePatrimonio.SaltoPagina = false;
tabellaTotalePatrimonio.Datasource = datitab.table;
tabellaTotalePatrimonio.Colonne.Add(new Colonna("Descrizione", "", 170, TipoAllineamento.SINISTRA, true, 8, true));
if (_mostracolonnacopertura)
{
tabellaTotalePatrimonio.Colonne.Add(new Colonna("Controvalore", "", 74, TipoAllineamento.DESTRA, true, 8, true));
//Hazem
tabellaTotalePatrimonio.Colonne.Add(new Colonna("Rischio", "", 48, TipoAllineamento.DESTRA, true, 8, true));
tabellaTotalePatrimonio.Colonne.Add(new Colonna("Copertura", "", 58, TipoAllineamento.DESTRA, true, 8, true));
}
else
{
tabellaTotalePatrimonio.Colonne.Add(new Colonna("Controvalore", "", 100, TipoAllineamento.DESTRA, true, 8, true));
//Hazem
tabellaTotalePatrimonio.Colonne.Add(new Colonna("Rischio", "", 80, TipoAllineamento.DESTRA, true, 8, true));
//tabellaTotalePatrimonio.Colonne.Add(new Colonna(80, true));
}
tabellaTotalePatrimonio.Draw(datitab, document);
#endregion
document.setLastPos(300);
}
}