Files
SIG/CGame/CatMotivosMerma.aspx.cs
MLopez 021e50c4b7 Limpieza masiva ClsPaginas
-RegistraScript se unifica en una sola clase static/shared y se simplica el código
-Alert se vuelve estático
-Random() no se manda a crear cada vez que se registra un script (esto tenía un costo alto)
-Se corrigieron unos errores en los nombres de funciones
-Las clases que ya heredan de Clspaginas, se les quita el this a RegistraScript y a Alert puesto que era innecesario (y además al haberlos vuelto métodos estáticos, NO pueden llamarse de un this)
2023-01-31 21:56:32 -07:00

24 lines
4.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using Extensiones;
public partial class CATMotivosMerma :ClsPaginas
{
#region Propiedades
private int CveMotivo
{
get{return (ViewState["CveMotivo"] == null) ? 0 : Convert.ToInt32(ViewState["CveMotivo"]);}
set{ViewState["CveMotivo"] =value;}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack){
CargaMotivosMerma();
}
}
protected void CargaMotivosMerma()
{
ClsCGame ObjMoti =new ClsCGame();
if (ObjMoti.GetMotivoMerma(UsuarioActual.CveEmpresa))
{
GVMotivosMerma.DataSource = ObjMoti.DtResultados;
GVMotivosMerma.DataBind();
}
ObjMoti.Dispose();
upDatosMoti.Update();
}
protected void LimpiaMotivosMerma()
{
TxtMotimotivo.Text= "";
UPModalMoti.Update();
}
protected void LnkEditarMoti_Click(object sender, EventArgs e)
{
LimpiaMotivosMerma();
GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
CveMotivo = gvRow.DataKey("CveMotivo").ToEntero();
TxtMotimotivo.Text= gvRow.DataKey("Motivo");
ChkMotiestatus.Checked = Convert.ToBoolean(gvRow.DataKey("Estatus"));
RegistraScript("$('#DModalMotivosMerma').modal();");
BtnMotiADD.Visible=false;
BtnMotiEdit.Visible=true;
DivEstatus.Visible = true;
UPModalMoti.Update();
}
protected void LnkAgregarMoti_Click(object sender, EventArgs e)
{
RegistraScript("$('#DModalMotivosMerma').modal();");
LimpiaMotivosMerma();
BtnMotiADD.Visible=true;
BtnMotiEdit.Visible=false;
DivEstatus.Visible = false;
UPModalMoti.Update();
}
protected void BtnMotiADD_Click(object sender, EventArgs e)
{
ClsCGame ObjMoti =new ClsCGame();
bool Continuar = ObjMoti.AddMotivoMerma(TxtMotimotivo.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa);
ObjMoti.Dispose();
if(Continuar)
{
RegistraScript("$('#DModalMotivosMerma').modal('hide');");
LimpiaMotivosMerma();
UPModalMoti.Update();
Alert("El Motivo de Merma se ha agregado");
CargaMotivosMerma();
}
}
protected void BtnMotiEdit_Click(object sender, EventArgs e)
{
ClsCGame ObjMoti =new ClsCGame();
bool Continuar = ObjMoti.UpdateMotivoMerma(CveMotivo, TxtMotimotivo.Text, ChkMotiestatus.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa);
ObjMoti.Dispose();
if(Continuar)
{
RegistraScript("$('#DModalMotivosMerma').modal('hide');");
LimpiaMotivosMerma();
UPModalMoti.Update();
Alert("El Motivo de Merma se ha actualizado");
CargaMotivosMerma();
}
}
protected void LnkEliminarMoti_Click(object sender, EventArgs e)
{
GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
ClsCGame ObjMoti = new ClsCGame();
bool Continuar = ObjMoti.RemoveMotivoMerma(gvRow.DataKey("CveMotivo").ToEntero());
ObjMoti.Dispose();
if(Continuar)
{
CargaMotivosMerma();
Alert("El Motivo de Merma se ha eliminado");
}
}
protected void GvMotivoMerma_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Convert.ToBoolean(e.Row.DBCampo("Estatus")) == true)
{
e.Row.FCLabel("lblestatus").Text = "Activo";
e.Row.FCLabel("lblestatus").ForeColor = System.Drawing.Color.Green;
}
else
{
e.Row.FCLabel("lblestatus").Text = "Inactivo";
e.Row.FCLabel("lblestatus").ForeColor = System.Drawing.Color.Red;
}
}
}
}