using System;
using System.Data;
using System.Configuration;
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 PDFGenerator.BusinessLayer.DataSection;
using PDFGenerator.BusinessLayer;
using System.Collections.Generic;
namespace PDFGenerator.BusinessLayer.DataSection
{
class DSS129Patrimonio: IDataSection
{
private string obtainAsteriscs(int number)
{
string sequence = string.Empty;
for (int i = 0; i < number; i++) sequence = string.Format("{0}{1}", sequence, "*");
return sequence;
}
public DSS129Patrimonio()
{
//
// TODO: Add constructor logic here
//
}
#region IDataSection Members
///
/// Implement the getDataSection function of the interface IDataSection.
///
///
/// Sql Statment to be executed to return the Profile Risk of the certain customer in a certain network
///
/// Data Table to be shown in the report
public DataSectionResult getDataSection(List tabelleSessione, string querySql, DataThread dataThread)
{
try
{
DataSectionResult customerPatrimonioDataSectionResult = new DataSectionResult();
DataRow CTVTotali;
decimal risorseFinanziarie = 0;
decimal CC = 0;
decimal investimentiInCorso = 0;
FormatNum formatnum = new FormatNum();
decimal totalePartiteViaggianti = dataThread.PartiteViaggiantiInvestimento + dataThread.PartiteViaggiantiDisinvestimento;
DataSetS129 customerPatrimonioRecordsDataSetS129 = new DataSetS129();
DataTable customerPatrimonioDataTable = SectionManager.GetDataSection(tabelleSessione, querySql, dataThread);
//if (dataThread.Patrimoniobancafideuramctv != 0 && customerPatrimonioDataTable.Rows.Count > 0)
//{
DataRow[] drFase1 = customerPatrimonioDataTable.Select(" fase = 1");
DataRow[] drFase2 = customerPatrimonioDataTable.Select(" fase = 2");
DataRow[] drFase3 = customerPatrimonioDataTable.Select(" fase = 3");
#region RISORSE FINANZIARIE
decimal PatrimonioBancaFideuramCTV_netto = dataThread.PatrimonioBancaFideuramCtvAlNettoContoCorrente;
//CTVDataRow = customerProfiloRischioRecordsDataSetS95.Dati.NewRow();
//CTVDataRow["Descrizione"] = "Risorse finanziarie";
risorseFinanziarie = PatrimonioBancaFideuramCTV_netto;
//CTVDataRow["Controvalore"] = formatnum.ConvertNum(PatrimonioBancaFideuramCTV_netto) + " €";
//customerProfiloRischioRecordsDataSetS95.Dati.Rows.Add(CTVDataRow);
#endregion
#region CONTO CORRENTE
//CTVDataRow = customerProfiloRischioRecordsDataSetS95.Dati.NewRow();
////CTVDataRow["Descrizione"] = "Conto corrente";
//CTVDataRow["Descrizione"] = "C/C a saldo negativo";
CC = dataThread.ContoCorrente;
//CTVDataRow["Controvalore"] = formatnum.ConvertNum(CC) + " €";
//if(CC != 0)
// customerProfiloRischioRecordsDataSetS95.Dati.Rows.Add(CTVDataRow);
#endregion
#region INVESTIMENTI IN CORSO
//CTVDataRow = customerProfiloRischioRecordsDataSetS95.Dati.NewDatiRow();
//CTVDataRow["Descrizione"] = Resource.PartiteViaggianti;
investimentiInCorso = dataThread.PartiteViaggiantiInvestimento + dataThread.PartiteViaggiantiDisinvestimento;
//CTVDataRow["Controvalore"] = formatnum.ConvertNum(investimentiInCorso) + " €";
//if (totalePartiteViaggianti != 0)
// customerProfiloRischioRecordsDataSetS95.Dati.Rows.Add(CTVDataRow);
#endregion
decimal totale = risorseFinanziarie + CC + investimentiInCorso +dataThread.TotalSelfNegCurrentAccountValue;
if (totale != 0)
{
#region Controvalore Attuale
CTVTotali = customerPatrimonioRecordsDataSetS129.Totali.NewRow();
CTVTotali["Descrizione"] = "Controvalore Attuale (€)";
//decimal totale = risorseFinanziarie + CC + investimentiInCorso;
CTVTotali["Controvalore"] = formatnum.ConvertNum(totale);
customerPatrimonioRecordsDataSetS129.Totali.Rows.Add(CTVTotali);
#endregion
}
//if (customerPatrimonioDataTable.Rows.Count > 0)
//{
#region Controvalore Trimestre Precedente
//Controvalore Trimestre Precedente
DataSetS129.ControvaloreTrimPrecRow drContrTrimPrecRow;
drContrTrimPrecRow = customerPatrimonioRecordsDataSetS129.ControvaloreTrimPrec.NewControvaloreTrimPrecRow();
drContrTrimPrecRow.Descrizione = "Controvalore trimestre precedente (€)";
if (drFase2.Length > 0)
{
if (!drFase2[0]["TotalePatrimonio"].Equals(System.DBNull.Value))
{
drContrTrimPrecRow.Valore = formatnum.ConvertNum(drFase2[0]["TotalePatrimonio"].ToString());
}
else
{
drContrTrimPrecRow.Valore = formatnum.ConvertNum(0);
}
}
else
{
drContrTrimPrecRow.Valore = formatnum.ConvertNum(0);
}
customerPatrimonioRecordsDataSetS129.ControvaloreTrimPrec.Rows.Add(drContrTrimPrecRow);
#endregion
#region Movimenti Ultimo Trimestre
DataSetS129.MovimentiUltTrimRow drMovUltTrimRow;
drMovUltTrimRow = customerPatrimonioRecordsDataSetS129.MovimentiUltTrim.NewMovimentiUltTrimRow();
drMovUltTrimRow.Descrizione = "Movimenti trimestre precedente (€)";
if (drFase3.Length > 0)
{
if (!drFase3[0]["DettMov"].Equals(System.DBNull.Value))
{
drMovUltTrimRow.Valore = formatnum.ConvertNum(drFase3[0]["DettMov"].ToString());
if (!drFase3[0]["NumeroAsterischiNota"].Equals(System.DBNull.Value))
{
string NumeroAsterischiNota = drFase3[0]["NumeroAsterischiNota"].ToString();
drMovUltTrimRow.Valore = string.Format("{0}{1}", drMovUltTrimRow.Valore,
obtainAsteriscs(Convert.ToInt16(NumeroAsterischiNota)));
}
}
else
{
drMovUltTrimRow.Valore = formatnum.ConvertNum(0);
}
}
else
{
drMovUltTrimRow.Valore = formatnum.ConvertNum(0);
}
customerPatrimonioRecordsDataSetS129.MovimentiUltTrim.AddMovimentiUltTrimRow(drMovUltTrimRow);
#endregion
#region Proventi Incassati nel Trimestre
// DataSetS129.ProventiIncasTrimRow drProvIncasTrimRow;
// drProvIncasTrimRow = customerPatrimonioRecordsDataSetS129.ProventiIncasTrim.NewProventiIncasTrimRow();
// drProvIncasTrimRow.Descrizione = "Proventi trimestre precedente (€)";
//if ((drFase1.Length == 0) && (drFase2.Length == 0) && (drFase3.Length == 0))
//{
// drProvIncasTrimRow.Valore = formatnum.ConvertNum(0);
//}
// else
// {
// if (drFase1.Length > 0)
// {
// if (!drFase1[0]["SommaProventi"].Equals(System.DBNull.Value))
// {
// drProvIncasTrimRow.Valore = formatnum.ConvertNum(drFase1[0]["SommaProventi"].ToString());
// }
// else
// drProvIncasTrimRow.Valore = formatnum.ConvertNum(0);
// }
// else
// {
// if ((drFase2.Length > 0) && drFase1[0]["SommaProventi"].Equals(System.DBNull.Value))
// {
// if (!drFase2[0]["SommaProventi"].Equals(System.DBNull.Value))
// {
// drProvIncasTrimRow.Valore = formatnum.ConvertNum(drFase2[0]["SommaProventi"].ToString());
// }
// else
// drProvIncasTrimRow.Valore = formatnum.ConvertNum(0);
// }
// else
// if ((drFase3.Length > 0)&& drFase1[0]["SommaProventi"].Equals(System.DBNull.Value)&& drFase2[0]["SommaProventi"].Equals(System.DBNull.Value))
// {
// if (!drFase3[0]["SommaProventi"].Equals(System.DBNull.Value))
// {
// drProvIncasTrimRow.Valore = formatnum.ConvertNum(drFase3[0]["SommaProventi"].ToString());
// }
// else
// drProvIncasTrimRow.Valore = formatnum.ConvertNum(0);
// }
// }
// }
// customerPatrimonioRecordsDataSetS129.ProventiIncasTrim.AddProventiIncasTrimRow(drProvIncasTrimRow);
#endregion
#region Utile / Perdita
DataSetS129.UtilePerditaRow drUtilePerditaRow;
drUtilePerditaRow = customerPatrimonioRecordsDataSetS129.UtilePerdita.NewUtilePerditaRow();
drUtilePerditaRow.Descrizione = "Utile / Perdita (€)";
decimal MovUltTrimValore = 0;
try { MovUltTrimValore = Convert.ToDecimal(drMovUltTrimRow.Valore); }
catch { MovUltTrimValore = 0; }
decimal ContrTrimPrecValore = 0;
try { ContrTrimPrecValore = Convert.ToDecimal(drContrTrimPrecRow.Valore); }
catch { ContrTrimPrecValore = 0; }
drUtilePerditaRow.Valore = formatnum.ConvertNum(totale - ContrTrimPrecValore - MovUltTrimValore);
customerPatrimonioRecordsDataSetS129.UtilePerdita.AddUtilePerditaRow(drUtilePerditaRow);
#endregion
//}
customerPatrimonioDataSectionResult.DatiSezione = customerPatrimonioRecordsDataSetS129;
customerPatrimonioDataSectionResult.Esito = customerPatrimonioRecordsDataSetS129.Totali.Rows.Count;
return customerPatrimonioDataSectionResult;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}