325 lines
16 KiB
C#
325 lines
16 KiB
C#
using System;
|
|
using System.Web;
|
|
using System.Text;
|
|
using System.Data;
|
|
using System.Collections;
|
|
using System.Configuration;
|
|
using PDFGenerator.BusinessLayer.DataSection;
|
|
using PDFGenerator.BusinessLayer;
|
|
using System.Collections.Generic;
|
|
using PDFGenerator;
|
|
using DataAccessLayer;
|
|
|
|
namespace PDFGenerator.BusinessLayer.DataSection
|
|
{
|
|
public class DSFD43BISProdottiAreeBisogno : IDataSection
|
|
{
|
|
private Int32? _ordinamentoProgettoPerAreeMonitorate;
|
|
|
|
public Int32? OrdinamentoProgettoPerAreeMonitorate { set { _ordinamentoProgettoPerAreeMonitorate = value; } }
|
|
|
|
|
|
#region IDataSection Members
|
|
|
|
public DataSectionResult getDataSection(List<SessionStruct> tabelleSessione, string querySql, DataThread dataThread)
|
|
{
|
|
try
|
|
{
|
|
DataSectionResult dsr = new DataSectionResult();
|
|
DataSetS43BIS ds43BIS = new DataSetS43BIS();
|
|
|
|
DataSetS43BIS.ProdottiAreeBisognoRow drDettaglioProdotti;
|
|
DataSetS43BIS.ProdottiTotaleRow drTotali;
|
|
|
|
FormatNum conv = new FormatNum();
|
|
string area = string.Empty;
|
|
string nomeProgetto = string.Empty;
|
|
|
|
|
|
ds43BIS.ProdottiAreeBisogno.Columns["Controvalore"].Caption = "Controvalore <br> € ";
|
|
|
|
DataTable dt = SectionManager.GetDataSection(tabelleSessione, querySql, dataThread);
|
|
//DataRow[] drS43BIS = dt.Select("ORDINAMENTO_PROGETTO =" + _ordinamentoProgettoPerAreeMonitorate + " and needarea='" + dataThread.Area + "' And nome_progetto='" + dataThread.Progetto.Replace("'", "''") + "'");
|
|
|
|
/************************** Modifica Nota Dinamica 11-03-2021 - Pino *************************************************************/
|
|
DataTable dtFlagNota = SectionManager.GetDataSection(tabelleSessione, "[C6StagingPeriodico].[ClienteProdottiFAI]", dataThread);
|
|
DataSetS43BIS.FlagNotaFAIRow drFlagFAI;
|
|
if (dtFlagNota.Rows.Count > 0)
|
|
{
|
|
drFlagFAI = ds43BIS.FlagNotaFAI.NewFlagNotaFAIRow();
|
|
drFlagFAI["FlagFAI"] = dtFlagNota.Rows[0][0].ToString();
|
|
drFlagFAI["DataFAI"] = dtFlagNota.Rows[0][1].ToString();
|
|
|
|
ds43BIS.FlagNotaFAI.AddFlagNotaFAIRow(drFlagFAI);
|
|
}
|
|
/*********************************************************************************************************************************/
|
|
|
|
|
|
DataTable distinctTable = dt.DefaultView.ToTable(true, "needarea", "nome_progetto");
|
|
DataRow[] drTotaleProgettiInvestimento = distinctTable.Select(" needarea = 'Inv'");
|
|
int totaleProgettiInvestimento = drTotaleProgettiInvestimento.Length;
|
|
|
|
|
|
//foreach (DataRow row in drS43BIS)
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
#region Totali
|
|
|
|
if (area != row["needarea"].ToString() || nomeProgetto != row["nome_progetto"].ToString())
|
|
{
|
|
drTotali = ds43BIS.ProdottiTotale.NewProdottiTotaleRow();
|
|
drTotali.AreaBisogno = row["needareades"].ToString();
|
|
if (row["needarea"].ToString().ToLower() == "na")
|
|
drTotali.Totale = "TOTALE RISORSE " + row["needareades"].ToString().ToUpper();
|
|
else
|
|
{
|
|
if (row["needarea"].ToString().ToLower() == "inv")
|
|
{
|
|
// Se c'è un solo progetto in investimento chiamato "progetto investimento" il totale deve essere TOTALE INVESTIMENTO
|
|
if (totaleProgettiInvestimento == 1 && row["nome_progetto"].ToString().ToLower() == "progetto investimento")
|
|
drTotali.Totale = "TOTALE " + row["needareades"].ToString().ToUpper();
|
|
else
|
|
drTotali.Totale = "TOTALE " + row["nome_progetto"].ToString().ToUpper();
|
|
|
|
}
|
|
else
|
|
drTotali.Totale = "TOTALE " + row["needareades"].ToString().ToUpper();
|
|
}
|
|
|
|
drTotali.Progetto = row["nome_progetto"].ToString();
|
|
drTotali.CodiceAreaBisogno = row["needarea"].ToString();
|
|
|
|
if (row["needarea"].ToString().ToLower() == "inv")
|
|
{
|
|
#region Controvalore, Var per area bisogno Investimento
|
|
|
|
//Controvalore, Var e copertura per area bisogno Investimento
|
|
drTotali.Controvalore = Convert.ToDecimal(row["somma_controval_need_prog"]);
|
|
|
|
if (row["var_need_progString"] != DBNull.Value)
|
|
drTotali.Var = row["var_need_progString"].ToString();
|
|
else
|
|
drTotali.Var = conv.ConvertNum(row["var_need_prog"]);
|
|
|
|
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
#region Controvalore, Var per area bisogno diversa da Investimento
|
|
|
|
// Controvalore, Var e copertura per area bisogno diversa da Investimento
|
|
drTotali.Controvalore = Convert.ToDecimal(row["somma_controval_needarea"]);
|
|
|
|
if (row["var_needareaString"] != DBNull.Value)
|
|
drTotali.Var = row["var_needareaString"].ToString();
|
|
else
|
|
drTotali.Var = conv.ConvertNum(row["var_needarea"]);
|
|
|
|
|
|
#endregion
|
|
}
|
|
|
|
ds43BIS.ProdottiTotale.AddProdottiTotaleRow(drTotali);
|
|
}
|
|
#endregion
|
|
|
|
area = row["needarea"].ToString();
|
|
nomeProgetto = row["nome_progetto"].ToString();
|
|
|
|
#region Dettaglio
|
|
|
|
drDettaglioProdotti = ds43BIS.ProdottiAreeBisogno.NewProdottiAreeBisognoRow();
|
|
drDettaglioProdotti.AreaBisogno = row["needareades"].ToString();
|
|
drDettaglioProdotti.Progetto = nomeProgetto;
|
|
drDettaglioProdotti.CodiceAreaBisogno = row["needarea"].ToString();
|
|
drDettaglioProdotti.DataAssociazione = row["dataAssociazione"].ToString();
|
|
drDettaglioProdotti.isAPC = row["isAPC"].ToString();
|
|
//Hazem
|
|
drDettaglioProdotti.Contratto = row["contrattoDossier"].ToString();
|
|
drDettaglioProdotti.Descrizione = row["descrizione"].ToString();
|
|
drDettaglioProdotti.Tipo_Prodotto = row["Tipo_Prodotto"].ToString();
|
|
|
|
//if (row["PartitaViaggiante"] != DBNull.Value && Convert.ToDouble(row["PartitaViaggiante"]) > 0)
|
|
// drDettaglioProdotti.__IMAGE_ = UtilityManager.getAppSetting("PartiteViaggianti");
|
|
//else
|
|
|
|
// SavingMap Precedente
|
|
//drDettaglioProdotti.__IMAGE_ = string.Empty;
|
|
//if (isSavingMap(drDettaglioProdotti.Contratto, dataThread.Periodico))
|
|
////if (drDettaglioProdotti.Descrizione.Substring(0, 2) == "FV")
|
|
// drDettaglioProdotti.__IMAGE_ = WebConfigParameter.getParameter("SavingMap");
|
|
//else
|
|
// drDettaglioProdotti.__IMAGE_ = string.Empty;
|
|
|
|
// SavingMap New
|
|
drDettaglioProdotti.__IMAGE_ = string.Empty;
|
|
if (drDettaglioProdotti.Contratto.IndexOf("VP") > 0 && drDettaglioProdotti.Tipo_Prodotto.Trim() == "CC")
|
|
{
|
|
drDettaglioProdotti.__IMAGE_ = WebConfigParameter.getParameter("SavingMap");
|
|
dataThread.IsSavingMap = true;
|
|
}
|
|
else
|
|
{
|
|
if (drDettaglioProdotti.Contratto.IndexOf("FO") > 0)
|
|
{
|
|
if (isSavingMap(dataThread.Rete, dataThread.CodiceFiscale.Trim(), drDettaglioProdotti.Contratto.Trim(), dataThread.Periodico))
|
|
{
|
|
drDettaglioProdotti.__IMAGE_ = WebConfigParameter.getParameter("SavingMap");
|
|
dataThread.IsSavingMap = true;
|
|
}
|
|
}
|
|
}
|
|
// End SavingMap
|
|
|
|
// Prova per APC103 da aggiungere
|
|
if (drDettaglioProdotti.isAPC == "S") //mock per APC
|
|
{
|
|
drDettaglioProdotti.__IMAGE_ = WebConfigParameter.getParameter("APC103");
|
|
dataThread.IsAPC103 = true;
|
|
}
|
|
|
|
// end prova APC103
|
|
drDettaglioProdotti.Controvalore = Convert.ToDecimal(row["controvalore"]);
|
|
|
|
|
|
if (row["varProdottoString"] != DBNull.Value)
|
|
drDettaglioProdotti.Var = row["varProdottoString"].ToString();
|
|
else
|
|
drDettaglioProdotti.Var = conv.ConvertNum(row["varProdotto"]);
|
|
|
|
//Hazem
|
|
if (row["CreditRiskString"] != DBNull.Value)
|
|
drDettaglioProdotti.CreditRisk = row["CreditRiskString"].ToString();
|
|
else
|
|
drDettaglioProdotti.CreditRisk = UtilityBusinessLayer.GetRiskCreditEmitClassName(row["CreditRiskEmit"].ToString());
|
|
|
|
drDettaglioProdotti.PerformanceYTD = conv.ConvertNum(row["PerformanceYTD"]);
|
|
drDettaglioProdotti.PerformanceDS = conv.ConvertNum(row["performanceDS"]);
|
|
|
|
drDettaglioProdotti.VersatoNetto = row["VersatoNetto"] == DBNull.Value ? row["VersatoNettoString"].ToString() : conv.ConvertNum(row["VersatoNetto"]);
|
|
drDettaglioProdotti.UtilePerdita = row["MinusPlusValenza"] == DBNull.Value ? row["MinusPlusValenzaString"].ToString() : conv.ConvertNum(row["MinusPlusValenza"]);
|
|
|
|
drDettaglioProdotti.CodiceAreaBisogno = row["needarea"].ToString();
|
|
|
|
|
|
#region E-DEFAULT4
|
|
|
|
if (
|
|
|
|
(drDettaglioProdotti.Descrizione.IndexOf("B MARCHE-2015 SUB TV", 0, StringComparison.CurrentCultureIgnoreCase) != -1) ||
|
|
(drDettaglioProdotti.Descrizione.IndexOf("BCA MARCHE FRN 16", 0, StringComparison.CurrentCultureIgnoreCase) != -1) ||
|
|
(drDettaglioProdotti.Descrizione.IndexOf("B MARCHE 18 6% SUB", 0, StringComparison.CurrentCultureIgnoreCase) != -1) ||
|
|
(drDettaglioProdotti.Descrizione.IndexOf("B MARCHE 12/18 6%", 0, StringComparison.CurrentCultureIgnoreCase) != -1) ||
|
|
(drDettaglioProdotti.Descrizione.IndexOf("BCA MARCHE FRN 17", 0, StringComparison.CurrentCultureIgnoreCase) != -1) ||
|
|
(drDettaglioProdotti.Descrizione.IndexOf("BP ETRURIA-16 STUSUB", 0, StringComparison.CurrentCultureIgnoreCase) != -1) ||
|
|
(drDettaglioProdotti.Descrizione.IndexOf("BP ETRURIA 17 SUB TV", 0, StringComparison.CurrentCultureIgnoreCase) != -1) ||
|
|
(drDettaglioProdotti.Descrizione.IndexOf("B ETRURIA 18 3,5%SUB", 0, StringComparison.CurrentCultureIgnoreCase) != -1) ||
|
|
(drDettaglioProdotti.Descrizione.IndexOf("B ETRURIA 13-23 5%", 0, StringComparison.CurrentCultureIgnoreCase) != -1) ||
|
|
(drDettaglioProdotti.Descrizione.IndexOf("BP ETRUR 16 STDW SUB", 0, StringComparison.CurrentCultureIgnoreCase) != -1) ||
|
|
(drDettaglioProdotti.Descrizione.IndexOf("BP ETRURIA 17 SUB SU", 0, StringComparison.CurrentCultureIgnoreCase) != -1) ||
|
|
(drDettaglioProdotti.Descrizione.IndexOf("CRCHIETI-16 STUP SUB", 0, StringComparison.CurrentCultureIgnoreCase) != -1) ||
|
|
(drDettaglioProdotti.Descrizione.IndexOf("CR FERRARA-16 TV SUB", 0, StringComparison.CurrentCultureIgnoreCase) != -1) ||
|
|
(drDettaglioProdotti.Descrizione.IndexOf("CR FERRARA-17 TV SUB", 0, StringComparison.CurrentCultureIgnoreCase) != -1)
|
|
)
|
|
{
|
|
|
|
drDettaglioProdotti.Controvalore = 999999999999;
|
|
|
|
|
|
}
|
|
#endregion E-DEFAULT4
|
|
|
|
|
|
// Nota sul grado di copertura
|
|
if (area.ToLower() == "inv")
|
|
{
|
|
if (!string.IsNullOrEmpty(row["copertura_need_progString"].ToString()))
|
|
drDettaglioProdotti.Copertura = row["copertura_need_progString"].ToString();
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(row["copertura_needareaString"].ToString()))
|
|
drDettaglioProdotti.Copertura = row["copertura_needareaString"].ToString();
|
|
}
|
|
|
|
//Bido Jan. Relaease
|
|
//if (area.ToLower() == "liq" && dataThread.ReportType().TipoReport == TipoReport.MONITORAGGIO)
|
|
//{
|
|
// drDettaglioProdotti.VersatoNetto = "n.d.";
|
|
// drDettaglioProdotti.UtilePerdita = "n.d.";
|
|
// drDettaglioProdotti.Var = "0,00";
|
|
// drDettaglioProdotti.CreditRisk = "n.a.";
|
|
|
|
//}
|
|
//Bido Jan. Release
|
|
|
|
ds43BIS.ProdottiAreeBisogno.AddProdottiAreeBisognoRow(drDettaglioProdotti);
|
|
|
|
#endregion
|
|
}
|
|
|
|
|
|
|
|
dsr.DatiSezione = ds43BIS;
|
|
dsr.Esito = ds43BIS.ProdottiAreeBisogno.Rows.Count;
|
|
return dsr;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
public bool isSavingMap(string pRete, string pCodFis, string pContratto, bool pPeriodico)
|
|
{
|
|
//dataThread.Rete, dataThread.CodiceFiscale, dr.Contratto, dr.Tipo_Prodotto, dataThread.Periodico
|
|
var parametri = new List<Parametro>
|
|
{
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "Rete",
|
|
Value = pRete
|
|
},
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "CodFis",
|
|
Value = pCodFis
|
|
},
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.String,
|
|
ParameterName = "CodConf",
|
|
Value = pContratto
|
|
}
|
|
};
|
|
string sSql = "";
|
|
|
|
if (pPeriodico)
|
|
sSql = "[C6MartPeriodico].[PL_SavingMap]";
|
|
else
|
|
sSql = "[C6Mart].[PL_SavingMap]";
|
|
|
|
DataAccessDE dataAccess = new DataAccessDE(DBProvider.SqlServerStampeC6);
|
|
DataTable dt = dataAccess.ExecuteDataTableStoredProcedure(DBProvider.SqlServerStampeC6, sSql, parametri);
|
|
|
|
if ((dt == null) || (dt.Rows.Count == 0))
|
|
return false;
|
|
else
|
|
{
|
|
if ((dt.Rows[0][0].ToString() == "0"))
|
|
return false;
|
|
else
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|