738 lines
34 KiB
C#
738 lines
34 KiB
C#
using System;
|
||
using System.Data;
|
||
using System.Configuration;
|
||
using System.Drawing;
|
||
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 Dundas.Charting.WebControl;
|
||
using Font = System.Drawing.Font;
|
||
using PDFGenerator.BusinessLayer;
|
||
using PDFGenerator;
|
||
using PDFGenerator.BusinessLayer.DataSection;
|
||
using PDFGenerator.Presentation.Section.Tables;
|
||
using PDFGenerator.Presentation.Section.Charts;
|
||
using PDFGenerator.Presentation.Section;
|
||
|
||
|
||
namespace PDFGenerator.Presentation.Section
|
||
{
|
||
class S134BIS: ISezione
|
||
{
|
||
FormatNum conv = new FormatNum();
|
||
#region ISezione Members
|
||
|
||
string Titolo = " ";
|
||
int Resolution = 300;
|
||
private string _testointroduttivo = "";
|
||
|
||
public string TestoIntroduttivo
|
||
{
|
||
get
|
||
{
|
||
return _testointroduttivo;
|
||
}
|
||
set
|
||
{
|
||
_testointroduttivo = value;
|
||
}
|
||
}
|
||
|
||
public void setTitolo(string label)
|
||
{
|
||
Titolo = label;
|
||
}
|
||
|
||
private void addNota(DocumentPDF doc)
|
||
{
|
||
FormatNum con = new FormatNum();
|
||
//doc.setSezFooter("(*) Alcuni prodotti non rientrano nel calcolo del rendimento. Il dettaglio del patrimonio non considerato viene fornito nel capitolo ''Patrimonio non rappresentabile''", dim);
|
||
//doc.StampaNote("(*) Alcuni prodotti non rientrano nel calcolo del rendimento. Il dettaglio del patrimonio non considerato viene fornito nel capitolo ''Patrimonio non rappresentabile''");
|
||
doc.setNotaPièDiPagina("(*) Alcuni prodotti non rientrano nel calcolo del rendimento. Il dettaglio del patrimonio non considerato viene fornito nel capitolo ''Patrimonio non rappresentabile''");
|
||
}
|
||
|
||
bool _hasselectedpatrimnonrap;
|
||
public bool HasSelectedPatrimNonRap
|
||
{
|
||
set
|
||
{
|
||
_hasselectedpatrimnonrap = value;
|
||
}
|
||
get
|
||
{
|
||
return _hasselectedpatrimnonrap;
|
||
}
|
||
|
||
}
|
||
|
||
|
||
public void writeSezioneGraficLeft(DataThread dataThread)
|
||
{
|
||
Tabella tab = new Tabella();
|
||
float dim = 0;
|
||
DocumentPDF document = dataThread.DocumentPDF;
|
||
DatiTabella datitab = new DatiTabella();
|
||
DataSetS134BIS set = (DataSetS134BIS)dataThread.Data.DatiSezione;
|
||
//string tempTesto = "";
|
||
|
||
//document.setSezTitolo(dataThread.SezioneReport.Titolo);
|
||
|
||
//tempTesto = dataThread.SezioneReport.TestoIntroduttivo;
|
||
//tempTesto = tempTesto.Replace("/$AREA$/", dataThread.SezioneReport.AreaProgettoDescrizione);
|
||
|
||
|
||
//if (dataThread.Rete.ToUpper() == "S")
|
||
// tempTesto = tempTesto.Replace("Banca Fideuram", "Sanpaolo Invest");
|
||
//document.setChapterHeader(tempTesto, 0, 520, 8);
|
||
|
||
|
||
//if (document.checkMargin(datitab.GetRowDim() * 10 + 60))
|
||
// document.addPage();
|
||
ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
|
||
|
||
#region Tabella "MONITORAGGIO ATTIVATO IL"
|
||
|
||
datitab = new DatiTabella();
|
||
datitab.table = set.Tables["AttivazioneMonitoraggio"];
|
||
|
||
Tabella tabellaMonitoraggioAttivato = new Tabella();
|
||
tabellaMonitoraggioAttivato.X = document.getMargineLeft();
|
||
tabellaMonitoraggioAttivato.Y = document.getLastPos() + 49;
|
||
tabellaMonitoraggioAttivato.Datasource = datitab.table;
|
||
tabellaMonitoraggioAttivato.AltezzaCella = 20;
|
||
|
||
//tabellaMonitoraggioAttivato.Colonne.Add(new Colonna("Descrizione", string.Empty, 325, TipoAllineamento.SINISTRA, true, 8, true));
|
||
tabellaMonitoraggioAttivato.Colonne.Add(new Colonna("Descrizione", string.Empty, 225, TipoAllineamento.SINISTRA, true, 7, true));
|
||
tabellaMonitoraggioAttivato.Draw(datitab, document);
|
||
|
||
#endregion
|
||
|
||
//dim += (datitab.GetRowDim() * datitab.getNumRow()) + 5;
|
||
dim += (datitab.GetRowDim() * datitab.getNumRow()) + 15;
|
||
|
||
//**********
|
||
datitab = new DatiTabella();
|
||
datitab.table = set.Tables["Monitoraggio"];
|
||
|
||
#region Determinazione presenza assenza nota
|
||
bool hasNota = false;
|
||
foreach (DataRow rw in datitab.table.Rows)
|
||
{
|
||
if (rw["Nota"] != DBNull.Value)
|
||
if (Convert.ToBoolean(rw["Nota"]))
|
||
hasNota = true;
|
||
}
|
||
#endregion
|
||
|
||
datitab.setY(document.getLastPos() + dim + 10);
|
||
datitab.setX(document.getMargineLeft());
|
||
datitab.setIsLinee(1);
|
||
datitab.SetRowDim(20);
|
||
datitab.setCellSpace(0);
|
||
//datitab.setDimFontCell(7);
|
||
datitab.setCell(115 /*200*/, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, true, 7);
|
||
datitab.setCell(110/*85*/, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdanaB, false, 7);
|
||
datitab.setCell(0, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false, 7);
|
||
|
||
document.InsertTable(tab.getTabella(datitab));
|
||
|
||
dim += datitab.GetRowDim() * datitab.getNumRow();
|
||
|
||
|
||
//<Bido> Commented
|
||
//**********
|
||
DatiTabella datitabRisorseApportate = new DatiTabella();
|
||
datitabRisorseApportate.table = set.Tables["RisorseApportate"];
|
||
|
||
datitabRisorseApportate.setY(document.getLastPos() + dim + 10);
|
||
datitabRisorseApportate.setX(document.getMargineLeft() + 35);
|
||
datitabRisorseApportate.setCellSpace(0);
|
||
datitabRisorseApportate.setIsLinee(1);
|
||
datitabRisorseApportate.SetRowDim(20);
|
||
datitabRisorseApportate.setCell(/*125*/ 80, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdana, true, 7);
|
||
datitabRisorseApportate.setCell(/*85*/ 110, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdana, false, 7);
|
||
|
||
//Bido Work
|
||
DataRow Temp = datitabRisorseApportate.table.NewRow();
|
||
DataRow CedoleRow = datitabRisorseApportate.table.Rows[2];
|
||
Temp[0] = CedoleRow[0];
|
||
Temp[1] = CedoleRow[1];
|
||
datitabRisorseApportate.table.Rows.Remove(CedoleRow);
|
||
//End Bido Work
|
||
|
||
|
||
document.InsertTable(tab.getTabella(datitabRisorseApportate));
|
||
|
||
page.Elements.Add(
|
||
new ceTe.DynamicPDF.PageElements.Rectangle(
|
||
document.getMargineLeft() - 4.5F,
|
||
document.getLastPos() + dim,
|
||
40,
|
||
(datitabRisorseApportate.GetRowDim() * datitabRisorseApportate.getNumRow()) + 2.5F,
|
||
new RgbColor(232, 236, 237),
|
||
new RgbColor(232, 236, 237))
|
||
);
|
||
|
||
|
||
|
||
datitab.CellClear();
|
||
dim += (datitabRisorseApportate.GetRowDim() * datitabRisorseApportate.getNumRow()) + 10;
|
||
|
||
|
||
//********* Riga fittizia per ottenere stesso effetto grafico
|
||
DatiTabella datitabLinea = new DatiTabella();
|
||
datitabLinea.table = set.Tables["RigaFittizia"];
|
||
datitabLinea.setY(document.getLastPos() + dim - 15);
|
||
datitabLinea.setX(document.getMargineLeft());
|
||
datitabLinea.setCellSpace(0);
|
||
datitabLinea.setIsLinee(2);
|
||
datitabLinea.setCell(225, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, true);
|
||
datitabLinea.SetRowDim(2);
|
||
|
||
document.InsertTable(tab.getTabella(datitabLinea));
|
||
//**********
|
||
DatiTabella datitabTotali = new DatiTabella();
|
||
datitabTotali.table = set.Tables["Totali"];
|
||
// Bido Work
|
||
//datitabTotali.table.Columns.Add("Notes");
|
||
// End of Bido Work
|
||
|
||
datitabTotali.setY(document.getLastPos() + dim + 5 + 1);
|
||
datitabTotali.setX(document.getMargineLeft());
|
||
datitabTotali.setCellSpace(0);
|
||
datitabTotali.setIsLinee(1);
|
||
datitabTotali.SetRowDim(20);
|
||
//datitabTotali.setCell(15, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, true);
|
||
datitabTotali.setCell(/*175*/ 115, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, true, 7);
|
||
datitabTotali.setCell(/*110*/ 110, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdana, false, 7);
|
||
|
||
//Bido Work
|
||
//Cedole e dividendi
|
||
DataRow CedoledividendiDR = datitabTotali.table.NewRow();
|
||
//Copying Row Items field by field, Whole row assigmnet generate error
|
||
CedoledividendiDR[0] = Temp[0];
|
||
CedoledividendiDR[1] = Temp[1];
|
||
datitabTotali.table.Rows.InsertAt(CedoledividendiDR, 1);
|
||
|
||
//Guadagno/Perdita Totale
|
||
DataRow GuadagnoPerditaDR = datitabTotali.table.NewRow();
|
||
//Copying Row Items field by field, Whole row assigmnet generate error
|
||
GuadagnoPerditaDR[0] = "Guadagno/Perdita Totale";
|
||
|
||
string AB = datitabTotali.table.Rows[0][1].ToString().Replace("€", "");
|
||
string C = datitabTotali.table.Rows[1][1].ToString().Replace("€", "");
|
||
double DB_GuadagnoPerdita = double.Parse(AB) + double.Parse(C);
|
||
|
||
string STR_GuadagnoPerdita = conv.ConvertNum(DB_GuadagnoPerdita).ToString() + " €";
|
||
//string STR_GuadagnoPerdita = DB_GuadagnoPerdita.ToString().Replace(".", ",") + " €";
|
||
|
||
if (DB_GuadagnoPerdita > 0)
|
||
STR_GuadagnoPerdita = "+" + STR_GuadagnoPerdita;
|
||
|
||
GuadagnoPerditaDR[1] = STR_GuadagnoPerdita;
|
||
datitabTotali.table.Rows.InsertAt(GuadagnoPerditaDR, 2);
|
||
|
||
|
||
string CumulatoNote = "";
|
||
if (datitabTotali.table.Rows.Count >= 5)
|
||
{
|
||
CumulatoNote = " (" + datitabTotali.table.Rows[4][1].ToString() + " su base annua)";
|
||
datitabTotali.table.Rows[3][1] = datitabTotali.table.Rows[3][1] + "<BR>" + CumulatoNote;
|
||
datitabTotali.table.Rows.RemoveAt(4);
|
||
}
|
||
|
||
//End Bido Work
|
||
document.InsertTable(tab.getTabella(datitabTotali));
|
||
|
||
|
||
dim += datitabTotali.GetRowDim() * datitabTotali.getNumRow();
|
||
|
||
//Bido Work
|
||
dim += (datitabTotali.GetRowDim() * datitabTotali.getNumRow());
|
||
float font = float.Parse("8,0");
|
||
|
||
|
||
//********* tabella che contiene il dettaglio temporale su data di avvio etc
|
||
//page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(document.getMargineLeft() + 390, 211, 130, datitab.GetRowDim() * datitab.getNumRow() - 5, new RgbColor(232, 236, 237), new RgbColor(232, 236, 237)));
|
||
datitab.CellClear();
|
||
//scrive la data di attivazione del monitoraggio
|
||
|
||
//Bido <For the hidden note under section 84>
|
||
dim = dim - 95;
|
||
//End Bido
|
||
/* Bido Commented */
|
||
|
||
DatiTabella tabRendimentoAnn = new DatiTabella();
|
||
tabRendimentoAnn.table = set.Tables["RendimentoAnnualizzato"];
|
||
tabRendimentoAnn.setY(document.getLastPos() + dim);
|
||
tabRendimentoAnn.setX(document.getMargineLeft());
|
||
tabRendimentoAnn.setCellSpace(0);
|
||
tabRendimentoAnn.setIsLinee(2);
|
||
//datitabTotali.setCell(15, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, true);
|
||
tabRendimentoAnn.setCell(/*175*/ 200, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, true);
|
||
tabRendimentoAnn.setCell(/*95*/ 125, ceTe.DynamicPDF.TextAlign.Right, Globals.OpenTypeFontVerdana, false);
|
||
document.InsertTable(tab.getTabella(tabRendimentoAnn));
|
||
dim += tabRendimentoAnn.GetRowDim() * tabRendimentoAnn.getNumRow();
|
||
|
||
if (hasNota && _hasselectedpatrimnonrap)
|
||
{
|
||
addNota(document);
|
||
}
|
||
|
||
|
||
//////aggiorno il puntatore alla posizione da cui si può scrivere
|
||
////V Problema sforamento in caso di presenza di rendimento annualizzato
|
||
//document.setLastPos(dim - 25);
|
||
//document.setLastPos(dim - 32);
|
||
//document.setHeaderSpace(50);
|
||
}
|
||
|
||
public void writeSezione(DataThread dataThread)
|
||
{
|
||
DocumentPDF document = dataThread.DocumentPDF;
|
||
DataSetS134BIS set = (DataSetS134BIS)dataThread.Data.DatiSezione;
|
||
|
||
|
||
|
||
string tempTesto = "";
|
||
|
||
document.setSezTitolo(dataThread.SezioneReport.Titolo, true);
|
||
|
||
if ((dataThread.Area.ToLower() != "inv") || ((dataThread.Area.ToLower() == "inv") && (dataThread.SezioneReport.NomeProgetto.ToLower() == "progetto investimento")))
|
||
{
|
||
document.setLastPos(-12);
|
||
tempTesto = dataThread.SezioneReport.TestoIntroduttivo;
|
||
tempTesto = tempTesto.Replace("/$AREA$/", dataThread.SezioneReport.AreaProgettoDescrizione);
|
||
}
|
||
else
|
||
{
|
||
tempTesto = dataThread.SezioneReport.TestoIntroduttivoAlternativo;
|
||
tempTesto = tempTesto.Replace("/$PROGETTO$/", dataThread.Progetto);
|
||
}
|
||
|
||
string tempTestoAlt2 = "Il grafico riporta l’andamento nel tempo del controvalore rispetto alle risorse da lei apportate, al netto delle cedole e dividendi incassati, a partire dalla data di attivazione del monitoraggio.";
|
||
|
||
document.setChapterHeader(tempTesto, 0, 520, 8);
|
||
//document.setTitolo(dataThread.SezioneReport.SottoTitolo, 20);
|
||
|
||
document.writeText(document.getMargineLeft() - 5, document.getLastPos() - 19, tempTestoAlt2, 8, 520, ceTe.DynamicPDF.TextAlign.Justify);
|
||
//document.setChapterHeader(tempTesto);
|
||
|
||
DatiTabella datitab = new DatiTabella();
|
||
//CombinationChart graficoCombinato = new CombinationChart(500, 200, Resolution);
|
||
|
||
writeSezioneGraficLeft(dataThread);
|
||
|
||
|
||
CombinationChart graficoCombinato = new CombinationChart(320, 200, Resolution);
|
||
|
||
//setta la datatable che contiene i Dati per disegnare la tabella
|
||
datitab.table = set.Tables["DatiGrafico"];
|
||
|
||
DateTime inizio = Convert.ToDateTime(datitab.table.Rows[0]["Data"]);
|
||
DateTime fine = Convert.ToDateTime(datitab.table.Rows[datitab.table.Rows.Count - 1]["Data"]); ;
|
||
TimeSpan differenza = fine.Subtract(inizio);
|
||
|
||
//calcola se entra nella pagina altrimenti aggiunge una nuova pagina. In questa sezione il # di righe è fissato
|
||
//if (document.checkMargin((float)(graficoCombinato.Height.Value + 50)))
|
||
if (document.checkMargin((float)(graficoCombinato.Height.Value - 100)))
|
||
|
||
document.addPage();
|
||
|
||
double totaleGiorni = fine.Subtract(inizio).TotalDays;
|
||
//document.setTitolo(Titolo);
|
||
//document.setChapterHeader(_testointroduttivo);
|
||
|
||
// associo il documento pdf corrente al grafico
|
||
graficoCombinato.DocumentPDF = document;
|
||
//graficoCombinato.PositionX = (int)document.getMargineLeft();
|
||
graficoCombinato.PositionX = (int)document.getMargineLeft() + 225;
|
||
//V Sforamento del footer nel caso di nota sulla S83
|
||
|
||
//graficoCombinato.PositionY = (int)(document.getLastPos()) + 9;
|
||
graficoCombinato.PositionY = (int)(document.getLastPos()+2);
|
||
|
||
|
||
|
||
graficoCombinato.TabIndex = 10;
|
||
graficoCombinato.BorderLineWidth = 0;
|
||
|
||
#region Settaggio della ChartArea
|
||
//imposto la chart area
|
||
ChartArea ChartArea = new ChartArea();
|
||
// Settaggi dell'area del grafico
|
||
|
||
#region Generale
|
||
ChartArea.Name = "Default";
|
||
ChartArea.Area3DStyle.WallWidth = 0;
|
||
ChartArea.BackColor = System.Drawing.Color.FromArgb(255, 255, 255);
|
||
ChartArea.BorderColor = System.Drawing.Color.Empty;
|
||
ChartArea.BorderWidth = 0;
|
||
|
||
#endregion
|
||
|
||
#region AsseX
|
||
ChartArea.AxisX.LabelsAutoFit = false;
|
||
ChartArea.AxisX.Margin = false;
|
||
ChartArea.AxisX.MinorGrid.Enabled = false;
|
||
ChartArea.AxisX.MajorGrid.Enabled = false;
|
||
ChartArea.AxisX.MinorTickMark.Enabled = false;
|
||
//ChartArea.AxisX.MinorTickMark.Size = 2F;
|
||
ChartArea.AxisX.LabelStyle.Enabled = true;
|
||
//ChartArea.AxisX.LabelStyle.FontAngle = 90;
|
||
//ChartArea.AxisX.LabelStyle.ShowEndLabels = false; // mostra le label per il primo e per l'ultimo valore sull'asse X
|
||
//ChartArea.AxisX.LabelStyle.Font = new Font("verdana", 5);
|
||
ChartArea.AxisX.LabelStyle.Font = new Font("verdana", 4);
|
||
ChartArea.AxisX.IntervalType = DateTimeIntervalType.Days;
|
||
ChartArea.AxisX.LabelStyle.Format = "d";
|
||
ChartArea.AxisX.Minimum = inizio.AddDays(-differenza.TotalDays / 200).ToOADate();
|
||
ChartArea.AxisX.Maximum = fine.AddDays(differenza.TotalDays / 100).ToOADate();
|
||
|
||
|
||
if (totaleGiorni < 10)
|
||
ChartArea.AxisX.Interval = 1;
|
||
else
|
||
ChartArea.AxisX.Interval = differenza.TotalDays / 6;
|
||
|
||
|
||
|
||
#endregion
|
||
|
||
#region AsseY
|
||
ChartArea.AxisY.Margin = false;
|
||
ChartArea.AxisY.LabelsAutoFit = false;
|
||
ChartArea.AxisY.MinorGrid.Enabled = false;//
|
||
ChartArea.AxisY.MajorGrid.LineColor = System.Drawing.Color.Gray;
|
||
ChartArea.AxisY.MajorGrid.LineStyle = ChartDashStyle.Dash;
|
||
ChartArea.AxisY.MajorGrid.Enabled = true;
|
||
ChartArea.AxisY.MinorTickMark.Size = 2F;
|
||
ChartArea.AxisY.LabelStyle.Format = "C"; //"€ {0}";
|
||
//ChartArea.AxisY.LabelStyle.Font = new Font("verdana", 6F);
|
||
ChartArea.AxisY.LabelStyle.Font = new Font("verdana", 5F);
|
||
|
||
//imposto i valori massimi dell'asse Y a seconda del controvalore massimo + 10%
|
||
|
||
//recupero il controvalore massimo che è il massimo tra il campo "Controvalore" e "RisorseAssociate"
|
||
decimal valMAxControvalore;
|
||
//decimal maxControvalore = Convert.ToDecimal(datitab.table.Compute("Max(Controvalore)", string.Empty)) / 1000;
|
||
//decimal maxRisorseAssociate = Convert.ToDecimal(datitab.table.Compute("Max(RisorseAssociate)", string.Empty)) / 1000;
|
||
|
||
decimal maxControvalore = Convert.ToDecimal(datitab.table.Compute("Max(Controvalore)", string.Empty));
|
||
decimal maxRisorseAssociate = Convert.ToDecimal(datitab.table.Compute("Max(RisorseAssociate)", string.Empty));
|
||
|
||
if (maxControvalore < maxRisorseAssociate)
|
||
valMAxControvalore = maxRisorseAssociate;
|
||
else
|
||
valMAxControvalore = maxControvalore;
|
||
|
||
|
||
//recupero il controvalore minimo che è il minimo tra il campo "Controvalore" e "RisorseAssociate"
|
||
decimal valMinControvalore;
|
||
//decimal minControvalore = Convert.ToDecimal(datitab.table.Compute("Min(Controvalore)", string.Empty)) / 1000;
|
||
//decimal minRisorseAssociate = Convert.ToDecimal(datitab.table.Compute("Min(RisorseAssociate)", string.Empty)) / 1000;
|
||
|
||
decimal minControvalore = Convert.ToDecimal(datitab.table.Compute("Min(Controvalore)", string.Empty));
|
||
decimal minRisorseAssociate = Convert.ToDecimal(datitab.table.Compute("Min(RisorseAssociate)", string.Empty));
|
||
|
||
if (minControvalore < minRisorseAssociate)
|
||
valMinControvalore = minControvalore;
|
||
else
|
||
valMinControvalore = minRisorseAssociate;
|
||
|
||
valMAxControvalore = Math.Ceiling(valMAxControvalore);
|
||
valMinControvalore = Math.Ceiling(valMinControvalore);
|
||
|
||
//valMAxControvalore = valMAxControvalore / 1000;
|
||
//valMinControvalore = valMinControvalore / 1000;
|
||
|
||
//aggiungo 10%
|
||
decimal valorepercentuale;
|
||
valorepercentuale = (valMAxControvalore / 100) * 10;
|
||
|
||
//valorepercentuale = (valMAxControvalore / 100) * 2;
|
||
|
||
//double valMaxAsseY = (double)valMAxControvalore + (double)valorepercentuale;
|
||
double valMaxAsseY = ((double)valMAxControvalore + (double)valorepercentuale);
|
||
|
||
if (valMaxAsseY <= 0)
|
||
valMaxAsseY = 10;
|
||
else
|
||
valMaxAsseY = LibFunction.ArrotondaAxis(valMaxAsseY, LibFunction.tipoArrotondamento.eccesso);
|
||
|
||
double valMinAsseY;
|
||
|
||
if (((double)valMinControvalore - (double)valorepercentuale) < 0)
|
||
{
|
||
valMinAsseY = 0;
|
||
}
|
||
else
|
||
{
|
||
valMinAsseY = LibFunction.ArrotondaAxis((double)valMinControvalore - (double)valorepercentuale, LibFunction.tipoArrotondamento.difetto);
|
||
// dato che non può essere negativa viene arrotondata per difetto altrimenti si sarebbe dovuto arrotondare per eccesso
|
||
//ChartArea.AxisY.Minimum = LibFunction.ArrotondaAxis(valMinAsseY, LibFunction.tipoArrotondamento.eccesso);
|
||
}
|
||
|
||
|
||
int numeroIntervalli = 6;
|
||
valMaxAsseY = valMaxAsseY / 1000;
|
||
valMinAsseY = valMinAsseY / 1000;
|
||
|
||
|
||
// Imposto l'intervallo sull'asse Y
|
||
double intervallo = LibFunction.ArrotondaAxis((valMaxAsseY - valMinAsseY) / numeroIntervalli, LibFunction.tipoArrotondamento.eccesso);
|
||
|
||
if (intervallo == 0)
|
||
{
|
||
valMaxAsseY = valMaxAsseY * 1.1;
|
||
intervallo = LibFunction.ArrotondaAxis((valMaxAsseY - valMinAsseY) / numeroIntervalli, LibFunction.tipoArrotondamento.eccesso);
|
||
}
|
||
|
||
|
||
ChartArea.AxisY.Maximum = (valMinAsseY + (intervallo * numeroIntervalli));
|
||
ChartArea.AxisY.Minimum = valMinAsseY;
|
||
ChartArea.AxisY.Interval = intervallo;
|
||
|
||
#endregion
|
||
|
||
#endregion
|
||
// associazione della ChartArea
|
||
graficoCombinato.Area = ChartArea;
|
||
|
||
#region Settaggio delle Series
|
||
|
||
#region Settaggio dei dati asse X
|
||
|
||
|
||
|
||
// imposto i dati
|
||
// override dei dati...
|
||
|
||
DataTable dtDati = datitab.table.Clone();
|
||
dtDati.TableName = "DatiGrafico";
|
||
dtDati.Columns.Add("RilevazioneEffettiva", typeof(Int16));
|
||
|
||
|
||
|
||
|
||
DateTime data = inizio;
|
||
//double intevalloData= differenza.TotalDays / 10;
|
||
double intevalloData = 1;
|
||
DataRow drUltima = null;
|
||
for (int i = 0; i <= totaleGiorni; i++)
|
||
{
|
||
|
||
string strData = data.ToShortDateString();
|
||
// controllo se la data è presente nel datatable di origine
|
||
DataRow[] drResult = datitab.table.Select(" data = '" + strData.Replace("'", "''") + "'");
|
||
|
||
if (drResult.Length > 0)
|
||
{
|
||
drUltima = drResult[0];
|
||
DataRow newRow = dtDati.NewRow();
|
||
|
||
string strControvalore1000 = Convert.ToString(Convert.ToDecimal(drResult[0]["Controvalore"]) / 1000);
|
||
newRow["Controvalore"] = Convert.ToString(Convert.ToDecimal(drResult[0]["Controvalore"]) / 1000);
|
||
string strRosorse1000 = Convert.ToString(Convert.ToDecimal(drResult[0]["RisorseAssociate"]) / 1000);
|
||
newRow["RisorseAssociate"] = Convert.ToString(Convert.ToDecimal(drResult[0]["RisorseAssociate"]) / 1000);
|
||
newRow["Data"] = drResult[0]["Data"];
|
||
newRow["Need_Area"] = drResult[0]["Need_Area"];
|
||
newRow["NomeProgetto"] = drResult[0]["NomeProgetto"];
|
||
newRow["RilevazioneEffettiva"] = 1;
|
||
dtDati.Rows.Add(newRow);
|
||
}
|
||
else
|
||
{
|
||
DataRow newRow = dtDati.NewRow();
|
||
//newRow["Controvalore"] = drUltima["Controvalore"];
|
||
string strControvalore1000 = Convert.ToString(Convert.ToDecimal(drUltima["Controvalore"]) / 1000);
|
||
newRow["Controvalore"] = Convert.ToString(Convert.ToDecimal(drUltima["Controvalore"]) / 1000);
|
||
newRow["RisorseAssociate"] = Convert.ToString(Convert.ToDecimal(drUltima["RisorseAssociate"]) / 1000);
|
||
newRow["Data"] = Convert.ToDateTime(strData);
|
||
newRow["Need_Area"] = drUltima["Need_Area"];
|
||
newRow["NomeProgetto"] = drUltima["NomeProgetto"];
|
||
newRow["RilevazioneEffettiva"] = 0;
|
||
dtDati.Rows.Add(newRow);
|
||
}
|
||
data = data.AddDays(intevalloData);
|
||
}
|
||
|
||
//setFattoreMoltiplicativo(dtDati); // Con la versione di grafico "StepLine" la funzione non dev piu esser richiamata.
|
||
|
||
graficoCombinato.Datasource = dtDati;
|
||
|
||
|
||
#endregion
|
||
|
||
ArrayList objSeries = new ArrayList(); // arraylist contenitore Series
|
||
|
||
//aggiungo la serie Risorse Apportate
|
||
Series sRisorseApportate = new Series("Risorse apportate");
|
||
sRisorseApportate.Color = System.Drawing.Color.Aquamarine;
|
||
sRisorseApportate.Type = SeriesChartType.StackedColumn;
|
||
sRisorseApportate.SetAttribute("AxisXColumnName", "Data");
|
||
sRisorseApportate.SetAttribute("AxisYColumnName", "RisorseAssociate");
|
||
sRisorseApportate.ValueMembersY = sRisorseApportate.ValueMembersY;
|
||
objSeries.Add(sRisorseApportate);
|
||
|
||
//aggiungo la serie ControvaloreMonitorato
|
||
Series sControvaloreMonitorato = new Series("Controvalore monitorato");
|
||
sControvaloreMonitorato.Color = System.Drawing.Color.Blue;
|
||
sControvaloreMonitorato.Type = SeriesChartType.StepLine;
|
||
sControvaloreMonitorato.SetAttribute("AxisXColumnName", "Data");
|
||
sControvaloreMonitorato.SetAttribute("AxisYColumnName", "Controvalore");
|
||
sControvaloreMonitorato.ValueMembersY = sControvaloreMonitorato.ValueMembersY;
|
||
//V
|
||
sControvaloreMonitorato.BorderWidth = 3;
|
||
|
||
//sControvaloreMonitorato.MarkerBorderWidth = 100;
|
||
//sControvaloreMonitorato.MarkerStep = 100;
|
||
|
||
|
||
objSeries.Add(sControvaloreMonitorato);
|
||
|
||
|
||
|
||
#endregion
|
||
|
||
// Aggiungo tutte le serie alla proprietà esposta dal grafico
|
||
graficoCombinato.ChartSeries = objSeries;
|
||
|
||
//graficoCombinato.ColumnWidth = 1;
|
||
graficoCombinato.ShowValueInChart = false;
|
||
|
||
//Khorne (added)
|
||
//disabilito la legenda generata dal grafico, per riscriverla manualmente.
|
||
graficoCombinato.ChartLegend.Enabled = false;
|
||
//Khorne end
|
||
|
||
//Commented By Bido 8 March 2011
|
||
////Imposto la Leggenda
|
||
//graficoCombinato.ChartLegend.LegendStyle = LegendStyle.Row;
|
||
//graficoCombinato.ChartLegend.Docking = LegendDocking.Bottom;
|
||
//graficoCombinato.ChartLegend.Alignment = StringAlignment.Center;
|
||
|
||
// Disegno
|
||
graficoCombinato.Draw();
|
||
|
||
//New Bido Work 9 March 2011
|
||
System.Reflection.Assembly thisExe;
|
||
thisExe = System.Reflection.Assembly.GetExecutingAssembly();
|
||
//System.IO.Stream fileImmagineA = thisExe.GetManifestResourceStream(UtilityManager.getAppSetting("ImmagineA_S83"));
|
||
//System.IO.Stream fileImmagineB = thisExe.GetManifestResourceStream(UtilityManager.getAppSetting("ImmagineB_S83"));
|
||
//System.IO.Stream fileImmagineC = thisExe.GetManifestResourceStream(UtilityManager.getAppSetting("ImmagineC_S83"));
|
||
|
||
ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
|
||
//page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Importi x 1.000", document.getMargineLeft() + 450, document.getLastPos() + 6, 512, 12, Globals.OpenTypeFontVerdana, 7));
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Importi x 1.000", document.getMargineLeft() + 450, document.getLastPos(), 512, 12, Globals.OpenTypeFontVerdana, 7));
|
||
|
||
int deltaY = -3;
|
||
//Khorne (added)
|
||
//page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(document.getMargineLeft() + 95, document.getLastPos() + 185 + deltaY, 15, 1
|
||
// , new ceTe.DynamicPDF.RgbColor(System.Drawing.Color.Blue.R, System.Drawing.Color.Blue.G, System.Drawing.Color.Blue.B)
|
||
// , new ceTe.DynamicPDF.RgbColor(System.Drawing.Color.Blue.R, System.Drawing.Color.Blue.G, System.Drawing.Color.Blue.B)));
|
||
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(document.getMargineLeft() + 265, document.getLastPos() + deltaY + 205, 15, 1
|
||
, new ceTe.DynamicPDF.RgbColor(System.Drawing.Color.Blue.R, System.Drawing.Color.Blue.G, System.Drawing.Color.Blue.B)
|
||
, new ceTe.DynamicPDF.RgbColor(System.Drawing.Color.Blue.R, System.Drawing.Color.Blue.G, System.Drawing.Color.Blue.B)));
|
||
|
||
//page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Controvalore Monitorato", document.getMargineLeft() + 115, document.getLastPos() + 180 + deltaY, 512, 12, Globals.OpenTypeFontVerdana, 9));
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Controvalore Monitorato", document.getMargineLeft() + 285, document.getLastPos() + deltaY + 200, 512, 12, Globals.OpenTypeFontVerdana, 8));
|
||
|
||
//page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(document.getMargineLeft() + 270, document.getLastPos() + 185 + deltaY, 15, 1
|
||
// , new ceTe.DynamicPDF.RgbColor(System.Drawing.Color.Aquamarine.R, System.Drawing.Color.Aquamarine.G, System.Drawing.Color.Aquamarine.B)
|
||
// , new ceTe.DynamicPDF.RgbColor(System.Drawing.Color.Aquamarine.R, System.Drawing.Color.Aquamarine.G, System.Drawing.Color.Aquamarine.B)));
|
||
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(document.getMargineLeft() + 420, document.getLastPos() + deltaY + 205, 15, 1
|
||
, new ceTe.DynamicPDF.RgbColor(System.Drawing.Color.Aquamarine.R, System.Drawing.Color.Aquamarine.G, System.Drawing.Color.Aquamarine.B)
|
||
, new ceTe.DynamicPDF.RgbColor(System.Drawing.Color.Aquamarine.R, System.Drawing.Color.Aquamarine.G, System.Drawing.Color.Aquamarine.B)));
|
||
|
||
//page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Risorse apportate", document.getMargineLeft() + 290, document.getLastPos() + 180 + deltaY, 512, 12, Globals.OpenTypeFontVerdana, 9));
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Risorse apportate", document.getMargineLeft() + 440, document.getLastPos() + deltaY + 200, 512, 12, Globals.OpenTypeFontVerdana, 8));
|
||
|
||
|
||
////aggiorno il puntatore alla posizione da cui si può scrivere
|
||
float heightChart = (float)graficoCombinato.Height.Value;
|
||
//document.setLastPos(heightChart);
|
||
document.setLastPos(163);
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// Disegna formato solo testuale.
|
||
/// Se un'area/progetto è oggetto di monitoraggio ma il suo controvalore monitorato è pari a 0, si stampa solo un testo introduttivo.
|
||
/// </summary>
|
||
/// <param name="dataThread"></param>
|
||
public void writeSezioneFormatoSoloTesto(DataThread dataThread)
|
||
{
|
||
DocumentPDF document = dataThread.DocumentPDF;
|
||
|
||
//calcola se entra nella pagina altrimenti aggiunge una nuova pagina. In questa sezione il # di righe è fissato
|
||
if (document.checkMargin(30))
|
||
document.addPage();
|
||
|
||
ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
|
||
document.setChapterHeader(_testointroduttivo);
|
||
|
||
//This flag will be used in S43Bis to check if S83 was not printed as normal section and it's just printed as note,
|
||
//in this case S43BIS will be printed just after S83 note as S84 & S85 will not be printed.
|
||
dataThread.UltimaSezioneStampata = "S134bis";
|
||
|
||
////aggiorno il puntatore alla posizione da cui si può scrivere
|
||
//document.setLastPos(30);
|
||
document.addPage();
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// Funzione utilizzata per la vecchia versione del grafico che prevedeva una tipo di grafico "Line" anziché "StepLine".
|
||
/// Con la nuova versione "StepLine" la funzione non serve più.
|
||
/// Mantengo in cao di cambio specifiche.
|
||
/// </summary>
|
||
/// <param name="dataTable"></param>
|
||
private void setFattoreMoltiplicativo(DataTable dataTable)
|
||
{
|
||
DataRow[] righeIndici = dataTable.Select(" RilevazioneEffettiva = 1");
|
||
int indiceInizio = 0;
|
||
int indiceFine = 0;
|
||
int numIntervalli = 0;
|
||
decimal ctvInizio = 0;
|
||
decimal ctvFine = 0;
|
||
decimal fattoreMoltiplicativo = 0;
|
||
for (int i = 0; i < righeIndici.Length; i++)
|
||
{
|
||
if ((i + 1) < righeIndici.Length)
|
||
{
|
||
indiceInizio = (int)dataTable.Rows.IndexOf((DataRow)righeIndici[i]);
|
||
indiceFine = (int)dataTable.Rows.IndexOf((DataRow)righeIndici[i + 1]);
|
||
if (indiceInizio + 1 < indiceFine)
|
||
{
|
||
ctvInizio = (decimal)dataTable.Rows[indiceInizio]["Controvalore"];
|
||
ctvFine = (decimal)dataTable.Rows[indiceFine]["Controvalore"];
|
||
numIntervalli = indiceFine - indiceInizio;
|
||
fattoreMoltiplicativo = (ctvFine - ctvInizio) / numIntervalli;
|
||
for (int j = indiceInizio + 1; j < indiceFine; j++)
|
||
{
|
||
//ctv per ogni riga
|
||
dataTable.Rows[j]["Controvalore"] = (decimal)dataTable.Rows[j - 1]["Controvalore"] + fattoreMoltiplicativo;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
}
|
||
}
|
||
|