Dar salida a productos
This commit is contained in:
479
Ashx/E48.ashx
Normal file
479
Ashx/E48.ashx
Normal file
@@ -0,0 +1,479 @@
|
|||||||
|
<%@ WebHandler Language="VB" Class="E48" %>
|
||||||
|
|
||||||
|
Imports System
|
||||||
|
Imports System.Web
|
||||||
|
Imports System.Data
|
||||||
|
Imports Newtonsoft.Json
|
||||||
|
Imports Extensiones
|
||||||
|
Imports System.IO
|
||||||
|
Imports System.Net.Http
|
||||||
|
Imports Newtonsoft.Json.Linq
|
||||||
|
|
||||||
|
Public Class E48 : Implements IHttpHandler, IRequiresSessionState
|
||||||
|
Private ReadOnly Property CveEmpresa As Integer = 48
|
||||||
|
|
||||||
|
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
|
||||||
|
Get
|
||||||
|
Return False
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
Public ReadOnly Property Application As HttpApplicationState
|
||||||
|
|
||||||
|
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
|
||||||
|
|
||||||
|
Try
|
||||||
|
Select Case context.Request("metodo")
|
||||||
|
Case "Salida"
|
||||||
|
Salida(context)
|
||||||
|
End Select
|
||||||
|
Catch ex As Exception
|
||||||
|
ex.GuardaLog(ex.Message)
|
||||||
|
End Try
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Function Salida(ByVal context As HttpContext) As String
|
||||||
|
Dim retorno As String = ""
|
||||||
|
Dim ObjInv As New ClsInventarios
|
||||||
|
Dim Respuesta As New FidelityAppsResponse
|
||||||
|
Dim RespuestaError As New FidelityAppsResponseError
|
||||||
|
Dim TieneError As Boolean = False
|
||||||
|
Dim JsonRequest As JObject = Nothing
|
||||||
|
Dim UsuarioActual As Usuario = ValidaUsuarioSistema(100, CveEmpresa)
|
||||||
|
Dim ObjInventario As New ClsInventarios
|
||||||
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
||||||
|
Dim CveMovimiento As Integer = 0
|
||||||
|
Dim Mensaje As String = ""
|
||||||
|
Dim SinExistencia As String = "No hay existencias suficientes del producto: "
|
||||||
|
|
||||||
|
Dim ErrorAC As Boolean = False
|
||||||
|
Dim ErrorMovInv As Boolean = False
|
||||||
|
|
||||||
|
If context.Request.InputStream IsNot Nothing Then
|
||||||
|
Using reader As New StreamReader(context.Request.InputStream)
|
||||||
|
Dim json = reader.ReadToEnd
|
||||||
|
|
||||||
|
If Not String.IsNullOrEmpty(json) Then
|
||||||
|
JsonRequest = JObject.Parse(json)
|
||||||
|
If JsonRequest Is Nothing Then
|
||||||
|
TieneError = True
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
TieneError = True
|
||||||
|
End If
|
||||||
|
|
||||||
|
End Using
|
||||||
|
End If
|
||||||
|
If TieneError Then
|
||||||
|
RespuestaError.Message = "Ocurrió un error al obtener el cuerpo de los parametros"
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Not TieneError AndAlso Not String.IsNullOrEmpty(JsonRequest("fecha")) AndAlso Not String.IsNullOrEmpty(JsonRequest("usuario")) AndAlso Not String.IsNullOrEmpty(JsonRequest("almacen")) AndAlso Not String.IsNullOrEmpty(JsonRequest("entrega")) AndAlso
|
||||||
|
Not String.IsNullOrEmpty(JsonRequest("observaciones")) AndAlso Not String.IsNullOrEmpty(JsonRequest("productos")) Then
|
||||||
|
Dim Inv As New ClsInventarios
|
||||||
|
Dim ObjProductosServicios As New ClsProductosServicios()
|
||||||
|
Dim ObjContaAC As ClsContPAQi = Nothing
|
||||||
|
Dim tFolio As Integer = Inv.GetFolioSiguiente(3, CveEmpresa)
|
||||||
|
Dim observaciones As String = JsonRequest("observaciones").ToString()
|
||||||
|
Dim CveAlmacen As Integer = 7
|
||||||
|
Dim IDPoliza As Integer = 0
|
||||||
|
|
||||||
|
Dim Fecha As Date = JsonRequest("fecha").ToString().ToDate
|
||||||
|
Dim usuario As String = JsonRequest("usuario").ToString()
|
||||||
|
Dim almacen As String = JsonRequest("almacen").ToString()
|
||||||
|
Dim Recibe As String = JsonRequest("entrega").ToString()
|
||||||
|
Dim GlobalDTInvConceptos As DataTable
|
||||||
|
Dim CveModalidad As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacen).FiltroPrimeroValor("CveModalidad").ToEntero()
|
||||||
|
|
||||||
|
Dim EsContabilizable As Boolean = (CveModalidad = 1)
|
||||||
|
If Inv.GetConceptos Then GlobalDTInvConceptos = Inv.DtResultados Else GlobalDTInvConceptos = Nothing
|
||||||
|
Try
|
||||||
|
|
||||||
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("ASHX/E48", 53, 0, 0, 1, Fecha, observaciones, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3)
|
||||||
|
CveMovimiento = ObjInventario.AddMovimiento(CveAlmacen, 3, 1, Fecha, tFolio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=observaciones, Recibio:=Recibe, Modulo:="ASHX/E48")
|
||||||
|
|
||||||
|
If CveMovimiento <= 0 OrElse CvePrePoliza <= 0 Then
|
||||||
|
RespuestaError.Message = "No se pudo almacenar el movimiento correctamente"
|
||||||
|
TieneError = True
|
||||||
|
ObjInventario.RollBack() 'deshace lo insertado
|
||||||
|
Else
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
''VALIDA EXISTENCIAS
|
||||||
|
Dim Cont As Integer = 0
|
||||||
|
Dim ListaPS = JArray.Parse(JsonRequest("productos").ToString())
|
||||||
|
|
||||||
|
For Each JsonPS As JObject In ListaPS
|
||||||
|
|
||||||
|
Dim Cantidad As Double = JsonPS("cantidad").ToString.ToDouble()
|
||||||
|
Dim CvePS As Integer = GlobalDTPSSimplificado(Codigo:=JsonPS("codigo").ToString()).FiltroPrimeroValor("CvePS").ToEntero()
|
||||||
|
Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
||||||
|
Dim CveUM As Integer
|
||||||
|
If ObjProductosServicios.GetPS(CvePS, -1, CveEmpresa) Then
|
||||||
|
If ObjProductosServicios.DtResultados.Rows.Count > 0 Then
|
||||||
|
CveUM = ObjProductosServicios.CveUnidadMedida.ToString.ToEntero
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
If ObjInventario.GetExistenciasPS(CvePS, CveUM, CveEmpresa, CveAlmacen, FechaMovto:=String.Format("{0} 00:00", Fecha.ToString("yyyy/MM/dd"))) >= Cantidad Then
|
||||||
|
|
||||||
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Cantidad, CveUM, CvePS, 0, Observaciones:=observaciones, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
||||||
|
Mensaje = "Error al guardar los movimientos"
|
||||||
|
RespuestaError.Message = Mensaje
|
||||||
|
|
||||||
|
ErrorMovInv = True
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
If UsuarioActual.TienePermisoProceso(114) Then
|
||||||
|
If ObjInventario.GetExistenciasPS(CvePS, CveUM, CveEmpresa, CveAlmacen, FechaMovto:=String.Format("{0} 00:00", Fecha.ToString("yyyy/MM/dd"))) >= Cantidad Then
|
||||||
|
Mensaje = "Error al guardar los movimientos"
|
||||||
|
RespuestaError.Message = Mensaje
|
||||||
|
ErrorMovInv = True
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
SinExistencia += String.Format("{0}, ", JsonPS("codigo").ToString())
|
||||||
|
RespuestaError.Message = SinExistencia
|
||||||
|
ErrorMovInv = True : Exit For
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
Cont += 1
|
||||||
|
Next
|
||||||
|
'Registro la prepóliza
|
||||||
|
If Not ErrorMovInv AndAlso ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
||||||
|
Dim tValorInventario As Decimal = ObjInventario.DtResultados.SUMD("Total", "").RoundSQL()
|
||||||
|
Dim tValorOtro As Decimal = tValorInventario
|
||||||
|
Dim idCtaContable As Integer = 0
|
||||||
|
Dim IdCtaContableOtro As Integer = UsuarioActual.Empresa.IdCuentaOtrosIngresos
|
||||||
|
Dim TipoMovtoAlmacen As Boolean = False
|
||||||
|
Dim TipoMovtoOtro As Boolean = True
|
||||||
|
Dim tCveSubProyecto As Integer = -1
|
||||||
|
|
||||||
|
Dim drA2 As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", CveAlmacen))
|
||||||
|
If drA2 IsNot Nothing Then
|
||||||
|
idCtaContable = drA2("IdCtaContable").ToString.ToEntero
|
||||||
|
tCveSubProyecto = drA2("CveSubProyecto").ToString.ToEntero
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & 3).ToEntero
|
||||||
|
If OrigenMov = 1 Then TipoMovtoAlmacen = False Else TipoMovtoAlmacen = True
|
||||||
|
TipoMovtoOtro = Not TipoMovtoAlmacen
|
||||||
|
|
||||||
|
Dim CveConceptoContable As Integer = 78
|
||||||
|
Dim CveClasificacion As Integer = -1
|
||||||
|
|
||||||
|
|
||||||
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAlmacen, tValorInventario, observaciones, 68, observaciones, Fecha, idCtaContable, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=tValorInventario, CveClasificacion:=CveClasificacion, Contabilizable:=EsContabilizable) Then
|
||||||
|
ErrorMovInv = True
|
||||||
|
Else
|
||||||
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoOtro, tValorOtro, observaciones, CveConceptoContable, observaciones, Fecha, IdCtaContableOtro, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=tValorOtro, CveSubProyecto:=tCveSubProyecto, CveClasificacion:=CveClasificacion, Contabilizable:=EsContabilizable) Then
|
||||||
|
ErrorMovInv = True
|
||||||
|
End If
|
||||||
|
'End Select
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
ErrorMovInv = True
|
||||||
|
End If
|
||||||
|
|
||||||
|
'------------------------------------------------
|
||||||
|
If Not ErrorMovInv Then
|
||||||
|
'DEVENGAR
|
||||||
|
Dim TotalPorDevengar As Double = 0
|
||||||
|
|
||||||
|
'cuando tiene AC y es salida de almacen, se manda al gasto, solo aplica si el almacen es contable
|
||||||
|
If UsuarioActual.Empresa.UsaAC AndAlso EsContabilizable Then
|
||||||
|
Dim DtII As DataTable = Nothing
|
||||||
|
Dim TotalDetalle As Double = 0.0
|
||||||
|
Dim Importe As Decimal = 0
|
||||||
|
'NOTA. CUANDO ES SALIDA, EN AUTOMATICO NO TENEMOS LOS VALORES DE LA SALIDA TODAVIA, Y POR ESO IMPORTE ES CERO, ES RECARGAR CON LOS DATOS YA INSERTADOS
|
||||||
|
|
||||||
|
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
||||||
|
DtII = ObjInventario.DtResultados
|
||||||
|
End If
|
||||||
|
|
||||||
|
TotalPorDevengar += Importe ' GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(Gvr) Math.Round(Gvr.DataKey("PU").ToString.ToDouble, 4) * Math.Round(Gvr.DataKey("CantidadF").ToString.ToDouble, 4))
|
||||||
|
TotalPorDevengar = Math.Round(TotalPorDevengar, 4)
|
||||||
|
ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
|
||||||
|
ObjContaAC.IniciaTransacSQL()
|
||||||
|
|
||||||
|
Dim AC As New ClsAC
|
||||||
|
Dim DtPresupuestos As DataTable = Nothing
|
||||||
|
If AC.GetPresupuestoEgresos(-1, True, UsuarioActual.Empresa.EjercicioActual, UsuarioActual.CveEmpresa) Then
|
||||||
|
DtPresupuestos = AC.DtResultados.Copy
|
||||||
|
Else
|
||||||
|
Alert("Ocurrió un error al cargar los Presupuestos. Por favor vuelva a cargar la página", TipoMensaje.MsgError)
|
||||||
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
||||||
|
End If
|
||||||
|
AC.Dispose()
|
||||||
|
|
||||||
|
IDPoliza = ObjContaAC.AddPoliza(3, "Salida de Almacen", TotalPorDevengar, TotalPorDevengar, UsuarioActual.CveUsuario, Fecha)
|
||||||
|
|
||||||
|
If IDPoliza > 0 Then
|
||||||
|
Dim CuentaCargoCOG As Integer
|
||||||
|
Dim CuentaAbonoAlmacen As Integer = 0
|
||||||
|
Dim drA As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", CveAlmacen))
|
||||||
|
|
||||||
|
If drA IsNot Nothing Then CuentaAbonoAlmacen = drA("IdCtaContable").ToString.ToEntero
|
||||||
|
If UsuarioActual.CveEmpresa = 48 Then ' APH
|
||||||
|
CuentaCargoCOG = 1386
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim ConceptoRenglon As String = "Salida de Almacen"
|
||||||
|
|
||||||
|
If IDPoliza > 0 Then
|
||||||
|
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
||||||
|
Dim DtMovtos = ObjInventario.DtResultados
|
||||||
|
Importe = DtMovtos.SUMD("Total", "Estatus = ''")
|
||||||
|
|
||||||
|
If Importe > 0 Then
|
||||||
|
If CuentaCargoCOG > 0 AndAlso CuentaAbonoAlmacen > 0 Then
|
||||||
|
If ObjContaAC.AddMovimiento(IDPoliza, CuentaCargoCOG, False, Importe, "", ConceptoRenglon, 0, Fecha, "") Then
|
||||||
|
'actualizo el idcuenta del presupuesto
|
||||||
|
If Not ObjContaAC.AddMovimiento(IDPoliza, CuentaAbonoAlmacen, True, Importe, "", ConceptoRenglon, 0, Fecha, "") Then
|
||||||
|
ErrorAC = True
|
||||||
|
Mensaje = "No se pudo insertar movimiento en la poliza 2."
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
ErrorAC = True
|
||||||
|
Mensaje = "No se pudo insertar movimiento en la poliza 1."
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
If IDPoliza > 0 Then
|
||||||
|
ObjInventario.UpdateMovimientoPoliza(IDPoliza, CveMovimiento, UsuarioActual.CveEmpresa)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Else
|
||||||
|
ErrorAC = True
|
||||||
|
Mensaje = "No se pudo insertar la poliza"
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
If Not ErrorAC And Not ErrorMovInv Then
|
||||||
|
Dim Msg As New StringBuilder
|
||||||
|
Msg.AppendFormat("<br/>El Movimiento se registro con el Folio: <b>{0}</b>", ObjInventario.Folio)
|
||||||
|
Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento)))
|
||||||
|
|
||||||
|
If ObjContaAC IsNot Nothing Then ObjContaAC.AjustaPoliza(IDPoliza)
|
||||||
|
If IDPoliza > 0 Then Msg = Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza</a>", IDPoliza)
|
||||||
|
|
||||||
|
ObjInventario.Commit() ' aplica los movimientos insertados
|
||||||
|
If ObjContaAC IsNot Nothing Then ObjContaAC.Commit()
|
||||||
|
|
||||||
|
|
||||||
|
'Limpia Valores cuando inserta de campos especiales
|
||||||
|
|
||||||
|
Else
|
||||||
|
ObjInventario.RollBack()
|
||||||
|
CveMovimiento = 0
|
||||||
|
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
Else
|
||||||
|
ObjInventario.RollBack() 'deshace lo insertado
|
||||||
|
CveMovimiento = 0
|
||||||
|
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
Catch ex As Exception
|
||||||
|
Try 'por si ya le habian dado rollback o commit
|
||||||
|
ObjInventario.RollBack() 'deshace lo insertad
|
||||||
|
Catch exx As Exception
|
||||||
|
|
||||||
|
End Try
|
||||||
|
CveMovimiento = 0
|
||||||
|
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
||||||
|
GuardaLog("Ocurrió un Error inesperado en el registro" & ex.ToString())
|
||||||
|
Mensaje = "Ocurrió un Error inesperado en el registro" & ex.ToString()
|
||||||
|
|
||||||
|
TieneError = True
|
||||||
|
End Try
|
||||||
|
|
||||||
|
ObjInventario.Dispose() 'elimino la instancia
|
||||||
|
If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose()
|
||||||
|
|
||||||
|
|
||||||
|
Else
|
||||||
|
TieneError = True
|
||||||
|
Mensaje = "Ocurrió un error al obtener el cuerpo de los parametros"
|
||||||
|
End If
|
||||||
|
|
||||||
|
If TieneError Or ErrorAC Or ErrorMovInv Then
|
||||||
|
context.Response.StatusCode = 200
|
||||||
|
RespuestaError.Message = Mensaje
|
||||||
|
retorno = JsonConvert.SerializeObject(RespuestaError).ToString
|
||||||
|
Else
|
||||||
|
context.Response.StatusCode = 200
|
||||||
|
Respuesta.Message = "La existencia se obtuvo correctamente"
|
||||||
|
retorno = JsonConvert.SerializeObject(Respuesta).ToString
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
context.Response.Write(retorno)
|
||||||
|
Return retorno
|
||||||
|
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Class FidelityAppsResponse
|
||||||
|
Sub New()
|
||||||
|
isSuccess = "true"
|
||||||
|
End Sub
|
||||||
|
Public Property IsSuccess As String
|
||||||
|
Public Property Message As String
|
||||||
|
End Class
|
||||||
|
|
||||||
|
Private Class FidelityAppsResponseError
|
||||||
|
Sub New()
|
||||||
|
isSuccess = "false"
|
||||||
|
End Sub
|
||||||
|
Public Property IsSuccess As String
|
||||||
|
Public Property Message As String
|
||||||
|
End Class
|
||||||
|
|
||||||
|
Private Class AuthMessage
|
||||||
|
Public Property IsSucces As Boolean
|
||||||
|
Public Property ErrorMessage As FidelityAppsResponseError
|
||||||
|
Public Property StatusCode As Integer
|
||||||
|
End Class
|
||||||
|
|
||||||
|
ReadOnly Property GlobalDTPS(CveEmpresa As Integer, Optional CvePS As Integer = -1, Optional SATClavePS As String = "-1", Optional AplicaParaVenta As Integer = -1, Optional Estatus As Integer = -1, Optional Codigo As String = "-1") As DataTable
|
||||||
|
Get
|
||||||
|
Dim ObjPS As New ClsProductosServicios
|
||||||
|
|
||||||
|
If ObjPS.GetPS(CvePS, -1, CveEmpresa, Codigo:=Codigo, SATClavePS:=SATClavePS, pAplicaParaVenta:=AplicaParaVenta, pEstado:=Estatus) Then
|
||||||
|
GlobalDTPS = ObjPS.DtResultados
|
||||||
|
Else
|
||||||
|
GlobalDTPS = Nothing
|
||||||
|
End If
|
||||||
|
|
||||||
|
ObjPS.Dispose()
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
Public Property GlobalDTPSSimplificado(Optional CveClasificacion As Integer = -1, Optional Codigo As String = "-1", Optional Estatus As Integer = 1, Optional AplicaParaVenta As Integer = -1, Optional CvePS As Integer = -1) As DataTable
|
||||||
|
Get
|
||||||
|
Dim AppNombre As String = String.Format("GlobalDTPSSimplificado-{0}", CveEmpresa)
|
||||||
|
If CveEmpresa <> -1 Then
|
||||||
|
'sino existe, recarga los datos
|
||||||
|
If HttpContext.Current.Application(AppNombre) Is Nothing Then
|
||||||
|
Dim ObjPS As New ClsProductosServicios
|
||||||
|
If ObjPS.GetPSSimplificado(CveEmpresa) Then HttpContext.Current.Application(AppNombre) = ObjPS.DtResultados.AsEnumerable()
|
||||||
|
ObjPS.Dispose()
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
Dim Cons = DirectCast(HttpContext.Current.Application(AppNombre), EnumerableRowCollection(Of DataRow))
|
||||||
|
|
||||||
|
Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveEmpresa) = CveEmpresa))
|
||||||
|
If CveClasificacion >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveClasificacion) = CveClasificacion))
|
||||||
|
Codigo = Codigo.ToUpper()
|
||||||
|
If Codigo <> "-1" Then Cons = Cons.Where((Function(a) Convert.ToString(a!Codigo).ToUpper() = Codigo))
|
||||||
|
If Estatus >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveEstado) = Estatus))
|
||||||
|
If AplicaParaVenta >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!AplicaParaVenta) = AplicaParaVenta))
|
||||||
|
If CvePS >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CvePS) = CvePS))
|
||||||
|
|
||||||
|
Try
|
||||||
|
GlobalDTPSSimplificado = Cons.OrderBy(Function(a) a!PSCodigo).CopyToDataTable
|
||||||
|
Catch ex As Exception
|
||||||
|
GlobalDTPSSimplificado = New DataTable
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Else
|
||||||
|
GlobalDTPSSimplificado = DirectCast(HttpContext.Current.Application(AppNombre), EnumerableRowCollection(Of DataRow)).CopyToDataTable
|
||||||
|
End If
|
||||||
|
End Get
|
||||||
|
Set(value As DataTable)
|
||||||
|
Dim AppNombre As String = String.Format("GlobalDTPSSimplificado-{0}", CveEmpresa)
|
||||||
|
HttpContext.Current.Application(AppNombre) = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
Private Function ValidaUsuarioSistema(CveUsuario As Integer, CveEmpresa As Integer) As Usuario
|
||||||
|
Dim UsuarioActual As Usuario = Nothing
|
||||||
|
Dim ObjUsuarios As New ClsSisUsuarios
|
||||||
|
If ObjUsuarios.GetUsuarios(CveUsuario) Then
|
||||||
|
If ObjUsuarios.DtResultados.Rows.Count > 0 Then
|
||||||
|
Dim Usuario = ObjUsuarios.DtResultados.Rows(0)("Usuario").ToString()
|
||||||
|
Dim Contrasenia = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString()
|
||||||
|
UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, IMEI, CveEmpresa)
|
||||||
|
UsuarioActual.CveEmpresa = CveEmpresa
|
||||||
|
CreaObjetoEmpresa(UsuarioActual)
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
ObjUsuarios.Dispose()
|
||||||
|
Return UsuarioActual
|
||||||
|
End Function
|
||||||
|
Private Sub CreaObjetoEmpresa(ByRef UsuarioActual As Usuario)
|
||||||
|
|
||||||
|
Dim ObjEmpresa As New ClsSisEmpresas()
|
||||||
|
If ObjEmpresa.GetEmpresas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1") Then
|
||||||
|
If ObjEmpresa.GetEmpresasFuncionalidades(UsuarioActual.CveEmpresa) Then
|
||||||
|
Dim dttmp As Data.DataTable = ObjEmpresa.DtResultados
|
||||||
|
|
||||||
|
Dim EmpresasFuncionalidades As New HybridDictionary
|
||||||
|
For Each Row As Data.DataRow In dttmp.Rows
|
||||||
|
EmpresasFuncionalidades.Add(Convert.ToInt32(Row("CveFuncionalidad")), Row("Valor").ToString)
|
||||||
|
Next
|
||||||
|
ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades)
|
||||||
|
End If
|
||||||
|
|
||||||
|
UsuarioActual.Empresa = ObjEmpresa.Empresa
|
||||||
|
End If
|
||||||
|
ObjEmpresa.Dispose()
|
||||||
|
End Sub
|
||||||
|
Property GlobalDTAlmacen(CveEmpresa As Integer, Optional CveTipoAlmacen As Integer = -1, Optional CveEstatus As Integer = 1, Optional CveAlmacen As Integer = -1) As DataTable
|
||||||
|
Get
|
||||||
|
Dim AppNombre As String = String.Format("GlobalDTAlmacen-{0}", CveEmpresa)
|
||||||
|
Dim dttemp As DataTable
|
||||||
|
'sino existe, recarga los datos
|
||||||
|
Dim ObjUsr As New ClsInventarios
|
||||||
|
If ObjUsr.GetAlmacenes(-1, -1, CveEmpresa, -1) Then dttemp = ObjUsr.DtResultados
|
||||||
|
ObjUsr.Dispose()
|
||||||
|
|
||||||
|
Dim Str As New StringBuilder
|
||||||
|
Str.Append("1=1 AND ")
|
||||||
|
If CveEmpresa <> -1 Then Str.AppendFormat(" CveEmpresa = {0} ", CveEmpresa)
|
||||||
|
If CveTipoAlmacen > 0 Then Str.AppendFormat("AND CveTipoAlmacen = {0}", CveTipoAlmacen)
|
||||||
|
If CveEstatus > 0 Then Str.AppendFormat("AND CveEstatus = {0}", CveEstatus)
|
||||||
|
If CveAlmacen > 0 Then Str.AppendFormat("AND CveAlmacen = {0}", CveAlmacen)
|
||||||
|
|
||||||
|
Dim Dv As New DataView(DirectCast(dttemp, DataTable), Str.ToString, "", DataViewRowState.CurrentRows)
|
||||||
|
GlobalDTAlmacen = Dv.ToTable
|
||||||
|
Dv.Dispose()
|
||||||
|
End Get
|
||||||
|
Set(value As DataTable)
|
||||||
|
Dim dttemp As DataTable
|
||||||
|
Dim AppNombre As String = String.Format("GlobalDTAlmacen-{0}", CveEmpresa)
|
||||||
|
dttemp = value
|
||||||
|
End Set
|
||||||
|
'Get
|
||||||
|
|
||||||
|
' Dim Str As New StringBuilder
|
||||||
|
' Str.Append("1=1 AND ")
|
||||||
|
' If CveEmpresa <> -1 Then Str.AppendFormat(" CveEmpresa = {0} ", CveEmpresa)
|
||||||
|
' If CveTipoAlmacen > 0 Then Str.AppendFormat("AND CveTipoAlmacen = {0}", CveTipoAlmacen)
|
||||||
|
' If CveEstatus > 0 Then Str.AppendFormat("AND CveEstatus = {0}", CveEstatus)
|
||||||
|
' If CveAlmacen > 0 Then Str.AppendFormat("AND CveAlmacen = {0}", CveAlmacen)
|
||||||
|
|
||||||
|
' Dim Dv As New DataView(DirectCast(Application("GlobalDTAlmacen"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows)
|
||||||
|
' GlobalDTAlmacen = Dv.ToTable
|
||||||
|
' Dv.Dispose()
|
||||||
|
|
||||||
|
'End Get
|
||||||
|
'Set(value As DataTable)
|
||||||
|
' Application("GlobalDTAlmacen") = value
|
||||||
|
'End Set
|
||||||
|
End Property
|
||||||
|
End Class
|
||||||
Reference in New Issue
Block a user