se agrego un nuevo catálogo de equivalencias en medidas para econollantas

This commit is contained in:
Antonio Gonzalez
2020-10-08 18:33:17 -07:00
parent bfdda92b7a
commit 7a7c1f71ea
7 changed files with 348 additions and 2 deletions

View File

@@ -0,0 +1,132 @@
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 General_CatMedidaEquivalencia : ClsPaginas
{
private int CveMedidaEquivalencia
{
get
{
return ViewState["CveMedidaEquivalencia"].ToString().ToEntero();
}
set
{
ViewState["CveMedidaEquivalencia"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CargaDatos();
CargaDatosModal();
}
}
private void CargaDatos()
{
ClsGenerales ObjGeneral = new ClsGenerales();
if (ObjGeneral.GetMedidasEquivalentes(UsuarioActual.CveEmpresa))
{
GvDatos.DataSource = ObjGeneral.DtResultados;
GvDatos.DataBind();
}
ObjGeneral.Dispose();
}
private void CargaDatosModal()
{
ClsGenerales ObjGeneral = new ClsGenerales();
if (ObjGeneral.GetMedidas(UsuarioActual.CveEmpresa))
{
DdlMedidas.DataSource = ObjGeneral.DtResultados;
DdlMedidasEquivalente.DataSource = ObjGeneral.DtResultados;
}
if (ObjGeneral.GetRimTamanios(UsuarioActual.CveEmpresa))
{
DdlRin.DataSource = ObjGeneral.DtResultados;
DdlRinEquivalente.DataSource = ObjGeneral.DtResultados;
}
ObjGeneral.Dispose();
DdlMedidas.DataBind();
DdlMedidasEquivalente.DataBind();
DdlRin.DataBind();
DdlRinEquivalente.DataBind();
DdlMedidas.Items.Insert(0, new ListItem("Seleccione", "-1"));
DdlMedidasEquivalente.Items.Insert(0, new ListItem("Seleccione", "-1"));
DdlRin.Items.Insert(0, new ListItem("Seleccione", "-1"));
DdlRinEquivalente.Items.Insert(0, new ListItem("Seleccione", "-1"));
}
protected void BtnAgregarMedidaEquivalente_Click(object sender, EventArgs e)
{
BtnAgregarEquivalente.Text = "Agregar";
DdlMedidas.SelectedValueExist(-1);
DdlMedidasEquivalente.SelectedValueExist(-1);
DdlRin.SelectedValueExist(-1);
DdlRinEquivalente.SelectedValueExist(-1);
UpModalTiposD.Update();
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD"));
}
protected void LnkEditar_Click(object sender, EventArgs e)
{
BtnAgregarEquivalente.Text = "Actualizar";
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
CveMedidaEquivalencia = GvRow.DataKey("CveMedidaEquivalencia").ToEntero();
int CveMedida = GvRow.DataKey("CveMedida").ToEntero();
int CveRin = GvRow.DataKey("CveRin").ToEntero();
int CveMedidaEquivalente = GvRow.DataKey("CveMedidaEquivalente").ToEntero();
int CveRinEquivalente = GvRow.DataKey("CveRinEquivalente").ToEntero();
DdlMedidas.SelectedValueExist(CveMedida);
DdlMedidasEquivalente.SelectedValueExist(CveMedidaEquivalente);
DdlRin.SelectedValueExist(CveRin);
DdlRinEquivalente.SelectedValueExist(CveRinEquivalente);
UpModalTiposD.Update();
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD"));
}
protected void LnkEliminar_Click(object sender, EventArgs e)
{
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
int CveMedidaEquivalenciaEliminar = GvRow.DataKey("CveMedidaEquivalencia").ToEntero();
ClsGenerales ObjGeneral = new ClsGenerales();
if (ObjGeneral.RemoveMedidasEquivalentes(CveMedidaEquivalenciaEliminar))
{
Alert("Equivalencia eliminada correctamente");
CargaDatos();
UpDatos.Update();
}
ObjGeneral.Dispose();
}
protected void BtnAgregarEquivalente_Click(object sender, EventArgs e)
{
ClsGenerales ObjGeneral = new ClsGenerales();
if(BtnAgregarEquivalente.Text == "Agregar")
{
if (ObjGeneral.AddMedidasEquivalentes(DdlMedidas.SelectedValue.ToEntero(),DdlRin.SelectedValue.ToEntero(), DdlMedidasEquivalente.SelectedValue.ToEntero(),DdlRinEquivalente.SelectedValue.ToEntero()))
{
Alert("Se agregó la equivalencia correctamente");
}
}else
{
if (ObjGeneral.UpdateMedidasEquivalentes(CveMedidaEquivalencia, DdlMedidas.SelectedValue.ToEntero(), DdlRin.SelectedValue.ToEntero(), DdlMedidasEquivalente.SelectedValue.ToEntero(), DdlRinEquivalente.SelectedValue.ToEntero()))
{
Alert("Se actualizó la equivalencia correctamente");
}
}
ObjGeneral.Dispose();
CargaDatos();
UpDatos.Update();
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD"));
}
}