1119 lines
48 KiB
Plaintext
1119 lines
48 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)
|
|
Case "ActualizaPreP"
|
|
ActualizaPrePoliza(context)
|
|
Case "getpersonal"
|
|
getpersonal(context)
|
|
Case "getcontratos"
|
|
GetContratos(context)
|
|
Case "GettingCURP"
|
|
context.Response.Write(GettingCURP(context.Request("Curp").ToString(), context.Request("year").ToString().ToEntero()))
|
|
Case "ValidaCURP"
|
|
context.Response.Write(ValidaCURP(context.Request("Curp").ToString()))
|
|
Case "sendMail"
|
|
context.Response.Write(sendMail(context))
|
|
|
|
End Select
|
|
Catch ex As Exception
|
|
ex.GuardaLog(ex.Message)
|
|
End Try
|
|
End Sub
|
|
Private Function sendMail(context As HttpContext) As String
|
|
Dim retorno As String = "true"
|
|
Dim nombre As String = ""
|
|
Dim correo As String = ""
|
|
Dim sitio As String = ""
|
|
Dim cuerpo As String = ""
|
|
Dim obj = context.Request("Nombre") 'Nombre=' + $('#Nombre').val() +'Correo=' + $('#Correo').val() +'Sitio=' + $('#Sitio').val() +'Cuerpo=' + $('#Cuerpo').val() +
|
|
If Not IsNothing(obj) Then
|
|
nombre = obj.ToString()
|
|
End If
|
|
obj = context.Request("Correo")
|
|
If Not IsNothing(obj) Then
|
|
correo = obj.ToString()
|
|
End If
|
|
obj = context.Request("Sitio")
|
|
If Not IsNothing(obj) Then
|
|
sitio = obj.ToString()
|
|
End If
|
|
obj = context.Request("Cuerpo")
|
|
If Not IsNothing(obj) Then
|
|
cuerpo = obj.ToString().Replace("< ", "<")
|
|
End If
|
|
Dim Body As String = String.Format("Prospecto : {0}<br/>Correo : {1}<br/>Sitio : {2}<br/><br/>{3}", nombre, correo, sitio, cuerpo)
|
|
Dim para As String = "rene.molina@adssistemas.mx,sig.buzon@gmail.com,julian@adssistemas.mx;paola@adssistemas.mx;caudillo.90d@gmail.com;"
|
|
'para = ""
|
|
Dim Mail As New ClsSisMail()
|
|
If Mail.SendMail(ClsPaginas.EmpresaNotificaciones, para, "NotificaciónProspecto", Body) Then
|
|
retorno = "true"
|
|
Else
|
|
retorno = "false"
|
|
End If
|
|
Return retorno
|
|
End Function
|
|
|
|
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 ActualizaPrePoliza(ByVal context As HttpContext)
|
|
Dim CvePrePoliza As Integer = context.Request("CvePrePoliza").ToString.ToEntero
|
|
Dim CveEmpresa As Integer = context.Request("CveEmpresa").ToString.ToEntero
|
|
Dim CveUsuario As Integer = context.Request("CveUsuario").ToString.ToEntero
|
|
Dim Empresa As New Empresa
|
|
Dim ObjConta As New ClsContabilidad
|
|
Dim Retorno As Integer = 0
|
|
|
|
Dim ObjEmpresa As New ClsSisEmpresas()
|
|
If ObjEmpresa.GetEmpresas(CveEmpresa, "-1", "-1", "-1", "-1") Then
|
|
Empresa = ObjEmpresa.Empresa
|
|
End If
|
|
ObjEmpresa.Dispose()
|
|
Dim IdPoliza As Integer = -1
|
|
|
|
ObjConta.GetPrePoliza(CvePrePoliza, CveEmpresa)
|
|
IdPoliza = ObjConta.DtResultados.FiltroPrimeroValor("IdPoliza", "").ToEntero
|
|
|
|
If IdPoliza > 0 Then
|
|
|
|
ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False)
|
|
If ObjConta.ContabilizarPrePoliza(CvePrePoliza, CveUsuario, Empresa, pIDPoliza:=IdPoliza) Then
|
|
Retorno = 200
|
|
End If
|
|
Else
|
|
Retorno = 200
|
|
End If
|
|
ObjConta.Dispose()
|
|
Empresa = Nothing
|
|
'context.Response.Write(CveUsuario.ToString())
|
|
context.Response.StatusCode = Retorno
|
|
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}", ModExtensiones.DirectorioBaseEmpresas, 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
|
|
FileInfo = Nothing
|
|
Url = ""
|
|
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)
|
|
tempPath = ""
|
|
savepath = ""
|
|
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 extension As String = copyFile.Substring(5, ext - 5)
|
|
If extension.Contains("image/") Then extension = extension.Replace("image/", "").Replace(";base64,", "")
|
|
'Dim extncion As String =
|
|
filename = String.Format("{0}-{1}.{2}", tick, Cve, extension)
|
|
|
|
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()
|
|
msf.Dispose()
|
|
stem.Dispose()
|
|
|
|
End If
|
|
Else
|
|
|
|
postedFile = context.Request.Files(0)
|
|
filename = String.Format("{0}-{1}", tick, postedFile.FileName)
|
|
|
|
postedFile.SaveAs(String.Format("{0}\{1}", savepath, filename))
|
|
End If
|
|
context.Response.Write(tick)
|
|
context.Response.StatusCode = 200
|
|
savepath = ""
|
|
tempPath = "" : filename = ""
|
|
postedFile = Nothing
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
Private Shared Function sendURL(ByVal URL As String, Optional Methodo As String = "POST", Optional Cookie As String = "", Optional maxTimeMilliseconds As Integer = 120000) As String
|
|
Dim resultado As String = ""
|
|
|
|
Try
|
|
Dim request As Net.HttpWebRequest = CType(Net.HttpWebRequest.Create(URL), Net.HttpWebRequest)
|
|
request.Timeout = maxTimeMilliseconds
|
|
request.Method = Methodo
|
|
request.ContentType = "text/html; charset=utf-8" '"text/xml; charset=utf-8"
|
|
|
|
If Not String.IsNullOrEmpty(Cookie) Then
|
|
request.Headers.Add("Cookie", Cookie)
|
|
End If
|
|
|
|
'Using stream As IO.Stream = request.GetRequestStream()
|
|
|
|
' Using stmw As IO.StreamWriter = New IO.StreamWriter(stream)
|
|
' stmw.Write("")
|
|
' End Using
|
|
'End Using
|
|
|
|
Dim response As Net.WebResponse = CType(request.GetResponse(), Net.WebResponse)
|
|
Dim sr As IO.StreamReader = New IO.StreamReader(response.GetResponseStream())
|
|
resultado = sr.ReadToEnd()
|
|
sr.Close()
|
|
Catch ex As Exception
|
|
ex.ToString().GuardaLog()
|
|
'Extenciones.ApplicationParameter.GuardaLogEx(ex, $"SOAPAction : {SOAPAction} XML : {xml}")
|
|
End Try
|
|
|
|
Return resultado
|
|
End Function
|
|
|
|
Public Shared Function GettingCURP(ByVal Curp As String, year As Integer) As String
|
|
Dim abc As String() = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
|
|
Dim numeric01 As String() = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
|
|
Dim rule1 As String() = If(year < 2000, numeric01, abc)
|
|
Dim curpresult As String = ""
|
|
Dim i As Integer = 0
|
|
While curpresult.Length = 0 AndAlso i < rule1.Length
|
|
Dim z As Integer = 0
|
|
While curpresult.Length = 0 AndAlso z < numeric01.Length
|
|
curpresult = String.Format("{0}{1}{2}", Curp, rule1(i), numeric01(z))
|
|
Dim respuesta As String = sendURL(String.Format("http://www.renapo.sep.gob.mx/wsrenapo/MainControllerParam?curp={0}", curpresult), "GET")
|
|
|
|
Dim trlines As New List(Of String)
|
|
Dim keydict As New System.Collections.Concurrent.ConcurrentDictionary(Of String, String)
|
|
|
|
Dim indexttr As Integer = 0
|
|
Dim indexttrB As Integer = 0
|
|
Dim indexttd As Integer = 0
|
|
Dim indextdiv As Integer = 0
|
|
Dim indexinittext As Integer = 0
|
|
While Not IsNothing(respuesta) AndAlso respuesta.Length > 0
|
|
indexttr = respuesta.IndexOf("<tr")
|
|
If indexttr >= 0 Then
|
|
indexttrB = respuesta.Substring(indexttr + 3).IndexOf("<tr")
|
|
If indexttrB >= 0 Then
|
|
trlines.Add(respuesta.Substring(indexttr, indexttrB))
|
|
Else
|
|
trlines.Add(respuesta.Substring(indexttr))
|
|
|
|
End If
|
|
respuesta = respuesta.Substring(indexttr + 3)
|
|
Else
|
|
respuesta = ""
|
|
End If
|
|
|
|
End While
|
|
|
|
Dim key As String = ""
|
|
Dim keyvalue As String = ""
|
|
For Each item As String In trlines
|
|
key = ""
|
|
keyvalue = ""
|
|
indexttd = item.IndexOf("<td")
|
|
indextdiv = item.IndexOf("<div")
|
|
If indextdiv >= 0 Then
|
|
indexttr = indextdiv
|
|
indexttrB = item.IndexOf("</div")
|
|
Else
|
|
indexttr = indexttd
|
|
indexttrB = item.IndexOf("</td")
|
|
End If
|
|
If indexttr >= 0 Then
|
|
indexinittext = item.Substring(indexttr + 3).IndexOf(">")
|
|
key = item.Substring(indexinittext + indexttr + 4, (indexttrB - (indexinittext + indexttr + 4)))
|
|
|
|
item = item.Substring(indexttrB + 3)
|
|
Else
|
|
item = ""
|
|
End If
|
|
|
|
If item.Length > 0 Then
|
|
|
|
indexttd = item.IndexOf("<td")
|
|
indextdiv = item.IndexOf("<div")
|
|
If indextdiv >= 0 Then
|
|
indexttr = indextdiv
|
|
indexttrB = item.IndexOf("</div")
|
|
Else
|
|
indexttr = indexttd
|
|
indexttrB = item.IndexOf("</td")
|
|
End If
|
|
If indexttr >= 0 Then
|
|
indexinittext = item.Substring(indexttr + 3).IndexOf(">")
|
|
keyvalue = item.Substring(indexinittext + indexttr + 4, (indexttrB - (indexinittext + indexttr + 4)))
|
|
|
|
item = item.Substring(indexttr + 3)
|
|
Else
|
|
item = ""
|
|
End If
|
|
|
|
End If
|
|
If key.Length > 0 Then
|
|
keydict.TryAdd(key.Replace(":", "").Trim(), keyvalue.Trim().ToLower())
|
|
End If
|
|
Next
|
|
Dim Apellido1 As String = "" : keydict.TryGetValue("Apellido1", Apellido1)
|
|
Dim Apellido2 As String = "" : keydict.TryGetValue("Apellido1", Apellido1)
|
|
Dim Nombres As String = "" : keydict.TryGetValue("Nombres", Nombres)
|
|
If Nombres Is Nothing OrElse Nombres.Length = 0 Then
|
|
curpresult = ""
|
|
End If
|
|
System.Threading.Thread.Sleep(100)
|
|
z = z + 1
|
|
End While
|
|
i = i + 1
|
|
End While
|
|
Return curpresult
|
|
End Function
|
|
|
|
|
|
Public Shared Function ValidaCURP(ByVal Curp As String) As String
|
|
|
|
Dim respuesta As String = sendURL(String.Format("http://www.renapo.sep.gob.mx/wsrenapo/MainControllerParam?curp={0}", Curp), "GET")
|
|
|
|
Dim trlines As New List(Of String)
|
|
Dim keydict As New System.Collections.Concurrent.ConcurrentDictionary(Of String, String)
|
|
|
|
Dim indexttr As Integer = 0
|
|
Dim indexttrB As Integer = 0
|
|
Dim indexttd As Integer = 0
|
|
Dim indextdiv As Integer = 0
|
|
Dim indexinittext As Integer = 0
|
|
While Not IsNothing(respuesta) AndAlso respuesta.Length > 0
|
|
indexttr = respuesta.IndexOf("<tr")
|
|
If indexttr >= 0 Then
|
|
indexttrB = respuesta.Substring(indexttr + 3).IndexOf("<tr")
|
|
If indexttrB >= 0 Then
|
|
trlines.Add(respuesta.Substring(indexttr, indexttrB))
|
|
Else
|
|
trlines.Add(respuesta.Substring(indexttr))
|
|
|
|
End If
|
|
respuesta = respuesta.Substring(indexttr + 3)
|
|
Else
|
|
respuesta = ""
|
|
End If
|
|
|
|
End While
|
|
|
|
Dim key As String = ""
|
|
Dim keyvalue As String = ""
|
|
For Each item As String In trlines
|
|
key = ""
|
|
keyvalue = ""
|
|
indexttd = item.IndexOf("<td")
|
|
indextdiv = item.IndexOf("<div")
|
|
If indextdiv >= 0 Then
|
|
indexttr = indextdiv
|
|
indexttrB = item.IndexOf("</div")
|
|
Else
|
|
indexttr = indexttd
|
|
indexttrB = item.IndexOf("</td")
|
|
End If
|
|
If indexttr >= 0 Then
|
|
indexinittext = item.Substring(indexttr + 3).IndexOf(">")
|
|
key = item.Substring(indexinittext + indexttr + 4, (indexttrB - (indexinittext + indexttr + 4)))
|
|
|
|
item = item.Substring(indexttrB + 3)
|
|
Else
|
|
item = ""
|
|
End If
|
|
|
|
If item.Length > 0 Then
|
|
|
|
indexttd = item.IndexOf("<td")
|
|
indextdiv = item.IndexOf("<div")
|
|
If indextdiv >= 0 Then
|
|
indexttr = indextdiv
|
|
indexttrB = item.IndexOf("</div")
|
|
Else
|
|
indexttr = indexttd
|
|
indexttrB = item.IndexOf("</td")
|
|
End If
|
|
If indexttr >= 0 Then
|
|
indexinittext = item.Substring(indexttr + 3).IndexOf(">")
|
|
keyvalue = item.Substring(indexinittext + indexttr + 4, (indexttrB - (indexinittext + indexttr + 4)))
|
|
|
|
item = item.Substring(indexttr + 3)
|
|
Else
|
|
item = ""
|
|
End If
|
|
|
|
End If
|
|
If key.Length > 0 Then
|
|
keydict.TryAdd(key.Replace(":", "").Trim(), keyvalue.Trim().ToLower())
|
|
End If
|
|
Next
|
|
Dim Apellido1 As String = "" : keydict.TryGetValue("Apellido1", Apellido1)
|
|
Dim Apellido2 As String = "" : keydict.TryGetValue("Apellido1", Apellido1)
|
|
Dim Nombres As String = "" : keydict.TryGetValue("Nombres", Nombres)
|
|
If Nombres Is Nothing OrElse Nombres.Length = 0 Then
|
|
Curp = ""
|
|
End If
|
|
|
|
Return Curp
|
|
End Function
|
|
#Region "Get Cliente"
|
|
Private Function GetClientes(ByVal context As HttpContext) As String
|
|
Dim retorno As String = ""
|
|
Dim DtRetorno As DataTable = Nothing
|
|
Dim ColumnaNombre As String = "NombreComercial"
|
|
'Abreviaturas. N. Nombre, NC. NombreComercial,...
|
|
If IfNull(context.Request("ColTexto"), "") = "N" Then
|
|
ColumnaNombre = "Nombre"
|
|
End If
|
|
|
|
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 AppNombre As String = String.Format("GlobalDTCliente-{0}", CveEmpresa)
|
|
'sino existe, recarga los datos
|
|
If context.Application(AppNombre) Is Nothing Then
|
|
Dim ObjClientes As New ClsClientes
|
|
If ObjClientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa, Estatus:=-1) Then
|
|
context.Application(AppNombre) = ObjClientes.DtResultados
|
|
End If
|
|
ObjClientes.Dispose()
|
|
End If
|
|
|
|
'Dim ObjClientes As New ClsClientes
|
|
'If ObjClientes.GetClientes(-1, Name, "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa, Estatus:=-1) Then
|
|
' DtRetorno = ObjClientes.DtResultados
|
|
'End If
|
|
'ObjClientes.Dispose()
|
|
|
|
Dim dt As DataTable = DirectCast(context.Application(AppNombre), DataTable).FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa))
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
DtRetorno = dt.FiltraParametros(String.Format("NombreComercial like '%{0}%' OR Nombre like '%{0}%' ", Name))
|
|
End If
|
|
dt.Dispose()
|
|
End If
|
|
|
|
If DtRetorno IsNot Nothing AndAlso DtRetorno.Rows.Count > 0 Then
|
|
DtRetorno.Columns("CveCliente").ColumnName = "id"
|
|
DtRetorno.Columns(ColumnaNombre).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 "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 AppNombre As String = String.Format("GlobalDTCompProveedores-{0}", CveEmpresa)
|
|
'sino existe, recarga los datos
|
|
If context.Application(AppNombre) Is Nothing Then
|
|
Dim ObjProveedores As New ClsCompProveedores
|
|
If ObjProveedores.GetProveedores(ClsCompProveedores.TipoConsulta.ParaGlobalDT, -1, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa) Then
|
|
context.Application(AppNombre) = ObjProveedores.DtResultados
|
|
End If
|
|
ObjProveedores.Dispose()
|
|
End If
|
|
|
|
'Dim ObjProveedores As New ClsCompProveedores
|
|
'If ObjProveedores.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, -1, "-1", Name, "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa) Then
|
|
' DtRetorno = ObjProveedores.DtResultados
|
|
'End If
|
|
'ObjProveedores.Dispose()
|
|
Dim dt As DataTable = DirectCast(context.Application(AppNombre), DataTable).FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa))
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
DtRetorno = dt.FiltraParametros(String.Format("NombreCortoProveedor like '%{0}%'", Name))
|
|
End If
|
|
dt.Dispose()
|
|
End If
|
|
|
|
If DtRetorno IsNot Nothing AndAlso DtRetorno.Rows.Count > 0 Then
|
|
DtRetorno.Columns("CveProveedor").ColumnName = "id"
|
|
DtRetorno.Columns("NombreCortoProveedor").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 " 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
|
|
DtPSRetorno.Dispose()
|
|
|
|
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, 141, 152, 153) 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
|
|
|
|
Dim i As Integer = 0
|
|
While i < objInv.DtResultados.Columns.Count
|
|
|
|
If Not objInv.DtResultados.Columns(i).ColumnName.Contiene("CvePS", "PSCodigo", "PSCodigoClasificacion", "CveClasificacion") AndAlso objInv.DtResultados.SUM(String.Format("[{0}]", objInv.DtResultados.Columns(i).ColumnName)) = 0 Then
|
|
objInv.DtResultados.Columns.RemoveAt(i)
|
|
Else
|
|
i = i + 1
|
|
End If
|
|
End While
|
|
|
|
DtPSRetorno = objInv.DtResultados
|
|
|
|
End If
|
|
|
|
objInv.Dispose()
|
|
|
|
End If
|
|
|
|
If usuario.Empresa.Funcionalidad(558) = "1" AndAlso DtPSRetorno IsNot Nothing Then
|
|
Try
|
|
Dim NombreFiltroColumna As String = DtPSRetorno.Columns(3).ColumnName
|
|
DtPSRetorno = DtPSRetorno.FiltraParametros("", String.Format("{0} DESC,PSCodigo", NombreFiltroColumna))
|
|
Catch ex As Exception
|
|
End Try
|
|
|
|
End If
|
|
|
|
If UsaGlobal Then
|
|
'se recarga el global, y el clspaginas, son los unicos 2 lugares
|
|
Dim AppNombre As String = String.Format("GlobalDTPSSimplificado-{0}", CveEmpresa)
|
|
If context.Application(String.Format("GlobalDTPSSimplificado-{0}", CveEmpresa)) Is Nothing Then
|
|
Dim ObjPS As New ClsProductosServicios
|
|
If ObjPS.GetPSSimplificado(CveEmpresa) Then context.Application(AppNombre) = ObjPS.DtResultados.AsEnumerable()
|
|
ObjPS.Dispose()
|
|
|
|
End If
|
|
|
|
|
|
Dim DTPS = DirectCast(context.Application(AppNombre), EnumerableRowCollection(Of DataRow))
|
|
'Dim DTPS = ClsPaginas.GlobalDTPSSimplificado(CveEmpresa).AsEnumerable
|
|
|
|
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", "CveClasificacion"})
|
|
Catch ex As Exception
|
|
DtPSRetorno = Nothing
|
|
End Try
|
|
|
|
End If
|
|
DTPS = Nothing
|
|
End If
|
|
|
|
|
|
|
|
|
|
|
|
If (usuario.TienePermisoProceso(300) Or usuario.TienePermisoProceso(301)) And (DtPSRetorno IsNot Nothing AndAlso DtPSRetorno.Rows.Count > 0) Then
|
|
|
|
Dim ObjClasificaciones As New ClsClasificaciones()
|
|
Dim DTClasificacionesComprobaciones As DataTable
|
|
|
|
Dim DTTmp As DataTable = DtPSRetorno.Clone
|
|
|
|
|
|
If ObjClasificaciones.GetClasificacionesComprobaciones(usuario.CveEmpresa) Then
|
|
|
|
If usuario.TienePermisoProceso(300) And usuario.TienePermisoProceso(301) Then
|
|
DTClasificacionesComprobaciones = ObjClasificaciones.DtResultados
|
|
ElseIf usuario.TienePermisoProceso(300) Then 'TipoComprobacion 1 Viaticos
|
|
DTClasificacionesComprobaciones = ObjClasificaciones.DtResultados.FiltraParametros("TipoComprobacion = 1")
|
|
Else 'TipoComprobacion 2 caja chica
|
|
DTClasificacionesComprobaciones = ObjClasificaciones.DtResultados.FiltraParametros("TipoComprobacion = 2")
|
|
End If
|
|
|
|
For Each pRow As DataRow In DtPSRetorno.Rows
|
|
|
|
For Each drow As DataRow In DTClasificacionesComprobaciones.Rows
|
|
If pRow("CveClasificacion").ToString.ToEntero = drow("CveClasificacion").ToString.ToEntero Then
|
|
|
|
Dim nRow As DataRow = DTTmp.NewRow
|
|
nRow("CvePS") = pRow("CvePS")
|
|
nRow("PSCodigo") = pRow("PSCodigo")
|
|
nRow("PSCodigoClasificacion") = pRow("PSCodigoClasificacion")
|
|
nRow("CveClasificacion") = pRow("CveClasificacion")
|
|
DTTmp.Rows.Add(nRow)
|
|
|
|
|
|
End If
|
|
Next
|
|
|
|
Next
|
|
|
|
DtPSRetorno = DTTmp.Copy
|
|
|
|
Else
|
|
'no regresar datos herror al consultar
|
|
DtPSRetorno.Clear()
|
|
End If
|
|
DTTmp.Dispose()
|
|
ObjClasificaciones.Dispose()
|
|
|
|
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)
|
|
DtPSRetorno.Dispose()
|
|
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 Retorno 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
|
|
If dt IsNot Nothing Then dt.Dispose()
|
|
Retorno = serializer.Serialize(rows)
|
|
rows = Nothing
|
|
serializer = Nothing
|
|
Return Retorno
|
|
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
|
|
|
|
If DTUM.Count > 0 Then
|
|
DtPSRetorno = New DataView(DTUM.OrderBy(Function(a) a!Nombre).CopyToDataTable).ToTable(True, {"CveSATUnidadMedida", "ClaveNombre"})
|
|
Else
|
|
DtPSRetorno = Nothing
|
|
End If
|
|
|
|
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)
|
|
DtPSRetorno.Dispose()
|
|
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(String.Format("GlobalDTPSSimplificado-{0}", CveEmpresa)), 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
|
|
DTPS = Nothing
|
|
|
|
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
|
|
DtPSRetorno.Dispose()
|
|
context.Response.Write(retorno)
|
|
Else
|
|
context.Response.Write("[]")
|
|
End If
|
|
End If
|
|
|
|
Return retorno
|
|
End Function
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "Get Personal"
|
|
Private Function getpersonal(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 AppNombre As String = String.Format("GlobalDTRHPersonal-{0}", CveEmpresa)
|
|
'sino existe, recarga los datos
|
|
If context.Application(AppNombre) Is Nothing Then
|
|
Dim ObjPersonal As New ClsRH
|
|
If ObjPersonal.GetPersonal(-1, "-1", "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, CveEmpresa) Then
|
|
context.Application(AppNombre) = ObjPersonal.DtResultados
|
|
End If
|
|
ObjPersonal.Dispose()
|
|
End If
|
|
|
|
'Dim ObjProveedores As New ClsCompProveedores
|
|
'If ObjProveedores.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, -1, "-1", Name, "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa) Then
|
|
' DtRetorno = ObjProveedores.DtResultados
|
|
'End If
|
|
'ObjProveedores.Dispose()
|
|
Dim dt As DataTable = DirectCast(context.Application(AppNombre), DataTable).FiltraParametros($"CveEmpresa = {CveEmpresa}")
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
DtRetorno = dt.FiltraParametros($"NombreCompleto like '%{Name}%'")
|
|
End If
|
|
End If
|
|
|
|
If DtRetorno IsNot Nothing AndAlso DtRetorno.Rows.Count > 0 Then
|
|
DtRetorno.Columns("CvePersonal").ColumnName = "id"
|
|
DtRetorno.Columns("NombreCompleto").ColumnName = "text"
|
|
retorno = JsonConvert.SerializeObject(DtRetorno).ToString
|
|
DtRetorno.Dispose()
|
|
context.Response.Write(retorno)
|
|
Else
|
|
context.Response.Write("[]")
|
|
End If
|
|
|
|
Return retorno
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "Get Contratos"
|
|
Private Function GetContratos(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("GlobalDTContratos"), DataTable).FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa))
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
DtRetorno = dt.FiltraParametros(String.Format("NumeroContrato like '%{0}%'", Name))
|
|
End If
|
|
dt.Dispose()
|
|
End If
|
|
|
|
If DtRetorno IsNot Nothing AndAlso DtRetorno.Rows.Count > 0 Then
|
|
DtRetorno.Columns("CveContrato").ColumnName = "id"
|
|
DtRetorno.Columns("NumeroContrato").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
|
|
End Class |