492 lines
22 KiB
C#
492 lines
22 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;
|
|
using ContrattoSei.Utilities;
|
|
using ceTe.DynamicPDF.PageElements;
|
|
|
|
namespace PDFGenerator.Presentation.Section
|
|
{
|
|
class S176 : ISezione
|
|
{
|
|
#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;
|
|
}
|
|
|
|
public void writeSezione(DataThread dataThread)
|
|
{
|
|
|
|
DocumentPDF document = dataThread.DocumentPDF;
|
|
ceTe.DynamicPDF.Merger.ImportedPage page;
|
|
|
|
DataSetS176 set = (DataSetS176)dataThread.Data.DatiSezione;
|
|
string nota = dataThread.SezioneReport.Nota;
|
|
|
|
DateTime dtSottoscrizione = Convert.ToDateTime(set.Prodotto.Rows[0]["DataSottoscrizione"].ToString());
|
|
DateTime dtTrimestrale = Convert.ToDateTime(set.DatiGrafico.Rows[0]["DataTrim"].ToString());
|
|
|
|
// Confrontare la Data di Riferimento con la Data di sottoscrizione, se < 4 settimane return
|
|
if ((((dtTrimestrale - dtSottoscrizione).TotalDays) / 7) < 4)
|
|
{
|
|
page = document.getCurrentPage();
|
|
|
|
// document.setChapterHeader(nota, 0, 520, 8);
|
|
|
|
FormattedTextArea textNota = new FormattedTextArea(nota, document.getMargineLeft(), document.getLastPos(), 510, 50, new ceTe.DynamicPDF.FontFamily("pipp", Globals.OpenTypeFontVerdana, Globals.OpenTypeFontVerdanaB, Globals.OpenTypeFontVerdanaZ, Globals.OpenTypeFontVerdanaZ), 7, false);
|
|
textNota.Height = textNota.GetRequiredHeight();
|
|
textNota.Style.Paragraph.Align = ceTe.DynamicPDF.TextAlign.Justify;
|
|
page.Elements.Add(textNota);
|
|
return;
|
|
}
|
|
|
|
RgbColor line1Color = new RgbColor(192, 0, 0);
|
|
RgbColor line2Color = new RgbColor(0, 112, 192);
|
|
RgbColor line3Color = new RgbColor(95, 215, 95);
|
|
|
|
//string tempTesto = "";
|
|
string Contratto = set.Tables["Prodotto"].Rows[0]["Contratto"].ToString();
|
|
|
|
document.setSezTitolo(dataThread.SezioneReport.Titolo);
|
|
string tempTesto = dataThread.SezioneReport.TestoIntroduttivo.Replace("$/Contratto/$", Contratto);
|
|
document.setChapterHeader(tempTesto, 0, 520, 8);
|
|
//document.setChapterHeader(tempTesto);
|
|
|
|
DatiTabella datitab = new DatiTabella();
|
|
//CombinationChart graficoCombinato = new CombinationChart(500, 200, Resolution);
|
|
CombinationChartS176 graficoCombinato = new CombinationChartS176(500, 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]["DataRiferimento"]);
|
|
|
|
//Adriano: prova per prendere come ultima data quella di trim:
|
|
|
|
DateTime fine = Convert.ToDateTime(datitab.table.Rows[datitab.table.Rows.Count - 1]["DataTrim"]);
|
|
|
|
//originale:
|
|
//DateTime fine = Convert.ToDateTime(datitab.table.Rows[datitab.table.Rows.Count - 1]["DataRiferimento"]);
|
|
|
|
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();
|
|
//V Sforamento del footer nel caso di nota sulla S83
|
|
//graficoCombinato.PositionY = (int)(document.getLastPos());
|
|
graficoCombinato.PositionY = (int)(document.getLastPos()) - 15;
|
|
|
|
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 = true; // mostra le label per il primo e per l'ultimo valore sull'asse X
|
|
ChartArea.AxisX.LabelStyle.Font = new Font("verdana", 5);
|
|
|
|
ChartArea.AxisX.IntervalType = DateTimeIntervalType.Auto;
|
|
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.Dot;
|
|
ChartArea.AxisY.MajorGrid.Enabled = true;
|
|
ChartArea.AxisY.MinorTickMark.Size = 2F;
|
|
ChartArea.AxisY.LabelStyle.Format = "##.##";
|
|
ChartArea.AxisY.LabelStyle.Font = new Font("verdana", 6F);
|
|
|
|
//imposto i valori massimi dell'asse Y a seconda del controvalore massimo + 10%
|
|
|
|
//recupero il controvalore massimo che è il massimo tra il campo "Controvalore", "ControvaloreProtetto" e "Fondi"
|
|
decimal valMAxControvalore;
|
|
decimal maxControvalore = Convert.ToDecimal(datitab.table.Compute("Max(Controvalore)", string.Empty));
|
|
decimal maxControvaloreProtetto = Convert.ToDecimal(datitab.table.Compute("Max(ControvaloreProtetto)", string.Empty));
|
|
decimal maxFondi = Convert.ToDecimal(datitab.table.Compute("Max(ControvaloreMonitorato)", string.Empty));
|
|
|
|
//recupero il controvalore minimo che è il minimo tra il campo "Controvalore", "RisorseAssociate" e "Fondi"
|
|
|
|
decimal valMinControvalore;
|
|
decimal minControvalore = Convert.ToDecimal(datitab.table.Compute("Min(Controvalore)", string.Empty));
|
|
decimal minControvaloreProtetto = Convert.ToDecimal(datitab.table.Compute("Min(ControValoreProtetto)", string.Empty));
|
|
decimal minFondi = Convert.ToDecimal(datitab.table.Compute("Min(ControvaloreMonitorato)", string.Empty));
|
|
|
|
valMAxControvalore = Math.Max(maxControvalore, Math.Max(maxControvaloreProtetto, maxFondi));
|
|
valMinControvalore = Math.Min(minControvalore, Math.Min(minControvaloreProtetto, minFondi));
|
|
|
|
|
|
//if (maxControvalore < maxControvaloreProtetto)
|
|
// valMAxControvalore = maxControvaloreProtetto;
|
|
//else
|
|
// valMAxControvalore = maxControvalore;
|
|
|
|
|
|
|
|
|
|
//if (minControvalore < minControvaloreProtetto)
|
|
// valMinControvalore = minControvalore;
|
|
//else
|
|
// valMinControvalore = minControvaloreProtetto;
|
|
|
|
|
|
valMAxControvalore = Math.Ceiling(valMAxControvalore);
|
|
valMinControvalore = Math.Ceiling(valMinControvalore);
|
|
//aggiungo 10%
|
|
decimal valorepercentuale;
|
|
valorepercentuale = (valMAxControvalore / 100) * 10;
|
|
|
|
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);
|
|
}
|
|
|
|
valMinAsseY = 0;
|
|
|
|
int numeroIntervalli = 6;
|
|
|
|
// 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(" datariferimento = '" + strData.Replace("'", "''") + "'");
|
|
|
|
if (drResult.Length > 0)
|
|
{
|
|
drUltima = drResult[0];
|
|
DataRow newRow = dtDati.NewRow();
|
|
newRow["Controvalore"] = drResult[0]["Controvalore"];
|
|
newRow["ControvaloreProtetto"] = drResult[0]["ControvaloreProtetto"];
|
|
newRow["ControvaloreMonitorato"] = drResult[0]["ControvaloreMonitorato"];
|
|
newRow["DataRiferimento"] = drResult[0]["DataRiferimento"];
|
|
newRow["RilevazioneEffettiva"] = 1;
|
|
dtDati.Rows.Add(newRow);
|
|
}
|
|
else
|
|
{
|
|
DataRow newRow = dtDati.NewRow();
|
|
newRow["Controvalore"] = drUltima["Controvalore"];
|
|
newRow["ControvaloreProtetto"] = drUltima["ControvaloreProtetto"];
|
|
newRow["ControvaloreMonitorato"] = drUltima["ControvaloreMonitorato"];
|
|
newRow["DataRiferimento"] = Convert.ToDateTime(strData);
|
|
newRow["RilevazioneEffettiva"] = 0;
|
|
dtDati.Rows.Add(newRow);
|
|
}
|
|
|
|
//PROVA PER METTERE COME ULTIMA DATA LA DATA TRIM
|
|
//if (i == totaleGiorni-1)
|
|
// data = dtTrimestrale;
|
|
//else
|
|
// data = data.AddDays(intevalloData);
|
|
//
|
|
//originale:
|
|
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 ControvaloreProtetto
|
|
Series sControvalore = new Series("Controvalore");
|
|
//sControvalore.Color = System.Drawing.Color.FromArgb((int)line1Color.R, (int)line1Color.G, (int)line1Color.B);
|
|
sControvalore.Color = System.Drawing.Color.FromArgb(192, 0, 0);
|
|
sControvalore.Type = SeriesChartType.StepLine;
|
|
sControvalore.SetAttribute("AxisXColumnName", "DataRiferimento");
|
|
sControvalore.SetAttribute("AxisYColumnName", "Controvalore");
|
|
sControvalore.BorderWidth = 3;
|
|
objSeries.Add(sControvalore);
|
|
|
|
|
|
//aggiungo la serie ControvaloreProtetto
|
|
Series sControvaloreProtetto = new Series("ControvaloreProtetto");
|
|
//sControvaloreProtetto.Color = System.Drawing.Color.FromArgb((int)line2Color.R, (int)line2Color.G, (int)line2Color.B);
|
|
sControvaloreProtetto.Color = System.Drawing.Color.FromArgb(0, 112, 192);
|
|
sControvaloreProtetto.Type = SeriesChartType.StepLine;
|
|
sControvaloreProtetto.SetAttribute("AxisXColumnName", "DataRiferimento");
|
|
sControvaloreProtetto.SetAttribute("AxisYColumnName", "ControvaloreProtetto");
|
|
sControvaloreProtetto.BorderWidth = 3;
|
|
objSeries.Add(sControvaloreProtetto);
|
|
|
|
|
|
//aggiungo la serie Controvalore
|
|
Series sControvaloreMonitorato = new Series("ControvaloreMonitorato");
|
|
//sGestioneFondi.Color = System.Drawing.Color.FromArgb((int)line3Color.R, (int)line3Color.G, (int)line3Color.B);
|
|
sControvaloreMonitorato.Color = System.Drawing.Color.FromArgb(95, 215, 95);
|
|
sControvaloreMonitorato.Type = SeriesChartType.StackedColumn;
|
|
sControvaloreMonitorato.SetAttribute("AxisXColumnName", "DataRiferimento");
|
|
sControvaloreMonitorato.SetAttribute("AxisYColumnName", "ControvaloreMonitorato");
|
|
sControvaloreMonitorato.BorderWidth = 3;
|
|
objSeries.Add(sControvaloreMonitorato);
|
|
|
|
|
|
//Adriano prova per evitare sovrapposizione delle linee
|
|
|
|
//double avgControvalore = Convert.ToDouble(set.DatiGrafico.Compute("AVG(Controvalore)", string.Empty));
|
|
//double avgControvaloreProtetto = Convert.ToDouble(set.DatiGrafico.Compute("AVG(ControvaloreProtetto)", string.Empty));
|
|
|
|
//if (avgControvalore - avgControvaloreProtetto < 100)
|
|
// sControvalore.BorderWidth = 6;
|
|
//--Adriano prova per evitare sovrapposizione delle linee
|
|
|
|
#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 = document.getCurrentPage();
|
|
|
|
int deltaY = -3;
|
|
|
|
float xStart = document.getMargineLeft() + 50;
|
|
float yPosition = document.getLastPos() + 180;
|
|
|
|
float lineWidth = 20;
|
|
float label1Width = 80;
|
|
float label2Width = 100;
|
|
//float label3Width = 250;
|
|
|
|
float line1XPosition = xStart + 20;
|
|
float label1XPosition = line1XPosition + lineWidth;
|
|
|
|
float line2XPosition = label1XPosition + label1Width;
|
|
float label2XPosition = line2XPosition + lineWidth;
|
|
|
|
float line3XPosition = label2XPosition + label2Width;
|
|
float label3XPosition = line3XPosition + lineWidth;
|
|
|
|
string label1String = "Controvalore (€)";
|
|
string label2String = "Controvalore Protetto (€)";
|
|
string label3String = "Gestione separata e Fondi monetari (€)";
|
|
|
|
// Disegno il rettangolo grigio( footer del grafico)
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(xStart, yPosition - 5, 430, 20, 0, new RgbColor(232, 236, 237)));
|
|
|
|
//Linea 1
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(line1XPosition, yPosition + 3, 15, 2, line1Color, line1Color));
|
|
//Label 1
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(label1String, label1XPosition, yPosition, 512, 30, Globals.OpenTypeFontVerdana, 7));
|
|
|
|
//Linea 2
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(line2XPosition, yPosition + 3, 15, 2, line2Color, line2Color));
|
|
//Label 2
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(label2String, label2XPosition, yPosition, 512, 30, Globals.OpenTypeFontVerdana, 7));
|
|
|
|
//Linea 3
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(line3XPosition, yPosition + deltaY, 12, 12, line3Color, line3Color));
|
|
//Label 3
|
|
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(label3String, label3XPosition, yPosition, 512, 30, Globals.OpenTypeFontVerdana, 7));
|
|
|
|
// FINE LEGENDA
|
|
|
|
////aggiorno il puntatore alla posizione da cui si può scrivere
|
|
float heightChart = (float)graficoCombinato.Height.Value;
|
|
//document.setLastPos(heightChart);
|
|
document.setLastPos(180);
|
|
|
|
// document.setChapterHeader(nota, 0, 520, 8);
|
|
|
|
FormattedTextArea text = new FormattedTextArea(nota, document.getMargineLeft(), document.getLastPos(), 510, 50, new ceTe.DynamicPDF.FontFamily("pipp", Globals.OpenTypeFontVerdana, Globals.OpenTypeFontVerdanaB, Globals.OpenTypeFontVerdanaZ, Globals.OpenTypeFontVerdanaZ), 7, false);
|
|
text.Height = text.GetRequiredHeight();
|
|
text.Style.Paragraph.Align = ceTe.DynamicPDF.TextAlign.Justify;
|
|
page.Elements.Add(text);
|
|
}
|
|
|
|
|
|
/// <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
|
|
}
|
|
} |