607 lines
25 KiB
Plaintext
607 lines
25 KiB
Plaintext
<%@ WebHandler Language="VB" Class="SIGWeb" %>
|
|
|
|
Imports System
|
|
Imports System.Web
|
|
Imports System.Data
|
|
Imports Newtonsoft.Json
|
|
Imports Extensiones
|
|
Imports System.IO
|
|
|
|
Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
|
|
|
|
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
|
|
context.Response.ContentType = "text/plain"
|
|
Try
|
|
Select Case context.Request("metodo")
|
|
Case "getps"
|
|
GETPS(context)
|
|
Case "getps2"
|
|
GETPS(context, "PSCodigoClasificacion")
|
|
Case "getpsalmacen"
|
|
getpsalmacen(context)
|
|
Case "Uploadfile"
|
|
uploadfile(context)
|
|
Case "Downfile"
|
|
Downfile(context)
|
|
Case "GetImg"
|
|
GetImg(context)
|
|
Case "getpssat"
|
|
GETPSSAT(context)
|
|
Case "getpsusados"
|
|
GETPSUSADOS(context)
|
|
Case "getumsat"
|
|
GETUMSAT(context)
|
|
Case "getcliente"
|
|
GetClientes(context)
|
|
Case "getproveedores"
|
|
GetProveedores(context)
|
|
Case "getfraccionarancelaria"
|
|
GetFraccionArancelaria(context)
|
|
Case "GetUser"
|
|
GetUser(context)
|
|
|
|
End Select
|
|
Catch ex As Exception
|
|
ex.GuardaLog(ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
Private Sub GetUser(ByVal context As HttpContext)
|
|
Dim usuario As String = context.Request("usuario").ToString()
|
|
Dim CveUsuario As Integer = -1
|
|
Dim objs As New ClsSisUsuarios
|
|
objs.GetWSusuarios(usuario)
|
|
If objs.DtResultados.Rows.Count > 0 Then
|
|
CveUsuario = objs.DtResultados.Rows(0)("CveUsuario").ToString().ToEntero()
|
|
End If
|
|
objs.Dispose()
|
|
If CveUsuario > 0 Then
|
|
CveUsuario = 1
|
|
End If
|
|
|
|
context.Response.Write(CveUsuario.ToString())
|
|
context.Response.StatusCode = 200
|
|
End Sub
|
|
|
|
Private Sub GetImg(ByVal context As HttpContext)
|
|
Dim Url As String = Decripta(context.Request("r").ToString)
|
|
|
|
Dim usuario As Usuario = UsuarioActual(context)
|
|
If Not IsNothing(usuario) Then
|
|
Url = String.Format("{0}Empresas\{1}\{2}", AppDomain.CurrentDomain.BaseDirectory, usuario.CveEmpresa, Url)
|
|
Dim FileInfo As FileInfo = New FileInfo(Url)
|
|
If FileInfo.Exists Then
|
|
context.Response.ContentType = "image/png"
|
|
context.Response.Flush()
|
|
context.Response.WriteFile(FileInfo.FullName)
|
|
context.Response.End()
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
#Region "File"
|
|
|
|
Private Sub Downfile(ByVal context As HttpContext)
|
|
Dim savepath As String = ""
|
|
Dim tempPath As String = ""
|
|
tempPath = String.Format("{0}{1}", System.Configuration.ConfigurationManager.AppSettings("FolderPath"), "/Temp")
|
|
savepath = context.Server.MapPath(tempPath)
|
|
Dim nombre As String = String.Format("{0}\{1}", savepath, context.Request("nombre"))
|
|
File.Delete(nombre)
|
|
context.Response.StatusCode = 200
|
|
End Sub
|
|
|
|
Private Sub uploadfile(ByVal context As HttpContext)
|
|
Dim postedFile As HttpPostedFile
|
|
Dim savepath As String = ""
|
|
Dim tempPath As String = ""
|
|
tempPath = String.Format("{0}{1}", System.Configuration.ConfigurationManager.AppSettings("FolderPath"), "/Temp")
|
|
savepath = context.Server.MapPath(tempPath)
|
|
Dim filename As String
|
|
Dim tick As String
|
|
tick = (DateTime.Now.Ticks + 1).ToString()
|
|
If Not Directory.Exists(savepath) Then
|
|
Directory.CreateDirectory(savepath)
|
|
End If
|
|
If context.Request.Files.Count = 0 Then
|
|
Dim copyFile As String = context.Request("File")
|
|
Dim Cve As String = context.Request("Cve")
|
|
|
|
If copyFile <> "" Then
|
|
Dim ext As Integer = copyFile.IndexOf(","c) + 1
|
|
|
|
Dim extncion As String = copyFile.Substring(5, ext - 5)
|
|
If extncion.Contains("image/") Then extncion = extncion.Replace("image/", "").Replace(";base64,", "")
|
|
'Dim extncion As String =
|
|
filename = String.Format("{0}-{1}.{2}", tick, Cve, extncion)
|
|
|
|
Dim msf As New MemoryStream(Convert.FromBase64String(copyFile.Substring(ext)))
|
|
Dim stem As Stream = New FileStream(String.Format("{0}\{1}", savepath, filename), FileMode.Create)
|
|
msf.WriteTo(stem)
|
|
msf.Close()
|
|
stem.Close()
|
|
|
|
End If
|
|
Else
|
|
|
|
postedFile = context.Request.Files(0)
|
|
filename = String.Format("{0}-{1}", tick, postedFile.FileName)
|
|
|
|
postedFile.SaveAs((savepath & "\") + filename)
|
|
End If
|
|
context.Response.Write(tick)
|
|
context.Response.StatusCode = 200
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "Get Cliente"
|
|
Private Function GetClientes(ByVal context As HttpContext) As String
|
|
Dim retorno As String = ""
|
|
Dim DtRetorno As DataTable = Nothing
|
|
|
|
Dim usuario As Usuario = UsuarioActual(context)
|
|
Dim CveEmpresa As String
|
|
If IsNothing(usuario) Then
|
|
context.Response.Write("")
|
|
Else
|
|
CveEmpresa = usuario.CveEmpresa
|
|
Dim Name = IfNull(context.Request("Name"), "-1").ToString
|
|
Dim dt As DataTable = DirectCast(context.Application("GlobalDTCliente"), DataTable).FiltraParametros($"CveEmpresa = {CveEmpresa}")
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
DtRetorno = dt.FiltraParametros($"NombreComercial like '%{Name}%'")
|
|
End If
|
|
End If
|
|
|
|
If DtRetorno IsNot Nothing AndAlso DtRetorno.Rows.Count > 0 Then
|
|
DtRetorno.Columns("CveCliente").ColumnName = "id"
|
|
DtRetorno.Columns("NombreComercial").ColumnName = "text"
|
|
retorno = JsonConvert.SerializeObject(DtRetorno).ToString
|
|
context.Response.Write(retorno)
|
|
Else
|
|
context.Response.Write("[]")
|
|
End If
|
|
|
|
Return retorno
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "Get Proveedor"
|
|
Private Function GetProveedores(ByVal context As HttpContext) As String
|
|
Dim retorno As String = ""
|
|
Dim DtRetorno As DataTable = Nothing
|
|
|
|
Dim usuario As Usuario = UsuarioActual(context)
|
|
Dim CveEmpresa As String
|
|
If IsNothing(usuario) Then
|
|
context.Response.Write("")
|
|
Else
|
|
CveEmpresa = usuario.CveEmpresa
|
|
Dim Name = IfNull(context.Request("Name"), "-1").ToString
|
|
Dim dt As DataTable = DirectCast(context.Application("GlobalDTCompProveedores"), DataTable).FiltraParametros($"CveEmpresa = {CveEmpresa}")
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
DtRetorno = dt.FiltraParametros($"RazonSocial like '%{Name}%'")
|
|
End If
|
|
End If
|
|
|
|
If DtRetorno IsNot Nothing AndAlso DtRetorno.Rows.Count > 0 Then
|
|
DtRetorno.Columns("CveProveedor").ColumnName = "id"
|
|
DtRetorno.Columns("RazonSocial").ColumnName = "text"
|
|
retorno = JsonConvert.SerializeObject(DtRetorno).ToString
|
|
context.Response.Write(retorno)
|
|
Else
|
|
context.Response.Write("[]")
|
|
End If
|
|
|
|
Return retorno
|
|
End Function
|
|
#End Region
|
|
|
|
|
|
#Region " GET PS "
|
|
Private Function getpsalmacen(ByVal context As HttpContext) As String
|
|
|
|
Dim usuario As Usuario = UsuarioActual(context)
|
|
Dim CveEmpresa As String
|
|
Dim retorno As String = ""
|
|
Dim DtPSRetorno As DataTable = Nothing
|
|
|
|
If IsNothing(usuario) Then
|
|
context.Response.Write("")
|
|
Else
|
|
CveEmpresa = usuario.CveEmpresa
|
|
|
|
DtPSRetorno = New DataTable
|
|
DtPSRetorno.Columns.Add(New DataColumn("id", System.Type.GetType("System.Int32")))
|
|
DtPSRetorno.Columns.Add(New DataColumn("existencia", System.Type.GetType("System.Int32")))
|
|
DtPSRetorno.Columns.Add(New DataColumn("almacen", System.Type.GetType("System.String")))
|
|
|
|
Dim CvePS = IfNull(context.Request("cveps"), "0").ToString.ToEntero
|
|
Dim objInv As New ClsInventarios
|
|
If objInv.GetExistenciasProducto(CvePS, -1, CveEmpresa, -1, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm")) Then
|
|
|
|
' limpio los almacenes donde no tiene ningun producto existencia
|
|
For i = objInv.DtResultados.Columns.Count - 1 To 1 Step -1
|
|
|
|
If Not objInv.DtResultados.Columns(i).ColumnName.Contiene("CveAlmacen", "Almacen", "Existencia") Then
|
|
objInv.DtResultados.Columns.RemoveAt(i)
|
|
End If
|
|
Next
|
|
|
|
DtPSRetorno = objInv.DtResultados.FiltraParametros("CveAlmacen > 0 and Existencia > 0")
|
|
End If
|
|
|
|
objInv.Dispose()
|
|
|
|
End If
|
|
|
|
If DtPSRetorno IsNot Nothing AndAlso DtPSRetorno.Rows.Count > 0 Then
|
|
DtPSRetorno.Columns("CveAlmacen").ColumnName = "id"
|
|
DtPSRetorno.Columns("Almacen").ColumnName = "almacen"
|
|
DtPSRetorno.Columns("Existencia").ColumnName = "existencia"
|
|
retorno = JsonConvert.SerializeObject(DtPSRetorno).ToString
|
|
context.Response.Write(retorno)
|
|
Else
|
|
context.Response.Write("[]")
|
|
End If
|
|
|
|
Return retorno
|
|
End Function
|
|
|
|
Private Function GETPS(ByVal context As HttpContext, Optional PSCodigoDescripcion As String = "PSCodigo") As String
|
|
Dim retorno As String = ""
|
|
Dim DtPSRetorno As DataTable = Nothing
|
|
|
|
'NOTA:
|
|
' EN EL WHERE DE LINQ NO SE DEBE USAS EL OPERADOR 'AND' SABE PORQUE FUNCIONA DIFERENTE SE DEBE USAR 'ANDALSO',
|
|
' EJEMPLO UNA CONDICION AND DE DOS CAMPOS ARROJA CERO RESULTADOS PERO SI SE PONE ESTAS DOS CONDICIONES POR SEPARADO ARROJA DATOS
|
|
Dim usuario As Usuario = UsuarioActual(context)
|
|
Dim CveEmpresa As String
|
|
If IsNothing(usuario) Then
|
|
context.Response.Write("")
|
|
Else
|
|
CveEmpresa = usuario.CveEmpresa
|
|
Dim FuePorXml = IfNull(context.Request("FuePorXml"), "-1").ToString.ToEntero
|
|
Dim Name = IfNull(context.Request("Name"), "-1").ToString
|
|
Dim CveClasificacion = IfNull(context.Request("CveClasificacion"), "-1").ToString.ToEntero
|
|
Dim CveSubFamilia = IfNull(context.Request("CveSubFamilia"), "-1").ToString.ToEntero
|
|
Dim CveClasificacionPresupuesto = IfNull(context.Request("CveClasificacionPresupuesto"), "-1").ToString.ToEntero
|
|
Dim Pagina = IfNull(context.Request("Pagina"), "-1").ToString
|
|
Dim Estatus = IfNull(context.Request("Estatus"), "1").ToString
|
|
Dim CveSucursal = IfNull(context.Request("cvesucursal"), "-1").ToString.ToEntero
|
|
Dim CveSubProyecto = IfNull(context.Request("cvesubproyecto"), "-1").ToString.ToEntero
|
|
Dim UsoClasificacion = IfNull(context.Request("usoclasificacion"), "-1").ToString.ToEntero
|
|
Dim AplicaParaVenta = IfNull(context.Request("aplicaparaventa"), "-1").ToString.ToEntero
|
|
|
|
Dim UsaGlobal As Boolean = True
|
|
|
|
|
|
'verifica existencias
|
|
If Pagina.Contiene("ventas/ventas", "oc/oc", "inv/traspaso") AndAlso CveEmpresa.Contiene(72, 80, 119, 140) Then
|
|
UsaGlobal = False
|
|
|
|
Dim objInv As New ClsInventarios
|
|
If objInv.GetExistenciasProductosLike(Name, CveClasificacion, CveSubProyecto, Estatus.ToEntero, AplicaParaVenta, CveEmpresa) Then
|
|
|
|
' limpio los almacenes donde no tiene ningun producto existencia
|
|
For i = objInv.DtResultados.Columns.Count - 1 To 1 Step -1
|
|
|
|
If Not objInv.DtResultados.Columns(i).ColumnName.Contiene("CvePS", "PSCodigo", "PSCodigoClasificacion") AndAlso objInv.DtResultados.SUM(String.Format("[{0}]", objInv.DtResultados.Columns(i).ColumnName)) = 0 Then
|
|
objInv.DtResultados.Columns.RemoveAt(i)
|
|
End If
|
|
Next
|
|
|
|
DtPSRetorno = objInv.DtResultados
|
|
End If
|
|
|
|
|
|
objInv.Dispose()
|
|
|
|
End If
|
|
|
|
If UsaGlobal Then
|
|
|
|
Dim DTPS = DirectCast(context.Application("GlobalDTPSSimplificado"), EnumerableRowCollection(Of DataRow))
|
|
|
|
|
|
If DTPS IsNot Nothing Then
|
|
|
|
|
|
'APLICACION DE FILTROS
|
|
DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveEmpresa) = CveEmpresa))
|
|
If Estatus = 1 Then
|
|
DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveEstado) = 1))
|
|
ElseIf Estatus = -1 Then
|
|
|
|
End If
|
|
|
|
'If FuePorXml >= 0 Then
|
|
' DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!FuePorXML) = FuePorXml))
|
|
'End If
|
|
|
|
If Name <> "-1" Then
|
|
If PSCodigoDescripcion = "PSCodigo" Then
|
|
DTPS = DTPS.Where((Function(a) a!PSCodigo.ToString.ToLower Like ("*" + Name.ToLower + "*")))
|
|
Else
|
|
DTPS = DTPS.Where((Function(a) a!PSCodigoClasificacion.ToString.ToLower Like ("*" + Name.ToLower + "*")))
|
|
End If
|
|
End If
|
|
|
|
If CveClasificacion > 0 Then
|
|
DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveClasificacion) = CveClasificacion))
|
|
ElseIf CveClasificacion = -1 Then
|
|
DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveClasificacion) >= 0))
|
|
End If
|
|
|
|
If AplicaParaVenta > 0 Then
|
|
DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!AplicaParaVenta) = 1))
|
|
End If
|
|
|
|
'If CveSubFamilia > 0 Then
|
|
' DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveSubFamilia) = CveSubFamilia))
|
|
' 'ElseIf CveSubFamilia = -1 Then
|
|
' 'DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveSubFamilia) > 0))
|
|
'End If
|
|
|
|
If CveClasificacionPresupuesto > 0 Then
|
|
DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveClasificacionPresupuesto) = CveClasificacionPresupuesto))
|
|
End If
|
|
|
|
If UsoClasificacion > 0 Then DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!UsoClasificacion) = UsoClasificacion))
|
|
|
|
If Pagina <> "-1" Then
|
|
If Pagina = "Compras" Then
|
|
DTPS = DTPS.Where((Function(a) a!CveTipoPS = 1 AndAlso a!CveEstado = 1))
|
|
ElseIf Pagina = "Compras2" Then
|
|
DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveTipoPS) = 1 AndAlso (Convert.ToInt32(a!CveEstado) = 1 OrElse Convert.ToInt32(a!CveEstado) = 2)))
|
|
ElseIf Pagina = "Inventarios" Then
|
|
DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveTipoPS) = 2))
|
|
End If
|
|
End If
|
|
|
|
'Try, generado para cuando el resultado no tiene valores(The source contains no DataRows.), no detenga la ejecucion, no se le puso un count previo, porque el costo se duplica, al preguntar y luego ordenar y convertir a datatable
|
|
Try
|
|
DtPSRetorno = New DataView(DTPS.OrderBy(Function(a) a!PSCodigo).CopyToDataTable).ToTable(True, {"CvePS", "PSCodigo", "PSCodigoClasificacion"})
|
|
|
|
Catch ex As Exception
|
|
DtPSRetorno = Nothing
|
|
End Try
|
|
|
|
End If
|
|
End If
|
|
If DtPSRetorno IsNot Nothing AndAlso DtPSRetorno.Rows.Count > 0 Then
|
|
DtPSRetorno.Columns("CvePS").ColumnName = "id"
|
|
DtPSRetorno.Columns(PSCodigoDescripcion).ColumnName = "text"
|
|
If PSCodigoDescripcion = "PSCodigo" Then
|
|
DtPSRetorno.Columns().Remove("PSCodigoClasificacion")
|
|
Else
|
|
DtPSRetorno.Columns().Remove("PSCodigo")
|
|
End If
|
|
retorno = JsonConvert.SerializeObject(DtPSRetorno).ToString
|
|
context.Response.Write(retorno)
|
|
Else
|
|
context.Response.Write("[]")
|
|
End If
|
|
End If
|
|
|
|
Return retorno
|
|
End Function
|
|
#End Region
|
|
|
|
|
|
|
|
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
|
|
Get
|
|
Return False
|
|
End Get
|
|
End Property
|
|
|
|
|
|
|
|
#Region "Funciones"
|
|
Public Function GetJson(ByVal dt As DataTable) As String
|
|
|
|
Dim serializer As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer()
|
|
Dim rows As New List(Of Dictionary(Of String, Object))
|
|
Dim row As Dictionary(Of String, Object)
|
|
|
|
For Each dr As DataRow In dt.Rows
|
|
row = New Dictionary(Of String, Object)
|
|
For Each col As DataColumn In dt.Columns
|
|
row.Add(col.ColumnName, dr(col))
|
|
Next
|
|
rows.Add(row)
|
|
Next
|
|
Return serializer.Serialize(rows)
|
|
End Function
|
|
ReadOnly Property UsuarioActual(ByVal context As HttpContext) As Usuario
|
|
Get
|
|
UsuarioActual = DirectCast(context.Session("UsuarioSIG"), Usuario)
|
|
End Get
|
|
End Property
|
|
#End Region
|
|
|
|
|
|
#Region " GET PS SAT "
|
|
Private Function GETPSSAT(ByVal context As HttpContext) As String
|
|
Dim retorno As String = ""
|
|
|
|
Dim DTPS = DirectCast(context.Application("GlobalDTPSATPS"), EnumerableRowCollection(Of DataRow))
|
|
Dim DtPSRetorno As DataTable
|
|
|
|
Dim Name = IfNull(context.Request("Name"), "-1").ToString
|
|
|
|
If Name <> "-1" Then
|
|
DTPS = DTPS.Where((Function(a) a!SATClaveProductoServicio.ToString.ToLower Like ($"*{Name.ToLower}*")))
|
|
End If
|
|
|
|
DtPSRetorno = New DataView(DTPS.OrderBy(Function(a) a!SATClavePS).CopyToDataTable).ToTable(True, {"CveSATPS", "SATClaveProductoServicio"})
|
|
|
|
If DtPSRetorno IsNot Nothing AndAlso DtPSRetorno.Rows.Count > 0 Then
|
|
DtPSRetorno.Columns("CveSATPS").ColumnName = "id"
|
|
DtPSRetorno.Columns("SATClaveProductoServicio").ColumnName = "text"
|
|
retorno = JsonConvert.SerializeObject(DtPSRetorno).ToString
|
|
context.Response.Write(retorno)
|
|
Else
|
|
context.Response.Write("[]")
|
|
End If
|
|
DtPSRetorno.Dispose()
|
|
Return retorno
|
|
End Function
|
|
#End Region
|
|
|
|
|
|
#Region " GET UM SAT "
|
|
Private Function GETUMSAT(ByVal context As HttpContext) As String
|
|
Dim retorno As String = ""
|
|
|
|
Dim DTUM = DirectCast(context.Application("GlobalDTPSATUM"), EnumerableRowCollection(Of DataRow))
|
|
Dim DtPSRetorno As DataTable
|
|
|
|
Dim Name = IfNull(context.Request("Name"), "-1").ToString
|
|
|
|
If Name <> "-1" Then
|
|
DTUM = DTUM.Where((Function(a) a!ClaveNombre.ToString.ToLower Like ("*" + Name.ToLower + "*")))
|
|
End If
|
|
|
|
DtPSRetorno = New DataView(DTUM.OrderBy(Function(a) a!Nombre).CopyToDataTable).ToTable(True, {"CveSATUnidadMedida", "ClaveNombre"})
|
|
|
|
If DtPSRetorno IsNot Nothing AndAlso DtPSRetorno.Rows.Count > 0 Then
|
|
DtPSRetorno.Columns("CveSATUnidadMedida").ColumnName = "id"
|
|
DtPSRetorno.Columns("ClaveNombre").ColumnName = "text"
|
|
retorno = JsonConvert.SerializeObject(DtPSRetorno).ToString
|
|
context.Response.Write(retorno)
|
|
Else
|
|
context.Response.Write("[]")
|
|
End If
|
|
Return retorno
|
|
End Function
|
|
#End Region
|
|
|
|
#Region " GET FRACCION ARANCELARIA "
|
|
Private Function GetFraccionArancelaria(ByVal context As HttpContext) As String
|
|
Dim retorno As String = ""
|
|
|
|
Dim DT = DirectCast(context.Application("GlobalDTFraccionArancelaria"), EnumerableRowCollection(Of DataRow))
|
|
Dim DtRetorno As DataTable
|
|
|
|
Dim Name = IfNull(context.Request("Name"), "-1").ToString
|
|
|
|
If Name <> "-1" Then
|
|
DT = DT.Where((Function(a) a!ClaveSATFraccionArancelariaDescripcion.ToString.ToLower Like ($"*{Name.ToLower}*")))
|
|
End If
|
|
|
|
DtRetorno = New DataView(DT.OrderBy(Function(a) a!ClaveSATFraccionArancelaria).CopyToDataTable).ToTable(True, {"CveFraccionArancelaria", "ClaveSATFraccionArancelariaDescripcion"})
|
|
|
|
If DtRetorno IsNot Nothing AndAlso DtRetorno.Rows.Count > 0 Then
|
|
DtRetorno.Columns("CveFraccionArancelaria").ColumnName = "id"
|
|
DtRetorno.Columns("ClaveSATFraccionArancelariaDescripcion").ColumnName = "text"
|
|
retorno = JsonConvert.SerializeObject(DtRetorno).ToString
|
|
context.Response.Write(retorno)
|
|
Else
|
|
context.Response.Write("[]")
|
|
End If
|
|
DtRetorno.Dispose()
|
|
Return retorno
|
|
End Function
|
|
#End Region
|
|
|
|
|
|
#Region "USADOS"
|
|
|
|
Private Function GETPSUSADOS(ByVal context As HttpContext) As String
|
|
Dim retorno As String = ""
|
|
Dim DtPSRetorno As DataTable = Nothing
|
|
|
|
Dim usuario As Usuario = UsuarioActual(context)
|
|
Dim CveEmpresa As String
|
|
If IsNothing(usuario) Then
|
|
context.Response.Write("")
|
|
Else
|
|
CveEmpresa = usuario.CveEmpresa
|
|
Dim FuePorXml = IfNull(context.Request("FuePorXml"), "-1").ToString.ToEntero
|
|
Dim Name = IfNull(context.Request("Name"), "-1").ToString
|
|
Dim CveClasificacion = IfNull(context.Request("CveClasificacion"), "-1").ToString.ToEntero
|
|
Dim CveSubFamilia = IfNull(context.Request("CveSubFamilia"), "-1").ToString.ToEntero
|
|
Dim CveClasificacionPresupuesto = IfNull(context.Request("CveClasificacionPresupuesto"), "-1").ToString.ToEntero
|
|
Dim Pagina = IfNull(context.Request("Pagina"), "-1").ToString
|
|
Dim Estatus = IfNull(context.Request("Estatus"), "1").ToString
|
|
Dim CveSucursal = IfNull(context.Request("cvesucursal"), "-1").ToString.ToEntero
|
|
Dim CveSubProyecto = IfNull(context.Request("cvesubproyecto"), "-1").ToString.ToEntero
|
|
Dim UsoClasificacion = IfNull(context.Request("usoclasificacion"), "-1").ToString.ToEntero
|
|
Dim UsaGlobal As Boolean = True
|
|
|
|
|
|
|
|
|
|
If UsaGlobal Then
|
|
|
|
|
|
|
|
Dim DTPS = DirectCast(context.Application("GlobalDTPSSimplificado"), EnumerableRowCollection(Of DataRow))
|
|
|
|
|
|
|
|
If DTPS IsNot Nothing Then
|
|
|
|
'APLICACION DE FILTROS
|
|
DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveEmpresa) = CveEmpresa))
|
|
If Estatus = 1 Then
|
|
DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveEstado) = 1))
|
|
ElseIf Estatus = -1 Then
|
|
|
|
End If
|
|
|
|
If Name <> "-1" Then
|
|
DTPS = DTPS.Where((Function(a) a!PSCodigo.ToString.ToLower Like ("*" + Name.ToLower + "*")))
|
|
End If
|
|
|
|
If CveClasificacion > 0 Then
|
|
DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveClasificacion) = CveClasificacion))
|
|
ElseIf CveClasificacion = -1 Then
|
|
DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveClasificacion) >= 0))
|
|
End If
|
|
|
|
If CveClasificacionPresupuesto > 0 Then
|
|
DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveClasificacionPresupuesto) = CveClasificacionPresupuesto))
|
|
End If
|
|
|
|
If UsoClasificacion > 0 Then DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!UsoClasificacion) = UsoClasificacion))
|
|
|
|
If Pagina <> "-1" Then
|
|
If Pagina = "Compras" Then
|
|
DTPS = DTPS.Where((Function(a) a!CveTipoPS = 1 AndAlso a!CveEstado = 1))
|
|
ElseIf Pagina = "Compras2" Then
|
|
DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveTipoPS) = 1 AndAlso (Convert.ToInt32(a!CveEstado) = 1 OrElse Convert.ToInt32(a!CveEstado) = 2)))
|
|
ElseIf Pagina = "Inventarios" Then
|
|
DTPS = DTPS.Where((Function(a) Convert.ToInt32(a!CveTipoPS) = 2))
|
|
End If
|
|
End If
|
|
|
|
Try
|
|
DtPSRetorno = New DataView(DTPS.OrderBy(Function(a) a!PSCodigo).CopyToDataTable).ToTable(True, {"CvePS", "PSCodigo", "CveTamaño"})
|
|
DtPSRetorno = DtPSRetorno.FiltraParametros("CveTamaño > 0")
|
|
Catch ex As Exception
|
|
DtPSRetorno = Nothing
|
|
End Try
|
|
End If
|
|
|
|
End If
|
|
If DtPSRetorno IsNot Nothing AndAlso DtPSRetorno.Rows.Count > 0 Then
|
|
DtPSRetorno.Columns("CvePS").ColumnName = "id"
|
|
DtPSRetorno.Columns("PSCodigo").ColumnName = "text"
|
|
retorno = JsonConvert.SerializeObject(DtPSRetorno).ToString
|
|
context.Response.Write(retorno)
|
|
Else
|
|
context.Response.Write("[]")
|
|
End If
|
|
End If
|
|
|
|
Return retorno
|
|
End Function
|
|
|
|
|
|
#End Region
|
|
|
|
End Class |