151 lines
6.0 KiB
C#
151 lines
6.0 KiB
C#
|
|
using System;
|
|
using System.Data;
|
|
//using Resources;
|
|
using PDFGenerator.BusinessLayer.DataSection;
|
|
using PDFGenerator;
|
|
using PDFGenerator.BusinessLayer;
|
|
using System.Collections.Generic;
|
|
|
|
/// <summary>
|
|
/// Summary description for DSS82DatiSintetici
|
|
/// </summary>
|
|
public class DSS82DatiSintetici : IDataSection
|
|
{
|
|
private Int32? _ordinamentoProgettoPerAreeMonitorate;
|
|
FormatNum conv = new FormatNum();
|
|
private DataRow getRowDatiSintesi(DataTable dt, string area, string nomeprogetto, Int32? ordinamento)
|
|
{
|
|
DataRow[] rowArray = null;
|
|
|
|
if (dt == null)
|
|
return null;
|
|
|
|
|
|
if (area.ToUpper() == "INV")
|
|
{
|
|
// Progetti
|
|
if (ordinamento == null)
|
|
rowArray = dt.Select(" nome_progetto = '" + nomeprogetto.Replace("'", "''") + "' and NEED_AREA = '" + area.Replace("'", "''") + "'");
|
|
else
|
|
rowArray = dt.Select(" ordinamento_progetto = " + ordinamento.ToString() + " and nome_progetto = '" + nomeprogetto.Replace("'", "''") + "' and NEED_AREA = '" + area.Replace("'", "''") + "'");
|
|
}
|
|
else
|
|
{
|
|
// no progetti
|
|
rowArray = dt.Select(" NEED_AREA = '" + area.Replace("'", "''") + "'");
|
|
}
|
|
|
|
if (rowArray.Length > 0)
|
|
{
|
|
return rowArray[0];
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public Int32? OrdinamentoProgettoPerAreeMonitorate { set { _ordinamentoProgettoPerAreeMonitorate = value;} }
|
|
public DataSectionResult getDataSection(List<SessionStruct> tabelleSessione, string querySql, DataThread dataThread)
|
|
{
|
|
|
|
|
|
DataSectionResult dsr = new DataSectionResult();
|
|
DataTable dt = SectionManager.GetDataSection(tabelleSessione, querySql, dataThread);
|
|
|
|
|
|
DataSetS82 ds82 = new DataSetS82();
|
|
DataSetS82.DatiSintetici_DettaglioRow drDettaglio;
|
|
DataSetS82.DT_CoperturaRow drCopertura;
|
|
DataSetS82.HeaderRow hRow;
|
|
DataSetS82.SeparatoreRow separatore;
|
|
DataSetS82.DT_TabellaBassaRow tabBassa;
|
|
|
|
|
|
DataRow rowDatiSintesi = getRowDatiSintesi(dt, dataThread.Area, dataThread.Progetto, _ordinamentoProgettoPerAreeMonitorate);
|
|
|
|
|
|
if(rowDatiSintesi != null)
|
|
{
|
|
if (rowDatiSintesi["need_area"].ToString().ToUpper() == dataThread.Area.ToUpper())
|
|
{
|
|
drDettaglio = ds82.DatiSintetici_Dettaglio.NewDatiSintetici_DettaglioRow();
|
|
drDettaglio.Descrizione = "Controvalore";//Resource.S82_Campo_ControvaloreAttuale;
|
|
drDettaglio.Valore = conv.ConvertNum(rowDatiSintesi["ControvaloreAttuale"], 2) + " €";
|
|
ds82.DatiSintetici_Dettaglio.Rows.Add(drDettaglio);
|
|
|
|
//Header.. Controvalore e Rischio
|
|
hRow = ds82.Header.NewHeaderRow();
|
|
hRow.Descrizione = "Controvalore e Rischio";
|
|
ds82.Header.AddHeaderRow(hRow);
|
|
|
|
separatore = ds82.Separatore.NewSeparatoreRow();
|
|
separatore.Descrizione = "";
|
|
ds82.Separatore.AddSeparatoreRow(separatore);
|
|
|
|
// VAR ATTUALE
|
|
drDettaglio = ds82.DatiSintetici_Dettaglio.NewDatiSintetici_DettaglioRow();
|
|
if (rowDatiSintesi["var_needarea"] != DBNull.Value)
|
|
{
|
|
if (rowDatiSintesi["var_needareastring"].ToString().Trim().Length == 0)
|
|
drDettaglio.Valore = conv.ConvertNum(rowDatiSintesi["var_needarea"]) + " %";
|
|
else
|
|
drDettaglio.Valore = conv.ConvertNum(rowDatiSintesi["var_needareastring"]).ToString();
|
|
}
|
|
else
|
|
drDettaglio.Valore = rowDatiSintesi["var_needareaString"].ToString();
|
|
|
|
drDettaglio.Descrizione = "Rischio Mercato (VaR %)";
|
|
|
|
ds82.DatiSintetici_Dettaglio.Rows.Add(drDettaglio);
|
|
|
|
// GRADO COPERTURA
|
|
|
|
drCopertura = ds82.DT_Copertura.NewDT_CoperturaRow();
|
|
drCopertura.Descrizione = "Copertura";
|
|
if (rowDatiSintesi["copertura_needarea"] != DBNull.Value)
|
|
drCopertura.Valore = conv.ConvertNum(rowDatiSintesi["copertura_needarea"]) + " %";
|
|
else
|
|
drCopertura.Valore = rowDatiSintesi["copertura_needareaString"].ToString();
|
|
//Fix 4 agosto riportare la copertura solo quando il valore è diverso da 100
|
|
if (drCopertura.Valore != "100,00 %")
|
|
ds82.DT_Copertura.Rows.Add(drCopertura);
|
|
|
|
|
|
|
|
//Peso Percentuale ctv
|
|
tabBassa = ds82.DT_TabellaBassa.NewDT_TabellaBassaRow();
|
|
tabBassa.Descrizione = "Peso percentuale controvalore";
|
|
|
|
DataView dwPeso = new DataView(dataThread.PesoPercentuale);
|
|
dwPeso.RowFilter = " AreaBisogno='" + dataThread.Area + "'";
|
|
DataTable dtPeso = dwPeso.ToTable();
|
|
tabBassa.Valore = conv.ConvertNum(dtPeso.Rows[0]["PesoPercentuale"]) + " %";
|
|
|
|
ds82.DT_TabellaBassa.Rows.Add(tabBassa);
|
|
|
|
|
|
|
|
//Rischio Relativo
|
|
tabBassa = ds82.DT_TabellaBassa.NewDT_TabellaBassaRow();
|
|
tabBassa.Descrizione = "Rischio relativo";
|
|
|
|
DataView dwRischio = new DataView(dataThread.RischioRelativo);
|
|
dwRischio.RowFilter = " AreaBisogno='" + dataThread.Area + "'";
|
|
DataTable dtRischio = dwRischio.ToTable();
|
|
tabBassa.Valore =dtRischio.Rows[0]["RischioRelativoString"].ToString().ToLower()=="n.c." ? "n.c.": conv.ConvertNum(Convert.ToDecimal(dtRischio.Rows[0]["RischioRelativo"]),2) + " %";
|
|
|
|
|
|
ds82.DT_TabellaBassa.Rows.Add(tabBassa);
|
|
}
|
|
}
|
|
|
|
dsr.DatiSezione = ds82;
|
|
dsr.Esito = ds82.DatiSintetici_Dettaglio.Rows.Count;
|
|
|
|
return dsr;
|
|
|
|
}
|
|
}
|