110 lines
3.7 KiB
C#
110 lines
3.7 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 AF_CatActividades : ClsPaginas
|
|
{
|
|
private int CveActividad
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveActividad"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveActividad"] = value;
|
|
}
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
CargaDatos();
|
|
}
|
|
}
|
|
|
|
private void CargaDatos()
|
|
{
|
|
ClsAF ObjAF = new ClsAF();
|
|
if (ObjAF.GetActividades(-1, -1, -1, UsuarioActual.CveEmpresa))
|
|
{
|
|
GvDatos.DataSource = ObjAF.DtResultados;
|
|
GvDatos.DataBind();
|
|
}
|
|
DdlPuesto.DataSource = get_GlobalDTRHPuestos(UsuarioActual.CveEmpresa);
|
|
DdlPuesto.DataBind();
|
|
DdlPuesto.Items.Insert(0,new ListItem("Seleccione", "-1"));
|
|
ObjAF.Dispose();
|
|
}
|
|
|
|
protected void BtnAgregarActividadD_Click(object sender, EventArgs e)
|
|
{
|
|
BtnAgregarActividad.Text = "Agregar";
|
|
TxtNombre.Text = "";
|
|
DdlPuesto.SelectedValueExist(-1);
|
|
TxtCantidad.Text = "";
|
|
UpModalTiposD.Update();
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarActividadD"));
|
|
}
|
|
|
|
protected void LnkEditar_Click(object sender, EventArgs e)
|
|
{
|
|
BtnAgregarActividad.Text = "Actualizar";
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
CveActividad = GvRow.DataKey("CveActividad").ToEntero();
|
|
TxtNombre.Text = GvRow.DataKey("Nombre");
|
|
DdlPuesto.SelectedValueExist(GvRow.DataKey("CvePuesto"));
|
|
TxtCantidad.Text = GvRow.DataKey("Cantidad");
|
|
UpModalTiposD.Update();
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarActividadD"));
|
|
}
|
|
|
|
protected void LnkEliminar_Click(object sender, EventArgs e)
|
|
{
|
|
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
CveActividad = GvRow.DataKey("CveActividad").ToEntero();
|
|
ClsAF ObjAF = new ClsAF();
|
|
if (ObjAF.DeleteActividades(CveActividad))
|
|
{
|
|
CargaDatos();
|
|
UpDatos.Update();
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarActividadD"));
|
|
Alert("Se eliminó la Actividad correctamente");
|
|
}
|
|
ObjAF.Dispose();
|
|
}
|
|
|
|
protected void BtnAgregarActividad_Click(object sender, EventArgs e)
|
|
{
|
|
ClsAF ObjAF = new ClsAF();
|
|
if (BtnAgregarActividad.Text == "Agregar")
|
|
{
|
|
if (ObjAF.AddActividades(TxtNombre.Text, DdlPuesto.SelectedValue.ToEntero(),TxtCantidad.Text.ToDecimal(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
|
{
|
|
CargaDatos();
|
|
UpDatos.Update();
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarActividadD"));
|
|
Alert("Se agregó la Actividad correctamente");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ObjAF.UpdateActividades(CveActividad,TxtNombre.Text, DdlPuesto.SelectedValue.ToEntero(), TxtCantidad.Text.ToDecimal(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
|
{
|
|
CargaDatos();
|
|
UpDatos.Update();
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarActividadD"));
|
|
Alert("Se actualizó la Actividad correctamente");
|
|
}
|
|
}
|
|
ObjAF.Dispose();
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarActividadD"));
|
|
}
|
|
} |