270 lines
11 KiB
VB.net
270 lines
11 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports Extensiones
|
|
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
|
|
|
|
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
|
|
Dim Txt As String = IfNull(Request("Txt"), "").ToString
|
|
If Txt <> "" Then LblTitulo.Text = String.Format("Búsqueda de {0}", Txt)
|
|
|
|
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
|
|
|
|
Protected Sub BtnBuscar_Click(sender As Object, e As System.EventArgs) Handles BtnBuscar.Click
|
|
If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then
|
|
CargarDatosMedRin()
|
|
CargaEquivalencia()
|
|
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 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) Then
|
|
Dim dr As Data.DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
|
|
|
If dr IsNot Nothing Then
|
|
LtPs.Text = $"Producto: <b>{dr("PSCodigo").ToString}</b>"
|
|
Dim CvePrecioLista As Integer = -1
|
|
If Not UsuarioActual.Empresa.Funcionalidad(404).ToEntero > 0 Then 'sino manneja precios de lista
|
|
CvePrecioLista = -2
|
|
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 de venta: <b>$: {objPS.DtResultados.Rows(0)("PrecioLista").ToString.FormatoNumero} {dr("Abreviatura").ToString}</b>"
|
|
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 = $"<b>% {(dr("IEPSPorcentaje").ToString.ToDouble * 100).FormatoNumero}</b>"
|
|
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 = $"<b>Si</b>"
|
|
Else
|
|
LtlIVA.Visible = False
|
|
LtlIVAPorcentaje.Visible = False
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
If UsuarioActual.TienePermisoPagina(624) Then
|
|
HlPendiente.Visible = True
|
|
HlPendiente.NavigateUrl = String.Format("/Inventarios/RepVentasXSurtir.aspx?CvePS={0}", CvePS)
|
|
End If
|
|
|
|
If ObjInventarios.DtResultados.Rows.Count > 0 Then
|
|
GV.DataSource = ObjInventarios.DtResultados
|
|
Else
|
|
GV.DataSource = Nothing
|
|
Dim Js = 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()
|
|
TblBusqueda.Visible = True
|
|
Else
|
|
Alert("Seleccione un producto", TipoMensaje.MsgAdvertencia)
|
|
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
|
|
|
|
|
|
|
|
#Region " BUSCA | CODIGO - SERIE "
|
|
Protected Sub BtnCodigoPS_Click(sender As Object, e As EventArgs)
|
|
|
|
If TxtCodigoPS.Text = "" Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"CodigoBarras = '{TxtCodigoPS.Text}'")
|
|
If DrPS Is Nothing Then
|
|
Alert($"No se ha encontrado un producto del Codigo ""<b>{TxtCodigoPS.Text}</b>"". ", 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 = ObjGral.DtResultados.FiltraParametros("", Orderby:="Medida")
|
|
If ObjGral.GetRimTamanios(UsuarioActual.CveEmpresa) Then
|
|
DdlRin.DataSource = ObjGral.DtResultados.FiltraParametros("", Orderby:="RinTamaño")
|
|
End If
|
|
End If
|
|
ObjGral.Dispose()
|
|
DdlMedidas.DataBind()
|
|
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
|
|
End If
|
|
ObjInventarios.Dispose()
|
|
GvMedRin.DataBind()
|
|
UPDatos.Update()
|
|
DivMedRin.Visible = True
|
|
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
|
|
|
|
End Class
|