226 lines
9.9 KiB
C#
226 lines
9.9 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Configuration;
|
|
using System.Web;
|
|
using System.Web.Security;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Web.UI.WebControls.WebParts;
|
|
using System.Web.UI.HtmlControls;
|
|
using System.Collections;
|
|
using ceTe.DynamicPDF;
|
|
using ceTe.DynamicPDF.Text;
|
|
using PDFGenerator.Presentation.Section.Tables;
|
|
using PDFGenerator.BusinessLayer.DataSection;
|
|
using PDFGenerator.Presentation.Section.Charts;
|
|
using PDFGenerator.BusinessLayer;
|
|
using ContrattoSei.Utilities;
|
|
|
|
|
|
namespace PDFGenerator.Presentation.Section {
|
|
public class S56 : ISezione {
|
|
|
|
|
|
public S56() {
|
|
//
|
|
// TODO: Add constructor logic here
|
|
//
|
|
}
|
|
|
|
#region ISezione Members
|
|
|
|
public void writeSezione(DataThread dataThread) {
|
|
DocumentPDF document = dataThread.DocumentPDF;
|
|
DatiTabella datitab = new DatiTabella();
|
|
DataSetS56 set = (DataSetS56)dataThread.Data.DatiSezione;
|
|
|
|
//setta la datatable
|
|
datitab.table = set.Tables["PatrimonioBFAreeBisogno"];
|
|
DataView view = new DataView(datitab.table);
|
|
view.RowFilter = "";
|
|
datitab.table = view.ToTable(false, setTableForTable());
|
|
|
|
//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(datitab.GetRowDim() * (datitab.getNumRow() + 5))) document.addPage();
|
|
|
|
|
|
//aggiorna l'indice, titolo e header sezione
|
|
document.setSezTitolo(dataThread.SezioneReport.Titolo);
|
|
document.setHeaderSpace(5);
|
|
|
|
//if (document.TipologiaDocumento == "report")
|
|
document.setChapterHeader(Resource.S56_Testo_Report.Replace("%Banca", document.Banca));
|
|
//else
|
|
// document.setChapterHeader(Resource.S56_Testo_Scheda);
|
|
//setto un margine tra l'header e la tabella (SISTEMARE in documentPDF)
|
|
// document.setHeaderSpace(20);
|
|
|
|
//disegno la parte della piramide
|
|
Piramide modello = new Piramide();
|
|
modello.writeSezione(document);
|
|
|
|
//settaggi dell'oggetto tabella
|
|
datitab.setX(190);
|
|
datitab.setCellSpace(0);
|
|
datitab.setY(document.getLastPos());
|
|
datitab.setHeader();
|
|
datitab.SetRowDim(30);
|
|
datitab.setCell(100, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdana, false);
|
|
datitab.setCell(60, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdana, false);
|
|
datitab.setCell(80, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdana, false);
|
|
|
|
Tabella tab = new Tabella();
|
|
//setta posizione tabella
|
|
document.InsertTable(tab.getTabella(datitab));
|
|
|
|
bool nota = false;
|
|
|
|
datitab.table = view.ToTable(false, "Nota");
|
|
nota = this.setDangerIcon(datitab, document);
|
|
|
|
ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
|
|
|
|
//aggiungo una riga in più nel conteggio per l'header
|
|
float dim = datitab.GetRowDim() * (datitab.getNumRow() + 1);
|
|
|
|
DatiGrafico dati = new DatiGrafico();
|
|
dati.dataTab = view.ToTable(false, setTableForChart());
|
|
dati.setHeight(185);
|
|
dati.setWidth(121);
|
|
dati.ActLabelSeries();
|
|
IstoDoppio isto = new IstoDoppio();
|
|
document.InsertGrafico(isto.getGrafico(dati), document.getMargineLeft() + 397, document.getLastPos() + 14);
|
|
|
|
datitab = new DatiTabella();
|
|
datitab.table = set.Tables["TotaleAreeBisogno"];
|
|
|
|
datitab.setY(document.getLastPos() + dim);
|
|
datitab.setX(document.getMargineLeft());
|
|
datitab.setCell(169, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, true);
|
|
datitab.setCell(80, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdanaB, true);
|
|
datitab.setCell(60, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdanaB, true);
|
|
datitab.setCell(79, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdanaB, true);
|
|
document.InsertTable(tab.getTabella(datitab));
|
|
|
|
dim += datitab.GetRowDim() * (datitab.getNumRow());
|
|
datitab = new DatiTabella();
|
|
datitab.table = set.Tables["ContoCorrente"];
|
|
|
|
datitab.setY(document.getLastPos() + dim);
|
|
datitab.setX(document.getMargineLeft());
|
|
datitab.setCell(170, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false);
|
|
datitab.setCell(80, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdana, false);
|
|
document.InsertTable(tab.getTabella(datitab));
|
|
|
|
dim += datitab.GetRowDim() * (datitab.getNumRow());
|
|
|
|
datitab = new DatiTabella();
|
|
datitab.table = set.Tables["PartiteViaggianti"];
|
|
|
|
datitab.setY(document.getLastPos() + dim);
|
|
datitab.setX(document.getMargineLeft());
|
|
datitab.setCell(170, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false);
|
|
datitab.setCell(80, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdana, false);
|
|
document.InsertTable(tab.getTabella(datitab));
|
|
|
|
dim += datitab.GetRowDim() * (datitab.getNumRow());
|
|
|
|
datitab = new DatiTabella();
|
|
datitab.table = set.Tables["RisorseNonAllocate"];
|
|
|
|
datitab.setY(document.getLastPos() + dim);
|
|
datitab.setX(document.getMargineLeft());
|
|
datitab.setCell(170, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false);
|
|
datitab.setCell(80, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdana, false);
|
|
document.InsertTable(tab.getTabella(datitab));
|
|
|
|
dim += datitab.GetRowDim() * (datitab.getNumRow());
|
|
|
|
datitab = new DatiTabella();
|
|
datitab.table = set.Tables["TotalePatrimonio"];
|
|
|
|
datitab.setY(document.getLastPos() + dim);
|
|
datitab.setX(document.getMargineLeft());
|
|
datitab.setCell(170, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, true);
|
|
datitab.setCell(80, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdanaB, true);
|
|
if (datitab.table.Rows.Count > 0)
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(document.getMargineLeft() - 5, document.getLastPos() + dim - 10, 399, 23, 0, new RgbColor(232, 236, 237)));
|
|
document.InsertTable(tab.getTabella(datitab));
|
|
|
|
dim += datitab.GetRowDim() * (datitab.getNumRow());
|
|
|
|
//disegno la grafica decorativa del grafico
|
|
this.headerChart(page, document.getMargineLeft() + 400, document.getLastPos());
|
|
|
|
if (nota) {
|
|
string relativePath = UtilityManager.getAppSetting("Danger");
|
|
System.Reflection.Assembly thisExe;
|
|
thisExe = System.Reflection.Assembly.GetExecutingAssembly();
|
|
System.IO.Stream file = thisExe.GetManifestResourceStream(relativePath);
|
|
|
|
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(file, document.getMargineLeft() - 5, document.getLastPos() + dim, 0.2F));
|
|
document.setSezFooter(Resource.S56_S57_Nota, dim, 18);
|
|
}
|
|
|
|
//dim += datitab.GetRowDim();
|
|
|
|
document.setLastPos(dim);
|
|
}
|
|
#endregion
|
|
|
|
private void headerChart(ceTe.DynamicPDF.Page page, float x, float y) {
|
|
//Header grafico a farfalla
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(x + 100, y + 2, 10, 5, 0, new RgbColor(121, 142, 185)));
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(x + 100, y - 9, 10, 5, 0, new RgbColor(239, 65, 53)));
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Peso (%)", x - 25, y, 120, 10, Globals.OpenTypeFontVerdana, 9, ceTe.DynamicPDF.TextAlign.Right));
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Rischio relativo(%)", x - 25, y - 11, 120, 10, Globals.OpenTypeFontVerdana, 9, ceTe.DynamicPDF.TextAlign.Right));
|
|
//////
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(x - 3, y + 170, 122, 23, 0, new RgbColor(232, 236, 237)));
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("0% 25% 50% 75% 100%", x - 3, y + 176, 320, 10, Globals.OpenTypeFontVerdana, 7, ceTe.DynamicPDF.TextAlign.Left));
|
|
}
|
|
|
|
private bool setDangerIcon(DatiTabella datitab, DocumentPDF document) {
|
|
bool nota = false;
|
|
float y = document.getLastPos() + 23;
|
|
ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
|
|
|
|
string relativePath = UtilityManager.getAppSetting("Danger");
|
|
System.Reflection.Assembly thisExe;
|
|
thisExe = System.Reflection.Assembly.GetExecutingAssembly();
|
|
System.IO.Stream file = thisExe.GetManifestResourceStream(relativePath);
|
|
|
|
|
|
foreach (DataRow myRow in datitab.table.Rows) {
|
|
if (!myRow.IsNull("Nota") && (int)myRow["Nota"] == 1) {
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(relativePath, 365, y + 2, 0.2F));
|
|
nota = true;
|
|
}
|
|
y += datitab.GetRowDim();
|
|
}
|
|
|
|
return nota;
|
|
}
|
|
|
|
private string[] setTableForTable() {
|
|
//eventuali operazioni sul dataset
|
|
string[] Columns = new String[3];
|
|
Columns[0] = "Controvalore";
|
|
Columns[1] = "Var";
|
|
Columns[2] = "GradoCopertura";
|
|
return Columns;
|
|
}
|
|
|
|
private string[] setTableForChart() {
|
|
string[] Columns = new String[2];
|
|
Columns[0] = "Peso";
|
|
Columns[1] = "RischioRelativo";
|
|
return Columns;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|