104 lines
3.1 KiB
C#
104 lines
3.1 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 Compras_CatTipoGasto : ClsPaginas
|
|
{
|
|
private int CveTipoGasto
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveTipoGasto"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveTipoGasto"] = value;
|
|
}
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
CargaDatos();
|
|
}
|
|
}
|
|
|
|
private void CargaDatos()
|
|
{
|
|
ClsAC ObjAC = new ClsAC();
|
|
if (ObjAC.GetTipoGasto())
|
|
{
|
|
GvDatos.DataSource = ObjAC.DtResultados;
|
|
GvDatos.DataBind();
|
|
}
|
|
ObjAC.Dispose();
|
|
}
|
|
|
|
protected void BtnAgregarTipoGastoD_Click(object sender, EventArgs e)
|
|
{
|
|
BtnAgregarTipoGasto.Text = "Agregar";
|
|
TxtTipoGasto.Text = "";
|
|
ChkEstatus.Checked = true;
|
|
ChkEstatus.Enabled = false;
|
|
UpModalTiposD.Update();
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD"));
|
|
}
|
|
protected void LnkEditar_Click(object sender, EventArgs e)
|
|
{
|
|
BtnAgregarTipoGasto.Text = "Actualizar";
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
CveTipoGasto = GvRow.DataKey("CveTipoGasto").ToEntero();
|
|
TxtTipoGasto.Text = GvRow.DataKey("TipoGasto");
|
|
ChkEstatus.Checked = GvRow.DataKey("Estatus") == "Activo";
|
|
ChkEstatus.Enabled = true;
|
|
UpModalTiposD.Update();
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD"));
|
|
}
|
|
|
|
protected void LnkEliminar_Click(object sender, EventArgs e)
|
|
{
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
CveTipoGasto = GvRow.DataKey("CveTipoGasto").ToEntero();
|
|
ClsAC ObjAC = new ClsAC();
|
|
if (ObjAC.RemoveTipoGasto(CveTipoGasto))
|
|
{
|
|
CargaDatos();
|
|
UpDatos.Update();
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD"));
|
|
Alert("Se eliminó el Tipo de Gasto correctamente");
|
|
}
|
|
ObjAC.Dispose();
|
|
}
|
|
|
|
protected void BtnAgregarTipoGasto_Click(object sender, EventArgs e)
|
|
{
|
|
ClsAC ObjAC = new ClsAC();
|
|
if (BtnAgregarTipoGasto.Text == "Agregar")
|
|
{
|
|
if (ObjAC.AddTipoGasto(TxtTipoGasto.Text,UsuarioActual.CveUsuario))
|
|
{
|
|
CargaDatos();
|
|
UpDatos.Update();
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD"));
|
|
Alert("Se agregó el Tipo de Gasto correctamente");
|
|
}
|
|
}else
|
|
{
|
|
if (ObjAC.UpdateTipoGasto(TxtTipoGasto.Text,ChkEstatus.Checked,CveTipoGasto))
|
|
{
|
|
CargaDatos();
|
|
UpDatos.Update();
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD"));
|
|
Alert("Se actualizó el Tipo de Gasto correctamente");
|
|
}
|
|
}
|
|
ObjAC.Dispose();
|
|
}
|
|
} |