114 lines
3.5 KiB
C#
114 lines
3.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using Extensiones;
|
|
using System.Data;
|
|
|
|
public partial class OI_CatDocumentoSubCategoria : ClsPaginas
|
|
{
|
|
private int CveSubCategoria
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveSubCategoria"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveSubCategoria"] = value;
|
|
}
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
CargaDatos();
|
|
CargaCategoria();
|
|
}
|
|
}
|
|
|
|
private void CargaDatos()
|
|
{
|
|
ClsOIEventos ObjOI = new ClsOIEventos();
|
|
if (ObjOI.GetDocumentoSubCategoria())
|
|
{
|
|
GvDatos.DataSource = ObjOI.DtResultados;
|
|
GvDatos.DataBind();
|
|
}
|
|
ObjOI.Dispose();
|
|
}
|
|
|
|
private void CargaCategoria()
|
|
{
|
|
ClsOIEventos ObjOI = new ClsOIEventos();
|
|
if (ObjOI.GetDocumentoCategoria())
|
|
{
|
|
DdlCategorias.DataSource = ObjOI.DtResultados.FiltraParametros("Estado = 1");
|
|
DdlCategorias.DataBind();
|
|
}
|
|
ObjOI.Dispose();
|
|
}
|
|
|
|
protected void BtnAgregarSubCategoria_Click(object sender, EventArgs e)
|
|
{
|
|
BtnAgregarSubCategoriaDoc.Text = "Agregar";
|
|
TxtSubCategoria.Text = "";
|
|
UpModalTiposD.Update();
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD"));
|
|
}
|
|
|
|
protected void LnkEditar_Click(object sender, EventArgs e)
|
|
{
|
|
BtnAgregarSubCategoriaDoc.Text = "Actualizar";
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
CveSubCategoria = GvRow.DataKey("CveSubCategoria").ToEntero();
|
|
TxtSubCategoria.Text = GvRow.DataKey("SubCategoria");
|
|
UpModalTiposD.Update();
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD"));
|
|
}
|
|
|
|
protected void LnkEliminar_Click(object sender, EventArgs e)
|
|
{
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
CveSubCategoria = GvRow.DataKey("CveSubCategoria").ToEntero();
|
|
ClsCompras ObjCompras = new ClsCompras();
|
|
if (ObjCompras.RemoveTipoGasto(CveSubCategoria))
|
|
{
|
|
CargaDatos();
|
|
UpDatos.Update();
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD"));
|
|
Alert("Se eliminó la Categoría de Documento correctamente");
|
|
}
|
|
ObjCompras.Dispose();
|
|
}
|
|
|
|
protected void BtnAgregarSubCategoriaDoc_Click(object sender, EventArgs e)
|
|
{
|
|
ClsOIEventos ObjOI = new ClsOIEventos();
|
|
if (BtnAgregarSubCategoriaDoc.Text == "Agregar")
|
|
{
|
|
if (ObjOI.AddDocumentoSubCategoria(TxtSubCategoria.Text, DdlCategorias.SelectedValue.ToEntero()))
|
|
{
|
|
CargaDatos();
|
|
UpDatos.Update();
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD"));
|
|
Alert("Se agregó la Categoría de Documento correctamente");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ObjOI.UpdateDocumentoSubCategoria(CveSubCategoria, TxtSubCategoria.Text, DdlCategorias.SelectedValue.ToEntero()))
|
|
{
|
|
CargaDatos();
|
|
UpDatos.Update();
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD"));
|
|
Alert("Se actualizó la Categoría de Documento correctamente");
|
|
}
|
|
}
|
|
ObjOI.Dispose();
|
|
}
|
|
} |