320 lines
19 KiB
C#
320 lines
19 KiB
C#
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 ceTe.DynamicPDF;
|
||
using ceTe.DynamicPDF.Text;
|
||
using PDFGenerator.BusinessLayer.DataSection;
|
||
using PDFGenerator.BusinessLayer;
|
||
using ContrattoSei.Utilities;
|
||
|
||
|
||
namespace PDFGenerator.Presentation.Section {
|
||
public class SProfiloDiRischio {
|
||
protected DataThread dsParam;
|
||
|
||
protected void creaTabella(DocumentPDF document, float var1) {
|
||
float yLabel = document.getLastPos() - 1;
|
||
float yDistanceHeaderLabel = 27;
|
||
float xMacroAsset = document.getMargineLeft() + 110;
|
||
float xControvalore = xMacroAsset + 100;
|
||
float xImg = document.getMargineLeft() + 163;
|
||
float xRect = xMacroAsset + 88;
|
||
float yRect = yLabel - 4;
|
||
float yImg = document.getLastPos() + 24;
|
||
float widthRect = 31;
|
||
float heigthRect = 21;
|
||
float widthMacroAsset = 120;
|
||
float widthControvalore = 80;
|
||
float fontSize = 9;
|
||
float heightLabel = 11;
|
||
OpenTypeFont font;
|
||
OpenTypeFont font2 = Globals.OpenTypeFontVerdana;
|
||
FormatNum conv = new FormatNum();
|
||
ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
|
||
ceTe.DynamicPDF.PageElements.Rectangle rect;
|
||
|
||
//Marker SX
|
||
if (dsParam.profiloIsAct) {
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(document.getMargineLeft() + 5, yImg - 5 + ((5 - var1) * yDistanceHeaderLabel), widthMacroAsset - 35, yDistanceHeaderLabel, 0, new RgbColor(232, 236, 237)));
|
||
rect = new ceTe.DynamicPDF.PageElements.Rectangle(document.getMargineLeft() + widthMacroAsset - 30, yImg - 5 + ((5 - var1) * yDistanceHeaderLabel), yDistanceHeaderLabel / 1.414F, yDistanceHeaderLabel / 1.414F, 0, new RgbColor(232, 236, 237));
|
||
rect.Angle = 45;
|
||
page.Elements.Add(rect);
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Profilo finanziario", document.getMargineLeft() + 10, yImg - 5 + ((5 - var1) * yDistanceHeaderLabel) + 7, widthMacroAsset + 70, heightLabel, Globals.OpenTypeFontVerdana, fontSize));
|
||
}
|
||
|
||
// Add label to page
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(document.getMargineLeft() - 5, document.getLastPos() - 12, 523, 22, 0, new RgbColor(232, 236, 237)));
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Profilo finanziario", xMacroAsset - 20, yLabel - 7, widthMacroAsset, heightLabel, Globals.OpenTypeFontVerdanaB, fontSize, ceTe.DynamicPDF.CmykColor.Red));
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("VaR massimo", xControvalore + 10, yLabel - 7, widthControvalore, heightLabel, Globals.OpenTypeFontVerdanaB, fontSize, ceTe.DynamicPDF.TextAlign.Right, ceTe.DynamicPDF.CmykColor.Red));
|
||
yLabel += yDistanceHeaderLabel;
|
||
|
||
|
||
if (var1 == 5)
|
||
font = Globals.OpenTypeFontVerdanaB;
|
||
else
|
||
font = Globals.OpenTypeFontVerdana;
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("5 Aggressivo", xMacroAsset, yLabel, widthMacroAsset + 60, heightLabel, font, fontSize));
|
||
rect = new ceTe.DynamicPDF.PageElements.Rectangle(xRect, yLabel - 4, widthRect, heigthRect, 0, new RgbColor(247, 30, 13));
|
||
rect.CornerRadius = 4;
|
||
page.Elements.Add(rect);
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(BusinessLayer.SoglieVar.sVar5 + " %", xControvalore, yLabel, widthControvalore, heightLabel, font2, fontSize, ceTe.DynamicPDF.TextAlign.Right));
|
||
|
||
yLabel += yDistanceHeaderLabel;
|
||
|
||
if (var1 == 4)
|
||
font = Globals.OpenTypeFontVerdanaB;
|
||
else
|
||
font = Globals.OpenTypeFontVerdana;
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("4 Dinamico", xMacroAsset, yLabel, widthMacroAsset + 60, heightLabel, font, fontSize));
|
||
rect = new ceTe.DynamicPDF.PageElements.Rectangle(xRect, yLabel - 4, widthRect, heigthRect, 0, new RgbColor(241, 153, 53));
|
||
rect.CornerRadius = 4;
|
||
page.Elements.Add(rect);
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(BusinessLayer.SoglieVar.sVar4 + " %", xControvalore, yLabel, widthControvalore, heightLabel, font2, fontSize, ceTe.DynamicPDF.TextAlign.Right));
|
||
|
||
yLabel += yDistanceHeaderLabel;
|
||
|
||
if (var1 == 3)
|
||
font = Globals.OpenTypeFontVerdanaB;
|
||
else
|
||
font = Globals.OpenTypeFontVerdana;
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("3 Equilibrato", xMacroAsset, yLabel, widthMacroAsset + 60, heightLabel, font, fontSize));
|
||
rect = new ceTe.DynamicPDF.PageElements.Rectangle(xRect, yLabel - 4, widthRect, heigthRect, 0, new RgbColor(242, 187, 49));
|
||
rect.CornerRadius = 4;
|
||
page.Elements.Add(rect);
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(BusinessLayer.SoglieVar.sVar3 + " %", xControvalore, yLabel, widthControvalore, heightLabel, font2, fontSize, ceTe.DynamicPDF.TextAlign.Right));
|
||
|
||
yLabel += yDistanceHeaderLabel;
|
||
|
||
if (var1 == 2)
|
||
font = Globals.OpenTypeFontVerdanaB;
|
||
else
|
||
font = Globals.OpenTypeFontVerdana;
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("2 Moderato", xMacroAsset, yLabel, widthMacroAsset + 60, heightLabel, font, fontSize));
|
||
rect = new ceTe.DynamicPDF.PageElements.Rectangle(xRect, yLabel - 4, widthRect, heigthRect, 0, new RgbColor(192, 226, 31));
|
||
rect.CornerRadius = 4;
|
||
page.Elements.Add(rect);
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(BusinessLayer.SoglieVar.sVar2 + " %", xControvalore, yLabel, widthControvalore, heightLabel, font2, fontSize, ceTe.DynamicPDF.TextAlign.Right));
|
||
|
||
yLabel += yDistanceHeaderLabel;
|
||
|
||
if (var1 == 1)
|
||
font = Globals.OpenTypeFontVerdanaB;
|
||
else
|
||
font = Globals.OpenTypeFontVerdana;
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("1 Prudente", xMacroAsset, yLabel, widthMacroAsset + 60, heightLabel, font, fontSize));
|
||
rect = new ceTe.DynamicPDF.PageElements.Rectangle(xRect, yLabel - 4, widthRect, heigthRect, 0, new RgbColor(66, 156, 39));
|
||
rect.CornerRadius = 4;
|
||
page.Elements.Add(rect);
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(BusinessLayer.SoglieVar.sVar1 + " %", xControvalore, yLabel, widthControvalore, heightLabel, font2, fontSize, ceTe.DynamicPDF.TextAlign.Right));
|
||
}
|
||
|
||
/// <summary>
|
||
/// Disegna la sezione specializzata per la S94.
|
||
/// </summary>
|
||
/// <param name="document"></param>
|
||
/// <param name="profilo"></param>
|
||
protected void disegnaS94(DocumentPDF document, int profilofinanziario, DateTime dataAggiornamento, decimal varRisorseFinanziarie, decimal gradoCopertura)
|
||
{
|
||
float yLabel = document.getLastPos() - 1;
|
||
float yDistanceHeaderLabel = 27;
|
||
float xMacroAsset = document.getMargineLeft() + 140;
|
||
float xControvalore = xMacroAsset + 100;
|
||
float xImg = document.getMargineLeft() + 163;
|
||
float xRect = xMacroAsset + 88;
|
||
float yRect = yLabel - 4;
|
||
float yImg = document.getLastPos() + 24;
|
||
float widthRect = 31;
|
||
float heigthRect = 21;
|
||
float widthMacroAsset = 100;
|
||
float widthControvalore = 80;
|
||
float fontSize = 9;
|
||
float heightLabel = 11;
|
||
OpenTypeFont font;
|
||
OpenTypeFont font2 = Globals.OpenTypeFontVerdana;
|
||
FormatNum conv = new FormatNum();
|
||
ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage();
|
||
ceTe.DynamicPDF.PageElements.Rectangle rect;
|
||
|
||
//Marker SX
|
||
if (dsParam.profiloIsAct)
|
||
{
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(document.getMargineLeft() + 5, yImg - 5 + ((5 - (int)profilofinanziario) * yDistanceHeaderLabel), widthMacroAsset, yDistanceHeaderLabel, 0, new RgbColor(232, 236, 237)));
|
||
|
||
rect = new ceTe.DynamicPDF.PageElements.Rectangle(document.getMargineLeft() + widthMacroAsset + 6, yImg - 5 + ((5 - (int)profilofinanziario) * yDistanceHeaderLabel), yDistanceHeaderLabel / 1.414F, yDistanceHeaderLabel / 1.414F, 0, new RgbColor(232, 236, 237));
|
||
rect.Angle = 45;
|
||
page.Elements.Add(rect);
|
||
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Profilo finanziario", document.getMargineLeft() + 10, yImg - 5 + ((5 - (int)profilofinanziario) * yDistanceHeaderLabel) + 4, widthMacroAsset + 70, heightLabel, Globals.OpenTypeFontVerdanaB, 7));
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Aggiornato il " + dataAggiornamento.ToShortDateString(), document.getMargineLeft() + 10, yImg - 5 + ((5 - (int)profilofinanziario) * yDistanceHeaderLabel) + 14, widthMacroAsset + 70, heightLabel, Globals.OpenTypeFontVerdana, 7));
|
||
}
|
||
|
||
// Add label to page
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Rectangle(document.getMargineLeft() - 5, document.getLastPos() - 12, 512, 22, 0, new RgbColor(232, 236, 237)));
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Profilo finanziario", xMacroAsset, yLabel - 7, widthMacroAsset, heightLabel, Globals.OpenTypeFontVerdanaB, fontSize, ceTe.DynamicPDF.CmykColor.Red));
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("VaR massimo", xControvalore + 10, yLabel - 7, widthControvalore, heightLabel, Globals.OpenTypeFontVerdanaB, fontSize, ceTe.DynamicPDF.TextAlign.Right, ceTe.DynamicPDF.CmykColor.Red));
|
||
yLabel += yDistanceHeaderLabel;
|
||
|
||
if (profilofinanziario == 5)
|
||
font = Globals.OpenTypeFontVerdanaB;
|
||
else
|
||
font = Globals.OpenTypeFontVerdana;
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("5 Aggressivo", xMacroAsset, yLabel, widthMacroAsset + 60, heightLabel, font, fontSize));
|
||
rect = new ceTe.DynamicPDF.PageElements.Rectangle(xRect, yLabel - 4, widthRect, heigthRect, 0, new RgbColor(247, 30, 13));
|
||
rect.CornerRadius = 4;
|
||
page.Elements.Add(rect);
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(BusinessLayer.SoglieVar.sVar5 + " %", xControvalore, yLabel, widthControvalore, heightLabel, font2, fontSize, ceTe.DynamicPDF.TextAlign.Right));
|
||
|
||
yLabel += yDistanceHeaderLabel;
|
||
|
||
if (profilofinanziario == 4)
|
||
font = Globals.OpenTypeFontVerdanaB;
|
||
else
|
||
font = Globals.OpenTypeFontVerdana;
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("4 Dinamico", xMacroAsset, yLabel, widthMacroAsset + 60, heightLabel, font, fontSize));
|
||
rect = new ceTe.DynamicPDF.PageElements.Rectangle(xRect, yLabel - 4, widthRect, heigthRect, 0, new RgbColor(241, 153, 53));
|
||
rect.CornerRadius = 4;
|
||
page.Elements.Add(rect);
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(BusinessLayer.SoglieVar.sVar4 + " %", xControvalore, yLabel, widthControvalore, heightLabel, font2, fontSize, ceTe.DynamicPDF.TextAlign.Right));
|
||
|
||
yLabel += yDistanceHeaderLabel;
|
||
|
||
if (profilofinanziario == 3)
|
||
font = Globals.OpenTypeFontVerdanaB;
|
||
else
|
||
font = Globals.OpenTypeFontVerdana;
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("3 Equilibrato", xMacroAsset, yLabel, widthMacroAsset + 60, heightLabel, font, fontSize));
|
||
rect = new ceTe.DynamicPDF.PageElements.Rectangle(xRect, yLabel - 4, widthRect, heigthRect, 0, new RgbColor(242, 187, 49));
|
||
rect.CornerRadius = 4;
|
||
page.Elements.Add(rect);
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(BusinessLayer.SoglieVar.sVar3 + " %", xControvalore, yLabel, widthControvalore, heightLabel, font2, fontSize, ceTe.DynamicPDF.TextAlign.Right));
|
||
|
||
yLabel += yDistanceHeaderLabel;
|
||
|
||
if (profilofinanziario == 2)
|
||
font = Globals.OpenTypeFontVerdanaB;
|
||
else
|
||
font = Globals.OpenTypeFontVerdana;
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("2 Moderato", xMacroAsset, yLabel, widthMacroAsset + 60, heightLabel, font, fontSize));
|
||
rect = new ceTe.DynamicPDF.PageElements.Rectangle(xRect, yLabel - 4, widthRect, heigthRect, 0, new RgbColor(192, 226, 31));
|
||
rect.CornerRadius = 4;
|
||
page.Elements.Add(rect);
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(BusinessLayer.SoglieVar.sVar2 + " %", xControvalore, yLabel, widthControvalore, heightLabel, font2, fontSize, ceTe.DynamicPDF.TextAlign.Right));
|
||
|
||
yLabel += yDistanceHeaderLabel;
|
||
|
||
if (profilofinanziario == 1)
|
||
font = Globals.OpenTypeFontVerdanaB;
|
||
else
|
||
font = Globals.OpenTypeFontVerdana;
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("1 Prudente", xMacroAsset, yLabel, widthMacroAsset + 60, heightLabel, font, fontSize));
|
||
rect = new ceTe.DynamicPDF.PageElements.Rectangle(xRect, yLabel - 4, widthRect, heigthRect, 0, new RgbColor(66, 156, 39));
|
||
rect.CornerRadius = 4;
|
||
page.Elements.Add(rect);
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(BusinessLayer.SoglieVar.sVar1 + " %", xControvalore, yLabel, widthControvalore, heightLabel, font2, fontSize, ceTe.DynamicPDF.TextAlign.Right));
|
||
|
||
|
||
//Inserisco l'indicatore per le Risorse Finanziarie.
|
||
// Disegno un rombo rosso coperto da uno bianco in modo da ottenere una freccia.
|
||
float yIndicatoreRisorseFinanziarie = yImg + ((4 - MarkPosition((float)varRisorseFinanziarie)) * yDistanceHeaderLabel);
|
||
|
||
// rombo rosso
|
||
rect = new ceTe.DynamicPDF.PageElements.Rectangle(xImg + 175, yIndicatoreRisorseFinanziarie, 10 / 1.414F, 10 / 1.414F, 0, new RgbColor(255, 0, 0));
|
||
rect.Angle = 45;
|
||
page.Elements.Add(rect);
|
||
|
||
// rombo bianco
|
||
rect = new ceTe.DynamicPDF.PageElements.Rectangle(xImg + 180, yIndicatoreRisorseFinanziarie, 10 / 1.414F, 10 / 1.414F, 0, new RgbColor(255, 255, 255));
|
||
rect.Angle = 45;
|
||
page.Elements.Add(rect);
|
||
|
||
|
||
//Testo per le Risorse Finanziarie.
|
||
if (gradoCopertura < 100M)
|
||
{
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Risorse finanziarie (VaR " + varRisorseFinanziarie + "%)", xImg + 185, yIndicatoreRisorseFinanziarie - 5, 200, heightLabel, Globals.OpenTypeFontVerdanaB, 7));
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Copertura " + gradoCopertura + " %", xImg + 185, yIndicatoreRisorseFinanziarie + 5, 200, heightLabel, Globals.OpenTypeFontVerdana, 7));
|
||
}
|
||
else
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Risorse finanziarie (VaR " + varRisorseFinanziarie + "%)", xImg + 185, yIndicatoreRisorseFinanziarie, 200, heightLabel, Globals.OpenTypeFontVerdanaB, 7));
|
||
|
||
|
||
//Imposta la nota
|
||
//string relativePath = UtilityManager.getAppSetting("Danger");
|
||
string flagPathOK = UtilityManager.getAppSetting("FlagOK");
|
||
string flagPathNO = UtilityManager.getAppSetting("FlagNO");
|
||
|
||
System.Reflection.Assembly thisExe;
|
||
thisExe = System.Reflection.Assembly.GetExecutingAssembly();
|
||
System.IO.Stream file = null;
|
||
|
||
// Se non <20> possibile il confronto tra il profilo finanziari e le riorse finanziarie,
|
||
// ovvero se manca uno dei due quindi decade la possibilit<69> di fare il confronto, non devono esserci gli indicatori (OK-NO)
|
||
if (varRisorseFinanziarie != 0 && profilofinanziario != 0)
|
||
{
|
||
decimal varMassimo = getVarMassimo(profilofinanziario);
|
||
if (varRisorseFinanziarie <= varMassimo)
|
||
{
|
||
file = thisExe.GetManifestResourceStream(flagPathOK);
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(file, document.getMargineLeft() + 10, yLabel + 25, 0.13F));
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(Resource.S94_Nota_OK, document.getMargineLeft() + 30, yLabel + 25, 500, heightLabel, Globals.OpenTypeFontVerdana, fontSize));
|
||
}
|
||
else
|
||
{
|
||
file = thisExe.GetManifestResourceStream(flagPathNO);
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(file, document.getMargineLeft() + 10, yLabel + 25, 0.13F));
|
||
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(Resource.S94_Nota_NO, document.getMargineLeft() + 30, yLabel + 25, 500, heightLabel, Globals.OpenTypeFontVerdana, fontSize));
|
||
}
|
||
}
|
||
}
|
||
|
||
protected int MarkPosition(float var)
|
||
{
|
||
int index = 0;
|
||
|
||
if (var <= Convert.ToSingle(BusinessLayer.SoglieVar.sVar1))
|
||
index = 0;
|
||
if ((Convert.ToSingle(BusinessLayer.SoglieVar.sVar1) < var) && (var <= Convert.ToSingle(BusinessLayer.SoglieVar.sVar2)))
|
||
index = 1;
|
||
if ((Convert.ToSingle(BusinessLayer.SoglieVar.sVar2) < var) && (var <= Convert.ToSingle(BusinessLayer.SoglieVar.sVar3)))
|
||
index = 2;
|
||
if ((Convert.ToSingle(BusinessLayer.SoglieVar.sVar3) < var) && (var <= Convert.ToSingle(BusinessLayer.SoglieVar.sVar4)))
|
||
index = 3;
|
||
if ((Convert.ToSingle(BusinessLayer.SoglieVar.sVar4) < var))
|
||
index = 4;
|
||
|
||
return index;
|
||
}
|
||
|
||
/// <summary>
|
||
/// Recupera il var Massimo a partire dal id del profilo finanziario associato al cliente.
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
protected decimal getVarMassimo(int profilofinanziario)
|
||
{
|
||
switch (profilofinanziario)
|
||
{
|
||
case 1:
|
||
return 1.5M;
|
||
case 2:
|
||
return 3.5M;
|
||
case 3:
|
||
return 7.5M;
|
||
case 4:
|
||
return 12M;
|
||
case 5 :
|
||
return 23M;
|
||
default:
|
||
return -1M;
|
||
//break;
|
||
}
|
||
}
|
||
}
|
||
}
|