//Consulta los soportes banarios de un encabezado protected void ConsultarDetalleSoportes() { int encSop_Id = int.Parse(Session["encSop_Id"].ToString()); DataTable dt = new DataTable(); dt = AdministrarSoportesBancarios.ConsultarDetalleSoportes(encSop_Id); grvConsutarSop.DataSource = dt; grvConsutarSop.DataBind(); //ocultar campos de tabla grvConsutarSop.HeaderRow.Cells[1].Visible = false; grvConsutarSop.HeaderRow.Cells[2].Visible = false; int cont = 0; foreach (DataRow rows in dt.Rows) { grvConsutarSop.Rows[cont].Cells[1].Visible = false; grvConsutarSop.Rows[cont].Cells[2].Visible = false; cont++; } }
// Tabla lista soportes, oculta o muestra los botones protected void grvListSop_RowCommand(object sender, GridViewCommandEventArgs e) { int index = int.Parse(e.CommandArgument.ToString()); GridViewRow row = grvListSop.Rows[(index)]; if (e.CommandName == "Consultar_Click") { int encSop_Id = int.Parse(row.Cells[1].Text); Session["encSop_Id"] = encSop_Id; lblTituloBanco.Text = "Banco: " + row.Cells[2].Text; lblTituloCuenta.Text = "Cuenta: " + row.Cells[3].Text; lblTituloTipoCuenta.Text = "Tipo cuenta: " + row.Cells[4].Text; lblFechaCongnacion.Text = "Fecha Movimiento: " + row.Cells[5].Text; lblValorToral.Text = "Valor total: " + row.Cells[6].Text; string recibido = HttpUtility.HtmlDecode(row.Cells[8].Text); Session["recibido"] = recibido; DataTable dt = new DataTable(); dt = AdministrarSoportesBancarios.ConsultarDetalleSoportes(encSop_Id); // Variable para validar si es nit no puede aplicar string tipDoc = dt.Rows[0]["Tipo Documento"].ToString(); long cedula = long.Parse(dt.Rows[0]["Identificación"].ToString()); Session["identificacion"] = cedula; grvConsutarSop.DataSource = dt; grvConsutarSop.DataBind(); lblValorToral.Text = "Valor Total: " + row.Cells[6].Text; //ocultar campos de tabla grvConsutarSop.HeaderRow.Cells[1].Visible = false; grvConsutarSop.HeaderRow.Cells[2].Visible = false; int cont = 0; foreach (DataRow rows in dt.Rows) { grvConsutarSop.Rows[cont].Cells[1].Visible = false; grvConsutarSop.Rows[cont].Cells[2].Visible = false; cont++; } // Controles buscador.Visible = false; tablaSoporte.Visible = true; tablaEncabezado.Visible = false; formMotivo.Visible = false; titleAcciones.Visible = false; } if (e.CommandName == "Modificar_Click") { string encSop_Id = row.Cells[1].Text; txtEncSop_Id.Text = encSop_Id; DataTable dt = new DataTable(); lblTituloBancoEdit.Text = "Banco: " + row.Cells[2].Text; lblTituloCuentaEdit.Text = "Cuenta: " + row.Cells[3].Text; lblTituloTipoCuentaEdit.Text = "Tipo Cuenta: " + row.Cells[4].Text; formEditarEncabezado.Visible = true; acciones.Visible = false; } if (e.CommandName == "Eliminar_Click") { string directo = row.Cells[8].Text; string estado = row.Cells[7].Text; if (directo == "Compania") { if (estado != "APLICADO" && estado != "DISTRIBUCION") { int encSop_Id = int.Parse(row.Cells[1].Text); int registros = AdministrarSoportesBancarios.EliminarSoporteBancario(encSop_Id); if (registros > 0) { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('El soporte se ha eliminado con éxito');", true); } else { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('El soporte no se eliminó. por favor validar.');", true); } } else { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('El soporte no puede ser eliminado cuando esta en estado distribución o aplicado.');", true); } ListarSoportes(); } else { if (estado != "APLICADO" && estado != "DISTRIBUCION" && estado != "APROBADO") { int encSop_Id = int.Parse(row.Cells[1].Text); int registros = AdministrarSoportesBancarios.EliminarSoporteBancario(encSop_Id); if (registros > 0) { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('El soporte se ha eliminado con éxito');", true); } else { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('El soporte no se eliminó. por favor validar.');", true); } ListarSoportes(); } else { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('El soporte no puede ser eliminado cuando esta en estado aprobado, distribución o aplicado.');", true); } } } }