-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)
127 lines
3.8 KiB
C#
127 lines
3.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI.WebControls;
|
|
using Extensiones;
|
|
|
|
public partial class CATProductos : ClsPaginas
|
|
{
|
|
|
|
#region Propiedades
|
|
|
|
private int CvePS
|
|
{
|
|
get{return (ViewState["CvePS"] == null) ? 0 : Convert.ToInt32(ViewState["CvePS"]);}
|
|
set{ViewState["CvePS"] =value;}
|
|
}
|
|
|
|
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack){
|
|
CargaProductos();
|
|
}
|
|
}
|
|
protected void CargaProductos()
|
|
{
|
|
ClsCGame ObjCGame =new ClsCGame();
|
|
if (ObjCGame.GetPS(UsuarioActual.CveEmpresa))
|
|
{
|
|
GVProductos.DataSource = ObjCGame.DtResultados;
|
|
GVProductos.DataBind();
|
|
}
|
|
ObjCGame.Dispose();
|
|
upDatosProd.Update();
|
|
}
|
|
|
|
protected void LimpiaProductos()
|
|
{
|
|
TxtProdpS.Text= "";
|
|
UPModalProd.Update();
|
|
}
|
|
protected void LnkEditarProd_Click(object sender, EventArgs e)
|
|
{
|
|
LimpiaProductos();
|
|
GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
CvePS = gvRow.DataKey("CvePS").ToEntero();
|
|
TxtProdpS.Text = gvRow.DataKey("PS");
|
|
ChkProdestatus.Checked = Convert.ToBoolean(gvRow.DataKey("Estatus"));
|
|
RegistraScript("$('#DModalProductos').modal();");
|
|
BtnProdADD.Visible = false;
|
|
BtnProdEdit.Visible = true;
|
|
DivEstatus.Visible = true;
|
|
UPModalProd.Update();
|
|
}
|
|
protected void LnkAgregarProd_Click(object sender, EventArgs e)
|
|
{
|
|
RegistraScript("$('#DModalProductos').modal();");
|
|
LimpiaProductos();
|
|
BtnProdADD.Visible=true;
|
|
BtnProdEdit.Visible=false;
|
|
DivEstatus.Visible = false;
|
|
UPModalProd.Update();
|
|
}
|
|
protected void BtnProdADD_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
ClsCGame ObjCGame = new ClsCGame();
|
|
bool Continuar = ObjCGame.AddPS(TxtProdpS.Text, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa);
|
|
ObjCGame.Dispose();
|
|
if (Continuar)
|
|
{
|
|
RegistraScript("$('#DModalProductos').modal('hide');");
|
|
LimpiaProductos();
|
|
UPModalProd.Update();
|
|
Alert("El Producto se ha agregado");
|
|
CargaProductos();
|
|
}
|
|
}
|
|
protected void BtnProdEdit_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
ClsCGame ObjCGame = new ClsCGame();
|
|
bool Continuar = ObjCGame.UpdatePS(CvePS, TxtProdpS.Text, 1, ChkProdestatus.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa);
|
|
ObjCGame.Dispose();
|
|
if (Continuar)
|
|
{
|
|
RegistraScript("$('#DModalProductos').modal('hide');");
|
|
LimpiaProductos();
|
|
UPModalProd.Update();
|
|
Alert("El Producto se ha actualizado");
|
|
CargaProductos();
|
|
}
|
|
}
|
|
protected void LnkEliminarProd_Click(object sender, EventArgs e)
|
|
{
|
|
GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
ClsCGame ObjCGame = new ClsCGame();
|
|
bool Continuar = ObjCGame.RemovePS(gvRow.DataKey("CvePS").ToEntero());
|
|
ObjCGame.Dispose();
|
|
if (Continuar)
|
|
{
|
|
CargaProductos();
|
|
Alert("El Producto se ha eliminado");
|
|
}
|
|
}
|
|
|
|
protected void GVProductos_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;
|
|
}
|
|
}
|
|
}
|
|
}
|