Files
SIG/Compras/CatTipoGasto.aspx.cs
2023-06-23 13:06:56 -07:00

108 lines
3.3 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()
{
ClsCompras ObjCompras = new ClsCompras();
if (ObjCompras.GetTipoGasto(-1, UsuarioActual.CveEmpresa))
{
GvDatos.DataSource = ObjCompras.DtResultados;
GvDatos.DataBind();
}
ObjCompras.Dispose();
}
private void RecargarGlobal()
{
set_GlobalDTTiposGastos(UsuarioActual.CveEmpresa, 1, null);
}
protected void BtnAgregarTipoGastoD_Click(object sender, EventArgs e)
{
BtnAgregarTipoGasto.Text = "Agregar";
TxtTipoGasto.Text = "";
ChkEstatus.Checked = true;
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();
ClsCompras ObjCompras = new ClsCompras();
if (ObjCompras.RemoveTipoGasto(CveTipoGasto))
{
CargaDatos();
UpDatos.Update();
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD"));
Alert("Se eliminó el Tipo de Gasto correctamente");
}
ObjCompras.Dispose();
RecargarGlobal();
}
protected void BtnAgregarTipoGasto_Click(object sender, EventArgs e)
{
ClsCompras ObjCompras = new ClsCompras();
if (BtnAgregarTipoGasto.Text == "Agregar")
{
if (ObjCompras.AddTipoGasto(TxtTipoGasto.Text,ChkEstatus.Checked,DateTime.Now.ToString(),UsuarioActual.CveUsuario,UsuarioActual.CveEmpresa))
{
Alert("Se agregó el Tipo de Gasto correctamente");
}
}
else
{
if (ObjCompras.UpdateTipoGasto(CveTipoGasto, TxtTipoGasto.Text, ChkEstatus.Checked, -1, -1))
{
Alert("Se actualizó el Tipo de Gasto correctamente");
}
}
ObjCompras.Dispose();
CargaDatos();
RecargarGlobal();
UpDatos.Update();
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD"));
}
}