362 lines
17 KiB
C#
362 lines
17 KiB
C#
using System;
|
|
using System.Web;
|
|
//using System.Web.Services;
|
|
//using System.Web.Services.Protocols;
|
|
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 DSFD43ProdottiAreeBisogno : IDataSection
|
|
{
|
|
public DataSectionResult getDataSection(List<SessionStruct> tabelleSessione, string querySql, DataThread dataThread)
|
|
{
|
|
try
|
|
{
|
|
DataSectionResult dsr = new DataSectionResult();
|
|
|
|
FormatNum conv = new FormatNum();
|
|
string area = string.Empty;
|
|
string nomeProgetto = string.Empty;
|
|
string ordinamentoProgetto = string.Empty;
|
|
DataSetS43 ds43 = new DataSetS43();
|
|
|
|
ds43.ProdottiAreeBisogno.Columns["Controvalore"].Caption = "Controvalore <br> (€) ";
|
|
|
|
DataTable dt = SectionManager.GetDataSection(tabelleSessione, querySql, dataThread);
|
|
|
|
/************************** Modifica Nota Dinamica 11-03-2021 - Pino *************************************************************/
|
|
DataTable dtFlagNota = SectionManager.GetDataSection(tabelleSessione, "[C6StagingPeriodico].[ClienteProdottiFAI]", dataThread);
|
|
DataSetS43.FlagNotaFAIRow drFlagFAI;
|
|
if (dtFlagNota.Rows.Count > 0)
|
|
{
|
|
drFlagFAI = ds43.FlagNotaFAI.NewFlagNotaFAIRow();
|
|
drFlagFAI["FlagFAI"] = dtFlagNota.Rows[0][0].ToString();
|
|
drFlagFAI["DataFAI"] = dtFlagNota.Rows[0][1].ToString();
|
|
|
|
ds43.FlagNotaFAI.AddFlagNotaFAIRow(drFlagFAI);
|
|
}
|
|
|
|
/*********************************************************************************************************************************/
|
|
|
|
DataSetS43.ProdottiAreeBisognoRow dr;
|
|
DataSetS43.ProdottiTotaleRow drTot;
|
|
DataSetS43.DettaglioProgettiRow drProgetti;
|
|
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
|
|
dr = ds43.ProdottiAreeBisogno.NewProdottiAreeBisognoRow();
|
|
|
|
//Se cambia l'area popolo la tabella dei totali. GESTIRE IL CASO DEI PROGETTI PER Inv
|
|
if (area != row["needarea"].ToString())
|
|
{
|
|
drTot = ds43.ProdottiTotale.NewProdottiTotaleRow();
|
|
drTot.AreaBisogno = row["needareades"].ToString();
|
|
if (row["needarea"].ToString().ToLower() == "na")
|
|
drTot.Totale = "TOTALE RISORSE " + row["needareades"].ToString().ToUpper();
|
|
else
|
|
drTot.Totale = "TOTALE " + row["needareades"].ToString().ToUpper();
|
|
drTot.CodiceAreaBisogno = row["needarea"].ToString();
|
|
drTot.Controvalore = Convert.ToDecimal(row["somma_controval_needarea"]);
|
|
|
|
if (row["var_needareaString"] != DBNull.Value)
|
|
drTot.Var = row["var_needareaString"].ToString();
|
|
else
|
|
drTot.Var = conv.ConvertNum(row["var_needarea"]);
|
|
|
|
|
|
ds43.ProdottiTotale.AddProdottiTotaleRow(drTot);
|
|
}
|
|
|
|
|
|
area = row["needarea"].ToString();
|
|
|
|
//V
|
|
//if (area == "Inv" && nomeProgetto != row["nome_progetto"].ToString())
|
|
if (dataThread.Periodico)
|
|
{
|
|
if (area == "Inv" && ordinamentoProgetto != row["ORDINAMENTO_PROGETTO"].ToString())
|
|
{
|
|
drProgetti = ds43.DettaglioProgetti.NewDettaglioProgettiRow();
|
|
drProgetti.NomeProgetto = row["nome_progetto"].ToString();
|
|
drProgetti.Controvalore = Convert.ToDecimal(row["somma_controval_need_prog"]);
|
|
drProgetti.OrdinamentoProgetto = row["ORDINAMENTO_PROGETTO"].ToString();
|
|
if (row["var_need_progString"] != DBNull.Value)
|
|
drProgetti.Var = row["var_need_progString"].ToString();
|
|
else
|
|
drProgetti.Var = conv.ConvertNum(row["var_need_prog"]);
|
|
|
|
|
|
ds43.DettaglioProgetti.AddDettaglioProgettiRow(drProgetti);
|
|
}
|
|
else
|
|
{
|
|
if (area == "Inv" && nomeProgetto != row["nome_progetto"].ToString())
|
|
{
|
|
drProgetti = ds43.DettaglioProgetti.NewDettaglioProgettiRow();
|
|
drProgetti.NomeProgetto = row["nome_progetto"].ToString();
|
|
drProgetti.Controvalore = Convert.ToDecimal(row["somma_controval_need_prog"]);
|
|
drProgetti.OrdinamentoProgetto = row["ORDINAMENTO_PROGETTO"].ToString();
|
|
if (row["var_need_progString"] != DBNull.Value)
|
|
drProgetti.Var = row["var_need_progString"].ToString();
|
|
else
|
|
drProgetti.Var = conv.ConvertNum(row["var_need_prog"]);
|
|
|
|
|
|
ds43.DettaglioProgetti.AddDettaglioProgettiRow(drProgetti);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (area == "Inv" && nomeProgetto != row["nome_progetto"].ToString())
|
|
{
|
|
drProgetti = ds43.DettaglioProgetti.NewDettaglioProgettiRow();
|
|
drProgetti.NomeProgetto = row["nome_progetto"].ToString();
|
|
drProgetti.Controvalore = Convert.ToDecimal(row["somma_controval_need_prog"]);
|
|
//drProgetti.OrdinamentoProgetto = row["ORDINAMENTO_PROGETTO"].ToString();
|
|
if (row["var_need_progString"] != DBNull.Value)
|
|
drProgetti.Var = row["var_need_progString"].ToString();
|
|
else
|
|
drProgetti.Var = conv.ConvertNum(row["var_need_prog"]);
|
|
|
|
|
|
ds43.DettaglioProgetti.AddDettaglioProgettiRow(drProgetti);
|
|
}
|
|
else
|
|
{
|
|
if (area == "Inv" && nomeProgetto != row["nome_progetto"].ToString())
|
|
{
|
|
drProgetti = ds43.DettaglioProgetti.NewDettaglioProgettiRow();
|
|
drProgetti.NomeProgetto = row["nome_progetto"].ToString();
|
|
drProgetti.Controvalore = Convert.ToDecimal(row["somma_controval_need_prog"]);
|
|
//drProgetti.OrdinamentoProgetto = row["ORDINAMENTO_PROGETTO"].ToString();
|
|
if (row["var_need_progString"] != DBNull.Value)
|
|
drProgetti.Var = row["var_need_progString"].ToString();
|
|
else
|
|
drProgetti.Var = conv.ConvertNum(row["var_need_prog"]);
|
|
|
|
|
|
ds43.DettaglioProgetti.AddDettaglioProgettiRow(drProgetti);
|
|
}
|
|
}
|
|
}
|
|
//V Modifica fatta in trimestrale per gestire il doppio nome progetto uguale in monitoraggio
|
|
if (dataThread.Periodico)
|
|
ordinamentoProgetto = row["ORDINAMENTO_PROGETTO"].ToString();
|
|
nomeProgetto = row["nome_progetto"].ToString();
|
|
|
|
//V Modifica fatta in trimestrale per gestire il doppio nome progetto uguale in monitoraggio
|
|
if (dataThread.Periodico)
|
|
dr.OrdinamentoProgetto = row["ORDINAMENTO_PROGETTO"].ToString();
|
|
|
|
dr.AreaBisogno = row["needareades"].ToString();
|
|
dr.Progetto = nomeProgetto;
|
|
dr.CodiceAreaBisogno = row["needarea"].ToString();
|
|
dr.DataSottoscrizione = row["dataSottoscrizione"].ToString();
|
|
dr.isAPC = row["isAPC"].ToString();
|
|
//Hazem
|
|
dr.Contratto = row["contrattoDossier"].ToString();
|
|
dr.Descrizione = row["descrizione"].ToString();
|
|
dr.Tipo_Prodotto = row["Tipo_Prodotto"].ToString();
|
|
|
|
//if (row["PartitaViaggiante"] != DBNull.Value && Convert.ToDouble(row["PartitaViaggiante"]) > 0)
|
|
// dr.__IMAGE_ = UtilityManager.getAppSetting("PartiteViaggianti");
|
|
//else
|
|
|
|
// SavingMap New
|
|
dr.__IMAGE_ = string.Empty;
|
|
if (dr.Contratto.IndexOf("VP") > 0 && dr.Tipo_Prodotto.Trim() == "CC")
|
|
{
|
|
dr.__IMAGE_ = WebConfigParameter.getParameter("SavingMap");
|
|
dataThread.IsSavingMap = true;
|
|
}
|
|
else
|
|
{
|
|
if (dr.Contratto.IndexOf("FO") > 0)
|
|
{
|
|
if (isSavingMap(dataThread.Rete, dataThread.CodiceFiscale.Trim(), dr.Contratto.Trim(), dataThread.Periodico))
|
|
{
|
|
dr.__IMAGE_ = WebConfigParameter.getParameter("SavingMap");
|
|
dataThread.IsSavingMap = true;
|
|
}
|
|
}
|
|
}
|
|
// End SavingMap
|
|
// Prova per APC103 da aggiungere
|
|
if (dr.isAPC == "S") //mock per APC
|
|
{
|
|
dr.__IMAGE_ = WebConfigParameter.getParameter("APC103");
|
|
dataThread.IsAPC103 = true;
|
|
}
|
|
// end prova APC103
|
|
|
|
dr.Controvalore = Convert.ToDecimal(row["controvalore"]);
|
|
|
|
if (row["varProdottoString"] != DBNull.Value)
|
|
dr.Var = row["varProdottoString"].ToString();
|
|
else
|
|
dr.Var = conv.ConvertNum(row["varProdotto"]);
|
|
|
|
//Hazem
|
|
if (row["CreditRiskString"] != DBNull.Value)
|
|
dr.CreditRisk = row["CreditRiskString"].ToString();
|
|
else
|
|
dr.CreditRisk = UtilityBusinessLayer.GetRiskCreditEmitClassName(row["CreditRiskEmit"].ToString());
|
|
|
|
dr.PerformanceYTD = conv.ConvertNum(row["PerformanceYTD"]);
|
|
|
|
dr.PerformanceDS = conv.ConvertNum(row["performanceDS"]);
|
|
dr.CodiceAreaBisogno = row["needarea"].ToString();
|
|
|
|
// Nota sul grado di copertura
|
|
if (!string.IsNullOrEmpty(row["copertura_needareaString"].ToString()))
|
|
dr.Copertura = row["copertura_needareaString"].ToString();
|
|
|
|
//Bido Jan 2011 release.
|
|
//Section 43.
|
|
//if (area == "Liq" && dataThread.ReportType().TipoReport == TipoReport.MONITORAGGIO)
|
|
//{
|
|
// dr.CreditRisk = "n.a.";
|
|
// dr.Var = "0,00";
|
|
//}
|
|
//End Bido Jan 2011 release
|
|
|
|
ds43.ProdottiAreeBisogno.AddProdottiAreeBisognoRow(dr);
|
|
}
|
|
|
|
|
|
#region conti correnti saldo negativo
|
|
DataTable dt_A = null;
|
|
|
|
if (dataThread.Periodico)
|
|
dt_A = SectionManager.GetDataSection(tabelleSessione, "[C6MartPeriodico].[PL_S43ContoCorrenteBF]", dataThread);
|
|
else
|
|
dt_A = SectionManager.GetDataSection(tabelleSessione, "[C6Mart].[PL_S43ContoCorrenteBF]", dataThread);
|
|
|
|
//ds43.ContoCorrente.Columns.Add(new DataColumn("isAPC", System.Type.GetType("System.String")));
|
|
|
|
DataSetS43.ContoCorrenteRow dr_A;
|
|
foreach (DataRow row in dt_A.Rows)
|
|
{
|
|
dr_A = ds43.ContoCorrente.NewContoCorrenteRow();
|
|
dr_A.Data = row["datadiSottoscrizione"].ToString();
|
|
dr_A.Numero = row["conto"].ToString();
|
|
|
|
dr_A.isAPC = row["isAPC"].ToString();
|
|
if (dr_A.isAPC == "S")
|
|
{
|
|
dr_A.__IMAGE_ = WebConfigParameter.getParameter("APC103");
|
|
dataThread.IsAPC103 = true;
|
|
}
|
|
|
|
if (row["ControValore"] != DBNull.Value)
|
|
dr_A.SaldoContabile = decimal.Parse(row["ControValore"].ToString());
|
|
|
|
if (row["SALDO_DISPONIBILE"] != DBNull.Value)
|
|
dr_A.SaldoDisponibile = decimal.Parse(row["SALDO_DISPONIBILE"].ToString());
|
|
dr_A.CreditRisk = "n.a.";
|
|
dr_A.Var = "0.00";
|
|
|
|
ds43.ContoCorrente.AddContoCorrenteRow(dr_A);
|
|
}
|
|
#endregion
|
|
|
|
#region conti correnti saldo negativo
|
|
DataTable dt_B = null;
|
|
|
|
if (dataThread.Periodico)
|
|
dt_B = SectionManager.GetDataSection(tabelleSessione, "[C6MartPeriodico].[PL_S43LineaSelfBF]", dataThread);
|
|
else
|
|
dt_B = SectionManager.GetDataSection(tabelleSessione, "[C6Mart].[PL_S43LineaSelfBF]", dataThread);
|
|
|
|
DataSetS43.LineaSelfRow dr_B;
|
|
foreach (DataRow row in dt_B.Rows)
|
|
{
|
|
dr_B = ds43.LineaSelf.NewLineaSelfRow();
|
|
dr_B.Numero = row["NumContratto"].ToString();
|
|
dr_B.SaldoContabile = decimal.Parse(row["ControValore"].ToString());
|
|
// dr_B.isAPC = row["isAPC"].ToString();
|
|
// if (dr_B.isAPC == "S")
|
|
//{
|
|
// dr_B.__IMAGE_ = WebConfigParameter.getParameter("APC103");
|
|
// dataThread.isAPC103 = true;
|
|
//}
|
|
dr_B.Data = row["DataSott"].ToString();
|
|
dr_B.NomeProdotto = row["NomeProdotto"].ToString();
|
|
// MIOFOGLIO 20181129
|
|
dr_B.CodInterno = row["CodInterno"].ToString();
|
|
dr_B.CodSottoprodotto = row["CodSottoprodotto"].ToString();
|
|
//--MIOFOGLIO 20181129
|
|
ds43.LineaSelf.AddLineaSelfRow(dr_B);
|
|
}
|
|
#endregion
|
|
|
|
dsr.DatiSezione = ds43;
|
|
dsr.Esito = ds43.ProdottiAreeBisogno.Rows.Count;
|
|
return dsr;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|