using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Xml; using Sensibilizacion.WCFServiciosGenerales; namespace Sensibilizacion { public partial class CuadroSensibilizacion : System.Web.UI.Page { //protected System.Web.UI.WebControls.Button b_cerrar; //protected System.Web.UI.WebControls.Label lbl_pa3_t; //protected System.Web.UI.WebControls.Label lbl_pa3_ct; //protected System.Web.UI.WebControls.Label lbl_es3_tc; //protected System.Web.UI.WebControls.Label lbl_es3_p; //protected System.Web.UI.WebControls.Label lbl_es3_t; //protected System.Web.UI.WebControls.Label lbl_es3_e; //protected System.Web.UI.WebControls.Label lbl_es3_ci; //protected System.Web.UI.WebControls.Label lbl_es3_in; //protected System.Web.UI.WebControls.Label lbl_es3_c; //protected System.Web.UI.WebControls.Label lbl_es3_mp; //protected System.Web.UI.WebControls.Label lbl_pa2_t; //protected System.Web.UI.WebControls.Label lbl_pa2_ct; //protected System.Web.UI.WebControls.Label lbl_es2_tc; //protected System.Web.UI.WebControls.Label lbl_es2_p; //protected System.Web.UI.WebControls.Label lbl_es2_t; //protected System.Web.UI.WebControls.Label lbl_es2_e; //protected System.Web.UI.WebControls.Label lbl_es2_ci; //protected System.Web.UI.WebControls.Label lbl_es2_in; //protected System.Web.UI.WebControls.Label lbl_es2_c; //protected System.Web.UI.WebControls.Label lbl_es2_mp; //protected System.Web.UI.WebControls.Label lbl_pa1_t; //protected System.Web.UI.WebControls.Label lbl_pa1_ct; //protected System.Web.UI.WebControls.Label lbl_es1_tc; //protected System.Web.UI.WebControls.Label lbl_es1_p; //protected System.Web.UI.WebControls.Label lbl_es1_t; //protected System.Web.UI.WebControls.Label lbl_es1_e; //protected System.Web.UI.WebControls.Label lbl_es1_ci; //protected System.Web.UI.WebControls.Label lbl_es1_in; //protected System.Web.UI.WebControls.Label lbl_es1_c; //protected System.Web.UI.WebControls.Label lbl_es1_mp; //protected System.Web.UI.WebControls.Label lbl_sn_tc; //protected System.Web.UI.WebControls.Label lbl_sn_p; //protected System.Web.UI.WebControls.Label lbl_sn_t; //protected System.Web.UI.WebControls.Label lbl_sn_e; //protected System.Web.UI.WebControls.Label lbl_sn_ci; //protected System.Web.UI.WebControls.Label lbl_sn_in; //protected System.Web.UI.WebControls.Label lbl_sn_c; //protected System.Web.UI.WebControls.Label lbl_sn_mp; //protected System.Web.UI.WebControls.Label lbl_ingneto; //protected System.Web.UI.WebControls.Label lbl_cuota; //protected System.Web.UI.WebControls.Button cerrar; //protected System.Web.UI.WebControls.TextBox txt_info; //protected System.Web.UI.WebControls.Label lbl_tipo_alerta; //protected System.Web.UI.WebControls.Panel Panel1; //protected System.Web.UI.WebControls.Label l_titulo; double inc_devesp1, inc_devesp2, tasa_minimo, tasa_promedio, tasa_maximo, inc_devesp3, esc1_cuota, esc1_ingresosnetos, esc1_cuotaingreso, esc1_endeudamiento, esc1_tasa, esc1_tipocambio_esp, esc2_cuota, esc2_ingresosnetos, esc2_cuotaingreso, esc2_endeudamiento, esc2_tasa, esc2_tipocambio_esp, esc3_cuota, esc3_ingresosnetos, esc3_cuotaingreso, esc3_endeudamiento, esc3_tasa, esc3_tipocambio_esp, esc_0_cuota_ingreso, esc_0_cuota, esc_0_endeudamiento, esc_0_tasa, esc_0_tipo_cambio_esp; #region PROPIEDADES private string strData { get { object o = ViewState["strData"]; return (o == null) ? "" : o.ToString(); } set { ViewState["strData"] = value; } } private string Proceso; private string Incidente; private string Solicitud; private string Identificacion; private string TipoCliente; private string SoloLectura; private string Moneda; private string CoMoneda; private string DescripcionMoneda; private string IngNetoCol; private string IngNetoDol; private string TipoCambio; private string TipoTasa; private string TipoTasaReferencia; private string MontoPrestamo; private string MontoPrestamoConSeguros; private string TasaPrestamo; private string PlazoPrestamo; private string CuotaPrestamo; private string TotalCompromiso; private string Seguro; private string IdCliente; private int Mode; //private double porc_devesp; #endregion #region carga de la aspx private void Page_Load(object sender, System.EventArgs e) { Response.Expires = -1; try { if (!this.Page.IsPostBack) { string[] arrData = new string[22]; this.strData = (this.Request["strData"] == null) ? "0" : this.Request["strData"].ToString().Trim(); arrData = strData.Split(('|')); this.Proceso = arrData[0]; this.Incidente = arrData[1]; this.Solicitud = arrData[2]; this.Identificacion = arrData[3]; this.TipoCliente = arrData[4]; this.SoloLectura = arrData[5]; this.CoMoneda = arrData[6]; this.Moneda = arrData[7]; this.IngNetoCol = arrData[8]; this.IngNetoDol = arrData[9]; this.TipoCambio = arrData[10]; this.TipoTasa = arrData[11]; this.TipoTasaReferencia = arrData[12]; this.MontoPrestamo = arrData[13]; this.TasaPrestamo = arrData[14]; this.PlazoPrestamo = arrData[15]; this.CuotaPrestamo = arrData[16]; this.TotalCompromiso = arrData[17]; this.Seguro = arrData[18]; this.DescripcionMoneda = arrData[19]; this.IdCliente = arrData[20]; this.Mode = int.Parse(arrData[21]); this.MontoPrestamoConSeguros = arrData[22]; this.Panel1.Visible = false; this.CargarData(); this.ColocarScriptControles(); } } catch (Exception ex) { this.Panel1.Visible = true; this.Panel1.BorderColor = System.Drawing.Color.Red; this.lbl_tipo_alerta.Text = "Excepción..."; this.txt_info.Attributes.Add("style", "border-color: 'Red'"); this.txt_info.Text = "Ha ocurrido una Excepción comuníquese con su Administrador " + ex.Message; } } #endregion #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { //this.cerrar.Click += new System.EventHandler(this.cerrar_Click); //this.Load += new System.EventHandler(this.Page_Load); } #endregion #region Colocar Script Controles public void ColocarScriptControles() { //para el boton de cerrar } #endregion #region Cargar Data private void CargarData() { string respuestaXML; XmlDocument xmlDoc; XmlNode xmlNodeRoot; string error = ""; double IngresoNeto = 0; WCFServiciosGenerales.ObtenerDatosSensibilizacionResponse resp = null; try { xmlDoc = new XmlDocument(); WCFServiciosGenerales.ServiciosClient objWS = new WCFServiciosGenerales.ServiciosClient(); //objWS.Credentials = System.Net.CredentialCache.DefaultCredentials; Sensibilizacion.WCFServiciosGenerales.EnumeradorProcesoUltimus _proceso = 0; if (this.Proceso.Contains("Prendario")) _proceso = EnumeradorProcesoUltimus.PrestamoPrendario; resp = objWS.ObtenerDatosSensibilizacion(new Sensibilizacion.WCFServiciosGenerales.ObtenerDatosSensibilizacionRequest() { Proceso = _proceso, Incidente = this.Incidente, Solicitud = this.Solicitud, Identificacion = this.Identificacion, TipoCliente = this.TipoCliente, SoloLectura = this.SoloLectura, CoMoneda = int.Parse(this.CoMoneda), Moneda = this.Moneda, IngNetoCol = this.IngNetoCol, IngNetoDol = this.IngNetoDol, TipoCambio = this.TipoCambio, TipoTasa = this.TipoTasa, TipoTasaReferencia = this.TipoTasaReferencia, MontoPrestamo = this.MontoPrestamo, TasaPrestamo = this.TasaPrestamo, PlazoPrestamo = this.PlazoPrestamo, CuotaPrestamo = this.CuotaPrestamo, TotalCompromiso = this.TotalCompromiso, Seguro = this.Seguro, IdCliente = int.Parse(this.IdCliente), Mode = this.Mode, }); if (resp.errCode != "00") { throw new Exception(resp.errMessage); } respuestaXML = resp.resultado; xmlDoc.LoadXml(respuestaXML); xmlNodeRoot = xmlDoc.SelectSingleNode("//Respuesta"); if (xmlNodeRoot != null) error = xmlNodeRoot.SelectSingleNode("Error").InnerText; if (error.Trim() != "") throw new Exception(error); ObtieneParametrosSensibilizacion(xmlNodeRoot); esc_0_cuota = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_Normal/esc_normal_cuota").InnerText); esc_0_cuota_ingreso = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_Normal/esc_normal_cuotaingreso").InnerText); esc_0_endeudamiento = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_Normal/esc_normal_endeudamiento").InnerText); esc_0_tasa = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_Normal/esc_normal_tasa").InnerText); esc_0_tipo_cambio_esp = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_Normal/esc_tipocambio_esp").InnerText); IngresoNeto = double.Parse(xmlNodeRoot.SelectSingleNode("IngresoNeto").InnerText); esc1_ingresosnetos = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_1/esc1_ingresosnetos").InnerText); esc2_ingresosnetos = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_2/esc2_ingresosnetos").InnerText); esc3_ingresosnetos = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_3/esc3_ingresosnetos").InnerText); if (Moneda == "0") //Colones { this.lbl_pa1_t.Text = inc_devesp1.ToString() + "%"; this.lbl_pa2_t.Text = inc_devesp2.ToString() + "%"; this.lbl_pa3_t.Text = inc_devesp3.ToString() + "%"; } this.esc1_tasa = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_1/esc1_tasa").InnerText); this.esc2_tasa = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_2/esc2_tasa").InnerText); this.esc3_tasa = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_3/esc3_tasa").InnerText); this.esc1_cuota = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_1/esc1_cuota").InnerText); this.esc2_cuota = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_2/esc2_cuota").InnerText); this.esc3_cuota = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_3/esc3_cuota").InnerText); this.esc1_cuotaingreso = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_1/esc1_cuotaingreso").InnerText); this.esc1_endeudamiento = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_1/esc1_endeudamiento").InnerText); this.esc1_tipocambio_esp = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_1/esc1_tipocambio_esp").InnerText); this.esc2_cuotaingreso = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_2/esc2_cuotaingreso").InnerText); this.esc2_endeudamiento = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_2/esc2_endeudamiento").InnerText); this.esc2_tipocambio_esp = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_2/esc2_tipocambio_esp").InnerText); this.esc3_cuotaingreso = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_3/esc3_cuotaingreso").InnerText); this.esc3_endeudamiento = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_3/esc3_endeudamiento").InnerText); this.esc3_tipocambio_esp = double.Parse(xmlNodeRoot.SelectSingleNode("Escenario_3/esc3_tipocambio_esp").InnerText); //setea data a los titulos dinamicos this.lbl_ingneto.Text = "Ingreso neto " + this.DescripcionMoneda; this.lbl_cuota.Text = "Cuota " + this.DescripcionMoneda; //setea data a los controles de situacion normal this.lbl_sn_mp.Text = string.Format("{0:N2}", double.Parse(this.MontoPrestamoConSeguros)); this.lbl_sn_c.Text = string.Format("{0:N2}", esc_0_cuota); this.lbl_sn_in.Text = string.Format("{0:N2}", IngresoNeto); this.lbl_sn_ci.Text = string.Format("{0:P2}", esc_0_cuota_ingreso); this.lbl_sn_e.Text = string.Format("{0:P2}", esc_0_endeudamiento); this.lbl_sn_t.Text = string.Format("{0:P2}", double.Parse(this.TasaPrestamo) / 100); this.lbl_sn_p.Text = this.PlazoPrestamo; this.lbl_sn_tc.Text = string.Format("{0:N2}", TipoCambio); //setea a los controles del escenario 1 this.lbl_es1_mp.Text = string.Format("{0:N2}", double.Parse(this.MontoPrestamoConSeguros)); this.lbl_es1_c.Text = string.Format("{0:N2}", this.esc1_cuota); this.lbl_es1_in.Text = string.Format("{0:N2}", esc1_ingresosnetos); this.lbl_es1_ci.Text = string.Format("{0:P2}", esc1_cuotaingreso); this.lbl_es1_e.Text = string.Format("{0:P2}", esc1_endeudamiento); this.lbl_es1_t.Text = string.Format("{0:P2}", esc1_tasa * 100); this.lbl_es1_p.Text = this.PlazoPrestamo; this.lbl_es1_tc.Text = string.Format("{0:N2}", esc1_tipocambio_esp); //setea a los controles del escenario 2 this.lbl_es2_mp.Text = string.Format("{0:N2}", double.Parse(this.MontoPrestamoConSeguros)); this.lbl_es2_c.Text = string.Format("{0:N2}", this.esc2_cuota); this.lbl_es2_in.Text = string.Format("{0:N2}", esc2_ingresosnetos); this.lbl_es2_ci.Text = string.Format("{0:P2}", esc2_cuotaingreso); this.lbl_es2_e.Text = string.Format("{0:P2}", esc2_endeudamiento); this.lbl_es2_t.Text = string.Format("{0:P2}", esc2_tasa * 100); this.lbl_es2_p.Text = this.PlazoPrestamo; this.lbl_es2_tc.Text = string.Format("{0:N2}", esc2_tipocambio_esp); //setea a los controles del escenario 3 this.lbl_es3_mp.Text = string.Format("{0:N2}", double.Parse(this.MontoPrestamoConSeguros)); this.lbl_es3_c.Text = string.Format("{0:N2}", this.esc3_cuota); this.lbl_es3_in.Text = string.Format("{0:N2}", esc3_ingresosnetos); this.lbl_es3_ci.Text = string.Format("{0:P2}", esc3_cuotaingreso); this.lbl_es3_e.Text = string.Format("{0:P2}", esc3_endeudamiento); this.lbl_es3_t.Text = string.Format("{0:P2}", esc3_tasa * 100); this.lbl_es3_p.Text = this.PlazoPrestamo; this.lbl_es3_tc.Text = string.Format("{0:N2}", esc3_tipocambio_esp); } catch (Exception ex) { this.Panel1.Visible = true; this.Panel1.BorderColor = System.Drawing.Color.Red; this.lbl_tipo_alerta.Text = "Excepción..."; this.txt_info.Attributes.Add("style", "border-color: 'Red'"); this.txt_info.Text = "Ha ocurrido una Excepción comuníquese con su Administrador " + ex.Message; } } #endregion #region Calcula Pmt Escenarios private void PmtEscenarios(int escenario) { double PmtEscenario = 0; if (escenario == 1) { PmtEscenario = (-1) * Microsoft.VisualBasic.Financial.Pmt((this.esc1_tasa / 12), double.Parse(this.PlazoPrestamo), double.Parse(this.MontoPrestamo), 0, 0); this.esc1_cuota = PmtEscenario; } else if (escenario == 2) { PmtEscenario = (-1) * Microsoft.VisualBasic.Financial.Pmt((this.esc2_tasa / 12), double.Parse(this.PlazoPrestamo), double.Parse(this.MontoPrestamo), 0, 0); this.esc2_cuota = PmtEscenario; } else if (escenario == 3) { PmtEscenario = (-1) * Microsoft.VisualBasic.Financial.Pmt((this.esc3_tasa / 12), double.Parse(this.PlazoPrestamo), double.Parse(this.MontoPrestamo), 0, 0); this.esc3_cuota = PmtEscenario; } } #endregion #region Busca Parametros Sensibilizacion private void ObtieneParametrosSensibilizacion(XmlNode nodeRoot) { try { tasa_minimo = double.Parse(nodeRoot.SelectSingleNode("tasa_minimo").InnerText) / 100; tasa_promedio = double.Parse(nodeRoot.SelectSingleNode("tasa_promedio").InnerText) / 100; tasa_maximo = double.Parse(nodeRoot.SelectSingleNode("tasa_maximo").InnerText) / 100; //porc_devesp = double.Parse(nodeRoot.SelectSingleNode("porc_devesp").InnerText); inc_devesp1 = double.Parse(nodeRoot.SelectSingleNode("Escenario_1/inc_devesp1").InnerText); inc_devesp2 = double.Parse(nodeRoot.SelectSingleNode("Escenario_2/inc_devesp2").InnerText); inc_devesp3 = double.Parse(nodeRoot.SelectSingleNode("Escenario_3/inc_devesp3").InnerText); this.lbl_pa1_ct.Text = tasa_minimo.ToString() + "pp"; this.lbl_pa2_ct.Text = tasa_promedio.ToString() + "pp"; this.lbl_pa3_ct.Text = tasa_maximo.ToString() + "pp"; this.lbl_pa1_t.Text = inc_devesp1.ToString() + "%"; this.lbl_pa2_t.Text = inc_devesp2.ToString() + "%"; this.lbl_pa3_t.Text = inc_devesp3.ToString() + "%"; } catch (Exception ex) { this.Panel1.Visible = true; this.Panel1.BorderColor = System.Drawing.Color.Red; this.lbl_tipo_alerta.Text = "Excepción..."; this.txt_info.Attributes.Add("style", "border-color: 'Red'"); this.txt_info.Text = "Ha ocurrido una Excepción comuníquese con su Administrador " + ex.Message; } } #endregion protected void cerrar_Click(object sender, System.EventArgs e) { this.Panel1.Visible = false; } protected void b_cerrar_Click(object sender, EventArgs e) { } } }