Option Explicit On Option Strict On Imports Extensiones Imports System.Data Partial Class Inventarios_Default Inherits ClsPaginas #Region "Propiedades" Private ReadOnly Property CvePS As Integer Get Return ViewState("CvePS").ToString.ToEntero End Get End Property #End Region Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then CType(Me.Master, BaseMasterPage).EsPopup = True CType(Me.Master, BaseMasterPage).PopupWidth = 780 RegistraScript("if($get('tdContenido')){$get('tdContenido').style.height='465px'}") InicializaValores() CargaSubProyecto() If Request("CvePS") IsNot Nothing AndAlso IsNumeric(Request("CvePS")) AndAlso Request("CvePS").ToEntero > 0 Then ViewState("CvePS") = Request("CvePS") CargaDatos(CvePS, 1) DDlPS.SelectedValue = CvePS.ToString End If If Not Request("EsThickbox") Is Nothing Then hdnEsThickbox.Value = Request("EsThickbox") Else hdnEsThickbox.Value = "N" End If Me.Form.DefaultButton = BtnBuscar.UniqueID If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then DivCodigoSeriePS.Visible = True TxtCodigoPS.Focus() End If If UsuarioActual.CveEmpresa.Contiene(119) Then LtPrecioPS.Visible = True DivSucursal.Visible = True End If If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then LtPrecioPS.Visible = True DivListasPrecios.Visible = True DivListasPreciosRow2.Visible = True DivListasPrecios2.Visible = True End If If UsuarioActual.CveRol = 1 Then LnkBsucarSerie.Visible = True End If End If End Sub Private Sub InicializaValores() 'FUNCIONALIDAD 105 If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then DDlPS.setEsWebService(True) Else DDlPS.setEsWebService(False) 'FUNCIONALIDAD DE COMPUESTO If UsuarioActual.Empresa.Funcionalidad(143) = "1" Then DDlPS.ddl.DataTextField = "PSCodigoCompuesto" End If DDlPS.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) DDlPS.DataBind() End If If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then DivMed.Visible = True DivRin.Visible = True CargarMedRin() DivMedRin.Visible = True DivEquivalentes.Visible = True DivPS.Visible = False End If If UsuarioActual.CveEmpresa = 119 Then TrCompuesto.Visible = True End If Dim Txt As String = IfNull(Request("Txt"), "").ToString If Txt <> "" Then LblTitulo.Text = String.Format("Búsqueda de {0}", Txt) If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then CargaListasPrecios() End If End Sub Private Sub CargaSubProyecto() DdlSubProyecto.Items.Clear() DdlSubProyecto.SelectedValue = Nothing DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa, Estatus:=1) DdlSubProyecto.DataBind() DdlSubProyecto.Items.Insert(0, New ListItem("-", "-1")) End Sub Private Sub CargaListasPrecios() DdlPrecioLista.DataSource = GlobalDTPrecioListas(UsuarioActual.CveEmpresa) DdlPrecioLista.DataBind() DdlPrecioLista.Items.Insert(0, New ListItem("-", "-1")) End Sub Protected Sub BtnBuscar_Click(sender As Object, e As System.EventArgs) Handles BtnBuscar.Click If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then CargarDatosMedRin() CargaEquivalencia() ElseIf UsuarioActual.CveEmpresa = 119 Then CargaDatosCompuesto() Else CargaDatos(DDlPS.SelectedValue.ToEntero, 1) End If End Sub Private Sub CargaDatos(CvePS As Integer, Tipo As Integer) If ValidarFiltrosSeleccionados() OrElse CvePS > 0 Then Dim RestringirAlmacenes As Integer = -1 If UsuarioActual.CveEmpresa = 119 Then RestringirAlmacenes = 1 'restringue los almacenes:Consignación,Productos Financieros Asignados,,roductos Financieros,Consumo Interno,Activo Fijo,Merma,Consignación de Contrato,Devolucion proveedor, End If Dim BuscarEnTabla As Boolean = False If UsuarioActual.Empresa.Funcionalidad(715) = "1" Then BuscarEnTabla = True End If Dim ObjInventarios As New ClsInventarios() If ObjInventarios.GetExistenciasProducto(CvePS, -1, UsuarioActual.CveEmpresa, -1, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), ExcluyeApartados:=-1, ExcluyeAdelantado:=1, CveSubProyecto:=DdlSubProyecto.SelectedValue.ToEntero, ExcluyeTransitorios:=1, RestringirAlmacenes:=RestringirAlmacenes, TopSelect:=100, BuscarEnTabla:=BuscarEnTabla) Then CargaPS(CvePS) If ObjInventarios.DtResultados.Rows.Count > 0 Then GV.DataSource = ObjInventarios.DtResultados Else GV.DataSource = Nothing Dim Js As String = If(Tipo = 1, "", "window.setTimeout(Focus,200);") Alert("No se encontraron registros con los parámetros solicitados.", Extensiones.TipoMensaje.MsgAdvertencia) End If End If ObjInventarios.Dispose() GV.DataBind() UPDatos.Update() Else Alert("Seleccione un producto", TipoMensaje.MsgAdvertencia) End If End Sub Private Sub CargaPS(CvePS As Integer) If CvePS <= 0 Then Exit Sub Dim dr As Data.DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") If dr IsNot Nothing Then TblBusqueda.Visible = True LtPs.Text = $"Producto: {dr("PSCodigo").ToString}" Dim CvePrecioLista As Integer = -1 If Not UsuarioActual.Empresa.Funcionalidad(404).ToEntero > 0 Then 'sino manneja precios de lista CvePrecioLista = -2 End If If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then If DdlPrecioLista.SelectedValue.ToEntero() > 0 Then CvePrecioLista = DdlPrecioLista.SelectedValue.ToEntero() Else CvePrecioLista = -2 End If End If Dim ObjVta As New ClsVentas Dim objPS As New ClsProductosServicios If ObjVta.GetPrecioListas(UsuarioActual.CveEmpresa) Then If ObjVta.DtResultados.Rows.Count > 0 Then If CvePrecioLista = -1 Then CvePrecioLista = ObjVta.DtResultados.Rows(0)("CvePrecioLista").ToString.ToEntero If objPS.GetPSPreciosLista(UsuarioActual.CveEmpresa, CvePrecioLista, -1, DDlPS.SelectedValue.ToEntero) Then If objPS.DtResultados.Rows.Count > 0 Then LtPrecioPS.Text = $"Precio: $: {objPS.DtResultados.Rows(0)("PrecioLista").ToString.FormatoNumero} {dr("Abreviatura").ToString}" End If End If End If End If ObjVta.Dispose() objPS.Dispose() If UsuarioActual.CveEmpresa = 119 Then If CBool(dr("AplicaIEPS")) Then LtlIEPS.Visible = True LtlIEPSPorcentaje.Visible = True LtlIEPSPorcentaje.Text = $"% {(dr("IEPSPorcentaje").ToString.ToDouble * 100).FormatoNumero}" Else LtlIEPS.Visible = False LtlIEPSPorcentaje.Visible = False End If If dr("IVA").ToString = "-1" OrElse dr("IVA").ToString.ToDecimal > 0 Then LtlIVA.Visible = True LtlIVAPorcentaje.Visible = True LtlIVAPorcentaje.Text = $"Si" Else LtlIVA.Visible = False LtlIVAPorcentaje.Visible = False End If End If If UsuarioActual.TienePermisoPagina(624) Then HlPendiente.Visible = True HlPendiente.NavigateUrl = String.Format("/Inventarios/RepVentasXSurtir.aspx?CvePS={0}", CvePS) End If End If End Sub Private Sub GV_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GV.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DBCampo("CveAlmacen") = "" Then e.Row.CssClass = "Totales" End If If UsuarioActual.CveEmpresa = 119 Then GV.Columns(5).Visible = True End If End If End Sub Private Sub GvMedRin_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvMedRin.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DBCampo("CveAlmacen") = "" Then e.Row.CssClass = "Totales" End If If UsuarioActual.CveEmpresa = 119 Then GV.Columns(6).Visible = True End If End If End Sub Private Sub CargaDatosCompuesto() Dim Compuesto As String = TxtCompuesto.Text.Trim If Compuesto = "" Then Compuesto = "-1" Dim ObjInventarios As New ClsInventarios If ObjInventarios.GetExistencias119(DDlPS.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveUsuario, Compuesto) Then GV.DataSource = ObjInventarios.DtResultados TblBusqueda.Visible = True CargaPS(DDlPS.SelectedValue.ToEntero) GV.Columns(6).Visible = True End If ObjInventarios.Dispose() GV.DataBind() UPDatos.Update() End Sub #Region " BUSCA | CODIGO - SERIE " Protected Sub BtnCodigoPS_Click(sender As Object, e As EventArgs) If TxtCodigoPS.Text = "" Then Exit Sub End If Dim DrPS As Data.DataRow = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"CodigoBarras = '{TxtCodigoPS.Text}'") If DrPS Is Nothing Then Alert($"No se ha encontrado un producto del Codigo ""{TxtCodigoPS.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);") TxtCodigoPS.Text = "" TxtCodigoPS.Focus() Exit Sub End If CargaDatos(DrPS("CvePS").ToString.ToEntero, 2) TxtCodigoPS.Text = "" TxtCodigoPS.Focus() End Sub #End Region Private Sub CargarMedRin() 'Dim ObjGral As New ClsGenerales 'If ObjGral.GetMedidas(UsuarioActual.CveEmpresa) Then ' DdlMedidas.DataSource = GlobalDTPS.FiltraParametros("", Orderby:="Medida") ' If ObjGral.GetRimTamanios(UsuarioActual.CveEmpresa) Then ' DdlRin.DataSource = ObjGral.DtResultados.FiltraParametros("", Orderby:="RinTamaño") ' End If 'End If 'ObjGral.Dispose() DdlMedidas.DataSource = GlobalDTPSMedidas(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Medida") DdlMedidas.DataBind() DdlRin.DataSource = GlobalDTPSRinTamaños(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="RinTamaño") DdlRin.DataBind() DdlMedidas.Items.Insert(0, New ListItem("-", "-1")) DdlRin.Items.Insert(0, New ListItem("-", "-1")) End Sub Private Sub CargarDatosMedRin() Dim ObjInventarios As New ClsInventarios If ObjInventarios.GetExistenciasMedRin(DDlPS.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlRin.SelectedValue.ToEntero, DdlMedidas.SelectedValue.ToEntero) Then GvMedRin.DataSource = ObjInventarios.DtResultados.Copy() If ObjInventarios.DtResultados.Rows.Count > 0 Then TblBusqueda.Visible = True GvMedRin.Columns(5).Visible = ObjInventarios.DtResultados.MAX("CantidadMinimaPromo") <> "" End If End If ObjInventarios.Dispose() DivMedRin.Visible = True GvMedRin.DataBind() UPDatos.Update() End Sub Private Sub CargaEquivalencia() Dim ObjGeneral As New ClsGenerales If ObjGeneral.GetMedidasEquivalentes(UsuarioActual.CveEmpresa, DdlMedidas.SelectedValue.ToEntero(), DdlRin.SelectedValue.ToEntero()) Then GvEquival.DataSource = ObjGeneral.DtResultados End If ObjGeneral.Dispose() GvEquival.DataBind() End Sub Private Function ValidarFiltrosSeleccionados() As Boolean If DDlPS.SelectedValue.ToEntero > 0 Then Return True Return False End Function Protected Sub LnkBsucarSerie_Click(sender As Object, e As EventArgs) GvPSSerie.DataSource = Nothing GvPSSerie.DataBind() UpModalBuscarPorSerie.Update() RegistraScript("$('#ModalBuscarPorSerie').modal('show');") End Sub Protected Sub BtnBuscarPorSerie_Click(sender As Object, e As EventArgs) Dim ObjInventario As New ClsInventarios If ObjInventario.GetProductoPorSerie(TxtBuscarPorSerie.Text, UsuarioActual.Empresa.CveEmpresa) Then GvPSSerie.DataSource = ObjInventario.DtResultados End If ObjInventario.Dispose() GvPSSerie.DataBind() UpModalBuscarPorSerie.Update() End Sub Protected Sub DdlPrecioLista_SelectedIndexChanged(sender As Object, e As EventArgs) Dim dr As Data.DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DDlPS.SelectedValue.ToEntero).FiltroPrimero("") If dr IsNot Nothing Then Dim ObjVta As New ClsVentas Dim objPS As New ClsProductosServicios If ObjVta.GetPrecioListas(UsuarioActual.CveEmpresa) Then If ObjVta.DtResultados.Rows.Count > 0 Then If objPS.GetPSPreciosLista(UsuarioActual.CveEmpresa, DdlPrecioLista.SelectedValue.ToEntero(), -1, DDlPS.SelectedValue.ToEntero) Then If objPS.DtResultados.Rows.Count > 0 Then LtPrecioPS.Text = $"Precio de venta: $: {objPS.DtResultados.Rows(0)("PrecioLista").ToString.FormatoNumero} {dr("Abreviatura").ToString}" End If End If End If End If ObjVta.Dispose() objPS.Dispose() End If UPDatos.Update() End Sub End Class