using System; using System.Web; using System.Text; using System.Data; using System.Collections; using PDFGenerator.BusinessLayer.DataSection; using PDFGenerator.BusinessLayer; using System.Collections.Generic; public class DSS158PiramideModello : IDataSection { #region IDataSection Members public StructColor zzztoBeFound = new StructColor(); public DataSectionResult zzzgetDataSection(List tabelleSessione, string querySql, DataThread dataThread) { try { DataSectionResult dsr = new DataSectionResult(); DataTable dt = SectionManager.GetDataSection(tabelleSessione, querySql, dataThread); if (Convert.ToDecimal(dt.Rows[0]["Totale"]) == 0) { dsr.DatiSezione = null; dsr.Esito = 0; return dsr; } //Decimal ctvTotale = 0; DataSetS158 ds158 = new DataSetS158(); DataRow dr; bool first = true; double percInv = 0; foreach (DataRow row in dt.Rows) { if (Convert.ToDouble(row["TOTALE"]) != 0) { if (row["need_breve"].ToString() == "Inv") { if (first) { dr = ds158.AreeBisogno.NewRow(); dr["Percentuale"] = row["totale_percentuale"]; percInv = Convert.ToDouble(row["totale_percentuale"]); ds158.AreeBisogno.Rows.Add(dr); } if (percInv > 0 && (Convert.ToInt32(row["NumeroProgettiInv"]) > 1 || (row["nome_progetto"].ToString() != "Progetto investimento"))) { dr = ds158.Investimenti.NewRow(); dr["progetto"] = row["nome_progetto"]; dr["Percentuale"] = row["perc_need"]; dr["Orizzonte"] = row["orizz_temp"]; dr["Controvalore"] = row["Controvalore"]; ds158.Investimenti.Rows.Add(dr); //if (first) //{ // dr = ds158.TotaleConti.NewRow(); // dr["Descrizione"] = "TOTALE"; // dr["Percentuale"] = row["totale_percentuale"]; // dr["Orizzonte"] = " "; // first = false; // ds158.TotaleConti.Rows.Add(dr); //} } else first = false; } else { dr = ds158.AreeBisogno.NewRow(); dr["Percentuale"] = row["totale_percentuale"]; ds158.AreeBisogno.Rows.Add(dr); } } } dsr.DatiSezione = ds158; //dsr.Esito = ds37.AreeBisogno.Rows.Count; dsr.Esito = ds158.Investimenti.Rows.Count; return dsr; } catch (Exception ex) { throw ex; } } public DataSectionResult getDataSection(List tabelleSessione, string querySql, DataThread dataThread) { try { DataSectionResult dsr = new DataSectionResult(); DataTable dt = SectionManager.GetDataSection(tabelleSessione, querySql, dataThread); DataSetS158 ds158 = new DataSetS158(); if (!(dt.Rows.Count == 1 && dt.Rows[0]["NomePrg"].Equals("Progetto investimento"))) { foreach (DataRow row in dt.Rows) { DataRow dr = ds158.Investimenti.NewRow(); dr["progetto"] = row["NomePrg"]; dr["Rischio (VaR %)"] = row["VarPrg"]; dr["Orizzonte"] = row["OrizzTempPrg"]; dr["Controvalore (€)"] = row["ControvalorePrg"]; ds158.Investimenti.Rows.Add(dr); } } dsr.DatiSezione = ds158; dsr.Esito = ds158.Investimenti.Rows.Count; return dsr; } catch (Exception ex) { throw ex; } } #endregion }