121 lines
5.1 KiB
C#
121 lines
5.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI.WebControls;
|
|
using Extensiones;
|
|
|
|
public partial class Ventas_ClasificacionesDetalle : ClsPaginas
|
|
{
|
|
|
|
|
|
#region Propiedades
|
|
private int CveClasificacionDetalle
|
|
{
|
|
get { return (ViewState["CveClasificacionDetalle"] == null) ? 0 : Convert.ToInt32(ViewState["CveClasificacionDetalle"]); }
|
|
set { ViewState["CveClasificacionDetalle"] = value; }
|
|
}
|
|
private string Modalidad
|
|
{
|
|
get { return (ViewState["Modalidad"] == null) ? "" : ViewState["Modalidad"].ToString(); }
|
|
set { ViewState["Modalidad"] = value; }
|
|
}
|
|
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
InicializaValores();
|
|
CargaDatos();
|
|
}
|
|
}
|
|
|
|
private void InicializaValores()
|
|
{
|
|
DdlClasificacion.DataSource = get_GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby: "Clasificacion");
|
|
DdlClasificacion.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
DdlClasificacion.DataBind();
|
|
}
|
|
|
|
protected void CargaDatos()
|
|
{
|
|
ClsVentas ObjVentas = new ClsVentas();
|
|
if (ObjVentas.GetClasificacionDetalle(UsuarioActual.CveEmpresa))
|
|
{
|
|
GvDatos.DataSource = ObjVentas.DtResultados;
|
|
}
|
|
ObjVentas.Dispose();
|
|
GvDatos.DataBind();
|
|
UpDatos.Update();
|
|
}
|
|
|
|
protected void LimpiaModal()
|
|
{
|
|
TxtClasificacionDetalle.Text = "";
|
|
DdlClasificacion.SelectedIndex = 0;
|
|
Modalidad = "A";
|
|
UpModal.Update();
|
|
}
|
|
|
|
protected void LnkAgregarClasificacionDetalle_Click(object sender, EventArgs e)
|
|
{
|
|
this.RegistraScript("$('#DModal').modal();");
|
|
LimpiaModal();
|
|
BtnAddClasificacionDetalle.Text = "Agregar";
|
|
DivEstatus.Visible = false;
|
|
UpModal.Update();
|
|
}
|
|
|
|
protected void GvDatos_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
|
|
if (Convert.ToBoolean(e.Row.DBCampo("Estatus")) == true)
|
|
{
|
|
e.Row.Cells[3].Text = "Activo";
|
|
e.Row.Cells[3].ForeColor = System.Drawing.Color.Green;
|
|
}
|
|
else
|
|
{
|
|
e.Row.Cells[3].Text = "Inactivo";
|
|
e.Row.Cells[3].ForeColor = System.Drawing.Color.Red;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void LnkEliminar_Click(object sender, EventArgs e)
|
|
{
|
|
GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
ClsVentas ObjVenta = new ClsVentas();
|
|
bool Continuar = ObjVenta.RemoveClasificacionDetalle(gvRow.DataKey("CveClasificacionDetalle").ToEntero());
|
|
ObjVenta.Dispose();
|
|
if (Continuar)
|
|
{
|
|
RecargaGlobal();
|
|
CargaDatos();
|
|
Alert("La Clasificacion Detalle se ha eliminado");
|
|
|
|
}
|
|
}
|
|
|
|
protected void LnkEditar_Click(object sender, EventArgs e)
|
|
{
|
|
LimpiaModal();
|
|
GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
CveClasificacionDetalle = gvRow.DataKey("CveClasificacionDetalle").ToEntero();
|
|
TxtClasificacionDetalle.Text = gvRow.DataKey("ClasificacionDetalle");
|
|
DdlClasificacion.SelectedValueExist(gvRow.DataKey("CveClasificacion"));
|
|
ChkEstatus.Checked = Convert.ToBoolean(gvRow.DataKey("Estatus"));
|
|
Modalidad = "U";
|
|
this.RegistraScript("$('#DModal').modal();");
|
|
BtnAddClasificacionDetalle.Text = "Actualizar";
|
|
DivEstatus.Visible = true;
|
|
UpModal.Update();
|
|
}
|
|
|
|
protected void BtnAddClasificacionDetalle_Click(object sender, EventArgs e)
|
|
{
|
|
ClsVentas ObjVentas = new ClsVentas();
|
|
if (Modalidad == "A")
|
|
{
|
|
if (ObjVentas.AddClasificacionDetalle(TxtClasificacionDetalle.Text, DdlClasificacion.SelectedValue.ToEntero(),
|
|
UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
|
{
|
|
CargaDatos();
|
|
this.RegistraScript("$('#DModal').modal('hide');");
|
|
Alert("Guardada Correctamente");
|
|
}
|
|
}
|
|
else if (Modalidad == "U")
|
|
{
|
|
if (ObjVentas.UpdateClasificacionDetalle(CveClasificacionDetalle, TxtClasificacionDetalle.Text, DdlClasificacion.SelectedValue.ToEntero(),
|
|
ChkEstatus.Checked))
|
|
{
|
|
CargaDatos();
|
|
this.RegistraScript("$('#DModal').modal('hide');");
|
|
Alert("Actualizada Correctamente");
|
|
}
|
|
}
|
|
ObjVentas.Dispose();
|
|
RecargaGlobal();
|
|
}
|
|
protected void RecargaGlobal()
|
|
{
|
|
ClsVentas ObjVentas = new ClsVentas();
|
|
|
|
if (ObjVentas.GetClasificacionDetalle(-1, -1,-1,-1))
|
|
{
|
|
Application["GlobalDTClasificacionesDetalle"] = ObjVentas.DtResultados;
|
|
}
|
|
|
|
ObjVentas.Dispose();
|
|
}
|
|
|
|
|
|
|
|
} |