protected void lbtnId_Click(object sender, EventArgs e) { pnlMpBA.Visible = false; MpUp_MA.Hide(); var id = ((LinkButton)sender).Text; var pPage = false; for (var i = 0; i <= gvCliBlo.PageCount - 1; i++) { gvCliBlo.DataSource = Session["dtVigencia"]; gvCliBlo.PageIndex = i; gvCliBlo.DataBind(); for (int j = 0; j <= gvCliBlo.Rows.Count - 1; j++) { if (gvCliBlo.Rows[j].Cells[0].Text.Trim() != id) { continue; } pPage = true; gvCliBlo.DataSource = Session["dtVigencia"]; gvCliBlo.PageIndex = i; gvCliBlo.DataBind(); gvCliBlo.Rows[j].BackColor = Color.LightYellow; break; } if (pPage) { break; } } }
protected void btnCanlBusq_Click(object sender, EventArgs e) { pnlMpBA.Visible = false; MpUp_MA.Hide(); }
protected void lbtnIdMSGA_Click(object sender, EventArgs e) { ((LinkButton)gvRelAlert.Rows[gvRelAlert.EditIndex].FindControl("lbtnIdMsgRel")).Text = ((LinkButton)sender).Text; pnlMpBA.Visible = false; MpUp_MA.Hide(); }
protected void gvCliBlo_RowCommand(object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case "Nuevo": { #region Nuevo Session["editOp"] = false; MpUp_MA.Hide(); gvCliBlo.EditIndex = -1; Session["dtDoc"] = null; DataTable dt = ((DataTable)Session["dtVigencia"]).Copy(); Session["RANew"] = Convert.ToInt32(e.CommandArgument.ToString()); if (dt.Rows[0][0].ToString() == "##" & gvCliBlo.Rows.Count == 1) { gvCliBlo.EditIndex = 0; gvCliBlo.DataSource = dt; gvCliBlo.DataBind(); } else { DataRow rw = dt.NewRow(); for (int i = 0; i <= dt.Columns.Count - 1; i++) { rw[i] = DBNull.Value; } dt.Rows.Add(rw); gvCliBlo.DataSource = dt; gvCliBlo.DataBind(); gvCliBlo.PageIndex = gvCliBlo.PageCount; gvCliBlo.DataBind(); gvCliBlo.EditIndex = gvCliBlo.Rows.Count - 1; gvCliBlo.DataBind(); } #endregion } break; case "Buscar": { #region Buscar Session["dtDoc"] = null; DataTable dt2 = ((DataTable)Session["dtVigencia"]).Copy(); if (dt2.Rows[0][0].ToString() == "##" & gvCliBlo.Rows.Count == 1) { return; } gvCliBlo.EditIndex = -1; gvCliBlo.DataSource = Session["dtVigencia"]; gvCliBlo.DataBind(); gv_Alertas.DataSource = new DataTable(); gv_Alertas.DataBind(); txtIdBusq.Text = String.Empty; txtMSGBusq.Text = String.Empty; lblId.Text = "Id:"; lblTxtCod.Text = "Codigo:"; txtIdBusq_TextBoxWatermarkExtender.WatermarkText = "Id"; txtMSGBusq_TextBoxWatermarkExtender.WatermarkText = "Cliente"; gv_Alertas.Visible = true; pnlMpBA.Visible = true; MpUp_MA.Show(); #endregion } break; case "Editar": { #region Editar Session["dtDoc"] = null; DataTable dt = ((DataTable)Session["dtVigencia"]).Copy(); ServCBloqueados serv = new ServCBloqueados(); string IdCli = gvCliBlo.Rows[Convert.ToInt32(e.CommandArgument.ToString())].Cells[0].Text.Trim(); Session["editOp"] = true; MpUp_MA.Hide(); if (dt.Rows[0][0].ToString() != "##") { Session["RANew"] = 0; gvCliBlo.EditIndex = Convert.ToInt32(e.CommandArgument.ToString()); gvCliBlo.DataSource = Session["dtVigencia"]; gvCliBlo.DataBind(); } ((TextBox)gvCliBlo.Rows[Convert.ToInt32(e.CommandArgument.ToString())].FindControl("txtIdCli")).Enabled = false; var itemSelected = serv.findClient(IdCli.ToString(), "8", ((IUsr)Session["Usr"]).usr.Pais.IdPais.ToString()); #endregion } break; case "Guardar": { #region Guardar var Id = gvCliBlo.Rows[Convert.ToInt32(e.CommandArgument.ToString())].Cells[0].Text.Trim(); var IdCli = ((TextBox)gvCliBlo.Rows[Convert.ToInt32(gvCliBlo.EditIndex)].FindControl("txtIdCli")).Text; var vigencia = ((TextBox)gvCliBlo.Rows[Convert.ToInt32(e.CommandArgument.ToString())].FindControl("txtVigencia")).Text.Trim(); ServCBloqueados serv = new ServCBloqueados(); switch (((int)Session["RANew"])) { case 0: { //Actualizar Cli string res = serv.updateValidyty(Id, IdCli, vigencia, ((IUsr)Session["Usr"]).usr.Pais.IdPais.ToString()); if (res.CompareTo("0") == 0) { lblEInsUp.ForeColor = Color.Red; lblEInsUp.Text = "No se ha podido realizar la modificación"; lblEInsUp.Visible = true; } else { Response.Redirect(Request.RawUrl); } } break; case 1: { //Nuevo Cli IdCli = ((TextBox)gvCliBlo.Rows[Convert.ToInt32(e.CommandArgument.ToString())].FindControl("txtIdCli")).Text.Trim(); string res = serv.insertValidity(IdCli, vigencia, ((IUsr)Session["Usr"]).usr.Pais.IdPais.ToString()); if (res.CompareTo("0") == 0) { lblEInsUp.ForeColor = Color.Red; lblEInsUp.Text = "El cliente ya se encuentra registrado"; lblEInsUp.Visible = true; } else { if (res.CompareTo("-1") == 0) { lblEInsUp.ForeColor = Color.Red; lblEInsUp.Text = "Datos Incorrectos"; lblEInsUp.Visible = true; } else { Response.Redirect(Request.RawUrl); } } } break; } #endregion } break; case "Borrar": { #region Borrar if (gvCliBlo.EditIndex != -1) { return; } var IdCli = gvCliBlo.Rows[Convert.ToInt32(e.CommandArgument.ToString())].Cells[0].Text.Trim(); ServCBloqueados serv = new ServCBloqueados(); string res = serv.deleteValidity(IdCli, ((IUsr)Session["Usr"]).usr.Pais.IdPais.ToString()); if (res.CompareTo("0") == 0) { lblEInsUp.ForeColor = Color.Red; lblEInsUp.Text = "No se pudo eliminar el Cliente"; lblEInsUp.Visible = true; } else { Response.Redirect(Request.RawUrl); } #endregion } break; case "Cancelar": { #region Cancelar MpUp_MA.Hide(); Session["dtDoc"] = null; lblEInsUp.Visible = false; Session["RANew"] = 0; gvCliBlo.EditIndex = -1; gvCliBlo.DataSource = Session["dtVigencia"]; gvCliBlo.DataBind(); #endregion } break; } }
protected void gvCliBlo_RowCommand(object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case "Nuevo": { #region Nuevo Session["editOp"] = false; MpUp_MA.Hide(); gvCliBlo.EditIndex = -1; Session["dtDoc"] = null; DataTable dt = ((DataTable)Session["dtCBloqueados"]).Copy(); Session["RANew"] = Convert.ToInt32(e.CommandArgument.ToString()); if (dt.Rows[0][0].ToString() == "##" & gvCliBlo.Rows.Count == 1) { gvCliBlo.EditIndex = 0; gvCliBlo.DataSource = dt; gvCliBlo.DataBind(); } else { DataRow rw = dt.NewRow(); for (int i = 0; i <= dt.Columns.Count - 1; i++) { rw[i] = DBNull.Value; } dt.Rows.Add(rw); gvCliBlo.DataSource = dt; gvCliBlo.DataBind(); gvCliBlo.PageIndex = gvCliBlo.PageCount; gvCliBlo.DataBind(); gvCliBlo.EditIndex = gvCliBlo.Rows.Count - 1; gvCliBlo.DataBind(); } IServCBloqueados serv = new ServCBloqueados(); var dtTEx = serv.getTypeExceptions(); LdDdlGv(gvCliBlo, dtTEx, "ddlTExCli | IdTEx | NTEx", 1); #endregion } break; case "Buscar": { #region Buscar Session["dtDoc"] = null; DataTable dt2 = ((DataTable)Session["dtCBloqueados"]).Copy(); if (dt2.Rows[0][0].ToString() == "##" & gvCliBlo.Rows.Count == 1) { return; } gvCliBlo.EditIndex = -1; gvCliBlo.DataSource = Session["dtCBloqueados"]; gvCliBlo.DataBind(); gv_Alertas.DataSource = new DataTable(); gv_Alertas.DataBind(); txtIdBusq.Text = String.Empty; txtMSGBusq.Text = String.Empty; lblId.Text = "Id:"; lblTxtCod.Text = "Codigo:"; txtIdBusq_TextBoxWatermarkExtender.WatermarkText = "Id"; txtMSGBusq_TextBoxWatermarkExtender.WatermarkText = "Cliente"; gv_Alertas.Visible = true; pnlMpBA.Visible = true; MpUp_MA.Show(); #endregion } break; case "Editar": { #region Editar Session["dtDoc"] = null; DataTable dt = ((DataTable)Session["dtCBloqueados"]).Copy(); DropDownList ddl = ((DropDownList)gvCliBlo.Rows[Convert.ToInt32(e.CommandArgument.ToString())].FindControl("ddlTExCli")); ServCBloqueados serv = new ServCBloqueados(); string IdCli = gvCliBlo.Rows[Convert.ToInt32(e.CommandArgument.ToString())].Cells[0].Text.Trim(); string tEx = ""; Session["editOp"] = true; MpUp_MA.Hide(); if (dt.Rows[0][0].ToString() != "##") { Session["RANew"] = 0; gvCliBlo.EditIndex = Convert.ToInt32(e.CommandArgument.ToString()); gvCliBlo.DataSource = Session["dtCBloqueados"]; gvCliBlo.DataBind(); } ((TextBox)gvCliBlo.Rows[Convert.ToInt32(e.CommandArgument.ToString())].FindControl("txtIdCli")).Enabled = false; var dtTEx = serv.getTypeExceptions(); var itemSelected = serv.findClient(IdCli.ToString(), "8", ((IUsr)Session["Usr"]).usr.Pais.IdPais.ToString()); foreach (DataRow row in itemSelected.Rows) { tEx = row["IdTEx"].ToString(); } LdDdlGv(gvCliBlo, dtTEx, "ddlTExCli | IdTEx | NTEx", 2, null, tEx); #endregion } break; case "Guardar": { #region Guardar var Id = gvCliBlo.Rows[Convert.ToInt32(e.CommandArgument.ToString())].Cells[0].Text.Trim(); var IdCli = ((TextBox)gvCliBlo.Rows[Convert.ToInt32(gvCliBlo.EditIndex)].FindControl("txtIdCli")).Text; var deudor = ((TextBox)gvCliBlo.Rows[Convert.ToInt32(e.CommandArgument.ToString())].FindControl("txtDeudor")).Text.Trim(); ServCBloqueados serv = new ServCBloqueados(); switch (((int)Session["RANew"])) { case 0: { //Actualizar Cli DropDownList ddl = ((DropDownList)gvCliBlo.Rows[Convert.ToInt32(gvCliBlo.EditIndex)].FindControl("ddlTExCli")); string selectedTE = Session["selectedEx"].ToString(); string res = serv.updateClient(Id, IdCli, deudor, ((IUsr)Session["Usr"]).usr.CemexId, ddl.SelectedValue, selectedTE, ((IUsr)Session["Usr"]).usr.Pais.IdPais.ToString()); if (res.CompareTo("0") == 0) { lblEInsUp.ForeColor = Color.Red; lblEInsUp.Text = "No se ha podido realizar la modificación"; lblEInsUp.Visible = true; } else { Response.Redirect(Request.RawUrl); } } break; case 1: { //Nuevo Cli IdCli = ((TextBox)gvCliBlo.Rows[Convert.ToInt32(e.CommandArgument.ToString())].FindControl("txtIdCli")).Text.Trim(); DropDownList ddl = ((DropDownList)gvCliBlo.Rows[Convert.ToInt32(gvCliBlo.EditIndex)].FindControl("ddlTExCli")); string selected = ddl.SelectedValue; string res = ""; if (selected.CompareTo("0") == 0 || IdCli.CompareTo("") == 0) { res = "-1"; } else { res = serv.insertClient(IdCli, deudor, ((IUsr)Session["Usr"]).usr.CemexId, ddl.SelectedValue, ((IUsr)Session["Usr"]).usr.Pais.IdPais.ToString(), "4"); } if (res.CompareTo("0") == 0) { lblEInsUp.ForeColor = Color.Red; lblEInsUp.Text = "El cliente ya se encuentra registrado con ese tipo de Excepción"; lblEInsUp.Visible = true; } else { if (res.CompareTo("-1") == 0) { lblEInsUp.ForeColor = Color.Red; lblEInsUp.Text = "Datos Incorrectos"; lblEInsUp.Visible = true; } else { Response.Redirect(Request.RawUrl); } } } break; } #endregion } break; case "Borrar": { #region Borrar if (gvCliBlo.EditIndex != -1) { return; } int ent; var IdCli = gvCliBlo.Rows[Convert.ToInt32(e.CommandArgument.ToString())].Cells[0].Text.Trim(); ServCBloqueados serv = new ServCBloqueados(); string res = serv.deleteClient(IdCli, ((IUsr)Session["Usr"]).usr.Pais.IdPais.ToString()); if (res.CompareTo("0") == 0) { lblEInsUp.ForeColor = Color.Red; lblEInsUp.Text = "No se pudo eliminar el Cliente"; lblEInsUp.Visible = true; } else { Response.Redirect(Request.RawUrl); } #endregion } break; case "Cancelar": { #region Cancelar MpUp_MA.Hide(); Session["dtDoc"] = null; lblEInsUp.Visible = false; Session["RANew"] = 0; gvCliBlo.EditIndex = -1; gvCliBlo.DataSource = Session["dtCBloqueados"]; gvCliBlo.DataBind(); #endregion } break; } }