protected void grdPersonal_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (Session["Usuario"] == null) { Response.Redirect("~/Security/frmCerrar.aspx"); } try { if (e.CommandName == "Editar") { Personal_ListarTotalResult objPersonal = JsonHelper.JsonDeserialize <List <Personal_ListarTotalResult> >((string)ViewState["lstPersonal"]).Find(x => x.NroDocumento.ToString() == e.CommandArgument.ToString()); ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "ShowCreate('" + JsonHelper.JsonSerializer(objPersonal) + "');", true); } } catch (Exception ex) { lblMensaje.Text = ex.Message; lblMensaje.CssClass = "mensajeError"; } }
protected void Page_Load(object sender, EventArgs e) { if (Session["Usuario"] == null) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CancelEdit();", true); } try { if (!Page.IsPostBack) { LoginWCF.LoginWCFClient objLoginWCF = new LoginWCF.LoginWCFClient(); objLoginWCF.AuditoriaMenu_Registrar(System.Web.HttpContext.Current.Request.Url.AbsolutePath, Environment.MachineName, ((Usuario_LoginResult)System.Web.HttpContext.Current.Session["Usuario"]).idUsuario); Empresa_Cargar(); cboEmpresa.SelectedValue = ((Usuario_LoginResult)Session["Usuario"]).idEmpresa.ToString(); Cargo_Cargar(cboEmpresa.SelectedValue); Reporte_Cargar(cboEmpresa.SelectedValue); if (Request.QueryString["objPersonal"] == "") { Title = "Registrar Colaborador"; cboEmpresa.SelectedValue = ((Usuario_LoginResult)Session["Usuario"]).idEmpresa.ToString(); lblMensaje.Text = "Listo para registrar Colaborador"; lblMensaje.CssClass = "mensajeExito"; btnGuardar.Enabled = false; } else { decimal numero; Title = "Modificar Colaborador"; string obj = Request.QueryString["objPersonal"]; Personal_ListarTotalResult objPersonal = JsonHelper.JsonDeserialize <Personal_ListarTotalResult>(Request.QueryString["objPersonal"]); ViewState["NroDocumento"] = objPersonal.NroDocumento; numero = Convert.ToDecimal(objPersonal.porcentaje); txtNroDocumento.Text = objPersonal.NroDocumento; txtApellidos.Text = objPersonal.ApPaterno + " " + objPersonal.ApMaterno; txtNombre.Text = objPersonal.Nombres; txtComision.Text = string.Format("{0:#,##0.00}", numero); txtImagen.Text = objPersonal.ImagenURL; cboReporte.SelectedValue = objPersonal.reporte.ToString(); cboEstado.SelectedValue = Convert.ToInt32(objPersonal.Comision).ToString(); cboEmpresa.SelectedValue = objPersonal.CodEmpresaGys.ToString(); cboCargo.SelectedValue = objPersonal.codCargo; cboReporte.Enabled = false; cboEmpresa.Enabled = false; cboCargo.Enabled = false; txtNroDocumento.Enabled = false; txtNombre.Enabled = false; txtApellidos.Enabled = false; txtImagen.Visible = false; acbUsuario.Enabled = true; btnBuscarUsuario.Enabled = true; lblMensaje.Text = "Listo para modificar Colaborador"; lblMensaje.CssClass = "mensajeExito"; } Session["idempresa"] = cboEmpresa.SelectedValue; Session["idCargo"] = cboCargo.SelectedValue; } } catch (Exception ex) { lblMensaje.Text = "ERROR: " + ex.Message; lblMensaje.CssClass = "mensajeError"; } }