protected void Page_Load(object sender, EventArgs e)
        {
            string Certificado;

            ocultarDiv();
            LogicaNegocio Ln = new LogicaNegocio();

            if (Page.Session["RESUMEN"] != null)
            {
                ViewState["RES"] = (Resumen)Page.Session["RESUMEN"];
            }
            asignacionResumen(ref objresumen);
            SPWeb           app2    = SPContext.Current.Web;
            DataTable       dt      = new DataTable("dt");
            ValidarPermisos validar = new ValidarPermisos
            {
                NombreUsuario = util.ObtenerValor(app2.CurrentUser.Name),
                Pagina        = pagina,
                Etapa         = objresumen.area,
            };

            dt = validar.ListarPerfil(validar);
            if (dt.Rows.Count > 0)
            {
                if (!Page.IsPostBack)
                {
                    if (Page.Session["RESUMEN"] != null)
                    {
                        Certificado = Page.Request.QueryString["NCertificado"] as string;

                        if (!String.IsNullOrEmpty(Certificado))
                        {
                            txtnCertificado.Text = Certificado;
                        }

                        ViewState["BUSQUEDA"]    = Page.Session["BUSQUEDA"];
                        Page.Session["BUSQUEDA"] = null;

                        objresumen = (Resumen)Page.Session["RESUMEN"];
                        Page.Session["RESUMEN"] = null;
                        ViewState["RES"]        = objresumen;
                        lbEmpresa.Text          = objresumen.desEmpresa;
                        lbRut.Text       = objresumen.rut;
                        lbEjecutivo.Text = objresumen.descEjecutivo;
                        lbOperacion.Text = objresumen.desOperacion;
                        DataSet res;
                        res = Ln.ConsultarDatosBasicoDevolucion(objresumen.idEmpresa, objresumen.idOperacion, objresumen.idUsuario, objresumen.descCargo);

                        if (res != null)
                        {
                            if (res.Tables[0].Rows.Count > 0)
                            {
                                txtnCertificado.Text     = res.Tables[0].Rows[0]["nCertificado"].ToString();
                                txtMontoComision.Text    = res.Tables[0].Rows[0]["comisionCLP"].ToString();
                                txtNumCredito.Text       = res.Tables[0].Rows[0]["NroCredito"].ToString();
                                txtCoberturaC.Text       = res.Tables[0].Rows[0]["Cobertura"].ToString();
                                txtFondo.Text            = res.Tables[0].Rows[0]["Fondo"].ToString();
                                txtFechaEmision.Text     = res.Tables[0].Rows[0]["fecEmision"].ToString();
                                txtFechaVencimiento.Text = res.Tables[0].Rows[0]["fechaVencimiento"].ToString();
                                txtPlazoAM.Text          = res.Tables[0].Rows[0]["PlazoAnos"].ToString() + " / " + res.Tables[0].Rows[0]["PlazoMeses"].ToString();
                                txtAcreedor.Text         = res.Tables[0].Rows[0]["Acreedor"].ToString();
                                txtCostoFondo.Text       = res.Tables[0].Rows[0]["CostoFondo"].ToString();

                                txtCostoFondos.Text = res.Tables[0].Rows[0]["CostoFondo"].ToString();
                                txtUltimaCta.Text   = res.Tables[0].Rows[0]["UltCtaPagada"].ToString();
                                ViewState["ACCION"] = Constantes.OPCION.MODIFICAR;

                                if (ddlContratoTipo.SelectedValue == "-1")
                                {
                                    divCalculo.Visible = false;
                                }
                            }
                            else
                            {
                                ViewState["ACCION"] = Constantes.OPCION.INSERTAR;
                                btnCancelar.Style.Add("display", "block");
                                btnImprimir.Style.Add("display", "block");
                                btnPrepagar.Style.Add("display", "block");
                            }
                            asignacionJS();
                        }

                        if (res != null)
                        {
                            if (res.Tables[1].Rows.Count > 0)
                            {
                                // dtcFechaCierre.SelectedDate = Convert.ToDateTime(res.Rows[0]["fecEstimadaCierre"].ToString());
                                if (res.Tables[1].Rows[0]["FechaTransaccion"].ToString() != "")
                                {
                                    dtcFechaDevolucion.SelectedDate = Convert.ToDateTime(res.Tables[1].Rows[0]["FechaTransaccion"].ToString());
                                }

                                if (res.Tables[1].Rows[0]["IdTipoContrato"].ToString() != "")
                                {
                                    ddlContratoTipo.SelectedIndex = ddlContratoTipo.Items.IndexOf(ddlContratoTipo.Items.FindByValue(Convert.ToString(res.Tables[1].Rows[0]["IdTipoContrato"].ToString())));
                                }

                                if (res.Tables[1].Rows[0]["PorcDevolucion"].ToString() != "")
                                {
                                    txtPorcDevolucion.Text = Convert.ToString(res.Tables[1].Rows[0]["PorcDevolucion"].ToString());
                                }

                                if (res.Tables[1].Rows[0]["PorcDescuentoFijo"].ToString() != "")
                                {
                                    txtPorcDescuentoFijo.Text = Convert.ToString(res.Tables[1].Rows[0]["PorcDescuentoFijo"].ToString());
                                }

                                txtCargos.Text = res.Tables[1].Rows[0]["Cargos"].ToString();
                                txtAbonos.Text = res.Tables[1].Rows[0]["Abonos"].ToString();

                                ContratoTipo();
                                CalculoSegunTipoContrato();

                                if (res.Tables[1].Rows[0]["descEstado"].ToString() == "Facturado")
                                {
                                    divCalculo.Disabled = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        Page.Response.Redirect("MensajeSession.aspx");
                    }
                }
                else
                {
                    ContratoTipo();
                    CalculoSegunTipoContrato();
                    ocultarDiv();
                }

                validar.Permiso      = dt.Rows[0]["Permiso"].ToString();
                ViewState["validar"] = validar;
                Control divFormulario = this.FindControl("dvFormulario");
                bool    TieneFiltro   = true;

                if (divFormulario != null)
                {
                    util.bloquear(divFormulario, dt.Rows[0]["Permiso"].ToString(), TieneFiltro);
                }
                else
                {
                    dvFormulario.Style.Add("display", "none");
                    dvWarning1.Style.Add("display", "block");
                    lbWarning1.Text = "Usuario sin permisos configurados";
                }
            }
            else
            {
                dvFormulario.Style.Add("display", "none");
                dvWarning1.Style.Add("display", "block");
                lbWarning1.Text = "Usuario sin permisos configurados";
            }
        }