using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI.WebControls; using Extensiones; public partial class CGame_CatScat : ClsPaginas { #region Propiedades private int CveScat { get { return (ViewState["CveScat"] == null) ? 0 : Convert.ToInt32(ViewState["CveScat"]); } set { ViewState["CveScat"] = value; } } #endregion protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CargaScat(); } } protected void CargaScat() { ClsCGame ObjCGame = new ClsCGame(); if (ObjCGame.GetScat(UsuarioActual.CveEmpresa)) { GvScat.DataSource = ObjCGame.DtResultados; } ObjCGame.Dispose(); GvScat.DataBind(); UpDatos.Update(); } protected void LimpiaScat() { TxtScat.Text = ""; UpModal.Update(); } protected void LnkAgregarScat_Click(object sender, EventArgs e) { RegistraScript("$('#DModalScat').modal();"); LimpiaScat(); BtnScatAdd.Visible = true; BtnScatEdit.Visible = false; DivEstatus.Visible = false; UpModal.Update(); } protected void GvScat_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; } } } protected void LnkEditar_Click(object sender, EventArgs e) { LimpiaScat(); GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); CveScat = gvRow.DataKey("CveScat").ToEntero(); TxtScat.Text = gvRow.DataKey("Scat"); ChkEstatus.Checked = Convert.ToBoolean(gvRow.DataKey("Estatus")); RegistraScript("$('#DModalScat').modal();"); BtnScatAdd.Visible = false; BtnScatEdit.Visible = true; DivEstatus.Visible = true; UpModal.Update(); } protected void imgD_Click(object sender, EventArgs e) { GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); ClsCGame ObjCGame = new ClsCGame(); bool Continuar = ObjCGame.RemoveScat(gvRow.DataKey("CveScat").ToEntero()); ObjCGame.Dispose(); if (Continuar) { CargaScat(); Alert("El Scat se ha eliminado"); } } protected void BtnScatAdd_Click(object sender, EventArgs e) { ClsCGame ObjCgame = new ClsCGame(); bool Continuar = ObjCgame.AddScat(TxtScat.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa); ObjCgame.Dispose(); if (Continuar) { RegistraScript("$('#DModalScat').modal('hide');"); LimpiaScat(); UpModal.Update(); Alert("El Scat se ha agregado"); CargaScat(); } } protected void BtnScatEdit_Click(object sender, EventArgs e) { ClsCGame ObjCGame = new ClsCGame(); bool Continuar = ObjCGame.UpdateScat(CveScat, TxtScat.Text, ChkEstatus.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa); ObjCGame.Dispose(); if (Continuar) { RegistraScript("$('#DModalScat').modal('hide');"); LimpiaScat(); UpModal.Update(); Alert("El Scat se ha actualizado"); CargaScat(); } } }