4942 lines
244 KiB
Plaintext
4942 lines
244 KiB
Plaintext
<%@ WebService Language="VB" Class="WSSIGApp" %>
|
|
|
|
Option Explicit On
|
|
|
|
Imports System.Data
|
|
Imports System.Web
|
|
Imports System.Web.Services
|
|
Imports System.Web.Services.Protocols
|
|
Imports Microsoft.Reporting.WebForms
|
|
Imports Extensiones
|
|
Imports Newtonsoft.Json
|
|
Imports WebServiceAppModels
|
|
Imports Modelos
|
|
Imports System.IO
|
|
Imports System
|
|
Imports System.Globalization
|
|
Imports Newtonsoft.Json.Linq
|
|
|
|
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
|
|
' <System.Web.Script.Services.ScriptService()> _
|
|
<WebService(Namespace:="http://ADSistemas.org/")>
|
|
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
|
|
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
|
|
Public Class WSSIGApp
|
|
Inherits System.Web.Services.WebService
|
|
|
|
#Region "P R O P I E D A D E S"
|
|
Public ReadOnly Property UrlSitio As String
|
|
Get
|
|
Return ConfigurationManager.AppSettings("UrlSitio").ToString
|
|
End Get
|
|
End Property
|
|
ReadOnly Property GlobalDTPS(CveEmpresa As Integer, Optional CvePS As Integer = -1, Optional SATClavePS As String = "-1") As DataTable
|
|
Get
|
|
Dim ObjPS As New ClsProductosServicios
|
|
|
|
If ObjPS.GetPS(CvePS, -1, CveEmpresa, SATClavePS:=SATClavePS) Then
|
|
GlobalDTPS = ObjPS.DtResultados
|
|
Else
|
|
GlobalDTPS = Nothing
|
|
End If
|
|
|
|
ObjPS.Dispose()
|
|
End Get
|
|
End Property
|
|
Property GlobalDTMonedas() As DataTable
|
|
Get
|
|
GlobalDTMonedas = DirectCast(Application("GlobalDTMonedas"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTMonedas") = value
|
|
End Set
|
|
End Property
|
|
Property GlobalDTVtaMetodoPago() As DataTable
|
|
Get
|
|
GlobalDTVtaMetodoPago = DirectCast(Application("GlobalDTVtaMetodoPago"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTVtaMetodoPago") = value
|
|
End Set
|
|
End Property
|
|
Property GlobalDTVtaFormaPago() As DataTable
|
|
Get
|
|
GlobalDTVtaFormaPago = DirectCast(Application("GlobalDTVtaFormaPago"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTVtaFormaPago") = value
|
|
End Set
|
|
End Property
|
|
Property GlobalDTSubProyectos(CveProyecto As Integer, Optional CveSubProyecto As Integer = -1, Optional CveEmpresa As Integer = -1, Optional Estatus As Integer = 1) As DataTable
|
|
Get
|
|
|
|
If DirectCast(Application("GlobalDTSubProyectos"), DataTable) Is Nothing Or (DirectCast(Application("GlobalDTSubProyectos"), DataTable) IsNot Nothing AndAlso DirectCast(Application("GlobalDTSubProyectos"), DataTable).Rows.Count = 0) Then
|
|
Dim P As New ClsSubProyectos
|
|
If P.GetSubProyectos Then
|
|
Application("GlobalDTSubProyectos") = P.DtResultados
|
|
End If
|
|
P.Dispose()
|
|
|
|
Dim msg As String = "aqui no se carga subproyectos"
|
|
'If Request IsNot Nothing Then
|
|
' msg = msg & Request.ServerVariables("URL")
|
|
'End If
|
|
msg.GuardaLog()
|
|
|
|
End If
|
|
|
|
If CveProyecto <> -1 OrElse CveSubProyecto <> -1 OrElse CveEmpresa <> -1 OrElse Estatus <> -1 Then
|
|
Dim StrSQL As New StringBuilder
|
|
If CveProyecto <> -1 Then StrSQL.AppendFormat(" AND CveProyecto = {0}", CveProyecto)
|
|
If CveSubProyecto <> -1 Then StrSQL.AppendFormat(" AND CveSubProyecto = {0}", CveSubProyecto)
|
|
If Estatus <> -1 Then StrSQL.AppendFormat(" AND CveEstatus = {0}", Estatus)
|
|
If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa)
|
|
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTSubProyectos"), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows)
|
|
GlobalDTSubProyectos = Dv.ToTable
|
|
Dv.Dispose()
|
|
|
|
Else
|
|
GlobalDTSubProyectos = DirectCast(Application("GlobalDTSubProyectos"), DataTable)
|
|
End If
|
|
|
|
End Get
|
|
Set(ByVal value As DataTable)
|
|
If value Is Nothing OrElse value.Rows.Count = 0 Then
|
|
Dim msg As String = "aqui no se carga subproyectos"
|
|
'If Request IsNot Nothing Then
|
|
' msg = msg & Request.ServerVariables("URL")
|
|
'End If
|
|
msg.GuardaLog()
|
|
|
|
End If
|
|
Application("GlobalDTSubProyectos") = value
|
|
End Set
|
|
End Property
|
|
Property GlobalDTSATUsosCFDI(Optional EsPersonaFisica As Integer = -1) As DataTable
|
|
Get
|
|
If EsPersonaFisica <> -1 Then
|
|
Dim Tipo As String = ""
|
|
If EsPersonaFisica = 1 Then Tipo = "AplicaPersonaFisica = 1" Else Tipo = "AplicaPersonaMoral = 1"
|
|
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTSATUsosCFDI"), DataTable), Tipo, " UsoCFDIDescripcion", DataViewRowState.CurrentRows)
|
|
GlobalDTSATUsosCFDI = Dv.ToTable
|
|
Dv.Dispose()
|
|
Else
|
|
GlobalDTSATUsosCFDI = DirectCast(Application("GlobalDTSATUsosCFDI"), DataTable)
|
|
End If
|
|
|
|
End Get
|
|
Set(ByVal value As DataTable)
|
|
Application("GlobalDTSATUsosCFDI") = value
|
|
End Set
|
|
End Property
|
|
Property GlobalDTUsuarios(Optional CveUsuario As Integer = -1, Optional CveEmpresa As Integer = -1, Optional CveCliente As Integer = -1, Optional CveProveedor As Integer = -1) As DataTable
|
|
Get
|
|
Dim Str As New StringBuilder
|
|
If CveUsuario <> -1 Then Str.AppendFormat("CveUsuario = {0}", CveUsuario)
|
|
If CveEmpresa <> -1 Then Str.AppendFormat(" {0} CveEmpresa = {1}", If(Str.Length > 0, "AND", ""), CveEmpresa)
|
|
If CveCliente <> -1 Then Str.AppendFormat(" {0} CveCliente = {1}", If(Str.Length > 0, "AND", ""), CveCliente)
|
|
If CveProveedor <> -1 Then Str.AppendFormat(" {0} CveProveedor = {1}", If(Str.Length > 0, "AND", ""), CveProveedor)
|
|
|
|
If CveUsuario <> -1 OrElse CveEmpresa <> -1 Then
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTUsuarios"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows)
|
|
GlobalDTUsuarios = Dv.ToTable
|
|
Dv.Dispose()
|
|
Else
|
|
GlobalDTUsuarios = DirectCast(Application("GlobalDTUsuarios"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTUsuarios") = value
|
|
End Set
|
|
End Property
|
|
Property GlobalDTUnidadesMedida(Optional CveEmpresa As Integer = -1) As DataTable
|
|
Get
|
|
If CveEmpresa <> -1 Then
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTUnidadesMedida"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), " UnidadMedida", DataViewRowState.CurrentRows)
|
|
GlobalDTUnidadesMedida = Dv.ToTable
|
|
Dv.Dispose()
|
|
Else
|
|
GlobalDTUnidadesMedida = DirectCast(Application("GlobalDTUnidadesMedida"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTUnidadesMedida") = value
|
|
End Set
|
|
End Property
|
|
Property GlobalDTGralCategorias(CveEmpresa As Integer) As DataTable
|
|
Get
|
|
If CveEmpresa <> -1 Then
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTGralCategorias"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
GlobalDTGralCategorias = Dv.ToTable
|
|
Dv.Dispose()
|
|
Else
|
|
GlobalDTGralCategorias = DirectCast(Application("GlobalDTGralCategorias"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTGralCategorias") = value
|
|
End Set
|
|
End Property
|
|
Private ReadOnly Property GlobalDTProyectos(CveEmpresa As Integer, Optional Estatus As Integer = -1) As DataTable
|
|
Get
|
|
If CveEmpresa <> -1 OrElse Estatus <> -1 Then 'OrElse CveProyecto <> -1
|
|
|
|
Dim StrSQL As New StringBuilder
|
|
If CveEmpresa <> -1 Then StrSQL.AppendFormat("CveEmpresa = {0}", CveEmpresa)
|
|
' If CveProyecto <> -1 Then StrSQL.AppendFormat(" {0} CveProyecto = {1}", If(StrSQL.Length > 0, "AND", ""), CveProyecto)
|
|
If Estatus <> -1 Then StrSQL.AppendFormat(" {0} CveEstatus = {1}", If(StrSQL.Length > 0, "AND", ""), Estatus)
|
|
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTProyectos"), DataTable), StrSQL.ToString, "", DataViewRowState.CurrentRows)
|
|
GlobalDTProyectos = Dv.ToTable
|
|
Dv.Dispose()
|
|
Else
|
|
GlobalDTProyectos = DirectCast(Application("GlobalDTProyectos"), DataTable)
|
|
End If
|
|
|
|
End Get
|
|
End Property
|
|
Property GlobalDTVendedores(CveEmpresa As Integer) As DataTable
|
|
Get
|
|
If CveEmpresa <> -1 Then
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTVendedores"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
GlobalDTVendedores = Dv.ToTable
|
|
Dv.Dispose()
|
|
Else
|
|
GlobalDTVendedores = DirectCast(Application("GlobalDTVendedores"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTVendedores") = value
|
|
End Set
|
|
End Property
|
|
Property GlobalDTCliente(CveEmpresa As Integer) As DataTable
|
|
Get
|
|
If CveEmpresa <> -1 Then
|
|
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTCliente"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
GlobalDTCliente = Dv.ToTable
|
|
Dv.Dispose()
|
|
Else
|
|
GlobalDTCliente = DirectCast(Application("GlobalDTCliente"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTCliente") = value
|
|
End Set
|
|
End Property
|
|
Property GlobalDTOCEstatus(CveEmpresa As Integer) As DataTable
|
|
Get
|
|
If CveEmpresa <> -1 Then
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTOCEstatus"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
GlobalDTOCEstatus = Dv.ToTable
|
|
Dv.Dispose()
|
|
Else
|
|
GlobalDTOCEstatus = DirectCast(Application("GlobalDTOCEstatus"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTOCEstatus") = value
|
|
End Set
|
|
End Property
|
|
Public Property GlobalTipoCambio(Optional Fecha As Date = MinFecha) As Double
|
|
Get
|
|
If GlobalTipoCambio <= 0 Then
|
|
'sino tiene dato lo recargo por si ya esta insertado
|
|
If Fecha = MinFecha Then Fecha = Now
|
|
|
|
Dim ObjGral As New ClsGenerales
|
|
If ObjGral.GetTipoCambio(-1, Fecha) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then
|
|
|
|
Application("GlobalTipoCambio") = ObjGral.DtResultados.Rows(0)("TipoCambio").ToString.ToDouble
|
|
Else
|
|
Application("GlobalTipoCambio") = 0
|
|
End If
|
|
ObjGral.Dispose()
|
|
|
|
End If
|
|
|
|
Return Application("GlobalTipoCambio").ToString.ToDouble
|
|
End Get
|
|
Set(value As Double)
|
|
Application("GlobalTipoCambio") = value
|
|
End Set
|
|
|
|
End Property
|
|
|
|
Property GlobalDTOCEstatusUsuarios(CveEmpresa As Integer, Optional CveUsuario As Integer = -1, Optional Tipo As String = "") As DataTable
|
|
Get
|
|
|
|
Dim AppNombre As String = String.Format("GlobalDTOCEstatusUsuarios-{0}", CveEmpresa)
|
|
'sino existe, recarga los datos
|
|
If DirectCast(HttpContext.Current.Application(AppNombre), DataTable) Is Nothing Then
|
|
|
|
Dim ObjOC As New ClsOC
|
|
If ObjOC.GetEstatusUsuarios(-1, -1, -1, -1, CveEmpresa) Then
|
|
HttpContext.Current.Application(AppNombre) = ObjOC.DtResultados
|
|
Else
|
|
HttpContext.Current.Application(AppNombre) = Nothing
|
|
End If
|
|
|
|
ObjOC.Dispose()
|
|
|
|
End If
|
|
|
|
Dim filtro As New StringBuilder
|
|
filtro.AppendFormat("CveEmpresa = {0} ", CveEmpresa)
|
|
If CveUsuario > 0 Then
|
|
filtro.AppendFormat(" AND CveUsuario={0} ", CveUsuario)
|
|
End If
|
|
If Tipo <> "" Then
|
|
filtro.AppendFormat(" AND Tipo='{0}'", Tipo)
|
|
End If
|
|
Dim Dv As New DataView(DirectCast(HttpContext.Current.Application(AppNombre), DataTable), filtro.ToString, "", DataViewRowState.CurrentRows)
|
|
GlobalDTOCEstatusUsuarios = Dv.ToTable
|
|
Dv.Dispose()
|
|
|
|
End Get
|
|
Set(value As DataTable)
|
|
Dim AppNombre As String = String.Format("GlobalDTOCEstatusUsuarios-{0}", CveEmpresa)
|
|
HttpContext.Current.Application(AppNombre) = value
|
|
End Set
|
|
End Property
|
|
|
|
Property GlobalDTCompProveedores(CveEmpresa As Integer) As DataTable
|
|
Get
|
|
If CveEmpresa <> -1 Then
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTCompProveedores"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
GlobalDTCompProveedores = Dv.ToTable
|
|
Dv.Dispose()
|
|
Else
|
|
GlobalDTCompProveedores = DirectCast(Application("GlobalDTCompProveedores"), DataTable)
|
|
End If
|
|
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTCompProveedores") = value
|
|
End Set
|
|
End Property
|
|
Property GlobalDTProductosServicios(CveEmpresa As Integer, Optional CveClasificacion As Integer = -1, Optional CveClasificacionCosto As Integer = -1, Optional Estatus As Integer = 1, Optional CvePS As Integer = -1, Optional AplicaParaVenta As Integer = -1, Optional CveTipoPS As Integer = -1) As DataTable
|
|
Get
|
|
If CveEmpresa = -1 Then
|
|
GlobalDTProductosServicios = DirectCast(Application("GlobalDTProductosServicios"), EnumerableRowCollection(Of DataRow)).CopyToDataTable
|
|
Else
|
|
|
|
Dim Cons = DirectCast(Application("GlobalDTProductosServicios"), 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))
|
|
If CveClasificacionCosto >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveClasificacionCosto) = CveClasificacionCosto))
|
|
If Estatus >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveEstado) = Estatus))
|
|
If CvePS >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CvePS) = CvePS))
|
|
If AplicaParaVenta >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!AplicaParaVenta) = AplicaParaVenta))
|
|
If CveTipoPS >= 0 Then Cons = Cons.Where((Function(a) Convert.ToInt32(a!CveTipoPS) = CveTipoPS))
|
|
|
|
'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
|
|
GlobalDTProductosServicios = Cons.OrderBy(Function(a) a!PS).CopyToDataTable
|
|
Catch ex As Exception
|
|
GlobalDTProductosServicios = New DataTable
|
|
End Try
|
|
End If
|
|
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTProductosServicios") = value
|
|
End Set
|
|
End Property
|
|
Property GlobalDTClasificaciones(Optional CveEmpresa As Integer = -1, Optional CveCategoria As Integer = -1) As DataTable
|
|
Get
|
|
If CveEmpresa <> -1 Then
|
|
Dim Str As New StringBuilder
|
|
Str.AppendFormat("CveEmpresa = {0}", CveEmpresa)
|
|
If CveCategoria <> -1 Then Str.AppendFormat(" AND CveCategoria = {0}", CveCategoria)
|
|
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTClasificaciones"), DataTable), Str.ToString(), "", DataViewRowState.CurrentRows)
|
|
GlobalDTClasificaciones = Dv.ToTable
|
|
Dv.Dispose()
|
|
Else
|
|
GlobalDTClasificaciones = DirectCast(Application("GlobalDTClasificaciones"), DataTable)
|
|
End If
|
|
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTClasificaciones") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Property GlobalDTTurno(CveEmpresa As Integer) As DataTable
|
|
Get
|
|
If CveEmpresa <> -1 Then
|
|
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTTurno"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
GlobalDTTurno = Dv.ToTable
|
|
Dv.Dispose()
|
|
Else
|
|
GlobalDTTurno = DirectCast(Application("GlobalDTTurno"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTTurno") = value
|
|
End Set
|
|
End Property
|
|
|
|
Property GlobalDTDepartamentos(CveEmpresa As Integer) As DataTable
|
|
Get
|
|
If CveEmpresa <> -1 Then
|
|
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTDepartamentos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
GlobalDTDepartamentos = Dv.ToTable
|
|
Dv.Dispose()
|
|
Else
|
|
GlobalDTDepartamentos = DirectCast(Application("GlobalDTDepartamentos"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTDepartamentos") = value
|
|
End Set
|
|
End Property
|
|
|
|
Property GlobalDTRHPuestos(CveEmpresa As Integer) As DataTable
|
|
Get
|
|
If CveEmpresa <> -1 Then
|
|
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTRHPuestos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
GlobalDTRHPuestos = Dv.ToTable
|
|
Dv.Dispose()
|
|
Else
|
|
GlobalDTRHPuestos = DirectCast(Application("GlobalDTRHPuestos"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTRHPuestos") = value
|
|
End Set
|
|
End Property
|
|
Property GlobalDTMetodosPago() As DataTable
|
|
Get
|
|
GlobalDTMetodosPago = DirectCast(Application("GlobalDTMetodosPago"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTMetodosPago") = value
|
|
End Set
|
|
End Property
|
|
|
|
Property GlobalDTAsistenciasInasistencias(CveEmpresa As Integer) As DataTable
|
|
Get
|
|
If CveEmpresa <> -1 Then
|
|
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTAsistenciasInasistencias"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
GlobalDTAsistenciasInasistencias = Dv.ToTable
|
|
Dv.Dispose()
|
|
Else
|
|
GlobalDTAsistenciasInasistencias = DirectCast(Application("GlobalDTAsistenciasInasistencias"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTAsistenciasInasistencias") = value
|
|
End Set
|
|
End Property
|
|
|
|
Property GlobalDTMotivosHorasExtras(CveEmpresa As Integer) As DataTable
|
|
Get
|
|
If CveEmpresa <> -1 Then
|
|
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTMotivosHorasExtras"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
GlobalDTMotivosHorasExtras = Dv.ToTable
|
|
Dv.Dispose()
|
|
Else
|
|
GlobalDTMotivosHorasExtras = DirectCast(Application("GlobalDTMotivosHorasExtras"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTMotivosHorasExtras") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
#Region "U S U A R I O S"
|
|
<WebMethod()>
|
|
Public Function Login(Cadena As String) As String
|
|
Dim retorno As String = ""
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[Usuario] = "",
|
|
Key .[Contrasenia] = "",
|
|
Key .[Ticks] = ""
|
|
}
|
|
|
|
Dim Salida As WSUSER = Nothing
|
|
Try
|
|
Dim decripParams As String = Decripta(Cadena, "AES")
|
|
Dim Entrada = JsonConvert.DeserializeAnonymousType(decripParams, Estructura)
|
|
|
|
If Not IsNothing(Entrada) Then
|
|
If IsCurrentDate(Entrada.Ticks) Then
|
|
|
|
Dim ObjUsuarios As New ClsSisUsuarios
|
|
Dim UsuarioActual = ObjUsuarios.ValidaUsuario(Entrada.Usuario, Encripta(Entrada.Contrasenia), IMEI)
|
|
|
|
If UsuarioActual IsNot Nothing Then
|
|
Salida = New WSUSER
|
|
Salida.CveUsuario = UsuarioActual.CveUsuario
|
|
Salida.CveEmpresa = UsuarioActual.CveEmpresa
|
|
Salida.Usuario = UsuarioActual.Usuario
|
|
Salida.Nombre = UsuarioActual.Nombre
|
|
Salida.CveRol = UsuarioActual.CveRol
|
|
Salida.Rol = UsuarioActual.Rol
|
|
Salida.Contrasenia = UsuarioActual.Contraseña
|
|
Salida.CveSubProyecto = UsuarioActual.CveSubProyecto
|
|
Salida.Procesos = UsuarioActual.Procesos.Values.Cast(Of String).ToList()
|
|
|
|
Dim UsuariosModulos As New List(Of WsModulos)
|
|
Dim Empresas As New List(Of WsEmpresa)
|
|
|
|
If ObjUsuarios.GetUsuariosModulos(Salida.CveUsuario, Salida.CveEmpresa) Then
|
|
Dim dttmp As DataTable = ObjUsuarios.DtResultados.FiltraParametros("CvePlataforma = 4")
|
|
For Each Row As DataRow In dttmp.Rows
|
|
UsuariosModulos.Add(New WsModulos With {.CveModulo = Row("CveModulo").ToString.ToEntero, .CvePadre = Row("CvePadre").ToString.ToEntero, .CvePlataforma = 4, .Estilo = Row("Estilo").ToString, .Liga = Row("Liga").ToString, .Modulo = Row("Modulo").ToString})
|
|
Next
|
|
End If
|
|
|
|
Salida.Modulos = UsuariosModulos
|
|
|
|
'Dim Dt As DataTable = GlobalDTUsuarios(UsuarioActual.CveUsuario)
|
|
|
|
'If Dt IsNot Nothing Then
|
|
' If Dt.Rows.Count > 0 Then
|
|
' For Each Row As DataRow In Dt.FiltraParametros("CvePlataforma = 3", "Empresa").Rows
|
|
' Empresas.Add(New WsEmpresa With {.CveEmpresa = Row("CveCliente").ToString.ToEntero, .CveEncuestaCRM = Row("CveEncuestaCRM").ToString.ToEntero, .Empresa = Row("Cliente").ToString})
|
|
' Next
|
|
' End If
|
|
'End If
|
|
|
|
If ObjUsuarios.GetUsuariosEmpresas(Salida.CveUsuario) Then
|
|
For Each Row As DataRow In ObjUsuarios.DtResultados.FiltraParametros("", "", {"CveEmpresa", "CveEncuestaCRM", "Empresa", "Tipo_CentroCosto"}).Rows
|
|
Empresas.Add(New WsEmpresa With {
|
|
.CveEmpresa = Row("CveEmpresa").ToString.ToEntero(),
|
|
.CveEncuestaCRM = Row("CveEncuestaCRM").ToString.ToEntero(),
|
|
.Empresa = Row("Empresa").ToString,
|
|
.Tipo_CentroCosto = Row("Tipo_CentroCosto").ToString.ToEntero()})
|
|
Next
|
|
End If
|
|
|
|
Salida.Empresas = Empresas
|
|
ObjUsuarios.Dispose()
|
|
|
|
retorno = Encripta(JsonConvert.SerializeObject(Salida), "AES")
|
|
End If
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrió un error al iniciar sesión.", ex)
|
|
End Try
|
|
|
|
Return retorno
|
|
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function LoginTest(Usuario As String, Contrasenia As String) As String
|
|
Dim retorno As String = ""
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[Usuario] = "",
|
|
Key .[Contrasenia] = "",
|
|
Key .[Ticks] = ""
|
|
}
|
|
|
|
Dim Salida As WSUSER = Nothing
|
|
Try
|
|
|
|
Dim tUsuario As New ClsSisUsuarios
|
|
Dim UsuarioActual = tUsuario.ValidaUsuario(Usuario, Encripta(Contrasenia), IMEI)
|
|
|
|
If UsuarioActual IsNot Nothing Then
|
|
Salida = New WSUSER
|
|
Salida.CveUsuario = UsuarioActual.CveUsuario
|
|
Salida.CveEmpresa = UsuarioActual.CveEmpresa
|
|
Salida.Usuario = UsuarioActual.Usuario
|
|
Salida.Nombre = UsuarioActual.Nombre
|
|
Salida.CveRol = UsuarioActual.CveRol
|
|
Salida.Rol = UsuarioActual.Rol
|
|
Salida.Contrasenia = UsuarioActual.Contraseña
|
|
Salida.CveSubProyecto = UsuarioActual.CveSubProyecto
|
|
Salida.Procesos = UsuarioActual.Procesos.Values.Cast(Of String).ToList()
|
|
|
|
Dim UsuariosModulos As New List(Of WsModulos)
|
|
Dim Empresas As New List(Of WsEmpresa)
|
|
If tUsuario.GetUsuariosModulos(Salida.CveUsuario, Salida.CveEmpresa) Then
|
|
Dim dttmp As DataTable = tUsuario.DtResultados.FiltraParametros("CvePlataforma = 4")
|
|
For Each Row As DataRow In dttmp.Rows
|
|
UsuariosModulos.Add(New WsModulos With {.CveModulo = Row("CveModulo").ToString.ToEntero, .CvePadre = Row("CvePadre").ToString.ToEntero, .CvePlataforma = 4, .Estilo = Row("Estilo").ToString, .Liga = Row("Liga").ToString, .Modulo = Row("Modulo").ToString})
|
|
Next
|
|
End If
|
|
Salida.Modulos = UsuariosModulos
|
|
If tUsuario.GetUsuariosEmpresas(Salida.CveUsuario) Then
|
|
For Each Row As DataRow In tUsuario.DtResultados.Rows
|
|
Empresas.Add(New WsEmpresa With {.CveEmpresa = Row("CveEmpresa").ToString.ToEntero, .Empresa = Row("Empresa").ToString})
|
|
Next
|
|
End If
|
|
Salida.Empresas = Empresas
|
|
retorno = JsonConvert.SerializeObject(Salida)
|
|
End If
|
|
tUsuario.Dispose()
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
|
|
Return retorno
|
|
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetIndicadoresUsuarios(params As String) As String
|
|
|
|
Dim retorno As String = ""
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[Usuario] = "",
|
|
Key .[Contrasenia] = "",
|
|
Key .[Ticks] = ""
|
|
}
|
|
|
|
Dim decripParams As String = Decripta(params, "AES")
|
|
Dim Ent = JsonConvert.DeserializeAnonymousType(decripParams, Estructura)
|
|
|
|
If IsCurrentDate(Ent.Ticks) Then
|
|
Dim tUsuario As New ClsSisUsuarios
|
|
Dim UsuarioActual = tUsuario.ValidaUsuario(Ent.Usuario, Ent.Contrasenia, IMEI)
|
|
tUsuario.Dispose()
|
|
|
|
If UsuarioActual IsNot Nothing Then
|
|
Dim ObjGral As New ClsGenerales
|
|
Dim ds As DataSet = ObjGral.GetIndicadores(UsuarioActual.CveEmpresa)
|
|
Dim dtIndicadores = ds.Tables(0)
|
|
Dim dtBancos = ds.Tables(1)
|
|
Dim dtVentas = ds.Tables(3)
|
|
ObjGral.Dispose()
|
|
|
|
Dim indicadores As New JArray()
|
|
Dim Graficas As New JArray()
|
|
|
|
If dtIndicadores.Rows.Count > 0 Then
|
|
Dim dr = dtIndicadores.Rows(0)
|
|
If UsuarioActual.TienePermisoIndicador(1) Then
|
|
Dim prop As New JObject()
|
|
prop.Add(New JProperty("Titulo", "Ventas"))
|
|
prop.Add(New JProperty("Valor", dr("TotalVentas").ToString.FormatoNumero(0)))
|
|
prop.Add(New JProperty("Imagen", "BlueIndicator(752x356).png"))
|
|
|
|
indicadores.Add(prop)
|
|
End If
|
|
|
|
If UsuarioActual.TienePermisoIndicador(2) Then
|
|
Dim prop As New JObject()
|
|
prop.Add(New JProperty("Titulo", "Compras"))
|
|
prop.Add(New JProperty("Valor", dr("TotalCompras").ToString.FormatoNumero(0)))
|
|
prop.Add(New JProperty("Imagen", "RedBarIndicator(752x356).png"))
|
|
|
|
indicadores.Add(prop)
|
|
End If
|
|
|
|
If UsuarioActual.TienePermisoIndicador(3) Then
|
|
Dim prop As New JObject()
|
|
prop.Add(New JProperty("Titulo", "Bancos"))
|
|
prop.Add(New JProperty("Valor", dr("TotalBancos").ToString.FormatoNumero(0)))
|
|
prop.Add(New JProperty("Imagen", "GreenIndicator(752x357).png"))
|
|
|
|
indicadores.Add(prop)
|
|
End If
|
|
|
|
If UsuarioActual.TienePermisoIndicador(5) Then
|
|
Dim prop As New JObject()
|
|
prop.Add(New JProperty("Titulo", "Inventario"))
|
|
prop.Add(New JProperty("Valor", dr("TotalAlmacen").ToString.FormatoNumero(0)))
|
|
prop.Add(New JProperty("Imagen", "MoradoIndicator(752x356).png"))
|
|
|
|
indicadores.Add(prop)
|
|
End If
|
|
End If
|
|
|
|
If dtVentas.Rows.Count > 0 Then
|
|
If UsuarioActual.TienePermisoIndicador(7) Then
|
|
Dim jdatosVentas = New JArray(From v In dtVentas
|
|
Where (v("Mes").ToString().ToEntero() <= Now.Month)
|
|
Select New JObject(
|
|
New JProperty("NombreMes", v("NombreMes").ToString()),
|
|
New JProperty("Importe", v("Importe").ToString().ToDouble())))
|
|
Dim jVentas As New JObject(
|
|
New JProperty("Titulo", "Ventas"),
|
|
New JProperty("Datos", jdatosVentas))
|
|
|
|
Graficas.Add(jVentas)
|
|
End If
|
|
End If
|
|
|
|
If dtBancos.Rows.Count > 0 Then
|
|
If UsuarioActual.TienePermisoIndicador(8) Then
|
|
Dim jDatosBancos = New JArray(From v In dtBancos
|
|
Where (v("Mes").ToString().ToEntero() <= Now.Month)
|
|
Select New JObject(
|
|
New JProperty("NombreMes", v("NombreMes").ToString()),
|
|
New JProperty("Importe", v("Importe").ToString().ToDouble())))
|
|
Dim jBancos As New JObject(
|
|
New JProperty("Titulo", "Bancos"),
|
|
New JProperty("Datos", jDatosBancos))
|
|
|
|
Graficas.Add(jBancos)
|
|
End If
|
|
End If
|
|
|
|
Dim Json As New JObject(
|
|
New JProperty("Indicadores", indicadores),
|
|
New JProperty("Graficas", Graficas))
|
|
|
|
retorno = Encripta(Json.ToString())
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
Return retorno
|
|
End Function
|
|
|
|
<WebMethod>
|
|
Public Function GetUsuarios(CveUsuario As Integer, CveEmpresa As Integer) As String
|
|
Dim Retorno As String = "[]"
|
|
Dim Str As New StringBuilder
|
|
If CveUsuario <> -1 Then Str.AppendFormat("CveUsuario = {0}", CveUsuario)
|
|
If CveEmpresa <> -1 Then Str.AppendFormat(" {0} CveEmpresa = {1}", If(Str.Length > 0, "AND", ""), CveEmpresa)
|
|
|
|
If CveUsuario <> -1 OrElse CveEmpresa <> -1 Then
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTUsuarios"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows)
|
|
Dim dt = Dv.ToTable
|
|
Retorno = JsonConvert.SerializeObject(dt.DataTableToObject(Of WSUSER)()).ToString
|
|
Dv.Dispose()
|
|
dt.Dispose()
|
|
End If
|
|
Return Retorno
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "C L I E N T E S"
|
|
<WebMethod>
|
|
Public Function AddClientes(parametros As String) As Boolean
|
|
Dim TieneError As Boolean = False
|
|
Dim ObjClientes As New ClsClientes
|
|
ObjClientes.IniciaTransacSQL()
|
|
Try
|
|
Dim Clientes As List(Of MCliente) = JsonConvert.DeserializeObject(Of List(Of MCliente))(parametros)
|
|
For Each Cliente As MCliente In Clientes
|
|
If Not ObjClientes.AddClienteApp(Cliente) Then
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
Catch ex As Exception
|
|
TieneError = True
|
|
GuardaLog(ex.ToString())
|
|
Finally
|
|
If TieneError Then
|
|
ObjClientes.RollBack()
|
|
Else
|
|
ObjClientes.Commit()
|
|
End If
|
|
ObjClientes.Dispose()
|
|
End Try
|
|
Return Not TieneError
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetClientes(CveEmpresa As Integer) As String
|
|
Dim Retorno As String = "[]"
|
|
Try
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTCliente"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
Dim dt = Dv.ToTable
|
|
If CveEmpresa <> -1 Then
|
|
Retorno = dt.ToJson()
|
|
End If
|
|
Dv.Dispose()
|
|
dt.Dispose()
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString())
|
|
End Try
|
|
Return Retorno
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetMetodosPago33() As String
|
|
Return GlobalDTVtaMetodoPago().ToJson()
|
|
End Function
|
|
|
|
<WebMethod>
|
|
Public Function GetFormasPago33() As String
|
|
Return GlobalDTVtaFormaPago().ToJson()
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetSATUsoCFDI(EsPersonaFisica As Integer) As String
|
|
Return GlobalDTSATUsosCFDI(EsPersonaFisica).ToJson()
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "R H"
|
|
Public Property CveClienteAsignado As Integer
|
|
Public Property CveTurno As Integer
|
|
Public Property CveDepartamento As Integer
|
|
Public Property CvePuesto As Integer
|
|
Public Property CveSubProyecto As Integer
|
|
<WebMethod>
|
|
Public Function GetPersonal(CveEmpresa As Integer) As String
|
|
Dim Retorno As String = "[]"
|
|
Dim Personal As New List(Of WSPersonal)
|
|
Dim ObjPersonal As New ClsRH
|
|
Try
|
|
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
|
|
If ObjPersonal.DtResultados IsNot Nothing Then
|
|
If ObjPersonal.DtResultados.Rows.Count > 0 Then
|
|
For Each Row As DataRow In ObjPersonal.DtResultados.Rows
|
|
Personal.Add(New WSPersonal With {.CvePersonal = Row("CvePersonal").ToString.ToEntero, .CodigoNombreCompleto = Row("CodigoNombreCompleto").ToString, .CveClienteAsignado = Row("CveClienteAsignado").ToString.ToEntero,
|
|
.CveTurno = Row("CveTurno").ToString.ToEntero, .CveDepartamento = Row("CveDepartamento").ToString.ToEntero,
|
|
.CvePuesto = Row("CvePuesto").ToString.ToEntero, .CveSubProyecto = Row("CveSubProyecto").ToString.ToEntero, .CveProyecto = Row("CveProyecto").ToString.ToEntero})
|
|
Next
|
|
End If
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString())
|
|
End Try
|
|
ObjPersonal.Dispose()
|
|
Retorno = JsonConvert.SerializeObject(Personal)
|
|
Return Retorno
|
|
End Function
|
|
|
|
<WebMethod>
|
|
Public Function GetTurnos(CveEmpresa As Integer) As String
|
|
Dim Retorno As String = "[]"
|
|
Try
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTTurno"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
Dim dt = Dv.ToTable
|
|
If CveEmpresa <> -1 Then
|
|
Retorno = dt.ToJson()
|
|
End If
|
|
Dv.Dispose()
|
|
dt.Dispose()
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString())
|
|
End Try
|
|
|
|
Return Retorno
|
|
End Function
|
|
|
|
<WebMethod>
|
|
Public Function GetDepartamentos(CveEmpresa As Integer) As String
|
|
Dim Retorno As String = "[]"
|
|
Try
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTDepartamentos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
Dim dt = Dv.ToTable
|
|
If CveEmpresa <> -1 Then
|
|
Retorno = dt.ToJson()
|
|
End If
|
|
Dv.Dispose()
|
|
dt.Dispose()
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString())
|
|
End Try
|
|
|
|
Return Retorno
|
|
End Function
|
|
|
|
<WebMethod>
|
|
Public Function GetPuestos(CveEmpresa As Integer) As String
|
|
Dim Retorno As String = "[]"
|
|
Try
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTRHPuestos"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
Dim dt = Dv.ToTable
|
|
If CveEmpresa <> -1 Then
|
|
Retorno = dt.ToJson()
|
|
End If
|
|
Dv.Dispose()
|
|
dt.Dispose()
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString())
|
|
End Try
|
|
|
|
Return Retorno
|
|
End Function
|
|
|
|
<WebMethod>
|
|
Public Function GetAsistenciasInasistencias(CveEmpresa As Integer) As String
|
|
Dim Retorno As String = "[]"
|
|
Try
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTAsistenciasInasistencias"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
Dim dt = Dv.ToTable
|
|
If CveEmpresa <> -1 Then
|
|
Retorno = dt.ToJson()
|
|
End If
|
|
Dv.Dispose()
|
|
dt.Dispose()
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString())
|
|
End Try
|
|
|
|
Return Retorno
|
|
End Function
|
|
|
|
<WebMethod>
|
|
Public Function GetMotivoHorasExtra(CveEmpresa As Integer) As String
|
|
Dim Retorno As String = "[]"
|
|
Try
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTMotivosHorasExtras"), DataTable), String.Format("CveEmpresa = {0}", CveEmpresa), "", DataViewRowState.CurrentRows)
|
|
Dim dt = Dv.ToTable
|
|
If CveEmpresa <> -1 Then
|
|
Retorno = dt.ToJson()
|
|
End If
|
|
Dv.Dispose()
|
|
dt.Dispose()
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString())
|
|
End Try
|
|
|
|
Return Retorno
|
|
End Function
|
|
|
|
<WebMethod>
|
|
Public Function UpdatePersonalAsistencia(params As String) As Boolean
|
|
Dim retorno = False
|
|
Try
|
|
Dim Estructura = New With
|
|
{
|
|
Key .ListaPersonal = New List(Of WSPersonal),
|
|
Key .ListaAsistencia = New List(Of WSAsistencia)
|
|
}
|
|
Dim JsonRequest = params
|
|
Dim RH = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
Dim ObjRH As New ClsRH
|
|
ObjRH.IniciaTransacSQL()
|
|
Dim ErrorTrans As Boolean = False
|
|
For Each item As WSPersonal In RH.ListaPersonal
|
|
If Not ObjRH.UpdatePersonalApp(item.CvePersonal, item.CveTurno, item.CveDepartamento, item.CvePuesto, item.CveSubProyecto, item.CveClienteAsignado) Then
|
|
ErrorTrans = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
For Each item As WSAsistencia In RH.ListaAsistencia
|
|
If Not ObjRH.AddAsistencia(item.CvePersonal, item.CveCliente, item.CveSubProyecto, item.FechaAsistencia, item.CveAsistenciasInasistencias, item.PorcentajePago, item.HorasDobles,
|
|
item.HorasTriples, item.CveMotivoHoraExtra, item.Observacion, item.CveUsuario, item.CveEmpresa) Then
|
|
ErrorTrans = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
If ErrorTrans Then
|
|
ObjRH.RollBack()
|
|
Else
|
|
retorno = True
|
|
ObjRH.Commit()
|
|
End If
|
|
ObjRH.Dispose()
|
|
Catch ex As Exception
|
|
OnError("Ocurrio un error al agregar la asistencia.", ex)
|
|
End Try
|
|
Return retorno
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "M O N E D A S"
|
|
<WebMethod()>
|
|
Public Function GetMonedas() As String
|
|
Dim Retorno = "[]"
|
|
Try
|
|
Dim dt = DirectCast(Application("GlobalDTMonedas"), DataTable)
|
|
Retorno = JsonConvert.SerializeObject(dt.DataTableToObject(Of WsMoneda))
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
Return Retorno
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "P R O Y E C T O S - S U B P R O Y E C T O S"
|
|
<WebMethod()>
|
|
Public Function GetProyectos(CveEmpresa As Integer, Estatus As Integer) As String
|
|
Dim Salida As String = "[]"
|
|
Salida = GlobalDTProyectos(CveEmpresa, Estatus).FiltraParametros("CveProyecto > 0", "Proyecto", {"CveEmpresa", "CveProyecto", "Proyecto"}).ToJson()
|
|
Return Salida
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetSubProyectos(CveEmpresa As Integer, CveProyecto As Integer, CveSubProyecto As Integer, Estatus As Integer) As String
|
|
Dim Salida As String = "[]"
|
|
If DirectCast(Application("GlobalDTSubProyectos"), DataTable) Is Nothing Or (DirectCast(Application("GlobalDTSubProyectos"), DataTable) IsNot Nothing AndAlso DirectCast(Application("GlobalDTSubProyectos"), DataTable).Rows.Count = 0) Then
|
|
Dim P As New ClsSubProyectos
|
|
If P.GetSubProyectos Then
|
|
Application("GlobalDTSubProyectos") = P.DtResultados
|
|
End If
|
|
P.Dispose()
|
|
End If
|
|
|
|
If CveProyecto <> -1 OrElse CveEmpresa <> -1 OrElse Estatus <> -1 Then
|
|
Dim dt As DataTable = Nothing
|
|
Dim StrSQL As New StringBuilder
|
|
If CveProyecto <> -1 Then StrSQL.AppendFormat(" AND CveProyecto = {0}", CveProyecto)
|
|
If CveEmpresa <> -1 Then StrSQL.AppendFormat(" AND CveEmpresa = {0}", CveEmpresa)
|
|
|
|
Dim Dv As New DataView(DirectCast(Application("GlobalDTSubProyectos"), DataTable), StrSQL.ToString.Trim.TrimStart("A"c, "N"c, "D"c), "", DataViewRowState.CurrentRows)
|
|
dt = Dv.ToTable
|
|
Salida = dt.FiltraParametros("CveSubProyecto > 0", "SubProyecto", {"CveProyecto", "CveSubProyecto", "SubProyecto", "CveEmpresa", "CveUsuario", "EsSucursal", "TipoSucursal", "Serie"}).ToJson()
|
|
Dv.Dispose()
|
|
End If
|
|
|
|
Return Salida
|
|
End Function
|
|
#End Region
|
|
|
|
#Region " "
|
|
|
|
Protected Function GeneraOrdenes(ByRef OCGeneradas As List(Of Integer), ByRef ObjConta As ClsContPAQi, ByRef objOrdenCompra As ClsOC, DrOC As DataRow, DtDetalle As DataTable, CveUsuarioActual As Integer, CveEmpresaActual As Integer, IDPolizaPresupuestal As Integer, UsaAC As Boolean, DtPresupuesto As DataTable) As Boolean
|
|
Dim HuboError As Boolean = False
|
|
Try
|
|
Dim CveOrdenCompra As Integer = DrOC("CveOrdenCompra").ToString.ToEntero
|
|
Dim CveCotizacion As Integer = 0
|
|
Dim CveColectiva As Integer = 0
|
|
Dim CveEmpresa As Integer = DrOC("CveEmpresa").ToString().ToEntero()
|
|
Dim CveUsuario As Integer = DrOC("CveUsuario").ToString().ToEntero()
|
|
Dim IVA = DrOC("IVA").ToString().ToDecimal() 'If(TxtIVA.Visible, TxtIVA.Text.ToDecimal, LblIVA.Text.ToDecimal)
|
|
Dim RequiereCotizacion = CBool(DrOC("RequiereCotizacion").ToString())
|
|
|
|
Dim Total As Decimal = DrOC("Total").ToString.ToDecimal
|
|
Dim LugarEntrega = If(DrOC("LugarEntrega").ToString() = "", "-1", DrOC("LugarEntrega").ToString())
|
|
|
|
|
|
Dim Descripcion As String = DrOC("Descripcion").ToString
|
|
Dim Justificacion As String = DrOC("Justificacion").ToString
|
|
Dim Prioridad As Integer = DrOC("Prioridad").ToString.ToEntero
|
|
Dim Fecha As Date = DrOC("Fecha").ToString.ToDate
|
|
|
|
Dim CveVendedor As Integer = If(DrOC("CveVendedor").ToString.ToEntero > 0, DrOC("CveVendedor").ToString.ToEntero, -1)
|
|
Dim CveCliente As Integer = If(DrOC("CveCliente").ToString.ToEntero > 0, DrOC("CveCliente").ToString.ToEntero, -1)
|
|
Dim CveMoneda As Integer = DrOC("CveMoneda").ToString.ToEntero
|
|
Dim FolioAdicional As String = DrOC("FolioAdicional").ToString
|
|
Dim FechaEstimadaEntrega As String = DrOC("FechaEstimadaEntrega").ToString
|
|
Dim PrioridadObservacion As String = DrOC("PrioridadObservacion").ToString
|
|
Dim EntregaDirecta As Integer = DrOC("EntregaDirecta").ToString.ToEntero
|
|
Dim CveDireccionEnvio As Integer = If(DrOC("CveDireccionEnvio").ToString.ToEntero > 0, DrOC("CveDireccionEnvio").ToString.ToEntero, -1)
|
|
Dim IEPS As Decimal = DrOC("IEPS").ToString.ToDecimal
|
|
Dim CveEstatusInicialOC As Integer = -1
|
|
Dim drE As DataRow = GlobalDTOCEstatus(CveEmpresaActual).FiltraParametros(String.Format("Tipo = 'OC' AND TipoTermino = 3")).FiltroPrimero("")
|
|
If drE IsNot Nothing Then CveEstatusInicialOC = drE("CveEstatus").ToString.ToEntero
|
|
Dim IdPoliza = -1
|
|
If RequiereCotizacion Then
|
|
Dim CveProveedor = -1
|
|
Dim TotalCot = 0.0, IVACot = 0D, RetIVA = 0.0, RetISR = 0.0, PorIVA = 0.0, Porcentaje = 0.0
|
|
|
|
|
|
For Each dr As DataRow In DtDetalle.FiltraParametros("", "CveProveedor").Rows
|
|
|
|
'SI ES DIFERENTE PROVEEDOR AGREGA UNA OC
|
|
If CveProveedor <> dr("CveProveedor").ToString.ToEntero Then
|
|
|
|
CveProveedor = dr("CveProveedor").ToString.ToEntero
|
|
|
|
Porcentaje = DtDetalle.SUM("Total", String.Format("CveProveedor = {0}", CveProveedor)) / DtDetalle.SUM("Total")
|
|
PorIVA = GlobalDTCompProveedores(CveEmpresa).FiltraParametros(String.Format("CveProveedor = {0}", CveProveedor)).Rows(0)("IVA").ToString.ToDouble
|
|
IVACot = (DtDetalle.SUM("Total", String.Format("CveProveedor = {0}", CveProveedor)) * PorIVA).ToString.ToDecimal
|
|
RetIVA = DrOC("RetIVA").ToString().ToDecimal * Porcentaje
|
|
RetISR = DrOC("RetISR").ToString().ToDecimal * Porcentaje
|
|
|
|
If objOrdenCompra.AddOrdenCompra("OC", -1, Descripcion, Justificacion, Prioridad, Fecha, CveMoneda, CveEstatusInicialOC, FechaEstimadaEntrega, LugarEntrega,
|
|
CveUsuario, CveEmpresaActual, 0, pCveProveedor:=CveProveedor, CveCliente:=CveCliente, CveVendedor:=CveVendedor, PrioridadObservacion:=PrioridadObservacion,
|
|
PorcentajeIVA:=PorIVA, IVA:=IVACot, RetIVA:=RetIVA.ToString.ToDecimal, RetISR:=RetISR.ToString.ToDecimal, IDPoliza:=IdPoliza, CveCotizacion:=CveCotizacion, FolioAdicional:=FolioAdicional,
|
|
EntregaDirecta:=EntregaDirecta, CveDireccionEnvio:=CveDireccionEnvio, IEPS:=IEPS) Then
|
|
|
|
OCGeneradas.Add(objOrdenCompra.CveOrdenCompra)
|
|
'CREA POLIZA POR CADA PROVEEDOR
|
|
If UsaAC AndAlso DtPresupuesto IsNot Nothing AndAlso DtPresupuesto.Rows.Count > 0 AndAlso objOrdenCompra.Folio > 0 AndAlso ObjConta IsNot Nothing Then
|
|
IdPoliza = GuardaAC(ObjConta, objOrdenCompra, DtDetalle, objOrdenCompra.CveOrdenCompra, objOrdenCompra.Folio, IDPolizaPresupuestal, Total, IVA, Fecha, Descripcion, CveUsuarioActual, CveEmpresaActual, DtPresupuesto, CveProveedor:=CveProveedor)
|
|
If IdPoliza <= 0 Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
Else
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
'AGREGA DETALLES
|
|
If Not objOrdenCompra.AddOrdenCompraDetalle(objOrdenCompra.CveOrdenCompra, dr("Cantidad").ToString.ToDouble(), dr("CveUnidadMedida").ToString.ToEntero, dr("CvePS").ToString.ToEntero, dr("Importe").ToString.ToDouble, dr("CveSubProyecto").ToString.ToEntero(), dr("CveActivoFijo").ToString.ToEntero, dr("Observacion").ToString, CveUsuarioActual, CveOrdenCompra, CvePresupuestoEgreso:=dr("CvePresupuestoEgreso").ToString.ToEntero, Descuento:=dr("Descuento").ToString.ToDouble) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
|
|
Next
|
|
Else
|
|
Dim CveProveedor As Integer = DrOC("CveProveedor").ToString.ToEntero
|
|
Dim RetIVA = DrOC("RetIVA").ToString().ToDecimal
|
|
Dim RetISR = DrOC("RetISR").ToString().ToDecimal
|
|
Dim PorcentajeIVA As Double = DrOC("PorcentajeIVA").ToString().ToDouble
|
|
If objOrdenCompra.AddOrdenCompra("OC", -1, Descripcion, Justificacion, Prioridad, Fecha, CveMoneda, CveEstatusInicialOC, FechaEstimadaEntrega, LugarEntrega,
|
|
CveUsuario, CveEmpresaActual, 0, CveProveedor, CveCliente:=CveCliente, CveVendedor:=CveVendedor, PrioridadObservacion:=PrioridadObservacion,
|
|
PorcentajeIVA:=PorcentajeIVA, IVA:=IVA, RetIVA:=RetIVA, RetISR:=RetISR, IDPoliza:=IDPolizaPresupuestal, CveCotizacion:=CveCotizacion, FolioAdicional:=FolioAdicional,
|
|
EntregaDirecta:=EntregaDirecta, CveDireccionEnvio:=CveDireccionEnvio, IEPS:=IEPS) Then
|
|
|
|
|
|
'USA AC
|
|
If UsaAC AndAlso DtPresupuesto IsNot Nothing AndAlso DtPresupuesto.Rows.Count > 0 AndAlso objOrdenCompra.Folio > 0 AndAlso ObjConta IsNot Nothing Then
|
|
If Not RequiereCotizacion Then
|
|
IdPoliza = GuardaAC(ObjConta, objOrdenCompra, DtDetalle, objOrdenCompra.CveOrdenCompra, objOrdenCompra.Folio, IDPolizaPresupuestal, Total, IVA, Fecha, Descripcion, CveUsuarioActual, CveEmpresaActual, DtPresupuesto, CveProveedor:=CveProveedor)
|
|
If IdPoliza <= 0 Then
|
|
HuboError = True
|
|
End If
|
|
End If
|
|
End If
|
|
'TERMINA: USA AC
|
|
If Not HuboError Then
|
|
For Each dr As DataRow In DtDetalle.Rows
|
|
If Not objOrdenCompra.AddOrdenCompraDetalle(objOrdenCompra.CveOrdenCompra, dr("Cantidad").ToString.ToDouble(), dr("CveUnidadMedida").ToString.ToEntero, dr("CvePS").ToString.ToEntero, dr("Importe").ToString.ToDouble, dr("CveSubProyecto").ToString.ToEntero(), dr("CveActivoFijo").ToString.ToEntero, dr("Observacion").ToString, CveUsuarioActual, CveOrdenCompra, CvePresupuestoEgreso:=dr("CvePresupuestoEgreso").ToString.ToEntero, Descuento:=dr("Descuento").ToString.ToDouble) Then
|
|
HuboError = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
Else
|
|
HuboError = True
|
|
End If
|
|
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
HuboError = True
|
|
End Try
|
|
|
|
Return HuboError
|
|
End Function
|
|
Private Function GuardaAC(Conta As ClsContPAQi, OC As ClsOC, DtDetalle As DataTable, CveOC As Integer, FolioOC As Integer, IDPolizaPresupuestal As Integer, Total As Decimal, IVA As Decimal, Fecha As Date, Descripcion As String, CveUsuarioActual As Integer, CveEmpresaActual As Integer, DtPresupuestos As DataTable, Optional CveProveedor As Integer = -1) As Integer
|
|
Dim TieneError = False
|
|
Dim IDPoliza = -1
|
|
Dim Folio = -1
|
|
|
|
|
|
'SI TIENE POLIZA ANTERIOR LA ELIMINA
|
|
If IDPolizaPresupuestal > 0 Then
|
|
If Not Conta.RemoveAllMovimientos(IDPolizaPresupuestal) Then
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
|
|
'INGRESA POLIZA
|
|
If Not TieneError Then
|
|
Dim ConceptoRenglon As String = String.Format("GC - OC {0}. {1}", FolioOC, Descripcion)
|
|
|
|
|
|
If Total > 0 Then
|
|
Total = Math.Round(Total, 2)
|
|
|
|
'INGRESA POLIZA SOLO CUANDO NO EXISTE YA UNA
|
|
If IDPolizaPresupuestal > 0 Then
|
|
IDPoliza = IDPolizaPresupuestal
|
|
Else
|
|
IDPoliza = Conta.AddPoliza(4, If(ConceptoRenglon.Length > 100, ConceptoRenglon.Substring(0, 99), ConceptoRenglon), 0, 0, CveUsuarioActual, Fecha)
|
|
Folio = Conta.Folio
|
|
End If
|
|
End If
|
|
|
|
If IDPoliza > 0 Then
|
|
|
|
Dim DtPresupuestosTemp As DataTable
|
|
Dim IdCuentaComprometido, IdCuentaPorEjercer As Integer
|
|
|
|
'SI VIENE CON PROVEEDOR FILTRA SOLO LOS CONCEPTOS DEL PROVEEDOR
|
|
Dim DT = If(CveProveedor = -1, DtDetalle.Copy, DtDetalle.FiltraParametros(String.Format("CveProveedor = {0}", CveProveedor)).Copy)
|
|
|
|
Dim Presup = From gvr As DataRow In DT.Rows.Cast(Of DataRow)()
|
|
Group gvr By Grp = New With {
|
|
Key .CvePresupuestoEgreso = gvr("CvePresupuestoEgreso").ToString.ToEntero
|
|
} Into Group
|
|
Select Grp.CvePresupuestoEgreso,
|
|
TotalImporte = Group.Sum(Function(r) r("Total").ToString.ToDecimal)
|
|
|
|
Dim tTotalIVA, tTotalGral, tIVA, tDiferenciaIVA, Importe, TotalDetalle As Decimal
|
|
Dim tPorIVA = 0D, tAjusteTotal = 0D, ipresup = 0
|
|
|
|
If CveProveedor > 0 Then
|
|
'CUANDO VIENE DE COTIZACION
|
|
tTotalIVA = (DtDetalle.SUM("Total", String.Format("CveProveedor = {0}", CveProveedor)) * tPorIVA).ToString.ToDecimal
|
|
tPorIVA = GlobalDTCompProveedores(CveEmpresaActual).FiltraParametros(String.Format("CveProveedor = {0}", CveProveedor)).Rows(0)("IVA").ToString.ToDecimal
|
|
tTotalGral = DtDetalle.SUM("Total", String.Format("CveProveedor = {0}", CveProveedor)).ToString.ToDecimal
|
|
Else
|
|
'CUANDO NO VIENE DE COTIZACION
|
|
If IVA > 0 Then
|
|
tTotalIVA = Total
|
|
Else
|
|
tTotalIVA = IVA
|
|
End If
|
|
|
|
tTotalGral = Total
|
|
tPorIVA = tTotalIVA / (tTotalGral - tTotalIVA)
|
|
End If
|
|
|
|
tDiferenciaIVA = tTotalIVA
|
|
|
|
For Each grp In Presup
|
|
Importe = grp.TotalImporte
|
|
TotalDetalle += Importe
|
|
ipresup += 1
|
|
If Importe > 0 Then
|
|
|
|
'saco la proporcion de iva que le corresponde
|
|
tIVA = Math.Round(Importe * tPorIVA, 2)
|
|
|
|
'le sumo el iva al concepto
|
|
Importe += tIVA
|
|
|
|
'Presupuesto Egresos
|
|
DtPresupuestosTemp = DtPresupuestos.FiltraParametros(String.Format("CvePresupuestoEgreso = {0}", grp.CvePresupuestoEgreso))
|
|
If DtPresupuestosTemp.Rows.Count <> 1 Then
|
|
TieneError = True : Exit For
|
|
End If
|
|
IdCuentaComprometido = DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString.ToEntero
|
|
IdCuentaPorEjercer = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString.ToEntero
|
|
|
|
If Conta.AddMovimiento(IDPoliza, IdCuentaComprometido, False, Importe, "", ConceptoRenglon, 0, Fecha, "") Then
|
|
If Not Conta.AddMovimiento(IDPoliza, IdCuentaPorEjercer, True, Importe, "", ConceptoRenglon, 0, Fecha, "") Then
|
|
TieneError = True : Exit For
|
|
End If
|
|
Else
|
|
TieneError = True : Exit For
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
|
|
If Not TieneError Then
|
|
If Not OC.UpdateOrdenCompraPoliza(IDPoliza, CveOC) Then
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
|
|
If Not TieneError Then
|
|
If Not Conta.AjustaPoliza(IDPoliza) Then
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
|
|
ElseIf Total > 0 Then
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
|
|
If TieneError Then
|
|
IDPoliza = -1
|
|
Else
|
|
'GUARDA ID Y FOLIO PARA MOSTRAR LIGA A POLIZA EN ALERT
|
|
End If
|
|
|
|
Return IDPoliza
|
|
End Function
|
|
|
|
Private Function ValidaGuardarOC(OC As WSOrdenCompra, DtDetalle As List(Of OrdenCompraDetalle), CveEmpresaActual As Integer, CveUsuario As Integer) As Boolean
|
|
Dim TieneError = False
|
|
|
|
'VALIDA QUE TENGA REGISTROS
|
|
If Not DtDetalle.Any Then
|
|
'Alert(String.Format("La {0} debe de tener registros", TipoLargo), TipoMensaje.MsgAdvertencia)
|
|
Return True
|
|
End If
|
|
|
|
'VALIDA DESCUENTOS
|
|
'If Not ValidarDescuentos() Then
|
|
' Alert("Los descuentos no cuadran. Por favor de verificar.", TipoMensaje.MsgAdvertencia)
|
|
' Return True
|
|
'End If
|
|
Dim drFinalOK As DataRow = If(GlobalDTOCEstatus(OC.CveEmpresa).FiltraParametros(String.Format("TipoTermino = 1 AND Tipo = '{0}'", OC.Tipo)).Rows.Count = 1, GlobalDTOCEstatus(OC.CveEmpresa).FiltraParametros(String.Format("TipoTermino = 1 AND Tipo = '{0}'", OC.Tipo)).Rows(0), Nothing)
|
|
Dim CveEstatusFinalOK = drFinalOK("CveEstatus").ToString.ToEntero
|
|
|
|
'SI ES REQUISICION, NO REQUIERE COTIZACION Y ES ESTATUSFINALOK... ENTONCES DEBE DE TENER UN PROVEEDOR SELECCIONADO Y LOS PRECIOS CAPTURADOS
|
|
If (OC.Tipo.Equals("REQ", StringComparison.InvariantCultureIgnoreCase) And OC.RequiereCotizacion = False And OC.CveEstatus = CveEstatusFinalOK) OrElse OC.Tipo = "OC" Then
|
|
'If Not UsuarioActual.TienePermisoProceso(179) Then 'PERMISO PARA GENERAR CON O
|
|
If DtDetalle.Any(Function(d) d.Importe = -1 Or d.Importe = 0) Then
|
|
'Alert("DEBE CAPTURAR EL PRECIO UNITARIO DE CADA PRODUCTO/SERVICIO", TipoMensaje.MsgAdvertencia)
|
|
Return True
|
|
End If
|
|
If OC.CveProveedor <= 0 Then
|
|
'Alert("DEBE CAPTURAR EL PROVEEDOR", TipoMensaje.MsgAdvertencia)
|
|
Return True
|
|
End If
|
|
'End If
|
|
End If
|
|
|
|
'VALIDA SUBPROYECTOS
|
|
|
|
Dim Subtotal As Double = DtDetalle.Where(Function(t) t.Total > 0).Sum(Function(d) d.Total)
|
|
Dim Total As Decimal = (Subtotal + OC.IVA).ToDecimal
|
|
|
|
Dim SubProyectosNoAutorizados = New List(Of String)
|
|
Dim TotalT As Decimal = Total 'If(OC.RequiereCotizacion, TotalCotizacionesGanadoras, Total)
|
|
TotalT = If(OC.CveMoneda <> 1, (TotalT * GlobalTipoCambio(OC.Fecha).ToString.ToDecimal), TotalT)
|
|
Dim RequiereSubProyecto = If(CveEmpresaActual = 48, False, True)
|
|
If RequiereSubProyecto = True AndAlso OC.CveEstatus > 0 Then ' cuando se cumpla la restriccion y no sea "Pre Solicitud"
|
|
|
|
If OC.CveMoneda <> 1 And GlobalTipoCambio(OC.Fecha).ToString.ToDecimal = 0 Then
|
|
' Alert("No se pudieron verificar los limites del usuario porque no se pudo cargar el tipo de cambio", TipoMensaje.MsgAdvertencia)
|
|
Return True
|
|
End If
|
|
|
|
Dim DtEstatusUsuarios = GlobalDTOCEstatusUsuarios(CveEmpresaActual, CveUsuario, OC.Tipo)
|
|
For Each Det As OrdenCompraDetalle In DtDetalle ' {"CveSubProyecto", "SubProyecto"}).Rows
|
|
'Primero Filtrar por SubProyecto
|
|
Dim SubPAut As DataTable = DtEstatusUsuarios.FiltraParametros(String.Format("CveSubProyecto = {0} AND CveEstatus = {1}", Det.CveSubProyecto, OC.CveEstatus))
|
|
If SubPAut.Rows.Count = 0 Then
|
|
SubProyectosNoAutorizados.Add(String.Format("{0}", Det.SubProyecto))
|
|
TieneError = True
|
|
ElseIf TotalT > 0 AndAlso SubPAut.FiltraParametros(String.Format("((LimiteInferior IS NULL OR LimiteInferior <= {0}) AND (LimiteSuperior IS NULL OR LimiteSuperior >= {0})) ", TotalT)).Rows.Count = 0 Then
|
|
'Segundo Filtrar por Limite Inferior y Superior
|
|
SubProyectosNoAutorizados.Add(String.Format("{0}, {1} - {2} ({3} - {4} Dolares)", Det.SubProyecto, FormatCurrency(SubPAut.Rows(0)("LimiteInferior").ToString.ToDecimal), FormatCurrency(SubPAut.Rows(0)("LimiteSuperior").ToString.ToDecimal), FormatCurrency(SubPAut.Rows(0)("LimiteInferior").ToString.ToDecimal / GlobalTipoCambio(OC.Fecha)), FormatCurrency(SubPAut.Rows(0)("LimiteSuperior").ToString.ToDecimal / GlobalTipoCambio(OC.Fecha))))
|
|
TieneError = True
|
|
End If
|
|
Next
|
|
|
|
If OC.RequiereCotizacion And SubProyectosNoAutorizados.Any Then
|
|
SubProyectosNoAutorizados.Add(String.Format("<br><br>Total de Cotizaciones: {0}", FormatCurrency(TotalT)))
|
|
End If
|
|
|
|
If TieneError Then
|
|
If SubProyectosNoAutorizados.Any Then
|
|
Dim ss As String = ""
|
|
For Each S As String In SubProyectosNoAutorizados
|
|
ss += "<br>- " + S
|
|
Next
|
|
'Alert(String.Format("No está autorizado a modificar el SubProyecto <br>{0}", ss), TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
If Not TieneError Then
|
|
Dim PermisoActual As DataTable
|
|
TieneError = DtDetalle.Any(Function(Dr) Dr.CveSubProyecto = -1)
|
|
|
|
If TieneError Then
|
|
Return TieneError
|
|
End If
|
|
|
|
Dim ObjOC As New ClsOC
|
|
Dim DtEstatusUsuariosClasificaciones As DataTable = Nothing
|
|
If ObjOC.GetEstatusUsuariosClasificaciones(-1, CveUsuario, -1, -1, CveEmpresaActual) Then
|
|
DtEstatusUsuariosClasificaciones = ObjOC.DtResultados
|
|
End If
|
|
ObjOC.Dispose()
|
|
|
|
For Each row As OrdenCompraDetalle In DtDetalle
|
|
'SI TIENE ALGUN PERMISO SE VALIDA, SI NO TIENE NINGUNA ES LIBRE
|
|
If DtEstatusUsuariosClasificaciones IsNot Nothing AndAlso DtEstatusUsuariosClasificaciones.Rows.Count > 0 Then
|
|
PermisoActual = DtEstatusUsuariosClasificaciones.FiltraParametros($"CveClasificacion = {row.CveClasificacion} AND CveSubProyecto = {row.CveSubProyecto} AND CveEstatus = {OC.CveEstatus}")
|
|
If PermisoActual.Rows.Count = 1 Then
|
|
'SI TIENE LIMITE INFERIOR SE VALIDA QUE ESTE EN EL RANGO
|
|
If PermisoActual.Rows(0)("LimiteInferior").ToString.ToDecimal > 0 Then
|
|
If Not row.Importe >= PermisoActual.Rows(0)("LimiteInferior").ToString.ToDecimal Then
|
|
' Alert($"No está autorizado a modificar el SubProyecto {row.DataKey("CveClasificacion")} con la Clasificación {row.DataKey("SubProyecto")}. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
'SI TIENE LIMITE SUPERIOR SE VALIDA QUE ESTE EN EL RANGO
|
|
If PermisoActual.Rows(0)("LimiteSuperior").ToString.ToDecimal > 0 Then
|
|
If Not row.Importe <= PermisoActual.Rows(0)("LimiteSuperior").ToString.ToDecimal Then
|
|
'Alert($"No está autorizado a modificar el SubProyecto {row.DataKey("CveClasificacion")} con la Clasificación {row.DataKey("SubProyecto")}. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
Else
|
|
'Alert($"No está autorizado a modificar el SubProyecto {row.DataKey("SubProyecto")} con la Clasificación {row.DataKey("Clasificacion")}. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
End If
|
|
Return TieneError
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
#Region "B I T A C O R A S"
|
|
<WebMethod()>
|
|
Public Function AddOCBitacora(Cadena As String) As Boolean
|
|
Dim retorno = False
|
|
Dim Estructura = New With
|
|
{
|
|
Key .Descripcion = "",
|
|
Key .Imagen1 = "",
|
|
Key .Extension = "",
|
|
Key .[CveEmpresa] = -1,
|
|
Key .[CveUsuario] = -1,
|
|
Key .CveOC = -1,
|
|
Key .Prioridad = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
Try
|
|
Dim json = Decripta(Cadena)
|
|
Dim Ent = JsonConvert.DeserializeAnonymousType(json, Estructura)
|
|
If IsCurrentDate(Ent.Ticks) Then
|
|
Dim ObjEventoBitacora As New ClsOIEventos
|
|
Dim FileExtension As String = If(IsNothing(Ent.Extension) AndAlso Ent.Imagen1 = "", "", Ent.Extension)
|
|
If ObjEventoBitacora.AddEventoBitacora(Ent.Descripcion, FileExtension, Ent.CveUsuario, Ent.CveEmpresa, CveOC:=Ent.CveOC, Prioridad:=Ent.Prioridad.ToEntero()) Then
|
|
If Ent.Imagen1 <> "" Then
|
|
Try
|
|
Dim FileURL As String = String.Format("{0}Empresas\{1}\OI\", ModExtensiones.DirectorioBaseEmpresas, Ent.CveEmpresa)
|
|
If Not IO.Directory.Exists(FileURL) Then
|
|
IO.Directory.CreateDirectory(FileURL)
|
|
End If
|
|
Dim FileName As String = String.Format("OI{0}{1}", ObjEventoBitacora.CveEvento.ToString, FileExtension)
|
|
Dim bmp1 As Drawing.Image = Ent.Imagen1.Base64ToImage()
|
|
bmp1.Save(String.Format("{0}{1}", FileURL, FileName))
|
|
Catch ex As Exception
|
|
GuardaLog(String.Format("WebService: {0}", ex))
|
|
End Try
|
|
End If
|
|
retorno = True
|
|
End If
|
|
ObjEventoBitacora.Dispose()
|
|
End If
|
|
Catch ex As Exception
|
|
End Try
|
|
Return retorno
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetOCBitacora(params As String) As String
|
|
|
|
Dim retorno = ""
|
|
Try
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[CveUsuario] = -1,
|
|
Key .[CveEmpresa] = -1,
|
|
Key .[CveOC] = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
Dim JsonRequest = Decripta(params)
|
|
Dim Ent = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
If IsCurrentDate(Ent.Ticks) Then
|
|
Dim ObjOI As New ClsOIEventos
|
|
If ObjOI.GetAgendaBitacora(Ent.CveUsuario, Ent.CveEmpresa, CveOC:=Ent.CveOC) Then
|
|
Dim json = ObjOI.DtResultados.FiltraParametros("CveTipoEvento IN (6,2)").ToJson
|
|
retorno = Encripta(json)
|
|
End If
|
|
ObjOI.Dispose()
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrio un error al obtener la bitacora de la oc", ex)
|
|
End Try
|
|
Return retorno
|
|
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetOIBitacora(Cadena As String) As String
|
|
|
|
Dim retorno = "[]"
|
|
Dim Ent As New WsFiltroEvento
|
|
Try
|
|
Ent = JsonConvert.DeserializeObject(Of WsFiltroEvento)(Cadena)
|
|
If notcurrentdate(Ent.Tick) Then
|
|
Ent = Nothing
|
|
End If
|
|
Catch ex As Exception
|
|
Ent = Nothing
|
|
End Try
|
|
If Not IsNothing(Ent) Then
|
|
Dim ObjOI As New ClsOIEventos
|
|
If ObjOI.GetAgendaBitacora(Ent.CveUsuario, Ent.CveEmpresa, Ent.CveActivoFijo, Ent.CveIE, Ent.CveProspecto, Ent.CveCliente, Ent.CveOS,
|
|
Ent.CveOC, Ent.CvePersonal, Ent.CveProveedor, Ent.CveCompra, Ent.CveVenta) Then
|
|
If ObjOI.DtResultados.Rows.Count > 0 Then
|
|
Dim retornoobj = ObjOI.DtResultados.DataTableToObject(Of Modelos.Evento)()
|
|
retorno = JsonConvert.SerializeObject(retornoobj).ToString
|
|
End If
|
|
End If
|
|
ObjOI.Dispose()
|
|
End If
|
|
Return retorno
|
|
|
|
End Function
|
|
|
|
<WebMethod()>
|
|
Public Function GetOI(Cadena As String) As String
|
|
Dim retorno = "[]"
|
|
Dim Ent As New WsFiltroEvento
|
|
Try
|
|
Ent = JsonConvert.DeserializeObject(Of WsFiltroEvento)(Cadena)
|
|
If notcurrentdate(Ent.Tick) Then
|
|
Ent = Nothing
|
|
End If
|
|
Catch ex As Exception
|
|
Ent = Nothing
|
|
End Try
|
|
Ent = New WsFiltroEvento()
|
|
Ent.CveEmpresa = 1
|
|
Ent.CveUsuario = 1360
|
|
Ent.FechaI = Now.AddDays(-180)
|
|
Ent.FechaF = Now
|
|
If Not IsNothing(Ent) Then
|
|
Dim ObjOI As New ClsOIEventos
|
|
If ObjOI.GetRepEventos(-1, 1, -1, "-1", "-1", -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, Ent.CveUsuario, Ent.CveEmpresa, Ent.FechaI, Ent.FechaF) Then
|
|
If ObjOI.DtResultados.Rows.Count > 0 Then
|
|
Dim retornoobj = ObjOI.DtResultados.FiltraParametros(String.Format("CveUsuarioPara = {0} Or CveUsuarioDe = {0}", Ent.CveUsuario)).DataTableToObject(Of Modelos.Evento)()
|
|
retorno = JsonConvert.SerializeObject(retornoobj).ToString
|
|
End If
|
|
End If
|
|
ObjOI.Dispose()
|
|
End If
|
|
Return retorno
|
|
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetOIEstatus(Cadena As String) As String
|
|
Dim retorno = "[]"
|
|
Dim Ent As New Modelos.EventoEstatus
|
|
Try
|
|
Ent = JsonConvert.DeserializeObject(Of Modelos.EventoEstatus)(Cadena)
|
|
If notcurrentdate(Ent.Tick) Then
|
|
Ent = Nothing
|
|
End If
|
|
Catch ex As Exception
|
|
Ent = Nothing
|
|
End Try
|
|
If Not IsNothing(Ent) Then
|
|
Dim ObjOI As New ClsOIEventos
|
|
If ObjOI.GetEstatusEventos(-1) Then
|
|
Dim retornoobj = ObjOI.DtResultados.DataTableToObject(Of Modelos.EventoEstatus)()
|
|
retorno = JsonConvert.SerializeObject(retornoobj).ToString
|
|
End If
|
|
ObjOI.Dispose()
|
|
End If
|
|
Return retorno
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "P R O V E D O R E S"
|
|
<WebMethod()>
|
|
Public Function GetProveedores(CveEmpresa As Integer) As String
|
|
Dim retorno = "[]"
|
|
Try
|
|
retorno = GlobalDTCompProveedores(CveEmpresa).ToJson()
|
|
Catch ex As Exception
|
|
retorno = "[]"
|
|
OnError("Ocurrio un error al obtener proveedores", ex)
|
|
End Try
|
|
Return retorno
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetProveedoresEmpresa(strUsuario As String) As String
|
|
Dim retorno = "[]"
|
|
Dim Ent As New WSUSER
|
|
Try
|
|
Ent = JsonConvert.DeserializeObject(Of WSUSER)(strUsuario)
|
|
Catch ex As Exception
|
|
Ent = Nothing
|
|
End Try
|
|
If Not IsNothing(Ent) Then
|
|
Dim ObjProveedores As New ClsCompProveedores
|
|
If ObjProveedores.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, -1, "-1", "-1", "-1", "-1", "-1", "-1", "-1", 1, Ent.CveEmpresa) Then
|
|
Dim retornoobj = ObjProveedores.DtResultados.DataTableToObject(Of WsProveedor)()
|
|
retorno = JsonConvert.SerializeObject(retornoobj).ToString
|
|
End If
|
|
ObjProveedores.Dispose()
|
|
End If
|
|
Return retorno
|
|
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "P R O D U C T O S - S E R V I C I O S"
|
|
<WebMethod>
|
|
Public Function AddPS(parametros As String) As Boolean
|
|
Dim TieneError As Boolean = False
|
|
'Dim ObjPS As New ClsProductosServicios
|
|
'ObjPS.IniciaTransacSQL()
|
|
'Try
|
|
' Dim Productos As List(Of MProductoServicio) = JsonConvert.DeserializeObject(Of List(Of MProductoServicio))(parametros)
|
|
' For Each PS As MProductoServicio In Productos
|
|
' Dim CvePS As Integer = ObjPS.AddPSApp(PS)
|
|
' If CvePS <= 0 Then
|
|
' TieneError = True
|
|
' Exit For
|
|
' End If
|
|
' Next
|
|
'Catch ex As Exception
|
|
' TieneError = True
|
|
' GuardaLog(ex.ToString())
|
|
'Finally
|
|
' If TieneError Then
|
|
' ObjPS.RollBack()
|
|
' Else
|
|
' ObjPS.Commit()
|
|
' End If
|
|
' ObjPS.Dispose()
|
|
'End Try
|
|
Return Not TieneError
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetPS(CveEmpresa As Integer) As String
|
|
Dim retorno As String = "[]"
|
|
Try
|
|
retorno = JsonConvert.SerializeObject(GlobalDTPS(CveEmpresa), Formatting.Indented)
|
|
|
|
Catch ex As Exception
|
|
OnError("Ocurrió un error al obtener los productos y servicios.", ex)
|
|
End Try
|
|
|
|
Return retorno
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetCategorias(CveEmpresa As Integer) As String
|
|
Dim retorno As String = "[]"
|
|
Try
|
|
retorno = GlobalDTGralCategorias(CveEmpresa).ToJson()
|
|
Catch ex As Exception
|
|
OnError("Ocurrió un error al obtener las categorias.", ex)
|
|
End Try
|
|
|
|
Return retorno
|
|
End Function
|
|
<WebMethod>
|
|
Public Function AddClasificaciones(parametros As String) As Boolean
|
|
Dim TieneError As Boolean = False
|
|
'Dim ObjClasi As New ClsClasificaciones
|
|
'ObjClasi.IniciaTransacSQL()
|
|
'Try
|
|
' Dim Clasificaciones As List(Of MClasificacion) = JsonConvert.DeserializeObject(Of List(Of MClasificacion))(parametros)
|
|
' For Each Clasi As MClasificacion In Clasificaciones
|
|
' If Not ObjClasi.AddClasificacionesApp(Clasi) Then
|
|
' TieneError = True
|
|
' Exit For
|
|
' End If
|
|
' Next
|
|
'Catch ex As Exception
|
|
' TieneError = True
|
|
' GuardaLog(ex.ToString())
|
|
'Finally
|
|
' If TieneError Then
|
|
' ObjClasi.RollBack()
|
|
' Else
|
|
' ObjClasi.Commit()
|
|
' End If
|
|
' ObjClasi.Dispose()
|
|
'End Try
|
|
Return Not TieneError
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetRepPS(params As String) As String
|
|
Dim retorno As String = "[]"
|
|
Dim Estructura = New With
|
|
{
|
|
.CveTipoPS = -1,
|
|
.Codigo = "",
|
|
.Nombre = "",
|
|
.AplicaParaVenta = -1,
|
|
.CveClasificacion = -1,
|
|
.Estado = -1,
|
|
.CveEmpresa = -1,
|
|
.Ticks = ""
|
|
}
|
|
Try
|
|
Dim JsonRequest = Decripta(params)
|
|
Dim Ent = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
If IsCurrentDate(Ent.Ticks) Then
|
|
|
|
Dim ObjPS As New ClsProductosServicios
|
|
If ObjPS.GetPS(-1, Ent.CveClasificacion, Ent.CveEmpresa, Codigo:=Ent.Codigo, PS:=Ent.Nombre, pEstado:=Ent.Estado, CveTipoPS:=Ent.CveTipoPS, pAplicaParaVenta:=Ent.AplicaParaVenta) Then
|
|
retorno = ObjPS.DtResultados.ToJson
|
|
End If
|
|
ObjPS.Dispose()
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrio un error al obtener los ps.", ex)
|
|
End Try
|
|
|
|
Return retorno
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetClasificaciones(params As String) As String
|
|
Dim retorno As String = "[]"
|
|
Dim Estructura = New With
|
|
{
|
|
.CveEmpresa = -1,
|
|
.Ticks = ""
|
|
}
|
|
Try
|
|
Dim JsonRequest = Decripta(params)
|
|
Dim Ent = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
If IsCurrentDate(Ent.Ticks) Then
|
|
Dim ObjClasificaciones As New ClsClasificaciones
|
|
If ObjClasificaciones.GetClasificaciones(Ent.CveEmpresa) Then
|
|
retorno = ObjClasificaciones.DtResultados.FiltraParametros($"Codigo IS NULL OR Codigo = ''").ToJson()
|
|
End If
|
|
ObjClasificaciones.Dispose()
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrio un error al obtener los ps.", ex)
|
|
End Try
|
|
|
|
Return retorno
|
|
End Function
|
|
|
|
<WebMethod()>
|
|
Public Function GetPSEquivalencias(PS As String) As String
|
|
|
|
Dim retorno = "[]"
|
|
Dim Ent As New OrdenCompraDetalle
|
|
Try
|
|
Ent = JsonConvert.DeserializeObject(Of Modelos.OrdenCompraDetalle)(PS)
|
|
Catch ex As Exception
|
|
Ent = Nothing
|
|
End Try
|
|
If Not IsNothing(Ent) Then
|
|
Dim ObjPS As New ClsProductosServicios
|
|
If ObjPS.GetPSEquivalencias(Ent.CvePS, -1) Then
|
|
Dim retornoobj = ObjPS.DtResultados.DataTableToObject(Of WsUnidadMedida)()
|
|
retorno = JsonConvert.SerializeObject(retornoobj).ToString
|
|
End If
|
|
ObjPS.Dispose()
|
|
End If
|
|
Return retorno
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetUM(CveEmpresa As Integer) As String
|
|
Return GlobalDTUnidadesMedida(CveEmpresa).ToJson
|
|
End Function
|
|
|
|
|
|
#End Region
|
|
#Region "V E N T A S"
|
|
<WebMethod()>
|
|
Public Function GetRepVentas(CveEmpresa As Integer, FechaI As String, FechaF As String, Gpo As Integer, CveUsuarioConsulta As Integer, TipoCambio As Integer, CveSubProyecto As Integer, CveCliente As Integer) As String
|
|
Dim retorno = "[]"
|
|
Dim FechaIEjec = If(IsDate(FechaI), FechaI.ToDate, MinFecha)
|
|
Dim FechaFEjec = If(IsDate(FechaF), FechaF.ToDate, MaxFecha)
|
|
Using ObjVentas As New ClsVentas
|
|
If ObjVentas.GetRepVentas(FechaI.ToDate, FechaF.ToDate, FechaIEjec, FechaFEjec, CveCliente, CveSubProyecto, "-1", -1, "-1", "-1", CveEmpresa, Gpo, CveUsuarioConsulta:=CveUsuarioConsulta) Then
|
|
retorno = ObjVentas.DtResultados.ToJson()
|
|
End If
|
|
End Using
|
|
Return retorno
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetRepCxC(CveEmpresa As Integer, FechaI As String, FechaF As String, FechaCorte As String, Gpo As Integer, CveUsuarioConsulta As Integer, TipoCambio As Integer, CveSubProyecto As Integer, CveCliente As Integer) As String
|
|
Dim retorno = "[]"
|
|
Using ObjVentas As New ClsMovimientos
|
|
If ObjVentas.GetCxC(FechaI, FechaF, CveCliente, CveSubProyecto, -1, -1, -1, "-1", CveEmpresa, Gpo, -1, TipoCambio, FechaVI:="-1", FechaVF:="-1", CveUsuarioConsulta:=CveUsuarioConsulta, FechaCorte:=FechaCorte.ToDate) Then
|
|
retorno = ObjVentas.DtResultados.ToJson()
|
|
End If
|
|
End Using
|
|
Return retorno
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetRepCxP(CveEmpresa As Integer, FechaI As String, FechaF As String, FechaCorte As String, Gpo As Integer, CveUsuarioConsulta As Integer, TipoCambio As Integer, CveSubProyecto As Integer) As String
|
|
Dim retorno = "[]"
|
|
Using ObjVentas As New ClsMovimientos
|
|
If ObjVentas.GetCxP(FechaI, FechaF, -1, CveSubProyecto, -1, -1, -1, -1, -1, CveEmpresa, Gpo, -1, TipoCambio, FechaVI:="-1", FechaVF:="-1", CveUsuarioConsulta:=CveUsuarioConsulta) Then
|
|
retorno = ObjVentas.DtResultados.ToJson()
|
|
End If
|
|
End Using
|
|
Return retorno
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetRepRecuperacion(CveEmpresa As Integer, FechaI As String, FechaF As String, Gpo As Integer, CveUsuarioConsulta As Integer, CveSubProyecto As Integer, CveCliente As Integer) As String
|
|
Dim retorno = "[]"
|
|
Using ObjVentas As New ClsMovimientos
|
|
If ObjVentas.GetRepRecuperacion(FechaI.ToDateTime(), FechaF.ToDateTime(), CveCliente, CveSubProyecto, -1, -1, -1, "-1", CveEmpresa, Gpo, -1, CveUsuarioConsulta:=CveUsuarioConsulta) Then
|
|
retorno = ObjVentas.DtResultados.ToJson()
|
|
End If
|
|
End Using
|
|
Return retorno
|
|
End Function
|
|
|
|
|
|
<WebMethod()>
|
|
Public Function GetVenta(CveVenta As Integer, CveEmpresa As Integer) As String
|
|
Dim retorno = "[]"
|
|
Using ObjVentas As New ClsVentas
|
|
If ObjVentas.GetVenta(CveVenta, CveEmpresa) Then
|
|
retorno = ObjVentas.DtResultados.ToJson()
|
|
End If
|
|
End Using
|
|
Return retorno
|
|
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
|
|
Else
|
|
End If
|
|
ObjEmpresa.Dispose()
|
|
End Sub
|
|
<WebMethod>
|
|
Public Function AddVentas(TipoDocto As String, CveCliente As Integer, CveSubProyecto As Integer, CveUsuario As Integer, SubTotal As Double, IVA As Double, CveMoneda As Integer, Observaciones As String, Productos As String) As String
|
|
Dim Retorno = New Modelos.Factura.MMensajeFactura()
|
|
Try
|
|
Dim ObjUsuarios As New ClsSisUsuarios()
|
|
Dim UsuarioActual As Usuario = Nothing
|
|
If ObjUsuarios.GetUsuarios(CveUsuario) Then
|
|
Dim Usuario = ObjUsuarios.DtResultados.Rows(0)("Usuario").ToString()
|
|
Dim Contrasenia = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString()
|
|
|
|
If ObjUsuarios.DtResultados.Rows.Count = 1 Then
|
|
UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, IMEI)
|
|
CreaObjetoEmpresa(UsuarioActual)
|
|
End If
|
|
End If
|
|
ObjUsuarios.Dispose()
|
|
|
|
If UsuarioActual IsNot Nothing Then
|
|
Dim ListaPS As List(Of MVentaProductos) = Nothing
|
|
If Not String.IsNullOrEmpty(Productos) Then
|
|
ListaPS = JsonConvert.DeserializeObject(Of List(Of MVentaProductos))(Productos)
|
|
End If
|
|
If ListaPS IsNot Nothing Then
|
|
Dim Factura As Modelos.Factura = CreaFactura(TipoDocto, SubTotal, IVA, CveCliente, CveSubProyecto, 1, UsuarioActual, ListaPS)
|
|
If Factura IsNot Nothing Then
|
|
Retorno = Factura.EmitirFactura()
|
|
Else
|
|
Retorno.Mensajes.Add("No se pudo generar la factura")
|
|
End If
|
|
Else
|
|
Retorno.Mensajes.Add("No se pudo procesar los productos")
|
|
End If
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
Retorno.Mensajes.Add(ex.ToString())
|
|
End Try
|
|
|
|
Return JsonConvert.SerializeObject(Retorno)
|
|
End Function
|
|
#Region "F A C T U R A C I O N"
|
|
Private Function CreaFactura(TipoDocto As String, SubTotal As Double, IVA As Double, CveCliente As Integer, CveSubProyecto As Integer, CveMoneda As Integer, UsuarioActual As Usuario, ListaPS As List(Of MVentaProductos)) As Modelos.Factura
|
|
If CveSubProyecto <= 0 Then
|
|
'SE ASIGNA EL SUBPROYECTO MATRIZ, EN CASO DE NO ENCONTRARSE SE LE ASIGNA CUALQUIERA
|
|
Dim Dr As DataRow = Nothing
|
|
If GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("TipoSucursal = 1").Rows.Count > 0 Then
|
|
Dr = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("TipoSucursal = 1").Rows(0)
|
|
ElseIf GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).Rows.Count > 0 Then
|
|
Dr = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).Rows(0)
|
|
End If
|
|
|
|
If Dr IsNot Nothing Then
|
|
CveSubProyecto = Dr("CveSubProyecto").ToString.ToEntero()
|
|
End If
|
|
|
|
If CveSubProyecto < 0 Then
|
|
Alert("No se tienen asignadas sucursales", TipoMensaje.MsgError)
|
|
Return Nothing
|
|
End If
|
|
End If
|
|
Dim ObjFactura = New Modelos.Factura(UsuarioActual)
|
|
ObjFactura.DirectorioServidor = ModExtensiones.DirectorioBaseEmpresas
|
|
|
|
Dim ObjFolios As New ClsGralFolios()
|
|
If ObjFolios.GetFolios(TipoDocto, UsuarioActual.CveEmpresa) Then
|
|
Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format("CveSubProyecto = {0} And Estado = 'Activo'", CveSubProyecto))
|
|
If DT.Rows.Count > 0 Then
|
|
ObjFactura.Folio = DT.Rows(0)("FActual").ToString()
|
|
ObjFactura.Serie = DT.Rows(0)("Serie").ToString()
|
|
End If
|
|
DT.Dispose()
|
|
End If
|
|
ObjFolios.Dispose()
|
|
|
|
If Not String.IsNullOrEmpty(ObjFactura.Folio) Then
|
|
|
|
Select Case CveMoneda
|
|
Case 1
|
|
ObjFactura.TipoCambio = "1"
|
|
Case 2
|
|
ObjFactura.TipoCambio = GlobalTipoCambio(Now).ToString
|
|
Case Else
|
|
ObjFactura.TipoCambio = GlobalTipoCambio(Now).ToString
|
|
End Select
|
|
ObjFactura.CveVendedor = -1
|
|
|
|
'VALIDA PROMOCIONES Y EXISTENCIAS
|
|
Dim ObjVentas As New ClsVentas
|
|
If ObjVentas.GetPromocionesPS(-1, Now, CveSubProyecto, CveCliente, ObjFactura.CveVendedor, 1, UsuarioActual.CveEmpresa) Then
|
|
ObjFactura.DtPromociones = ObjVentas.DtResultados
|
|
End If
|
|
ObjVentas.Dispose()
|
|
|
|
Dim TipoDocumento As String = ""
|
|
Select Case TipoDocto
|
|
Case "Ing"
|
|
TipoDocumento = "Ingresos"
|
|
Case "Pd2"
|
|
TipoDocumento = "Pedido"
|
|
Case "Rem"
|
|
TipoDocumento = "Remisión"
|
|
End Select
|
|
|
|
ObjFactura.TipoMensajeRespuesta = TipoMensajeRespuesta.TextoLimpio
|
|
ObjFactura.Version = "3.3"
|
|
ObjFactura.CveUsuario = UsuarioActual.CveUsuario
|
|
ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa
|
|
ObjFactura.TipoCambio = 0
|
|
ObjFactura.ConvertirPesos = False
|
|
ObjFactura.CveMoneda = CveMoneda
|
|
ObjFactura.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {CveMoneda} ")
|
|
ObjFactura.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", "CveMoneda = 1")
|
|
ObjFactura.TipoDocto = TipoDocto
|
|
ObjFactura.RefDocto = ""
|
|
ObjFactura.CveMesa = -1
|
|
ObjFactura.Fecha = Now
|
|
ObjFactura.CvePrePoliza = -1
|
|
ObjFactura.FechaPago = Now
|
|
ObjFactura.MotivoDescuento = ""
|
|
ObjFactura.Observaciones = ""
|
|
ObjFactura.FechaEjecucion = Now
|
|
ObjFactura.UsuarioCreo = UsuarioActual.Usuario
|
|
ObjFactura.CveCondicionEntrega = -1
|
|
ObjFactura.CondicionEntrega = ""
|
|
ObjFactura.NumeroCuenta = ""
|
|
ObjFactura.CondicionesPago = 0
|
|
ObjFactura.FormaPago = 0
|
|
ObjFactura.PedidoContrato = ""
|
|
ObjFactura.NumeroContrato = ""
|
|
ObjFactura.DescripcionContrato = ""
|
|
ObjFactura.CveCorte = -1
|
|
ObjFactura.TipoDocumento = TipoDocumento
|
|
ObjFactura.Alfa1 = ""
|
|
ObjFactura.Alfa2 = ""
|
|
ObjFactura.Alfa3 = ""
|
|
ObjFactura.Descuento = 0
|
|
ObjFactura.Amortizacion = 0
|
|
ObjFactura.CveContrato = 0
|
|
ObjFactura.CveSubProyecto = CveSubProyecto
|
|
ObjFactura.CveSubProyectoCobranza = CveSubProyecto
|
|
ObjFactura.CveSubProyectoEjecucion = CveSubProyecto
|
|
ObjFactura.SubProyecto = New SubProyectoModel(GlobalDTSubProyectos(-1).FiltroPrimero($"CveSubProyecto = {CveSubProyecto}"))
|
|
ObjFactura.SubProyectoMatriz = New SubProyectoModel(GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1"))
|
|
'DETALLES
|
|
ObjFactura.DtDetalle = CreaDTDetalle(UsuarioActual.CveEmpresa, CveSubProyecto, ListaPS)
|
|
ObjFactura.SubTotal = SubTotal
|
|
ObjFactura.Descuento = 0
|
|
ObjFactura.Amortizacion = 0
|
|
ObjFactura.IVA = IVA
|
|
ObjFactura.RetIVA = 0
|
|
ObjFactura.RetISR = 0
|
|
ObjFactura.IEPS = 0
|
|
ObjFactura.Total = SubTotal + IVA
|
|
'CLIENTE
|
|
ObjFactura.CveCliente = CveCliente
|
|
ObjFactura.SetCliente()
|
|
|
|
Dim ObjCliente As New ClsClientes
|
|
If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=-1) Then
|
|
If ObjCliente.DtResultados.Rows.Count > 0 Then
|
|
ObjFactura.CveFormaPago33 = ObjCliente.CveFormaPago33
|
|
ObjFactura.FormaPago33 = GlobalDTVtaFormaPago.FiltroPrimeroValor("FormaPago", $"CveFormaPago = {ObjCliente.CveFormaPago33}")
|
|
ObjFactura.FormaPagoSAT33 = GlobalDTVtaFormaPago.FiltroPrimeroValor("ClaveFormaPagoSAT", $"CveFormaPago = {ObjCliente.CveFormaPago33}")
|
|
|
|
ObjFactura.CveMetodoPago33 = ObjCliente.CveMetodoPago33
|
|
ObjFactura.MetodoPago33 = GlobalDTVtaMetodoPago.FiltroPrimeroValor("MetodoPago", $"CveMetodoPago = {ObjCliente.CveMetodoPago33}")
|
|
ObjFactura.ClaveMetodoPagoSAT = GlobalDTVtaMetodoPago.FiltroPrimeroValor("ClaveMetodoPagoSAT", $"CveMetodoPago = {ObjCliente.CveMetodoPago33}")
|
|
|
|
ObjFactura.CveUsoCFDI = ObjCliente.CveUsoCFDI
|
|
ObjFactura.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("Descripcion", $"CveUsoCFDI = {ObjCliente.CveUsoCFDI}")
|
|
ObjFactura.ClaveUsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", $"CveUsoCFDI = {ObjCliente.CveUsoCFDI}")
|
|
|
|
'ObjFactura.CveMetodoPago = ObjCliente.CveMetodoPago
|
|
'If GlobalDTMetodosPago.FiltraParametros($"CveMetodoPago = {ObjCliente.CveMetodoPago}").Rows.Count > 0 Then
|
|
' ObjFactura.MetodoPago = GlobalDTMetodosPago.FiltraParametros($"CveMetodoPago = {ObjCliente.CveMetodoPago}").Rows(0)("MetodoPago").ToString
|
|
'Else
|
|
' ObjFactura.CveMetodoPago = 1
|
|
' ObjFactura.MetodoPago = "Efectivo"
|
|
'End If
|
|
|
|
ObjFactura.CveClienteSucursal = -1
|
|
End If
|
|
End If
|
|
ObjCliente.Dispose()
|
|
|
|
ObjFactura.Timbre = PreParaTimbre(ObjFactura)
|
|
ObjFactura.CveContratoSecciones = ""
|
|
|
|
Return ObjFactura
|
|
Else
|
|
Return Nothing
|
|
End If
|
|
End Function
|
|
|
|
Private Function CreaDTDetalle(CveEmpresa As Integer, CveSubProyecto As Integer, ListaPS As List(Of MVentaProductos)) As DataTable
|
|
Dim TmpDT = New DataTable
|
|
TmpDT.Columns.Add("CveVenta", GetType(Integer))
|
|
TmpDT.Columns.Add("Consec", GetType(Integer))
|
|
TmpDT.Columns.Add("Cantidad", GetType(Decimal))
|
|
TmpDT.Columns.Add("Codigo", GetType(String))
|
|
TmpDT.Columns.Add("CveUM", GetType(Integer))
|
|
TmpDT.Columns.Add("UM", GetType(String))
|
|
TmpDT.Columns.Add("SATClaveUM", GetType(String))
|
|
TmpDT.Columns.Add("CveClasificacion", GetType(Integer))
|
|
TmpDT.Columns.Add("Clasificacion", GetType(String))
|
|
TmpDT.Columns.Add("CvePS", GetType(Integer))
|
|
TmpDT.Columns.Add("PS", GetType(String))
|
|
TmpDT.Columns.Add("CodigoPS", GetType(String))
|
|
TmpDT.Columns.Add("SATClaveProdServ", GetType(String))
|
|
TmpDT.Columns.Add("NoIdentificacion", GetType(String))
|
|
TmpDT.Columns.Add("CveTipoPS", GetType(Integer))
|
|
TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer))
|
|
TmpDT.Columns.Add("SerieLote", GetType(String))
|
|
TmpDT.Columns.Add("CuentaPredial", GetType(String))
|
|
TmpDT.Columns.Add("Obs", GetType(String))
|
|
TmpDT.Columns.Add("TiempoEntrega", GetType(String))
|
|
TmpDT.Columns.Add("PU", GetType(Decimal))
|
|
TmpDT.Columns.Add("IVA", GetType(Decimal))
|
|
TmpDT.Columns.Add("ImporteIVA", GetType(Decimal))
|
|
TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal))
|
|
TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal))
|
|
TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal))
|
|
TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal))
|
|
TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal))
|
|
TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal))
|
|
TmpDT.Columns.Add("IEPS", GetType(Decimal))
|
|
TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal))
|
|
TmpDT.Columns.Add("Descuento", GetType(Decimal))
|
|
TmpDT.Columns.Add("TipoDescuento", GetType(Integer))
|
|
TmpDT.Columns.Add("TotalImporte", GetType(Decimal))
|
|
TmpDT.Columns.Add("Total", GetType(Decimal))
|
|
'Para uso del módulo contable
|
|
TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer))
|
|
TmpDT.Columns.Add("IdCtaContVentas", GetType(Integer))
|
|
TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean))
|
|
TmpDT.Columns.Add("CveProyecto", GetType(Integer))
|
|
TmpDT.Columns.Add("Proyecto", GetType(String))
|
|
TmpDT.Columns.Add("CveSubProyecto", GetType(Integer))
|
|
TmpDT.Columns.Add("SubProyecto", GetType(String))
|
|
'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto
|
|
TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer))
|
|
TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer))
|
|
'Contratos
|
|
TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer))
|
|
'Remisiones a Facturas
|
|
TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer))
|
|
TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer))
|
|
TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer))
|
|
|
|
'Pedido2 a Facturas
|
|
TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer))
|
|
|
|
TmpDT.Columns.Add("Origen", GetType(Integer))
|
|
'Ordenes Servicio
|
|
TmpDT.Columns.Add("CveOS", GetType(Integer))
|
|
TmpDT.Columns.Add("CveOSDetalle", GetType(Integer))
|
|
TmpDT.Columns.Add("SeFacturara", GetType(Integer))
|
|
TmpDT.Columns.Add("Folio", GetType(Integer))
|
|
TmpDT.Columns.Add("Estatus", GetType(String))
|
|
'Ordenamiento
|
|
TmpDT.Columns.Add("Orden", GetType(Integer))
|
|
TmpDT.Columns.Add("TipoDocto", GetType(String))
|
|
'OC
|
|
TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer))
|
|
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
|
|
|
|
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
|
|
TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal))
|
|
TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal))
|
|
TmpDT.Columns.Add("CantidadInventario", GetType(Decimal))
|
|
|
|
TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String))
|
|
TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String))
|
|
TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String))
|
|
TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String))
|
|
|
|
For Each PS In ListaPS
|
|
Dim Row As DataRow = AgregarProductoServicioRem(TmpDT, PS, CveEmpresa, CveSubProyecto)
|
|
If Row IsNot Nothing Then
|
|
TmpDT.Rows.Add(Row)
|
|
End If
|
|
Next
|
|
|
|
Return TmpDT
|
|
End Function
|
|
Private Function AgregarProductoServicioRem(TmpDT As DataTable, PS As MVentaProductos, CveEmpresa As Integer, CveSubProyecto As Integer,
|
|
Optional Serie As String = "", Optional TiempoEntrega As String = "", Optional EntregaDirecta As Integer = 0,
|
|
Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0,
|
|
Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0,
|
|
Optional CuentaPredial As String = "", Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0) As DataRow
|
|
|
|
|
|
Dim Row As DataRow = Nothing
|
|
Dim TotalCalculableImpuestos As Decimal = 0
|
|
PS.Precio = Math.Round(PS.Precio, 6) ' el precio unitario puede llevar hasta 6 decimales permitidos
|
|
|
|
Dim DrPS As DataRow = Nothing
|
|
|
|
DrPS = GlobalDTPS(CveEmpresa, CvePS:=PS.CvePS).FiltroPrimero("") ' Estado = -1
|
|
|
|
If DrPS Is Nothing Then
|
|
Alert("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Return Nothing
|
|
End If
|
|
|
|
'verifica si tiene ventaminima
|
|
If PS.Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDecimal > 0 Then
|
|
'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15...
|
|
If PS.Cantidad Mod DrPS("VentaMinima").ToString.ToDecimal <> 0 Then
|
|
Return Nothing
|
|
End If
|
|
End If
|
|
|
|
Dim DrSubProyecto As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto).Rows(0)
|
|
|
|
Row = TmpDT.NewRow()
|
|
Row("CveProyecto") = DrSubProyecto("CveProyecto").ToString().ToEntero()
|
|
Row("Proyecto") = DrSubProyecto("Proyecto").ToString()
|
|
Row("CveSubProyecto") = CveSubProyecto
|
|
Row("SubProyecto") = DrSubProyecto("SubProyecto").ToString()
|
|
Row("Serie") = Serie
|
|
Row("TiempoEntrega") = TiempoEntrega
|
|
Row("Orden") = TmpDT.Rows.Count + 1
|
|
Row("Cantidad") = PS.Cantidad
|
|
Row("CveUM") = DrPS("CveUnidadMedida").ToString().ToEntero()
|
|
Row("UM") = DrPS("UnidadMedida").ToString()
|
|
Row("CveClasificacion") = DrPS("CveClasificacion").ToString().ToEntero()
|
|
Row("Clasificacion") = DrPS("Clasificacion").ToString()
|
|
Row("CvePS") = PS.CvePS
|
|
Row("Obs") = PS.Obs
|
|
|
|
TotalCalculableImpuestos = (PS.Cantidad * (PS.Precio)) - PS.Descuento
|
|
|
|
Row("PU") = PS.Precio
|
|
Row("Codigo") = DrPS("Codigo")
|
|
Row("NoIdentificacion") = DrPS("Codigo")
|
|
Row("ClaveSATFraccionArancelaria") = DrPS("ClaveSATFraccionArancelaria")
|
|
Row("ClaveSATUnidadAduana") = DrPS("ClaveSATUnidadAduana")
|
|
Row("ClaveSATFraccionArancelariaDescripcion") = DrPS("ClaveSATFraccionArancelariaDescripcion")
|
|
Row("ClaveSATUnidadAduanaDescripcion") = DrPS("ClaveSATUnidadAduanaDescripcion")
|
|
|
|
Row("PS") = DrPS("PS")
|
|
Row("CodigoPS") = DrPS("PSCodigo").ToString
|
|
Row("CveTipoPS") = DrPS("CveTipoPS")
|
|
Row("CveTipoInvPS") = DrPS("Inv_CveMetodoInventario")
|
|
|
|
If DrPS("IVA").ToString.Contiene("-1", "") Then
|
|
'Row("PorcentajeIVA") = SubProyectoPorcentajeIVA
|
|
Else
|
|
Row("PorcentajeIVA") = DrPS("IVA")
|
|
End If
|
|
|
|
Row("IVA") = Row("PorcentajeIVA")
|
|
Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, 2)
|
|
|
|
Row("Total") = (PS.Cantidad * PS.Precio).Value
|
|
Row("TotalImporte") = Math.Round(PS.Cantidad.Value * PS.Precio, 2)
|
|
|
|
Row("SATClaveProdServ") = DrPS("SATClavePS")
|
|
Row("SATClaveUM") = DrPS("SATClaveUnidadMedida")
|
|
|
|
Row("EntregaDirecta") = EntregaDirecta
|
|
'Contratos
|
|
Row("CveContratoDetalle") = CveContratoDetalle
|
|
Row("CveVentaDetalle") = CveVentaDetalle
|
|
Row("CveMovimientoDetallePedido") = CveVentaDetalle
|
|
Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle
|
|
Row("CveVentaDetalleRemision") = CveVentaDetalleRemision
|
|
Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion
|
|
Row("CveVentaDetallePedido2") = CveVentaDetallePedido2
|
|
Row("CuentaPredial") = CuentaPredial
|
|
|
|
Return Row
|
|
End Function
|
|
Private Function PreParaTimbre(Obj As Modelos.Factura) As CFDITimbre
|
|
Dim Timbre As New CFDITimbre
|
|
Timbre.Comprobante.TipoComprobante = If(Obj.TipoDocto.Contiene("Ing", "Ant"), "I", If(Obj.TipoDocto.Contiene("Egs", "Dev"), "E", ""))
|
|
Timbre.Comprobante.Folio = Obj.Folio.ToString
|
|
Timbre.Comprobante.Serie = Obj.Serie
|
|
Timbre.Comprobante.Fecha = Obj.Fecha
|
|
Timbre.Comprobante.FormadePago = Obj.FormaPagoSAT33
|
|
Timbre.Comprobante.CondicionesdePago = Obj.FormaPago33
|
|
Timbre.Comprobante.MetodoPago = Obj.ClaveMetodoPagoSAT
|
|
Timbre.Comprobante.Subtotal = Obj.SubTotal
|
|
Timbre.Comprobante.Descuentos = Obj.Descuento
|
|
Timbre.Comprobante.Moneda = Obj.MonedaSAT
|
|
Timbre.Comprobante.TipoCambio = If(Obj.CveMoneda = 1, "1", Obj.TipoCambio.ToString)
|
|
Timbre.Comprobante.Total = Obj.Total
|
|
|
|
Timbre.Comprobante.LugarExpedicion = Obj.SubProyecto.CP
|
|
Timbre.Comprobante.Confirmacion = ""
|
|
|
|
Timbre.Receptor.RFC = Obj.Cliente.RFC
|
|
Timbre.Receptor.Nombre = Obj.Cliente.Nombre
|
|
Timbre.Receptor.ResidenciaFiscal = ""
|
|
Timbre.Receptor.NumeroRegistroTributario = ""
|
|
Timbre.Receptor.UsoCFDI = Obj.ClaveUsoCFDI
|
|
|
|
|
|
If Obj.CveTipoRelacion > 0 Then
|
|
Select Case Obj.CveTipoRelacion
|
|
Case 1
|
|
Timbre.CFDIRelacionados.TipoRelacion = "01"
|
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "01-Nota de Crédito aplicada a Ingreso"
|
|
Case 2
|
|
Timbre.CFDIRelacionados.TipoRelacion = "02"
|
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "02-Nota de débito de los documentos relacionados"
|
|
Case 3
|
|
Timbre.CFDIRelacionados.TipoRelacion = "03"
|
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "03-Devolución aplicada a Ingreso"
|
|
Case 4
|
|
Timbre.CFDIRelacionados.TipoRelacion = "04"
|
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "04-Refacturación de Ingreso"
|
|
Case 7
|
|
Timbre.CFDIRelacionados.TipoRelacion = "07"
|
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo"
|
|
Case 8
|
|
Timbre.CFDIRelacionados.TipoRelacion = "08"
|
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "08-Factura generada por pagos en parcialidades "
|
|
Case 9
|
|
Timbre.CFDIRelacionados.TipoRelacion = "09"
|
|
Timbre.CFDIRelacionados.TipoRelacionTexto = "09-Factura generada por pagos diferidos"
|
|
|
|
End Select
|
|
|
|
End If
|
|
|
|
|
|
Dim totSubTotal As Decimal = Obj.SubTotal
|
|
Dim totIVA As Decimal = Obj.IVA
|
|
Dim totRetIVA As Decimal = Obj.RetIVA
|
|
Dim totRetISR As Decimal = Obj.RetISR
|
|
Dim i As Integer = 1
|
|
|
|
'DETALLES
|
|
Dim tPS As String = ""
|
|
|
|
For Each drr As DataRow In Obj.DtDetalle.Rows
|
|
If drr("PS").ToString.Length = 1 Then
|
|
tPS = drr("Obs").ToString
|
|
Else
|
|
If drr("PS").ToString.Length = 0 Then
|
|
tPS = ""
|
|
Else
|
|
tPS = String.Format("{0} {1}", drr("PS"), drr("Obs"))
|
|
End If
|
|
End If
|
|
|
|
'CONDICIONANTE, ESPECIAL
|
|
If Obj.CveEmpresa = 15 Then drr("UM") = "" 'LES COMENTAN QUE NO DEBE IR LA ETIQUETA DE LA UNIDAD EN EL PRODUCTO
|
|
|
|
Dim concepto As New CFDIConceptos With {.Cantidad = drr("Cantidad").ToString.ToDecimal,
|
|
.Descripcion = tPS,
|
|
.ValorUnitario = drr("PU").ToString.ToDecimal,
|
|
.Importe = drr("TotalImporte").ToString.ToDecimal,
|
|
.Descuento = drr("Descuento").ToString.ToDecimal,
|
|
.Unidad = drr("UM").ToString,
|
|
.ClaveUnidad = drr("SATClaveUM").ToString,
|
|
.ClaveProdServ = drr("SATClaveProdServ").ToString,
|
|
.Noidentificacion = drr("Noidentificacion").ToString,
|
|
.CuentaPredial = drr("CuentaPredial").ToString}
|
|
'VERIFICA SUMA SUBTOTALES
|
|
If i = Obj.DtDetalle.Rows.Count AndAlso totSubTotal <> concepto.Importe Then 'PROCESO DE AJUSTA DE DECIMALES
|
|
concepto.Importe = totSubTotal
|
|
End If
|
|
totSubTotal = totSubTotal - concepto.Importe
|
|
|
|
'SIEMPRE ESTAMOS AGREGANDO EL IVA
|
|
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteIVA").ToString.ToDecimal})
|
|
|
|
If drr("ImporteIEPS").ToString.ToDouble > 0 Then
|
|
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIEPS").ToString.ToDecimal, .Impuesto = "003", .Importe = drr("ImporteIEPS").ToString.ToDecimal})
|
|
End If
|
|
|
|
If drr("ImporteRetIVA").ToString.ToDouble > 0 Then 'si hay retenciones
|
|
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeRetIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteRetIVA").ToString.ToDecimal})
|
|
End If
|
|
|
|
If drr("ImporteRetISR").ToString.ToDouble > 0 Then 'retención de ISR
|
|
concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "R", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeRetISR").ToString.ToDecimal, .Impuesto = "001", .Importe = drr("ImporteRetISR").ToString.ToDecimal})
|
|
End If
|
|
|
|
Timbre.Conceptos.Add(concepto)
|
|
i += 1
|
|
Next
|
|
Return Timbre
|
|
End Function
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
#Region "O R D E N E S C O M P R A"
|
|
<WebMethod()>
|
|
Public Function GetOCEstatus(Cadena As String) As String
|
|
Dim Salida As String = ""
|
|
Try
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[Tipo] = "",
|
|
Key .[CveEmpresa] = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
Dim JsonRequest = Decripta(Cadena)
|
|
Dim Entrada = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
|
|
If IsCurrentDate(Entrada.Ticks) Then
|
|
Dim jsonRetorno = GlobalDTOCEstatus(Entrada.CveEmpresa).FiltraParametros(String.Format(" (Tipo = '{0}' OR '{0}' = '-1')", Entrada.Tipo)).ToJson
|
|
Salida = Encripta(jsonRetorno)
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrio un error al obtener los estatus de oc.", ex)
|
|
End Try
|
|
Return Salida
|
|
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetOCEstatusFinal(Cadena As String) As String
|
|
Dim Salida As String = ""
|
|
Try
|
|
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[Tipo] = "",
|
|
Key .[CveEstatus] = -1,
|
|
Key .[CveEmpresa] = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
Dim JsonRequest = Decripta(Cadena)
|
|
|
|
Dim Ent = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
If IsCurrentDate(Ent.Ticks) Then
|
|
Dim Tipo As String = Ent.Tipo
|
|
If Ent.Tipo.Equals("REQ", StringComparison.InvariantCultureIgnoreCase) Then
|
|
Tipo = "Req"
|
|
End If
|
|
Dim CveEstatusInicial, CveEstatusFinalOK, CveEstatusFinalError As Integer
|
|
Dim drInicial As DataRow = If(GlobalDTOCEstatus(Ent.CveEmpresa).FiltraParametros(String.Format("TipoTermino = 3 AND Tipo = '{0}'", Tipo)).Rows.Count = 1, GlobalDTOCEstatus(Ent.CveEmpresa).FiltraParametros(String.Format("TipoTermino = 3 AND Tipo = '{0}'", Tipo)).Rows(0), Nothing)
|
|
Dim drFinalOK As DataRow = If(GlobalDTOCEstatus(Ent.CveEmpresa).FiltraParametros(String.Format("TipoTermino = 1 AND Tipo = '{0}'", Tipo)).Rows.Count = 1, GlobalDTOCEstatus(Ent.CveEmpresa).FiltraParametros(String.Format("TipoTermino = 1 AND Tipo = '{0}'", Tipo)).Rows(0), Nothing)
|
|
Dim drFinalError As DataRow = If(GlobalDTOCEstatus(Ent.CveEmpresa).FiltraParametros(String.Format("TipoTermino = 2 AND Tipo = '{0}'", Tipo)).Rows.Count = 1, GlobalDTOCEstatus(Ent.CveEmpresa).FiltraParametros(String.Format("TipoTermino = 2 AND Tipo = '{0}'", Tipo)).Rows(0), Nothing)
|
|
|
|
If Not drInicial Is Nothing Then CveEstatusInicial = drInicial("CveEstatus").ToString.ToEntero Else CveEstatusInicial = -1
|
|
If Not drFinalOK Is Nothing Then CveEstatusFinalOK = drFinalOK("CveEstatus").ToString.ToEntero Else CveEstatusFinalOK = -1
|
|
If Not drFinalError Is Nothing Then CveEstatusFinalError = drFinalError("CveEstatus").ToString.ToEntero Else CveEstatusFinalError = -1
|
|
|
|
Dim Retorno = New With
|
|
{
|
|
Key .CveEstatusInicial = CveEstatusInicial,
|
|
Key .CveEstatusFinalOK = CveEstatusFinalOK,
|
|
Key .CveEstatusEstatusFinalError = CveEstatusFinalError
|
|
}
|
|
Dim json = JsonConvert.SerializeObject(Retorno)
|
|
Salida = Encripta(json)
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
OnError("Ocurrio un error al obtener los estatus finales", ex)
|
|
End Try
|
|
Return Salida
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetOCEstatusEspecifico(Cadena As String) As String
|
|
Dim Salida As String = ""
|
|
Try
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[CveEstatus] = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
Dim JsonRequest = Decripta(Cadena)
|
|
|
|
Dim Entrada = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
|
|
If IsCurrentDate(Entrada.Ticks) Then
|
|
Dim jsonRetorno = GlobalDTOCEstatusUsuarios(-1).FiltraParametros($"CveEstatus = {Entrada.CveEstatus}").ToJson
|
|
Salida = Encripta(jsonRetorno)
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrio un error al obtener los estatus de oc.", ex)
|
|
End Try
|
|
Return Salida
|
|
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetOCEstatusUsuarios(Cadena As String) As String
|
|
Dim Salida As String = ""
|
|
Try
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[Tipo] = "",
|
|
Key .[CveEmpresa] = -1,
|
|
Key .[CveUsuario] = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
|
|
Dim JsonRequest = Decripta(Cadena)
|
|
Dim Entrada = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
If IsCurrentDate(Entrada.Ticks) Then
|
|
Dim Tipo As String = Entrada.Tipo
|
|
If Entrada.Tipo.Equals("REQ", StringComparison.InvariantCultureIgnoreCase) Then
|
|
Tipo = "Req"
|
|
End If
|
|
Dim JsonSalida = GlobalDTOCEstatusUsuarios(Entrada.CveEmpresa, Entrada.CveUsuario).FiltraParametros(String.Format(" (Tipo = '{0}' OR '{0}' = '-1') AND TipoTermino <> 2 ", Tipo), "Nivel DESC").ToJson
|
|
Salida = Encripta(JsonSalida)
|
|
End If
|
|
Catch ex As Exception
|
|
End Try
|
|
Return Salida
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function UpdateOCEstatus(Cadena As String) As Boolean
|
|
Dim Retorno As Boolean = False
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[CveEstatus] = -1,
|
|
Key .[CveOrdenCompra] = -1,
|
|
Key .[CveEmpresa] = -1,
|
|
Key .[CveUsuario] = -1,
|
|
Key .[Motivo] = "",
|
|
Key .[Ticks] = ""
|
|
}
|
|
Try
|
|
Dim JsonRequest = Decripta(Cadena)
|
|
Dim Ent = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
If IsCurrentDate(Ent.Ticks) Then
|
|
Dim DtPresupuestos As DataTable = Nothing
|
|
Dim UsaAC = False
|
|
Dim Empresa As Empresa = Nothing
|
|
|
|
Dim ObjEmpresa As New ClsSisEmpresas
|
|
|
|
If ObjEmpresa.GetEmpresas(Ent.CveEmpresa, "-1", "-1", "-1", "-1") Then
|
|
If ObjEmpresa.DtResultados.Rows.Count > 0 Then
|
|
Empresa = ObjEmpresa.Empresa
|
|
UsaAC = False
|
|
If UsaAC Then
|
|
Dim AC As New ClsAC
|
|
Dim Ejercicio = DateTime.Now.Year
|
|
If AC.GetPresupuestoEgresos(-1, True, Ejercicio, Ent.CveEmpresa, True) Then
|
|
DtPresupuestos = AC.DtResultados.Copy
|
|
End If
|
|
AC.Dispose()
|
|
End If
|
|
End If
|
|
End If
|
|
ObjEmpresa.Dispose()
|
|
|
|
Dim ObjOC As New ClsOC
|
|
ObjOC.IniciaTransacSQL()
|
|
|
|
Dim TipoOC As String = ""
|
|
Dim Estatus As String = ""
|
|
Dim Folio As String = ""
|
|
Dim Total As Decimal = 0
|
|
Dim FolioOCGeneradas As New List(Of Integer)
|
|
Dim DtDetalle As DataTable = Nothing
|
|
If ObjOC.UpdateOrdenCompraEstatus(Ent.CveEstatus, Ent.CveOrdenCompra, Ent.CveUsuario, Ent.Motivo) Then
|
|
If ObjOC.GetOC(Ent.CveOrdenCompra, -1) Then
|
|
Dim DtOC = ObjOC.DtResultados.Copy
|
|
TipoOC = DtOC.Rows(0)("Tipo").ToString
|
|
Estatus = DtOC.Rows(0)("Estatus").ToString
|
|
Folio = DtOC.Rows(0)("Folio").ToString
|
|
Total = DtOC.Rows(0)("Total").ToString.ToDecimal
|
|
|
|
Dim drFinalOK As DataRow = If(GlobalDTOCEstatus(ObjOC.CveEmpresa).FiltraParametros(String.Format("TipoTermino = 1 AND Tipo = '{0}'", TipoOC)).Rows.Count = 1, GlobalDTOCEstatus(ObjOC.CveEmpresa).FiltraParametros(String.Format("TipoTermino = 1 AND Tipo = '{0}'", TipoOC)).Rows(0), Nothing)
|
|
Dim CveEstatusFinalOK = drFinalOK("CveEstatus").ToString.ToEntero
|
|
|
|
If CveEstatusFinalOK > 0 AndAlso CveEstatusFinalOK = Ent.CveEstatus Then
|
|
Dim IDPolizaPresupuestal = ObjOC.IdPoliza
|
|
If ObjOC.GetOrdenesDetalle(Ent.CveOrdenCompra) Then
|
|
DtDetalle = ObjOC.DtResultados.Copy
|
|
Dim ObjConta As ClsContPAQi = Nothing
|
|
Retorno = Not GeneraOrdenes(FolioOCGeneradas, ObjConta, ObjOC, DtOC.Rows(0), DtDetalle, Ent.CveUsuario, Ent.CveEmpresa, IDPolizaPresupuestal, UsaAC, DtPresupuestos)
|
|
End If
|
|
Else
|
|
Retorno = True
|
|
End If
|
|
End If
|
|
End If
|
|
If Retorno Then
|
|
ObjOC.Commit()
|
|
ObjOC.Dispose()
|
|
|
|
'Dim Body As String = GeneraCorreoOC(Ent.CveOrdenCompra, "", TipoOC, Ent.CveEmpresa)
|
|
EnviarCorreoCambioEstatus(Ent.CveOrdenCompra, Ent.CveEstatus, Estatus, Total, TipoOC, Folio, DtDetalle, Ent.CveUsuario, Ent.CveEmpresa, FolioOCGeneradas)
|
|
Else
|
|
ObjOC.RollBack()
|
|
ObjOC.Dispose()
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrio un error al actualizar el estatus", ex)
|
|
Retorno = False
|
|
End Try
|
|
Return Retorno
|
|
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetRepOC(params As String) As String
|
|
Dim retorno As String = ""
|
|
Try
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[Folio] = -1,
|
|
Key .[Tipo] = "",
|
|
Key .[TipoBusqueda] = -1,
|
|
Key .[CveProyecto] = -1,
|
|
Key .[CveSubProyecto] = -1,
|
|
Key .[CveEstatus] = -1,
|
|
Key .[CveCliente] = -1,
|
|
Key .[CveUsuario] = -1,
|
|
Key .[CveEmpresa] = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
Dim jsonRequest As String = Decripta(params)
|
|
Dim Entrada = JsonConvert.DeserializeAnonymousType(jsonRequest, Estructura)
|
|
If IsCurrentDate(Entrada.Ticks) Then
|
|
Dim ObjOC As New ClsOC
|
|
If ObjOC.GetOrdenesPendientes(Entrada.Tipo, Entrada.TipoBusqueda, Entrada.CveEmpresa, Entrada.CveProyecto, Entrada.CveSubProyecto, Entrada.CveEstatus, Entrada.CveUsuario, Entrada.CveCliente) Then
|
|
Dim jsonRetorno = ObjOC.DtResultados.FiltraParametros($"Folio = {Entrada.Folio} OR {Entrada.Folio} = -1").ToJson
|
|
retorno = Encripta(jsonRetorno)
|
|
End If
|
|
ObjOC.Dispose()
|
|
End If
|
|
Catch ex As Exception
|
|
End Try
|
|
Return retorno
|
|
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetOrdenesCompraRep(params As String) As String
|
|
|
|
Dim retorno As String = ""
|
|
Try
|
|
Dim JsonRequest As String = Decripta(params)
|
|
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[Tipo] = "",
|
|
Key .[CveProyecto] = -1,
|
|
Key .[CveSubProyecto] = -1,
|
|
Key .[CveEstatus] = -1,
|
|
Key .[FechaI] = "",
|
|
Key .[FechaF] = "",
|
|
Key .[CveUsuario] = -1,
|
|
Key .[CveEmpresa] = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
Dim ent = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
If IsCurrentDate(ent.Ticks) Then
|
|
|
|
Dim ObjOrdenesCompra As New ClsOC()
|
|
If ObjOrdenesCompra.GetOrdenesCompraRep(ent.Tipo, ent.CveProyecto, ent.CveSubProyecto, -1, ent.CveEstatus, ent.FechaI.ToDate(), ent.FechaF.ToDate(), -1, -1, -1, -1, ent.CveUsuario, ent.CveEmpresa, -1) Then
|
|
Dim json = ObjOrdenesCompra.DtResultados.FiltraParametros("", "Folio DESC").ToJson
|
|
retorno = Encripta(json)
|
|
End If
|
|
ObjOrdenesCompra.Dispose()
|
|
|
|
End If
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
|
|
Return retorno
|
|
|
|
End Function
|
|
|
|
<WebMethod()>
|
|
Public Function GetRepOCEspecifico(Cadena As String, CveOrdenCompra As Integer) As String
|
|
Dim retorno As String = "[]"
|
|
Dim Entrada As WsRepOCGet
|
|
Try
|
|
Entrada = JsonConvert.DeserializeObject(Of WsRepOCGet)(Cadena)
|
|
If notcurrentdate(Entrada.Tick) Then
|
|
Entrada = Nothing
|
|
End If
|
|
Catch ex As Exception
|
|
Entrada = Nothing
|
|
End Try
|
|
If Not IsNothing(Entrada) Then
|
|
Dim ObjOC As New ClsOC
|
|
If ObjOC.GetOrdenesPendientes("REQ", 0, Entrada.CveEmpresa, Entrada.CveProyecto, Entrada.CveSubProyecto, Entrada.CveEstatus, Entrada.CveUsuario, Entrada.CveCliente) Then
|
|
retorno = JsonConvert.SerializeObject(ObjOC.DtResultados.FiltraParametros($"CveOrdenCompra={CveOrdenCompra}", "").DataTableToObject(Of WsOCGetRep2)()).ToString
|
|
End If
|
|
ObjOC.Dispose()
|
|
End If
|
|
Return retorno
|
|
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function AddOC(params As String) As String
|
|
Dim JsonRequest As String = ""
|
|
Dim Retorno As String = ""
|
|
|
|
Dim settings = New JsonSerializerSettings With {.NullValueHandling = NullValueHandling.Ignore}
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[OrdenCompra] = New Modelos.WSOrdenCompra,
|
|
Key .[Conceptos] = New List(Of OrdenCompraDetalle),
|
|
Key .[Bitacoras] = New List(Of WsBitacora),
|
|
Key .[Ticks] = ""
|
|
}
|
|
Dim Ent = Estructura.OrdenCompra
|
|
Dim Productos = Estructura.Conceptos
|
|
Dim Bitacoras = Estructura.Bitacoras
|
|
Dim ObjOC As ClsOC = Nothing
|
|
Try
|
|
JsonRequest = Decripta(params)
|
|
Dim Request = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura, settings)
|
|
|
|
Ent = Request.OrdenCompra
|
|
Productos = Request.Conceptos
|
|
Bitacoras = Request.Bitacoras
|
|
|
|
If IsCurrentDate(Request.Ticks) Then
|
|
Dim TieneError As Boolean = False
|
|
If ValidaGuardarOC(Ent, Productos, Ent.CveEmpresa, Ent.CveUsuario) Then
|
|
TieneError = True
|
|
Retorno = ""
|
|
End If
|
|
ObjOC = New ClsOC
|
|
If Not TieneError Then
|
|
Dim ObjOI As New ClsOIEventos(ObjOC.IniciaTransacSQL())
|
|
Dim CvePresupuestoEgreso As Integer = -1
|
|
If ObjOC.AddOrdenCompraMovil(Ent) Then
|
|
For Each ObjPS As OrdenCompraDetalle In Productos
|
|
If Not ObjOC.AddOrdenCompraDetalle(ObjOC.CveOrdenCompra, ObjPS.Cantidad, ObjPS.CveUnidadMedida, ObjPS.CvePS, ObjPS.Importe, ObjPS.CveSubProyecto, ObjPS.CveActivoFijo, ObjPS.Observacion, Ent.CveUsuario, Descuento:=ObjPS.Descuento) Then
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
If Not TieneError Then
|
|
If Bitacoras IsNot Nothing Then
|
|
For Each Bit As WsBitacora In Bitacoras
|
|
Dim FileExtension As String = If(IsNothing(Bit.Extension) AndAlso Bit.Imagen1 = "", "", Bit.Extension)
|
|
If ObjOI.AddEventoBitacora(Bit.Descripcion, FileExtension, Ent.CveUsuario, Ent.CveEmpresa, CveOC:=ObjOC.CveOrdenCompra, Prioridad:=Bit.CvePrioridad) Then
|
|
If Bit.Imagen1 <> "" Then
|
|
Try
|
|
Dim FileURL As String = String.Format("{0}Empresas\{1}\OI\", ModExtensiones.DirectorioBaseEmpresas, Ent.CveEmpresa)
|
|
If Not IO.Directory.Exists(FileURL) Then
|
|
IO.Directory.CreateDirectory(FileURL)
|
|
End If
|
|
Dim FileName As String = String.Format("OI{0}{1}", ObjOI.CveEvento.ToString, FileExtension)
|
|
Dim bmp1 As Drawing.Image = Bit.Imagen1.Base64ToImage()
|
|
bmp1.Save(String.Format("{0}{1}", FileURL, FileName))
|
|
Catch ex As Exception
|
|
GuardaLog(String.Format("WebService: {0}", ex))
|
|
End Try
|
|
End If
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
|
|
If Not TieneError Then
|
|
ObjOC.Commit()
|
|
Retorno = ObjOC.Folio
|
|
Else
|
|
ObjOC.RollBack()
|
|
Retorno = ""
|
|
End If
|
|
End If
|
|
|
|
ObjOC.Dispose()
|
|
End If
|
|
Catch ex As Exception
|
|
If ObjOC IsNot Nothing Then
|
|
ObjOC.RollBack()
|
|
ObjOC.Dispose()
|
|
End If
|
|
Ent = Nothing
|
|
End Try
|
|
|
|
Return Retorno
|
|
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetOrdenCompra(Cadena As String) As String
|
|
Dim Retorno As String = ""
|
|
Try
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[CveOrdenCompra] = -1,
|
|
Key .[CveEmpresa] = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
Dim JsonRequest As String = Decripta(Cadena)
|
|
Dim Entrada = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
If IsCurrentDate(Entrada.Ticks) Then
|
|
Dim ObjOC As New ClsOC
|
|
If ObjOC.GetOC(Entrada.CveOrdenCompra, -1) Then
|
|
Dim jarray As JArray = JArray.Parse(ObjOC.DtResultados.ToJson)
|
|
Dim json As JObject = jarray.Children(Of JObject).FirstOrDefault()
|
|
If json IsNot Nothing Then
|
|
If ObjOC.GetOrdenesDetalle(Entrada.CveOrdenCompra) Then
|
|
json.Add(New JProperty("Detalle", JArray.Parse(ObjOC.DtResultados.ToJson)))
|
|
End If
|
|
Retorno = Encripta(json.ToString)
|
|
End If
|
|
End If
|
|
ObjOC.Dispose()
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrio un error al obtener la orden de compra", ex)
|
|
End Try
|
|
Return Retorno
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function GetOCDetalle(Cadena As String) As String
|
|
|
|
Dim retorno As String = ""
|
|
Try
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[CveOrdenCompra] = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
Dim JsonRequest As String = Decripta(Cadena)
|
|
Dim Entrada = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
If IsCurrentDate(Entrada.Ticks) Then
|
|
Dim ObjOC As New ClsOC
|
|
If ObjOC.GetOrdenesDetalle(Entrada.CveOrdenCompra) Then
|
|
Dim JsonRetorno = ObjOC.DtResultados.ToJson
|
|
retorno = Encripta(JsonRetorno)
|
|
End If
|
|
ObjOC.Dispose()
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrio un error al traer el detalle de la orden de compra", ex)
|
|
End Try
|
|
Return retorno
|
|
End Function
|
|
|
|
<WebMethod>
|
|
Public Function GetFolioActual(params As String) As String
|
|
Dim Retorno As String = ""
|
|
Dim JsonRequest = Decripta(params)
|
|
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[TipoOC] = "",
|
|
Key .[CveEmpresa] = -1,
|
|
Key .[CveSubProyecto] = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
Try
|
|
Dim Request = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
|
|
If IsCurrentDate(Request.Ticks) Then
|
|
Dim Folio As New WsFolio
|
|
Dim ObjFolios As New ClsGralFolios()
|
|
If ObjFolios.GetFolios(If(Request.TipoOC = "REQ", "Req", Request.TipoOC), Request.CveEmpresa) Then
|
|
Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros("Estado = 'Activo'")
|
|
|
|
'Verificar primero el subproyecto del usuario
|
|
If DT.FiltraParametros("CveSubProyecto = " + Request.CveSubProyecto.ToString).Rows.Count > 0 Then
|
|
Dim Row As DataRow = DT.FiltraParametros("CveSubProyecto = " + Request.CveSubProyecto.ToString).Rows(0)
|
|
|
|
Folio.CveFolio = Row("CveFolio").ToString.ToEntero
|
|
Folio.FolioActual = Row("FActual").ToString
|
|
|
|
ElseIf DT.Rows.Count > 0 Then
|
|
|
|
Folio.CveFolio = DT.Rows(0)("CveFolio").ToString.ToEntero
|
|
Folio.FolioActual = DT.Rows(0)("FActual").ToString
|
|
End If
|
|
DT.Dispose()
|
|
End If
|
|
ObjFolios.Dispose()
|
|
Retorno = Folio.FolioActual
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrio un error al obtener el folio", ex)
|
|
End Try
|
|
|
|
Return Retorno
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function UpdateOCDetalle(strOCDetalle As String, strUsuario As String) As Boolean
|
|
Dim retorno = False
|
|
Dim OCDetalle As New Modelos.OrdenCompraDetalle
|
|
Dim Usuario As New WSUSER
|
|
Try
|
|
OCDetalle = JsonConvert.DeserializeObject(Of Modelos.OrdenCompraDetalle)(strOCDetalle)
|
|
Usuario = JsonConvert.DeserializeObject(Of WSUSER)(strUsuario)
|
|
Catch ex As Exception
|
|
OCDetalle = Nothing
|
|
End Try
|
|
If Not IsNothing(OCDetalle) Then
|
|
Dim ObjOC As New ClsOC
|
|
If ObjOC.UpdateOrdenCompraDetalle(OCDetalle.Cantidad, OCDetalle.CveUM, OCDetalle.CvePS, OCDetalle.Importe, OCDetalle.CveSubProyecto, OCDetalle.CveActivoFijo, OCDetalle.Observacion, Usuario.CveUsuario, OCDetalle.CveOrdenCompraDetalle) > 0 Then
|
|
retorno = True
|
|
End If
|
|
ObjOC.Dispose()
|
|
End If
|
|
Return retorno
|
|
|
|
End Function
|
|
<WebMethod()>
|
|
Public Function UpdateOC(params As String) As Boolean
|
|
Dim retorno = False
|
|
Try
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[CveSubProyecto] = -1,
|
|
Key .Descripcion = "",
|
|
Key .Justificacion = "",
|
|
Key .Prioridad = -1,
|
|
Key .RequiereCotizacion = False,
|
|
Key .FechaEstimadaEntrega = DateTime.Now,
|
|
Key .LugarEntrega = "",
|
|
Key .CveMoneda = -1,
|
|
Key .CveProveedor = -1,
|
|
Key .CveOrdenCompra = -1,
|
|
Key .CveUsuarioModifico = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
Dim JsonRequest = Decripta(params)
|
|
Dim OC = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
If IsCurrentDate(OC.Ticks) Then
|
|
Dim ObjOC As New ClsOC
|
|
If ObjOC.UpdateOrdenCompra(OC.CveSubProyecto, OC.Descripcion, OC.Justificacion, OC.Prioridad, OC.RequiereCotizacion, OC.FechaEstimadaEntrega.ToString("dd/MM/yyyy"), OC.LugarEntrega, OC.CveMoneda, OC.CveProveedor, OC.CveOrdenCompra, OC.CveUsuarioModifico) Then
|
|
retorno = True
|
|
End If
|
|
ObjOC.Dispose()
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrio un error al actualizar la orden de compra", ex)
|
|
End Try
|
|
Return retorno
|
|
|
|
End Function
|
|
|
|
<WebMethod()>
|
|
Public Function RemoveOCDetalle(params As String) As Boolean
|
|
Dim retorno = False
|
|
Try
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[CveOrdenCompraDetalle] = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
Dim jsonRequest = Decripta(params)
|
|
Dim Ent = JsonConvert.DeserializeAnonymousType(jsonRequest, Estructura)
|
|
If IsCurrentDate(Ent.Ticks) Then
|
|
Dim ObjOC As New ClsOC
|
|
If ObjOC.RemoveOrdenCompraDetalle(Ent.CveOrdenCompraDetalle, -1) Then
|
|
retorno = True
|
|
End If
|
|
ObjOC.Dispose()
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrio un erro al eliminar el detalle de una oc", ex)
|
|
End Try
|
|
Return retorno
|
|
|
|
End Function
|
|
|
|
<WebMethod()>
|
|
Public Function SolicitarCotizacionOC(Cadena As String) As Boolean
|
|
Dim retorno As Boolean = False
|
|
Try
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[CveOrdenCompra] = -1,
|
|
Key .CveProveedor = -1,
|
|
Key .CveColectiva = -1,
|
|
Key .CveEmpresa = -1,
|
|
Key .FechaEntrega = "",
|
|
Key .FechaEstimadaEntrega = "",
|
|
Key .LugarEntrega = "",
|
|
Key .Correo = "",
|
|
Key .[Ticks] = ""
|
|
}
|
|
Dim json = Decripta(Cadena)
|
|
Dim settings = New JsonSerializerSettings With {.NullValueHandling = NullValueHandling.Ignore}
|
|
Dim Ent = JsonConvert.DeserializeAnonymousType(json, Estructura)
|
|
If IsCurrentDate(Ent.Ticks) Then
|
|
Dim TieneError As Boolean = False
|
|
|
|
Dim ObjOC As New ClsOC
|
|
ObjOC.IniciaTransacSQL()
|
|
Dim CveCotizacion = 0
|
|
If ObjOC.AddCotizacion(Ent.CveOrdenCompra, Ent.CveProveedor, Ent.CveColectiva, "-1", "-1", "", 1, 0, 0) Then
|
|
CveCotizacion = ObjOC.CveCotizacion
|
|
'Cargar los detalles de la cotizacion
|
|
If ObjOC.GetOrdenesDetalle(Ent.CveOrdenCompra) Then
|
|
'Agrega CveCotizacion a la lista
|
|
|
|
For Each RowCD As DataRow In ObjOC.DtResultados.Rows
|
|
If Not ObjOC.AddCotizacionDetalle(ObjOC.CveCotizacion, RowCD("CvePS").ToString.ToEntero, -1, RowCD("Cantidad").ToString.ToDouble, RowCD("CveUnidadMedida").ToString.ToEntero, 0, "-1", "", RowCD("CveOrdenCompraDetalle").ToString.ToEntero) Then TieneError = True : Exit For
|
|
Next
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
If Not TieneError Then
|
|
|
|
Dim Body As String = GeneraCorreoCotizacion(CveCotizacion, Ent.CveOrdenCompra, Ent.CveEmpresa, Ent.FechaEntrega, Ent.FechaEstimadaEntrega, Ent.LugarEntrega)
|
|
Dim Mail As New ClsSisMail()
|
|
retorno = Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Ent.Correo, "SIG - Solicitud de Cotizacion", Body)
|
|
|
|
If retorno Then
|
|
ObjOC.Commit()
|
|
ObjOC.Dispose()
|
|
Else
|
|
ObjOC.RollBack()
|
|
ObjOC.Dispose()
|
|
End If
|
|
Else
|
|
ObjOC.RollBack()
|
|
ObjOC.Dispose()
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
End Try
|
|
Return retorno
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetEstatusFinal(Cadena As String) As Integer
|
|
Dim CveEstatusFinalError = 0
|
|
|
|
|
|
Dim Estructura = New With
|
|
{
|
|
Key .CveEmpresa = -1,
|
|
Key .Tipo = ""
|
|
}
|
|
|
|
Try
|
|
Dim json = Cadena
|
|
Dim settings = New JsonSerializerSettings With {.NullValueHandling = NullValueHandling.Ignore}
|
|
Dim Ent = JsonConvert.DeserializeAnonymousType(json, Estructura)
|
|
If Ent IsNot Nothing Then
|
|
Dim drFinalError As DataRow = If(GlobalDTOCEstatus(Ent.CveEmpresa).FiltraParametros(String.Format("TipoTermino = 2 AND Tipo = '{0}'", Ent.Tipo)).Rows.Count = 1, GlobalDTOCEstatus(Ent.CveEmpresa).FiltraParametros(String.Format("TipoTermino = 2 AND Tipo = '{0}'", Ent.Tipo)).Rows(0), Nothing)
|
|
If Not drFinalError Is Nothing Then CveEstatusFinalError = drFinalError("CveEstatus").ToString.ToEntero Else CveEstatusFinalError = -1
|
|
End If
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString())
|
|
End Try
|
|
Return CveEstatusFinalError
|
|
End Function
|
|
|
|
<WebMethod()>
|
|
Public Function RechazarOC(Cadena As String) As Boolean
|
|
Dim retorno As Boolean = False
|
|
Dim objOrdenCompra As New ClsOC
|
|
Try
|
|
Dim Estructura = New With
|
|
{
|
|
Key .CveEstatusFinalError = -1,
|
|
Key .CveOrdenCompra = -1,
|
|
Key .CveUsuario = -1,
|
|
Key .Cancelacion = "",
|
|
Key .Tipo = "",
|
|
Key .Folio = -1,
|
|
Key .CveEmpresa = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
Dim jsonRequest = Decripta(Cadena)
|
|
Dim Ent = JsonConvert.DeserializeAnonymousType(jsonRequest, Estructura)
|
|
If IsCurrentDate(Ent.Ticks) Then
|
|
Dim Tipo As String = If(Ent.Tipo.Equals("REQ", StringComparison.InvariantCultureIgnoreCase), "Requisición", "Orden de Compra")
|
|
If objOrdenCompra.UpdateOrdenCompraEstatus(Ent.CveEstatusFinalError, Ent.CveOrdenCompra, Ent.CveUsuario, Ent.Cancelacion) Then
|
|
' Dim Body As String = GeneraCorreoOC(Ent.CveOrdenCompra, "", Tipo, Ent.CveEmpresa)
|
|
'EnviarCorreoCambioEstatus(Ent.CveEstatusFinalError, "Cancelada", Tipo, Ent.Folio.ToString, Body, Ent.CveUsuario)
|
|
retorno = True
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
End Try
|
|
objOrdenCompra.Dispose()
|
|
Return retorno
|
|
End Function
|
|
<WebMethod>
|
|
Function GetOCHistorialSeguimiento(Cadena As String) As String
|
|
Dim Salida As String = ""
|
|
Try
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[CveOrdenCompra] = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
Dim JsonRequest = Decripta(Cadena)
|
|
Dim Entrada = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
If IsCurrentDate(Entrada.Ticks) Then
|
|
Dim ObjOC As New ClsOC
|
|
If ObjOC.GetOrdenesEstatus(Entrada.CveOrdenCompra) Then
|
|
Dim json = ObjOC.DtResultados.ToJson
|
|
Salida = Encripta(json)
|
|
End If
|
|
ObjOC.Dispose()
|
|
End If
|
|
Catch ex As Exception
|
|
End Try
|
|
Return Salida
|
|
End Function
|
|
<WebMethod>
|
|
Function GetOCHistorial(Cadena As String) As String
|
|
Dim Salida As String = "[]"
|
|
Try
|
|
Dim Estructura = New With
|
|
{
|
|
Key .[CveOrdenCompra] = -1,
|
|
Key .[Ticks] = ""
|
|
}
|
|
Dim JsonRequest = Decripta(Cadena)
|
|
Dim Entrada = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
If IsCurrentDate(Entrada.Ticks) Then
|
|
Dim ObjOC As New ClsOC
|
|
If ObjOC.GetOrdenesHistorial(Entrada.CveOrdenCompra) Then
|
|
If ObjOC.DtResultados.Rows.Count > 0 Then
|
|
Salida = JsonConvert.SerializeObject(ObjOC.DtResultados.FiltraParametros("CveConceptoHistorialOrdenCompra <> 1").DataTableToObject(Of WsHistorial)()).ToString()
|
|
End If
|
|
End If
|
|
ObjOC.Dispose()
|
|
End If
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
Return Salida
|
|
End Function
|
|
|
|
Protected Sub EnviarCorreoCambioEstatus(CveOrdenCompra As Integer, pCveEstatus As Integer, Estatus As String, Total As Decimal, TipoLargo As String, Folio As String, DtDetalle As DataTable, CveUsuario As Integer, CveEmpresaActual As Integer, FolioOCGeneradas As List(Of Integer), Optional CveEstatusSiguiente As Integer = -1, Optional CveSuperior As Integer = -1)
|
|
Dim strOpciones As New StringBuilder
|
|
Dim Para As String = GlobalDTUsuarios(CveUsuario)(0)("correo").ToString
|
|
Dim CorreosCCPNombre As New List(Of String)
|
|
Dim objUsuarios As New ClsSisUsuarios
|
|
Dim StrCorreos As New StringBuilder
|
|
|
|
'MANDA CORREO A LOS USUARIOS CON EL ESTATUS SIGUIENTE (MODIFICADO) PARA QUE DEN EL SIGUIENTE PASO
|
|
If CveEstatusSiguiente > 0 Then
|
|
If CveSuperior > 0 Then
|
|
'SI TIENE SUPERIOR MANDA CORREO A TODOS LOS DEL SIGUIENTE ESTATUS
|
|
StrCorreos.AppendFormat("{0};", GlobalDTUsuarios(CveSuperior)(0)("correo").ToString)
|
|
Else
|
|
'SI NO TIENE SUPERIOR LO BUSCA PARA MANDAR CORREO
|
|
Dim objOC As New ClsOC
|
|
For Each RowSP As DataRow In DtDetalle.FiltraParametros("", "", {"CveSubProyecto"}).Rows
|
|
If RowSP("CveSubProyecto").ToString.ToEntero > 0 Then
|
|
If objOC.GetEstatusUsuarios(-1, pCveEstatus, RowSP("CveSubProyecto").ToString.ToEntero, -1, CveEmpresaActual) Then
|
|
For Each Row As DataRow In objOC.DtResultados.Rows
|
|
'INCLUIR FILTRO DE LIMITE SUPERIOR E INFERIOR
|
|
If (IsDBNull(Row("LimiteInferior")) OrElse Row("LimiteInferior").ToString.ToDecimal < Total) And (IsDBNull(Row("LimiteSuperior")) OrElse Row("LimiteSuperior").ToString.ToDecimal > Total) Then
|
|
StrCorreos.AppendFormat("{0};", GlobalDTUsuarios(Row("CveUsuario").ToString.ToEntero)(0)("correo").ToString)
|
|
CorreosCCPNombre.Add(GlobalDTUsuarios(Row("CveUsuario").ToString.ToEntero)(0)("nombre").ToString)
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
Next
|
|
objOC.Dispose()
|
|
End If
|
|
End If
|
|
|
|
Dim DtHistorial = GetOCHistorialBitacora(CveOrdenCompra, CveEmpresaActual)
|
|
'MANDA CORREO A TODOS LOS USUARIOS INVOLUCRADOS
|
|
If DtHistorial IsNot Nothing AndAlso DtHistorial.AsEnumerable().Any() Then
|
|
For Each Row As DataRow In DtHistorial.FiltraParametros("CveConceptoHistorialBitacora = 1").Rows
|
|
StrCorreos.AppendFormat("{0};", GlobalDTUsuarios(Row("CveUsuario").ToString.ToEntero)(0)("correo").ToString)
|
|
CorreosCCPNombre.Add(GlobalDTUsuarios(Row("CveUsuario").ToString.ToEntero)(0)("nombre").ToString)
|
|
Next
|
|
End If
|
|
|
|
strOpciones.AppendFormat("Se ha cambiado la {0} #{1} al estatus <b>{2}</b><br><br>", TipoLargo, Folio, Estatus)
|
|
strOpciones.Append(" <div style='width: 400px'> ")
|
|
strOpciones.Append(" <fieldset> ")
|
|
strOpciones.Append(" <legend>Opciones</legend> ")
|
|
strOpciones.Append(" <table width=""350px""> ")
|
|
|
|
'verifico los permisos según el estatus
|
|
'Const Sitio As String = "rm:90/"
|
|
Dim StrSupervisa As String = "" '= String.Format("http://{0}/OC/RegOp.aspx?p={1}", Sitio, Encripta(String.Format("Op=SUPERVISAR&Oc={0}&CveUsuario={1}&Fecha={2}", CveOrdenCompra, CveUsuario, Now)))
|
|
Dim StrAutoriza As String = "" '= String.Format("http://{0}/OC/RegOp.aspx?p={1}", Sitio, Encripta(String.Format("Op=AUTORIZAR&Oc={0}&CveUsuario={1}&Fecha={2}", CveOrdenCompra, CveUsuario, Now)))
|
|
Dim StrCancela As String = "" ' = String.Format("http://{0}/OC/RegOp.aspx?p={1}", Sitio, Encripta(String.Format("Op=CANCELAR&Oc={0}&CveUsuario={1}&Fecha={2}", CveOrdenCompra, UsuarioActual.CveUsuario, Now)))
|
|
Dim StrReqCotiza As String = "" '= String.Format("http://{0}/OC/RegOp.aspx?p={1}", Sitio, Encripta(String.Format("Op=REQCONTIZACION&Oc={0}&CveUsuario={1}&Fecha={2}", CveOrdenCompra, CveUsuario, Now)))
|
|
|
|
'si se acaba de solicitar y se necesita supervisar
|
|
If pCveEstatus = 1 Then strOpciones.AppendFormat(" <tr><td><a href=""{0}""><span style=""font-size: 15px""><strong>Supervisar</strong></span></a></td></tr> ", StrSupervisa)
|
|
'si se acaba de supervisar y se necesita autorizar
|
|
If pCveEstatus = 2 Then
|
|
strOpciones.AppendFormat(" <tr><td><a href=""{0}""><span style=""font-size: 15px""><strong>Autorizar</strong></span></a></td></tr> ", StrAutoriza)
|
|
strOpciones.AppendFormat(" <tr><td><a href=""{0}""><span style=""font-size: 15px""><strong> Autorizar con Cotización</strong></span></a></td></tr> ", StrReqCotiza)
|
|
End If
|
|
'si se quiere cancelar
|
|
strOpciones.AppendFormat(" <tr><td><a href=""{0}""><span style=""font-size: 15px""><strong>Cancelar</strong></span></a></td></tr> ", StrCancela)
|
|
|
|
strOpciones.Append(" </table> ")
|
|
strOpciones.Append(" </fieldset> ")
|
|
strOpciones.Append(" </div> ")
|
|
|
|
strOpciones.AppendLine()
|
|
|
|
'NOTIFICA QUE OCS SE GENERARON
|
|
Dim OCsGeneradas As New StringBuilder
|
|
If FolioOCGeneradas.Count > 0 Then
|
|
OCsGeneradas.Append("Se generaron la(s) siguiente(s) orden(es) de compra: ")
|
|
For Each FolioOC In FolioOCGeneradas
|
|
OCsGeneradas.Append($" #<b>{FolioOC}</b> ")
|
|
Next
|
|
End If
|
|
strOpciones.Append(OCsGeneradas.ToString)
|
|
Dim Body As String = GeneraCorreoOC(CveOrdenCompra, strOpciones.ToString(), TipoLargo, CveEmpresaActual)
|
|
Try
|
|
Dim Asunto As String = String.Format("SIG - La {0} #{1} cambió de estatus.", TipoLargo, Folio)
|
|
'Dim a As String = String.Format("{0} -- {1} --- {2}", Asunto, Para, StrCorreos.ToString())
|
|
|
|
Dim Mail As New ClsSisMail()
|
|
Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, StrCorreos.ToString())
|
|
Catch ex As Exception
|
|
OnError("Ocurrió error al mandar MAIL por cambio de Estatus", ex)
|
|
End Try
|
|
End Sub
|
|
Protected Function GetOCHistorialBitacora(CveOrdenCompra As Integer, CveEmpresa As Integer) As DataTable
|
|
Dim dt As DataTable = Nothing
|
|
Dim ObjGral As New ClsGenerales
|
|
|
|
If ObjGral.GetHistorialBitacora(-1, CveOrdenCompra, -1, -1, -1, -1, -1, CveEmpresa) Then
|
|
dt = ObjGral.DtResultados
|
|
End If
|
|
ObjGral.Dispose()
|
|
Return dt
|
|
End Function
|
|
Public Function GetCveSuperior(CveUsuario As Integer, CveEmpresaActual As Integer, CveEstatus As Integer, TipoOC As String, DtDetalle As DataTable, Total As Decimal) As Integer
|
|
Dim DtEstatusUsuarios = GlobalDTOCEstatusUsuarios(CveEmpresaActual, CveUsuario, TipoOC)
|
|
Dim RowActual As DataRow = GlobalDTOCEstatus(CveEmpresaActual).FiltroPrimero(String.Format("CveEstatus = {0}", CveEstatus))
|
|
Dim CveSuperior As Integer = -1
|
|
If Not IsNothing(RowActual) Then
|
|
|
|
'Si el TipoTermino es diferente de 1 (Autorizada) y 2 (Rechazada), revisar cual seria el superior
|
|
If RowActual("TipoTermino").ToString.ToEntero <> 1 And RowActual("TipoTermino").ToString.ToEntero <> 2 AndAlso DtEstatusUsuarios IsNot Nothing Then
|
|
For Each Row As DataRow In DtDetalle.FiltraParametros("", "", {"CveSubProyecto"}).Rows
|
|
For Each RowE As DataRow In DtEstatusUsuarios.FiltraParametros(String.Format("{0} CveEstatus = {1} AND ((LimiteInferior IS NULL OR LimiteInferior <= {2}) AND (LimiteSuperior IS NULL OR LimiteSuperior >= {2})) ", If(Row("CveSubProyecto").ToString <> "", String.Format("CveSubProyecto = {0} AND ", Row("CveSubProyecto").ToString), ""), CveEstatus, Total)).Rows
|
|
CveSuperior = RowE("CveSuperior").ToString.ToEntero
|
|
Next
|
|
Next
|
|
End If
|
|
End If
|
|
Return CveSuperior
|
|
End Function
|
|
Private Function GeneraCorreoCotizacion(CveCotizacion As Integer, CveOrdenCompra As Integer, CveEmpresa As Integer, FechaEntrega As String, FechaEstimadaEntrega As String, LugarEntrega As String) As String
|
|
Dim strBody As New StringBuilder
|
|
Dim Empresa As String = ""
|
|
Dim ObjEmpresas As New ClsSisEmpresas
|
|
If ObjEmpresas.GetEmpresas(CveEmpresa, "-1", "-1", "-1", "-1") Then
|
|
Empresa = ObjEmpresas.DtResultados.FiltroPrimeroValor("Empresa")
|
|
End If
|
|
ObjEmpresas.Dispose()
|
|
strBody.Append("<html xmlns=""http://www.w3.org/1999/xhtml""> ")
|
|
strBody.Append("<head> ")
|
|
strBody.Append(" <style type=""text/css""> ")
|
|
strBody.Append(" body ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" margin:0px; ")
|
|
strBody.Append(" padding:0px 0px 0px 0px; ")
|
|
strBody.Append(" font-family: Verdana, Arial, Helvetica, sans-serif; ")
|
|
strBody.Append(" font-size: 10px; ")
|
|
strBody.Append(" background-color:#F0F0F0; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" a.Texto ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" font-size:11px; ")
|
|
strBody.Append(" background-color:#F7F6F3; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" font-weight:bold; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Texto ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color:#F7F6F3; color:Black; font-family:Verdana; font-size:10px; text-align:center; vertical-align:middle; height:20px;")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .TextoAlterno ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color:White; color:Black; font-family:Verdana; font-size:10px; text-align:center; ")
|
|
strBody.Append(" vertical-align:middle; height:20px;")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .BarraIdentidad ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" color:#FFFFFF; ")
|
|
strBody.Append(" background:#F0F0F0; ")
|
|
strBody.Append(" font-weight:bold; ")
|
|
strBody.Append(" font-size:19px; ")
|
|
strBody.Append(" font-style:oblique; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Titulos ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color: Gray;")
|
|
strBody.Append(" color:White; ")
|
|
strBody.Append(" font-family:Verdana; font-size:12px; text-align:center; ")
|
|
strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Contenido2 ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color: White;")
|
|
strBody.Append(" font-family:Verdana; font-size:12px; text-align:center; ")
|
|
strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Verde {color: #00CC00;} ")
|
|
strBody.Append(" .Negro {color: #000000;} ")
|
|
strBody.Append(" .Rojo {color: #FF0000;} ")
|
|
strBody.Append(" </style> ")
|
|
strBody.Append("</head> ")
|
|
strBody.Append("<body> ")
|
|
|
|
strBody.Append("<div class='Titulos'>Por medio del Presente Correo Electronico, solicito a usted tenga a bien emitir cotización</div><br>")
|
|
|
|
strBody.Append("<div class='Contenido2' style='display: table!important'>")
|
|
strBody.AppendFormat(" <div id=""C_divOC"" style=""width: 660px""> <fieldset> <legend><b>Datos {0}</b></legend> ", "Cotización")
|
|
strBody.Append(" <table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%""> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td style=""width: 130px""> Empresa:</td><td colspan=""3""><b>{0}</b></td> ", Empresa)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>Fecha Entrega:</td><td><b>{0}</b></td><td> </td><td><b> </b></td> ", FechaEstimadaEntrega)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>Lugar Entrega:</td><td><b>{0}</b></td><td> </td><td><b> </b></td> ", LugarEntrega)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" </table> ")
|
|
strBody.Append(" </fieldset> ")
|
|
strBody.Append(" </div> ")
|
|
'Cargo el detalle
|
|
|
|
strBody.Append(" <div style='width: 650px'> ")
|
|
strBody.Append(" <fieldset> ")
|
|
strBody.Append(" <legend>Productos a Cotizar</legend> ")
|
|
strBody.Append(" <table width=""650px""> <tr style='background-color:gray;color:White;font-family:Verdana;font-size:10px;text-align:center;vertical-align:middle;font-weight:bold;height:20px;text-decoration:none;'><th scope='col' style='width: 50px'>Cantidad</th><th scope='col' style='width: 50px'>Unidad</th><th scope='col' style='width: 225px'>Descripción</th><th scope='col' style='width: 225'>Observación</th>")
|
|
strBody.Append(" </tr>")
|
|
|
|
'verifico los permisos según el estatus
|
|
|
|
Dim dtConceptos As DataTable = Nothing
|
|
Dim ObjOCdb As New ClsOC
|
|
If ObjOCdb.GetOrdenesDetalle(CveOrdenCompra) Then
|
|
dtConceptos = ObjOCdb.DtResultados
|
|
End If
|
|
|
|
For Each dr As DataRow In dtConceptos.Rows
|
|
strBody.AppendFormat("<tr class='Texto'><td style='width:50px;'>{0}</td><td style='width:50px;'>{1}</td><td align='left' style='width:225px;'>{2}</td><td align='left' style='width:225px;'>{3}</td></tr>", dr("Cantidad").ToString.FormatoNumero, dr("Abreviatura"), dr("PS"), dr("Obs"))
|
|
Next
|
|
|
|
strBody.Append(" </table> ")
|
|
strBody.Append(" </fieldset> ")
|
|
strBody.Append(" </div> ")
|
|
strBody.AppendFormat("<div>Capture la cotizacion <a href='http://sig.adsistemas.mx/OC/CotizacionEnLinea.aspx?P={0}'>AQUI</a></div>", ModExtensiones.Encripta(String.Format("CveCotizacion={0}", CveCotizacion)))
|
|
strBody.Append("</div>")
|
|
strBody.Append("</body></html>")
|
|
ObjOCdb.Dispose()
|
|
Return strBody.ToString
|
|
End Function
|
|
|
|
Private Function GeneraCorreoOC(CveOrdenCompra As Integer, Opciones As String, TipoLargo As String, CveEmpresaActual As Integer, Optional IncluirDetalles As Boolean = True, Optional Bitacora As String = "", Optional LigaAdjunto As String = "") As String
|
|
Dim strBody As New StringBuilder
|
|
Dim objOC As New ClsOC
|
|
Try
|
|
If objOC.GetOC(CveOrdenCompra, CveEmpresaActual) Then
|
|
strBody.Append("<html xmlns=""http://www.w3.org/1999/xhtml""> ")
|
|
strBody.Append("<head> ")
|
|
strBody.Append(" <style type=""text/css""> ")
|
|
strBody.Append(" body ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" margin:0px; ")
|
|
strBody.Append(" padding:0px 0px 0px 0px; ")
|
|
strBody.Append(" font-family: Verdana, Arial, Helvetica, sans-serif; ")
|
|
strBody.Append(" font-size: 10px; ")
|
|
strBody.Append(" background-color:#F0F0F0; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" a.Texto ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" font-size:11px; ")
|
|
strBody.Append(" background-color:#F7F6F3; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" font-weight:bold; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Texto ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color:#F7F6F3; color:Black; font-family:Verdana; font-size:10px; text-align:center; vertical-align:middle; height:20px;")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .TextoAlterno ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color:White; color:Black; font-family:Verdana; font-size:10px; text-align:center; ")
|
|
strBody.Append(" vertical-align:middle; height:20px;")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .BarraIdentidad ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" color:#FFFFFF; ")
|
|
strBody.Append(" background:#F0F0F0; ")
|
|
strBody.Append(" font-weight:bold; ")
|
|
strBody.Append(" font-size:19px; ")
|
|
strBody.Append(" font-style:oblique; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Titulos ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color: Gray;")
|
|
strBody.Append(" color:White; ")
|
|
strBody.Append(" font-family:Verdana; font-size:12px; text-align:center; ")
|
|
strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Verde {color: #00CC00;} ")
|
|
strBody.Append(" .Negro {color: #000000;} ")
|
|
strBody.Append(" .Rojo {color: #FF0000;} ")
|
|
strBody.Append(" </style> ")
|
|
strBody.Append("</head> ")
|
|
strBody.Append("<body> ")
|
|
strBody.AppendFormat(" <div id=""C_divOC"" style=""width: 550px""> <fieldset> <legend><b>Datos {0}</b></legend> ", TipoLargo)
|
|
strBody.Append(" <table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%""> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td style=""width: 90px""> Folio:</td><td style=""width: 125px""><b><a href=""{0}OC/OC.aspx?OC={1}"">{2}<a></b></td><td style=""width: 90px""> Estatus: </td><td><b>{3}</b></td> ", UrlSitio, objOC.CveOrdenCompra, objOC.Folio, objOC.Estatus)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td style=""width: 90px""> Empresa:</td><td colspan=""3""><b>{0}</b></td> ", objOC.Empresa)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 20px""> ")
|
|
strBody.AppendFormat(" <td>Descripción:</td><td colspan='3'><b>{0}</b></td> ", objOC.Descripcion)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 20px""> ")
|
|
strBody.AppendFormat(" <td>Justificación</td><td colspan=""3""><textarea name=""ctlTJ"" rows=""5"" cols=""20"" readonly=""readonly""id=""ctlTJ"" style=""width: 300px;"">{0}</textarea></td> ", objOC.Justificacion)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" </table> ")
|
|
strBody.Append(" </fieldset> ")
|
|
strBody.Append(" </div> ")
|
|
'Cargo el detalle
|
|
If IncluirDetalles = True Then
|
|
strBody.Append(" <div style='width: 550px'> ")
|
|
strBody.Append(" <fieldset> ")
|
|
strBody.Append(" <legend>Opciones</legend> ")
|
|
strBody.Append(" <table width=""550px""> <tr style='background-color:gray;color:White;font-family:Verdana;font-size:10px;text-align:center;vertical-align:middle;font-weight:bold;height:20px;text-decoration:none;'><th scope='col' style='width: 50px'>Cantidad</th><th scope='col' style='width: 50px'>Unidad</th><th scope='col' style='width: 225px'>Producto o Servicio</th>")
|
|
strBody.AppendFormat(" <th scope='col' style='width: 100px'>Observacion</th><th scope='col' style='width: 150px'>{0}</th><th scope='col' style='width: 85px'>Activo Fijo</th><th scope='col' style='width: 70px'>P.U.</th><th scope='col' style='width: 85px'>Total</th></tr>", If(CveEmpresaActual = 66, "Proyecto", "Proyecto<br>SubProyecto"))
|
|
|
|
'verifico los permisos según el estatus
|
|
|
|
If objOC.GetOrdenesDetalle(CveOrdenCompra) Then
|
|
For Each dr As DataRow In objOC.DtResultados.Rows
|
|
strBody.AppendFormat("<tr class='Texto'><td>{0}</td><td>{1}</td><td><span style='width: 220px; border-bottom: 1px solid gray;'>{2}</span><br>{3}</td><td>{4}</td><td style='width:150px;'><span style='width: 150px; border-bottom: 1px solid gray;'>{5}</span><br>{6}</td><td>{7}</td><td align='right'>{8}</td><td align='right'>{9}</td></tr>",
|
|
dr("Cantidad").ToString.FormatoNumero, dr("Abreviatura"), dr("Clasificacion"), dr("PS"), dr("Observacion"), dr("Proyecto"), If(CveEmpresaActual = 66, "", dr("SubProyecto")), dr("Codigo"), If(Not IsDBNull(dr("Importe")), FormatCurrency(dr("Importe").ToString), ""), If(Not IsDBNull(dr("Total")), FormatCurrency(dr("Total").ToString), ""))
|
|
|
|
Next
|
|
End If
|
|
|
|
strBody.Append(" </table> ")
|
|
strBody.Append(" </fieldset> ")
|
|
strBody.Append(" </div> ")
|
|
Else
|
|
strBody.Append(" <div style='width: 550px; height: 50px'> ")
|
|
strBody.Append(" <fieldset> ")
|
|
strBody.Append(" <legend>Bitacora</legend> ")
|
|
strBody.Append(" <table width=""550px""> ")
|
|
strBody.Append(" <tr> ")
|
|
strBody.Append(" <td> ")
|
|
strBody.AppendFormat(" {0}", Bitacora)
|
|
strBody.Append(" </td> ")
|
|
If LigaAdjunto <> "" Then strBody.AppendFormat(" <tr><td>El usuario agrego el siguiente archivo: <a href='{0}'>Adjunto</a></td></tr>", LigaAdjunto)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" </table> ")
|
|
strBody.Append(" </fieldset> ")
|
|
strBody.Append(" </div> ")
|
|
End If
|
|
'strBody.Append(Opciones)
|
|
strBody.Append(Opciones)
|
|
strBody.Append("</body></html>")
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrio un error al general el correo.", ex)
|
|
End Try
|
|
objOC.Dispose()
|
|
Return strBody.ToString
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "F U N C I O N E S"
|
|
Private Function notcurrentdate(fecha As DateTime) As Boolean
|
|
Return Not (fecha > (DateTime.Now).AddMinutes(-15) And fecha < (DateTime.Now).AddMinutes(15))
|
|
End Function
|
|
Private Function ValorXML(n As System.Xml.XmlNode, Campo As String, Optional Retorno As String = "") As String
|
|
Dim o As System.Xml.XmlNode = n.Attributes.Cast(Of System.Xml.XmlAttribute)().SingleOrDefault(Function(a) String.Compare(a.Name, Campo, True) = 0)
|
|
If o Is Nothing Then
|
|
Return Retorno
|
|
Else
|
|
Return o.Value
|
|
End If
|
|
End Function
|
|
Private Function IsCurrentDate(StrFecha As String) As Boolean
|
|
'Dim FechaServer As DateTime = ReturnTimeOnServer(StrFecha)
|
|
'Return (FechaServer > (DateTime.Now).AddMinutes(-15) And FechaServer < (DateTime.Now).AddMinutes(15))
|
|
Return True
|
|
End Function
|
|
Public Function ReturnTimeOnServer(clientString As String) As DateTime
|
|
Dim format As String = "dd/MM/yyyy H:m:s zzz"
|
|
Try
|
|
Dim clientTime As DateTimeOffset = DateTimeOffset.ParseExact(clientString, format, CultureInfo.InvariantCulture)
|
|
Dim serverTime As DateTimeOffset = TimeZoneInfo.ConvertTime(clientTime, TimeZoneInfo.Local)
|
|
Return serverTime.DateTime
|
|
Catch e As FormatException
|
|
Return DateTimeOffset.MinValue.DateTime
|
|
End Try
|
|
End Function
|
|
Public Function CreateListFromSingle(Of T)(ByVal p1 As T) As List(Of T)
|
|
Dim list As New List(Of T)
|
|
list.Add(p1)
|
|
Return list
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "T I P O C A M B I O "
|
|
<WebMethod>
|
|
Public Function GetTipoCambio() As String
|
|
Dim Retorno = "[]"
|
|
Dim ObjTC As New ClsGenerales
|
|
If ObjTC.GetTipoCambio(-1, DateTime.Now) Then
|
|
Retorno = JsonConvert.SerializeObject(ObjTC.DtResultados.Rows(0).DataRowToObject(Of WsTipoCambio))
|
|
End If
|
|
ObjTC.Dispose()
|
|
Return Retorno
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "I N D I C A D O R E S"
|
|
<WebMethod>
|
|
Public Function GetIndicadores(CveEmpresa As Integer) As String
|
|
Dim Retorno = "[]"
|
|
Dim ds As DataSet = Nothing
|
|
Dim ObjGral As New ClsGenerales
|
|
Try
|
|
ds = ObjGral.GetIndicadores(CveEmpresa)
|
|
Dim dt = ds.Tables(0)
|
|
Dim dr = dt.Rows(0)
|
|
Dim TotalBancos As Double = dr("TotalBancos").ToString.ToDouble
|
|
Dim TotalCxC As Double = dr("CxCTotal").ToString.ToDouble
|
|
Dim TotalCxP As Double = dr("CxPTotal").ToString.ToDouble
|
|
|
|
Dim ObjIndicador = New WsIndicador
|
|
ObjIndicador.TotalBancos = TotalBancos
|
|
ObjIndicador.CxCTotal = TotalCxC
|
|
ObjIndicador.CxPTotal = TotalCxP
|
|
|
|
Retorno = JsonConvert.SerializeObject(ObjIndicador)
|
|
|
|
Catch ex As Exception
|
|
Retorno = "[]"
|
|
End Try
|
|
Return Retorno
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "C R M"
|
|
<WebMethod>
|
|
Public Function GetEmpresasCRM(CveEmpresa As Integer) As String
|
|
Dim Retorno = "[]"
|
|
Using ObjCRM As New ClsCRM
|
|
If ObjCRM.GetEmpresasCRM(CveEmpresa) Then
|
|
Retorno = ObjCRM.DtResultados.ToJson()
|
|
End If
|
|
End Using
|
|
Return Retorno
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetMediosCaptacion(CveEmpresa As Integer) As String
|
|
Dim Retorno = "[]"
|
|
Using ObjCRM As New ClsCRM
|
|
If ObjCRM.GetMedioCaptacion(CveEmpresa, 1) Then
|
|
Retorno = ObjCRM.DtResultados.ToJson()
|
|
End If
|
|
End Using
|
|
Return Retorno
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetContactos(CveEmpresa As Integer, CveEmpresaCRM As Integer, CveContacto As Integer) As String
|
|
Dim Retorno = "[]"
|
|
Using ObjCRM As New ClsCRM
|
|
If ObjCRM.GetContactoEmpresa(CveEmpresaCRM, CveContacto, CveEmpresa) Then
|
|
Retorno = ObjCRM.DtResultados.ToJson()
|
|
End If
|
|
End Using
|
|
Return Retorno
|
|
End Function
|
|
|
|
<WebMethod>
|
|
Public Function SyncEmpresa(params As String) As Boolean
|
|
Dim TieneError As Boolean = False
|
|
Dim Estructura = New With
|
|
{
|
|
.CveEncuestaCRM = -1,
|
|
.EmpresaCRM = New With {
|
|
.IDTemp = -1,
|
|
.CveEmpresaCRM = -1,
|
|
.Empresa = "", .RFC = "",
|
|
.CveEncuestaAplicada = -1,
|
|
.CveMedioCaptacion = -1,
|
|
.Vendedor = "",
|
|
.MedioCaptacion = "",
|
|
.CveUsuarioIng = -1,
|
|
.CveUsuarioMod = -1,
|
|
.CveVendedorAsignado = -1,
|
|
.CveEmpresa = -1
|
|
},
|
|
.Respuestas = CreateListFromSingle(New With {.IDTempCveEmpresaCRM = -1, .CveEmpresaCRM = -1, .CveEncuesta = -1, .CveEncuestaAplicadaDetalle = -1, .CveEmpresa = -1, .CveUsuario = -1, .CvePregunta = -1, .CveRespuesta = -1, .Valor = ""}),
|
|
.Contactos = CreateListFromSingle(New With {.IDTempCveEmpresaCRM = -1, .CveContacto = -1, .Nombre = "", .TelefonoOficina = "", .Celular = "", .Correo = "", .CveUsuarioIng = -1, .CveEmpresaCRM = -1}),
|
|
.Acercamientos = CreateListFromSingle(New With {.IDTemp = -1, .CveAcercamiento = -1, .CveEmpresaCRM = -1, .CveContactoPrincipal = -1, .CveTipoProceso = -1, .CveEtapaProcesoActual = -1, .CveVendedor = -1, .CveMedioCaptacion = -1, .CveRechazoMotivo = -1, .CveProbabilidadAcercamiento = -1, .FechaApertura = Now, .NombreAcercamiento = "", .Descripcion = "", .Importe = 0D, .Comision = 0D, .Prioridad = -1, .CveEmpresa = -1, .CveUsuarioIng = -1, .CveUsuarioMod = -1, .FechaCierre = Now, .CveEncuestaAplicadaProceso = -1}),
|
|
.BitacorasAcercamientos = CreateListFromSingle(New With {.IDTempCveAcercamiento = -1, .CveEvento = -1, .Descripcion = "", .CveTipoProcesoCRM = -1, .CveEmpresa = -1, .CveUsuarioIng = -1, .CveAcercamiento = -1, .CveEtapaProcesoCRM = -1})
|
|
}
|
|
Dim ObjCRM As New ClsCRM
|
|
Dim ObjDatosTecnicos As New ClsEncuestas(ObjCRM.IniciaTransacSQL())
|
|
Dim ObjBitacora As New ClsOIEventos(ObjCRM.IniciaTransacSQL())
|
|
|
|
Try
|
|
Dim JsonRequest = Decripta(params)
|
|
Dim Ent = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
Dim Mensaje As String = ""
|
|
|
|
'ACTUALIZAR EMPRESA EXISTENTE
|
|
If Ent.EmpresaCRM.CveEmpresaCRM > 0 Then
|
|
If Ent.EmpresaCRM.CveEncuestaAplicada > 0 Then
|
|
For Each Resp In Ent.Respuestas
|
|
If Not ObjDatosTecnicos.UpdateDatosTecnicosCRM(Resp.CveEncuestaAplicadaDetalle, Ent.EmpresaCRM.CveEncuestaAplicada, Resp.CvePregunta, Resp.CveRespuesta, IfNull(Resp.Valor, "")) Then
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
If Not TieneError Then
|
|
TieneError = Not ObjCRM.UpdateEmpresCRM(Ent.EmpresaCRM.Empresa, Ent.EmpresaCRM.RFC, Ent.EmpresaCRM.CveMedioCaptacion, Ent.EmpresaCRM.CveEmpresaCRM, Ent.EmpresaCRM.CveVendedorAsignado, Ent.EmpresaCRM.CveUsuarioMod)
|
|
If Not TieneError Then
|
|
For Each item In Ent.Contactos
|
|
If item.CveContacto > 0 Then
|
|
TieneError = Not ObjCRM.UpdateContactoEmpresa(item.Nombre, item.TelefonoOficina, item.Celular, item.Correo, item.CveContacto, item.CveUsuarioIng)
|
|
Else
|
|
TieneError = Not ObjCRM.AddContactoEmpresa(item.Nombre, item.TelefonoOficina, item.Celular, item.Correo, item.CveEmpresaCRM, item.CveUsuarioIng)
|
|
End If
|
|
If TieneError Then
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
If Not TieneError Then
|
|
For Each item In Ent.Acercamientos
|
|
If item.CveAcercamiento > 0 Then
|
|
TieneError = Not ObjCRM.UpdateAcercamiento(item.CveAcercamiento, item.CveContactoPrincipal, item.CveTipoProceso, item.CveEtapaProcesoActual, item.CveVendedor, item.CveMedioCaptacion, item.CveProbabilidadAcercamiento, item.NombreAcercamiento, item.Descripcion, item.Importe, item.Comision, item.Prioridad, item.CveUsuarioMod, item.CveRechazoMotivo, item.CveEncuestaAplicadaProceso, item.FechaApertura, item.FechaCierre)
|
|
|
|
If Not TieneError Then
|
|
Dim bitacoras = Ent.BitacorasAcercamientos.Where(Function(x) x.IDTempCveAcercamiento = item.IDTemp)
|
|
|
|
For Each bita In bitacoras
|
|
TieneError = Not ObjBitacora.AddEventoBitacora(bita.Descripcion, "", bita.CveUsuarioIng, bita.CveEmpresa, CveTipoProcesoCRM:=bita.CveTipoProcesoCRM, CveAcercamientoCRM:=item.CveAcercamiento, CveEtapaProcesoCRM:=bita.CveEtapaProcesoCRM)
|
|
If TieneError Then
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
Else
|
|
Dim CveAcercamiento As Integer = ObjCRM.AddAcercamiento(Ent.EmpresaCRM.CveEmpresaCRM, item.CveContactoPrincipal, item.CveTipoProceso, item.CveEtapaProcesoActual, item.CveVendedor, item.CveMedioCaptacion, item.CveRechazoMotivo, item.CveProbabilidadAcercamiento, item.FechaApertura, item.NombreAcercamiento, item.Descripcion, item.Importe, item.Comision, item.Prioridad, item.CveEmpresa, item.CveUsuarioIng, item.FechaCierre)
|
|
Dim bitacoras = Ent.BitacorasAcercamientos.Where(Function(x) x.IDTempCveAcercamiento = item.IDTemp)
|
|
|
|
If CveAcercamiento > 0 Then
|
|
Dim bitacorass = Ent.BitacorasAcercamientos.Where(Function(x) x.IDTempCveAcercamiento = item.IDTemp)
|
|
|
|
For Each bita In bitacorass
|
|
TieneError = Not ObjBitacora.AddEventoBitacora(bita.Descripcion, "", bita.CveUsuarioIng, bita.CveEmpresa, CveTipoProcesoCRM:=bita.CveTipoProcesoCRM, CveAcercamientoCRM:=CveAcercamiento, CveEtapaProcesoCRM:=bita.CveEtapaProcesoCRM)
|
|
If TieneError Then
|
|
Exit For
|
|
End If
|
|
Next
|
|
Else
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
|
|
End If
|
|
If TieneError Then
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
End If
|
|
Else 'CREAR UN NUEVA EMPRESA
|
|
TieneError = Not ObjDatosTecnicos.AddEncuestaAplicada(Ent.CveEncuestaCRM, -1, -1, Ent.EmpresaCRM.CveUsuarioIng, Ent.EmpresaCRM.CveEmpresa)
|
|
If Not TieneError Then
|
|
Dim CveEncuestaAplicada = ObjDatosTecnicos.DtResultados.Rows(0)(0).ToString().ToEntero()
|
|
If CveEncuestaAplicada > 0 Then
|
|
For Each Resp In Ent.Respuestas
|
|
If Not ObjDatosTecnicos.AddEncuestaAplicadaDetalle(CveEncuestaAplicada, Resp.CvePregunta, Resp.CveRespuesta, Resp.Valor) Then
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
If Not TieneError Then
|
|
Dim CveEmpresaCRM As Integer = ObjCRM.AddEmpresaCRM(Ent.EmpresaCRM.Empresa, Ent.EmpresaCRM.RFC, Ent.EmpresaCRM.CveMedioCaptacion, Ent.EmpresaCRM.CveEmpresa, Ent.EmpresaCRM.CveUsuarioIng, CveEncuestaAplicada, Ent.EmpresaCRM.CveVendedorAsignado)
|
|
If CveEmpresaCRM > 0 Then
|
|
Mensaje = String.Format("Se registró la empresa {0} con datos RFC: {1}, Vendedor: {2}", Ent.EmpresaCRM.Empresa, Ent.EmpresaCRM.RFC, Ent.EmpresaCRM.Vendedor)
|
|
If Ent.EmpresaCRM.CveMedioCaptacion > 0 Then
|
|
Mensaje = Mensaje & String.Format(", Medio de Captación: {0}", Ent.EmpresaCRM.MedioCaptacion)
|
|
End If
|
|
If Ent.Contactos.Count > 0 Then
|
|
Mensaje = Mensaje & " y Contactos: "
|
|
Dim i = 1
|
|
For Each Cont In Ent.Contactos
|
|
If Not ObjCRM.AddContactoEmpresa(Cont.Nombre, Cont.TelefonoOficina, Cont.Celular, Cont.Correo, CveEmpresaCRM, Cont.CveUsuarioIng) Then
|
|
TieneError = True
|
|
Exit For
|
|
Else
|
|
i = i + 1
|
|
Mensaje = Mensaje & Cont.Nombre & If(i = Ent.Contactos.Count, "", ", ")
|
|
End If
|
|
Next
|
|
End If
|
|
If Ent.Acercamientos.Count > 0 Then
|
|
If Not TieneError Then
|
|
For Each item In Ent.Acercamientos
|
|
If item.CveAcercamiento > 0 Then
|
|
TieneError = Not ObjCRM.UpdateAcercamiento(item.CveAcercamiento, item.CveContactoPrincipal, item.CveTipoProceso, item.CveEtapaProcesoActual, item.CveVendedor, item.CveMedioCaptacion, item.CveProbabilidadAcercamiento, item.NombreAcercamiento, item.Descripcion, item.Importe, item.Comision, item.Prioridad, item.CveUsuarioMod, item.CveRechazoMotivo, item.CveEncuestaAplicadaProceso, item.FechaApertura, item.FechaCierre)
|
|
Else
|
|
Dim CveAcercamiento As Integer = ObjCRM.AddAcercamiento(CveEmpresaCRM, item.CveContactoPrincipal, item.CveTipoProceso, item.CveEtapaProcesoActual, item.CveVendedor, item.CveMedioCaptacion, item.CveRechazoMotivo, item.CveProbabilidadAcercamiento, item.FechaApertura, item.NombreAcercamiento, item.Descripcion, item.Importe, item.Comision, item.Prioridad, item.CveEmpresa, item.CveUsuarioIng, item.FechaCierre)
|
|
|
|
If CveAcercamiento > 0 Then
|
|
Dim bitacoras = Ent.BitacorasAcercamientos.Where(Function(x) x.IDTempCveAcercamiento = item.IDTemp)
|
|
|
|
For Each bita In bitacoras
|
|
TieneError = Not ObjBitacora.AddEventoBitacora(bita.Descripcion, "", bita.CveUsuarioIng, bita.CveEmpresa, CveTipoProcesoCRM:=bita.CveTipoProcesoCRM, CveAcercamientoCRM:=CveAcercamiento, CveEtapaProcesoCRM:=bita.CveEtapaProcesoCRM)
|
|
If TieneError Then
|
|
Exit For
|
|
End If
|
|
Next
|
|
Else
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
|
|
End If
|
|
If TieneError Then
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
If Not TieneError Then
|
|
TieneError = Not ObjBitacora.AddEventoBitacora(Mensaje, "", Ent.EmpresaCRM.CveUsuarioIng, Ent.EmpresaCRM.CveEmpresa, CveEmpresaCRM:=CveEmpresaCRM)
|
|
End If
|
|
End If
|
|
End If
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
TieneError = True
|
|
OnError("Ocurrió un error al sincronizar los contactos", ex)
|
|
Finally
|
|
If TieneError Then
|
|
ObjCRM.RollBack()
|
|
Else
|
|
ObjCRM.Commit()
|
|
End If
|
|
ObjCRM.Dispose()
|
|
ObjDatosTecnicos.Dispose()
|
|
ObjBitacora.Dispose()
|
|
End Try
|
|
Return Not TieneError
|
|
End Function
|
|
<WebMethod>
|
|
Public Function SyncContactos(params As String) As Boolean
|
|
Dim TieneError As Boolean = False
|
|
Dim Estructura = CreateListFromSingle(New With {.CveContacto = -1, .Nombre = "", .TelefonoOficina = "", .Celular = "", .Correo = "", .CveUsuarioIng = -1, .CveEmpresaCRM = -1})
|
|
Dim ObjCRM As New ClsCRM
|
|
ObjCRM.IniciaTransacSQL()
|
|
Try
|
|
Dim JsonRequest = Decripta(params)
|
|
Dim Contactos = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
For Each item In Contactos
|
|
If item.CveContacto > 0 Then
|
|
TieneError = Not ObjCRM.UpdateContactoEmpresa(item.Nombre, item.TelefonoOficina, item.Celular, item.Correo, item.CveContacto, item.CveUsuarioIng)
|
|
Else
|
|
TieneError = Not ObjCRM.AddContactoEmpresa(item.Nombre, item.TelefonoOficina, item.Celular, item.Correo, item.CveEmpresaCRM, item.CveUsuarioIng)
|
|
End If
|
|
If TieneError Then
|
|
Exit For
|
|
End If
|
|
Next
|
|
Catch ex As Exception
|
|
TieneError = True
|
|
OnError("Ocurrió un error al sincronizar los contactos", ex)
|
|
Finally
|
|
If TieneError Then
|
|
ObjCRM.RollBack()
|
|
Else
|
|
ObjCRM.Commit()
|
|
End If
|
|
ObjCRM.Dispose()
|
|
End Try
|
|
Return Not TieneError
|
|
End Function
|
|
<WebMethod>
|
|
Public Function SyncAcercamiento(params As String) As Boolean
|
|
Dim TieneError As Boolean = False
|
|
Dim Estructura = CreateListFromSingle(New With {.CveAcercamiento = -1, .CveEmpresaCRM = -1, .CveContactoPrincipal = -1, .CveTipoProceso = -1, .CveEtapaProcesoActual = -1, .CveVendedor = -1, .CveMedioCaptacion = -1, .CveRechazoMotivo = -1, .CveProbabilidadAcercamiento = -1, .FechaApertura = Now, .NombreAcercamiento = "", .Descripcion = "", .Importe = 0D, .Comision = 0D, .Prioridad = -1, .CveEmpresa = -1, .CveUsuarioIng = -1, .CveUsuarioMod = -1, .FechaCierre = Now, .CveEncuestaAplicadaProceso = -1})
|
|
Dim ObjCRM As New ClsCRM
|
|
Try
|
|
Dim JsonRequest = Decripta(params)
|
|
Dim Acercamientos = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
For Each item In Acercamientos
|
|
If item.CveAcercamiento > 0 Then
|
|
TieneError = Not ObjCRM.UpdateAcercamiento(item.CveAcercamiento, item.CveContactoPrincipal, item.CveTipoProceso, item.CveEtapaProcesoActual, item.CveVendedor, item.CveMedioCaptacion, item.CveProbabilidadAcercamiento, item.NombreAcercamiento, item.Descripcion, item.Importe, item.Comision, item.Prioridad, item.CveUsuarioMod, item.CveRechazoMotivo, item.CveEncuestaAplicadaProceso, item.FechaApertura, item.FechaCierre)
|
|
Else
|
|
TieneError = Not ObjCRM.AddAcercamiento(item.CveEmpresaCRM, item.CveContactoPrincipal, item.CveTipoProceso, item.CveEtapaProcesoActual, item.CveVendedor, item.CveMedioCaptacion, item.CveRechazoMotivo, item.CveProbabilidadAcercamiento, item.FechaApertura, item.NombreAcercamiento, item.Descripcion, item.Importe, item.Comision, item.Prioridad, item.CveEmpresa, item.CveUsuarioIng, item.FechaCierre)
|
|
End If
|
|
If TieneError Then
|
|
Exit For
|
|
End If
|
|
Next
|
|
Catch ex As Exception
|
|
TieneError = True
|
|
OnError("Ocurrió un error al sincronizar los acercamientos", ex)
|
|
Finally
|
|
ObjCRM.Dispose()
|
|
End Try
|
|
Return Not TieneError
|
|
End Function
|
|
<WebMethod>
|
|
Public Function SyncBitacoras(params As String) As Boolean
|
|
Dim TieneError As Boolean = False
|
|
Dim Estructura = CreateListFromSingle(New With {.CveEvento = -1, .Base64Archivo = "", .Archivo = "", .Descripcion = "", .CveTipoProcesoCRM = -1, .CveEmpresa = -1, .CveUsuarioIng = -1, .CveAcercamientoCRM = -1, .CveEtapaProcesoCRM = -1})
|
|
Dim ObjBitacora As New ClsOIEventos
|
|
Try
|
|
Dim Acercamientos = JsonConvert.DeserializeAnonymousType(params, Estructura)
|
|
For Each item In Acercamientos
|
|
If item.CveAcercamientoCRM > 0 Then
|
|
Dim FileExtension = ""
|
|
If Not String.IsNullOrEmpty(item.Archivo) Then
|
|
FileExtension = System.IO.Path.GetExtension(item.Archivo)
|
|
End If
|
|
|
|
TieneError = Not ObjBitacora.AddEventoBitacora(item.Descripcion, FileExtension, item.CveUsuarioIng, item.CveEmpresa, CveTipoProcesoCRM:=item.CveTipoProcesoCRM, CveAcercamientoCRM:=item.CveAcercamientoCRM, CveEtapaProcesoCRM:=item.CveEtapaProcesoCRM)
|
|
|
|
If TieneError Then
|
|
Exit For
|
|
Else
|
|
If Not String.IsNullOrEmpty(FileExtension) Then
|
|
Dim Directorio As String = String.Format("{0}\Empresas\{1}\OI\OI{2}{3}", ModExtensiones.DirectorioBaseEmpresas, item.CveEmpresa, ObjBitacora.CveEvento.ToString(), FileExtension)
|
|
File.WriteAllBytes(Directorio, Convert.FromBase64String(item.Base64Archivo))
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
Catch ex As Exception
|
|
TieneError = True
|
|
OnError("Ocurrió un error al sincronizar las bitacoras", ex)
|
|
Finally
|
|
ObjBitacora.Dispose()
|
|
End Try
|
|
Return Not TieneError
|
|
End Function
|
|
<WebMethod>
|
|
Public Function SyncBitacoraArchivo(params As String) As Boolean
|
|
Dim TieneError As Boolean = False
|
|
Dim Estructura = New With {.CveEvento = -1, .Base64Archivo = "", .Archivo = "", .Descripcion = "", .CveTipoProcesoCRM = -1, .CveEmpresa = -1, .CveUsuarioIng = -1, .CveAcercamientoCRM = -1, .CveEtapaProcesoCRM = -1}
|
|
Dim ObjBitacora As New ClsOIEventos
|
|
Try
|
|
Dim item = JsonConvert.DeserializeAnonymousType(params, Estructura)
|
|
If item.CveAcercamientoCRM > 0 Then
|
|
Dim FileExtension = ""
|
|
If Not String.IsNullOrEmpty(item.Archivo) Then
|
|
FileExtension = System.IO.Path.GetExtension(item.Archivo)
|
|
End If
|
|
|
|
TieneError = Not ObjBitacora.AddEventoBitacora(item.Descripcion, FileExtension, item.CveUsuarioIng, item.CveEmpresa, CveTipoProcesoCRM:=item.CveTipoProcesoCRM, CveAcercamientoCRM:=item.CveAcercamientoCRM, CveEtapaProcesoCRM:=item.CveEtapaProcesoCRM)
|
|
|
|
If Not TieneError Then
|
|
If Not String.IsNullOrEmpty(FileExtension) Then
|
|
Dim Directorio As String = String.Format("{0}\Empresas\{1}\OI\OI{2}{3}", ModExtensiones.DirectorioBaseEmpresas, item.CveEmpresa, ObjBitacora.CveEvento.ToString(), FileExtension)
|
|
File.WriteAllBytes(Directorio, Convert.FromBase64String(item.Base64Archivo))
|
|
End If
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
TieneError = True
|
|
OnError("Ocurrió un error al sincronizar las bitacoras", ex)
|
|
Finally
|
|
ObjBitacora.Dispose()
|
|
End Try
|
|
Return Not TieneError
|
|
End Function
|
|
<WebMethod>
|
|
Public Function AddImagenAcercamiento(params As String) As Boolean
|
|
Dim TieneError As Boolean = False
|
|
Dim Estructura = New With {.Base64Archivo = "", .Archivo = "", .Titulo = "", .Descripcion = "", .CveEmpresaCRM = -1, .CveEmpresa = -1, .CveUsuarioIng = -1, .CveAcercamiento = -1}
|
|
Dim ObjBitacora As New ClsCRM
|
|
ObjBitacora.IniciaTransacSQL()
|
|
Try
|
|
Dim item = JsonConvert.DeserializeAnonymousType(params, Estructura)
|
|
If item.CveAcercamiento > 0 Then
|
|
Dim FileExtension = ""
|
|
If Not String.IsNullOrEmpty(item.Archivo) Then
|
|
FileExtension = System.IO.Path.GetExtension(item.Archivo)
|
|
End If
|
|
Dim CveArchivo As Integer = ObjBitacora.AddImagenAcercamiento("", item.Titulo, item.Descripcion, item.CveUsuarioIng, item.CveEmpresaCRM, item.CveAcercamiento, item.CveEmpresa)
|
|
If CveArchivo > 0 Then
|
|
If Not String.IsNullOrEmpty(FileExtension) Then
|
|
Dim Archivo As String = String.Format("{0}{1}", CveArchivo, FileExtension)
|
|
Dim Directorio As String = String.Format("{0}\Empresas\{1}\Acercamientos\{2}\Imagenes\", ModExtensiones.DirectorioBaseEmpresas, item.CveEmpresa, item.CveAcercamiento)
|
|
If Not Directory.Exists(Directorio) Then
|
|
Directory.CreateDirectory(Directorio)
|
|
End If
|
|
File.WriteAllBytes(String.Format("{0}{1}", Directorio, Archivo), Convert.FromBase64String(item.Base64Archivo))
|
|
If Not ObjBitacora.UpdateImagenAcercamiento(CveArchivo, Archivo, item.Titulo, item.Descripcion) Then
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
TieneError = True
|
|
OnError("Ocurrió un error al sincronizar las bitacoras", ex)
|
|
Finally
|
|
If TieneError Then
|
|
ObjBitacora.RollBack()
|
|
Else
|
|
ObjBitacora.Commit()
|
|
End If
|
|
ObjBitacora.Dispose()
|
|
End Try
|
|
Return Not TieneError
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetTareas(CveEmpresa As Integer, CveUsuario As Integer, FechaI As DateTime, FechaF As DateTime, PorHacer As Boolean, Asigne As Boolean) As String
|
|
Dim Retorno = "[]"
|
|
Dim ObjProspectos As New ClsOIEventos
|
|
Dim CveEventoEstatus As Integer = -1
|
|
If ObjProspectos.GetRepEventos(-1, 1, -1, "-1", "-1", -1, -1, -1, 1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, CveUsuario, CveEmpresa, FechaI, FechaF) Then
|
|
Dim DT As DataTable = ObjProspectos.DtResultados.Clone
|
|
If PorHacer Then DT.Merge(ObjProspectos.DtResultados.FiltraParametros(String.Format("CveUsuarioPara = {0} ", CveUsuario)))
|
|
If Asigne Then DT.Merge(ObjProspectos.DtResultados.FiltraParametros(String.Format("CveUsuarioDe = {0} ", CveUsuario)))
|
|
Retorno = DT.ToJson()
|
|
End If
|
|
ObjProspectos.Dispose()
|
|
Return Retorno
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetTiposAgenda() As String
|
|
Dim Retorno = "[]"
|
|
Dim ObjEventos As New ClsOIEventos
|
|
If ObjEventos.GetAgendaTipo() Then
|
|
Retorno = ObjEventos.DtResultados.ToJson()
|
|
End If
|
|
ObjEventos.Dispose()
|
|
Return Retorno
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetDatosTecnicos(CveEncuestaCRM As Integer, CveEncuestaAplicada As Integer, CveEmpresa As Integer) As String
|
|
Dim json As New JObject
|
|
Dim ObjEncuestas As New ClsEncuestas
|
|
If ObjEncuestas.GetRespuestas(CveEncuestaCRM) Then
|
|
json.Add(New JProperty("Respuestas", JArray.Parse(ObjEncuestas.DtResultados.ToJson())))
|
|
End If
|
|
If ObjEncuestas.GetDatosTecnicosEmpresaCRM(CveEncuestaCRM, CveEncuestaAplicada, CveEmpresa) Then
|
|
json.Add(New JProperty("DatosTecnicos", JArray.Parse(ObjEncuestas.DtResultados.ToJson())))
|
|
End If
|
|
ObjEncuestas.Dispose()
|
|
Return json.ToString()
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetEventos(CveEmpresa As Integer, CveUsuario As Integer, FechaI As DateTime, FechaF As DateTime) As String
|
|
Dim Retorno = "[]"
|
|
Dim Eventos = GetEventosCalendario(CveUsuario, CveEmpresa, FechaI, FechaF)
|
|
If Eventos IsNot Nothing AndAlso Eventos.Count > 0 Then
|
|
Retorno = JsonConvert.SerializeObject(Eventos)
|
|
End If
|
|
Return Retorno
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetAcercamientos(CveEmpresa As Integer, CveEmpresaCRM As Integer, CveAcercamiento As Integer, CveTipoProceso As Integer, CveVendedor As Integer) As String
|
|
Dim Retorno = "[]"
|
|
Using ObjCRM As New ClsCRM
|
|
If ObjCRM.GetAcercamiento(CveEmpresa, CveEmpresaCRM, CveAcercamiento, CveTipoProceso, CveVendedor) Then
|
|
Retorno = ObjCRM.DtResultados.ToJson()
|
|
End If
|
|
End Using
|
|
Return Retorno
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetEtapasProceso(CveEmpresa As Integer, CveTipoProceso As Integer, CveEtapaProceso As Integer, CveEstatus As Integer) As String
|
|
Dim Retorno = "[]"
|
|
Using ObjCRM As New ClsCRM
|
|
If ObjCRM.GetEtapaProceso(CveEmpresa, CveTipoProceso, CveEtapaProceso, CveEstatus) Then
|
|
Retorno = ObjCRM.DtResultados.ToJson()
|
|
End If
|
|
End Using
|
|
Return Retorno
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetBitacorasAcercamiento(CveEmpresa As Integer, CveUsuario As Integer, CveAcercamiento As Integer) As String
|
|
Dim Retorno = "[]"
|
|
Using ObjCRM As New ClsOIEventos
|
|
If ObjCRM.GetAgendaBitacora(CveUsuario, CveEmpresa, CveAcercamientoCRM:=CveAcercamiento) Then
|
|
Retorno = ObjCRM.DtResultados.ToJson()
|
|
End If
|
|
End Using
|
|
Return Retorno
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetTiposProceso(CveEmpresa As Integer, CveEstatus As Integer) As String
|
|
Dim Retorno = "[]"
|
|
Using ObjCRM As New ClsCRM
|
|
If ObjCRM.GetTipoProceso(CveEmpresa, CveEstatus) Then
|
|
Retorno = ObjCRM.DtResultados.ToJson()
|
|
End If
|
|
End Using
|
|
Return Retorno
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetVendedores(CveEmpresa As Integer) As String
|
|
Dim Retorno = "[]"
|
|
Try
|
|
Retorno = GlobalDTVendedores(CveEmpresa).ToJson()
|
|
Catch ex As Exception
|
|
OnError("Ocurrió un error al obtener los vendedores.", ex)
|
|
End Try
|
|
Return Retorno
|
|
End Function
|
|
Public Function AddEmpresaCRM(params As String) As String
|
|
Dim Retorno As String = "[]"
|
|
Dim Estructura = New With
|
|
{
|
|
.CveEmpresa = -1,
|
|
.CveUsuario = -1,
|
|
.NombreEmpresa = "",
|
|
.RFC = "",
|
|
.CveMedioCaptacion = -1,
|
|
.CveEncuestaAplicada = -1,
|
|
.CveVendedorActualizar = -1,
|
|
.MedioCaptacion = "",
|
|
.Vendedor = "",
|
|
.Conctactos = CreateListFromSingle(New With {.NombreContacto = "", .TelefonoOficina = "", .Celular = "", .Correo = ""})
|
|
}
|
|
Dim CveEmpresaCRM As Integer = -1
|
|
Dim Mensaje As String = ""
|
|
Dim TieneError As Boolean = False
|
|
Dim ObjCRM As New ClsCRM
|
|
Dim ObjBitacora As New ClsOIEventos(ObjCRM.IniciaTransacSQL())
|
|
|
|
Try
|
|
Dim JsonRequest = Decripta(params)
|
|
Dim Ent = JsonConvert.DeserializeAnonymousType(JsonRequest, Estructura)
|
|
|
|
CveEmpresaCRM = ObjCRM.AddEmpresaCRM(Ent.NombreEmpresa, Ent.RFC, Ent.CveMedioCaptacion, Ent.CveEmpresa, Ent.CveUsuario, Ent.CveEncuestaAplicada, Ent.CveVendedorActualizar)
|
|
|
|
If CveEmpresaCRM > 0 Then
|
|
Mensaje = String.Format("Se registró la empresa {0} con datos RFC: {1}, Vendedor: {2}", Ent.NombreEmpresa, Ent.RFC, Ent.Vendedor)
|
|
If Ent.CveMedioCaptacion > 0 Then
|
|
Mensaje = Mensaje & String.Format(", Medio de Captación: {0}", Ent.MedioCaptacion)
|
|
End If
|
|
Dim numContactos = Ent.Conctactos.Count
|
|
If numContactos > 0 Then
|
|
Mensaje = Mensaje & " y Contactos: "
|
|
Dim i As Integer = 1
|
|
For Each Con In Ent.Conctactos
|
|
TieneError = Not ObjCRM.AddContactoEmpresa(Con.NombreContacto, Con.TelefonoOficina, Con.Celular, Con.Correo, CveEmpresaCRM, Ent.CveUsuario)
|
|
If Not TieneError Then
|
|
Mensaje = Mensaje & Con.NombreContacto & If(i = numContactos, "", ", ")
|
|
End If
|
|
i = i + 1
|
|
Next
|
|
End If
|
|
|
|
If Not TieneError Then
|
|
TieneError = Not ObjBitacora.AddEventoBitacora(Mensaje, "", Ent.CveUsuario, Ent.CveEmpresa, CveEmpresaCRM:=CveEmpresaCRM)
|
|
End If
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrió un error al agregar la empresa", ex)
|
|
Finally
|
|
If Not TieneError Then
|
|
ObjCRM.Commit()
|
|
Else
|
|
ObjCRM.RollBack()
|
|
End If
|
|
ObjCRM.Dispose()
|
|
ObjBitacora.Dispose()
|
|
|
|
Dim Datos = New With {
|
|
.CveEmpresa = CveEmpresaCRM,
|
|
.Mensaje = Mensaje
|
|
}
|
|
Retorno = JsonConvert.SerializeObject(Datos)
|
|
End Try
|
|
Return Retorno
|
|
|
|
End Function
|
|
|
|
Private Function GetEventosCalendario(CveUsuario As Integer, CveEmpresa As Integer, pFI As Date, pFF As Date) As List(Of CalendarEvent)
|
|
Dim Events = New List(Of CalendarEvent)
|
|
Dim ObjEventos As New ClsOIEventos
|
|
Dim ErrorEventos = False
|
|
If ObjEventos.GetEventos(-1, -1, -1, "-1", "-1", -1, CveUsuario, CveUsuario, -1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, CveUsuario, CveUsuario, CveUsuario, CveEmpresa, pFI, pFF) Then
|
|
If ObjEventos.DtResultados.Rows.Count > 0 Then
|
|
Events = New List(Of CalendarEvent)
|
|
Try
|
|
For Each dr As DataRow In ObjEventos.DtResultados.Rows
|
|
Dim cevent As CalendarEvent = New CalendarEvent()
|
|
cevent.id = dr("CveEvento").ToString.ToEntero
|
|
cevent.title = dr("Asunto").ToString
|
|
cevent.description = dr("Descripcion").ToString
|
|
cevent.start = String.Format("{0:s}", dr("FechaInicio").ToString.ToDateTime)
|
|
cevent.end = String.Format("{0:s}", dr("FechaFin").ToString.ToDateTime)
|
|
cevent.allDay = False
|
|
cevent.CveEventoEstatus = dr("CveEventoEstatus").ToString.ToEntero
|
|
cevent.cveagendatipo = dr("CveAgendaTipo").ToString
|
|
cevent.prioridad = dr("CvePrioridad").ToString.ToEntero
|
|
cevent.backgroundColor = dr("BackGroundColor").ToString
|
|
cevent.recurrenciatipo = dr("RecurrenciaTipo").ToString.ToEntero
|
|
cevent.frecuencia = dr("Frecuencia").ToString.ToEntero
|
|
cevent.diassemana = dr("DiasSemana").ToString
|
|
cevent.dia = dr("Dia").ToString.ToEntero
|
|
cevent.mes = dr("Mes").ToString.ToEntero
|
|
cevent.recurrenciafin = dr("RecurrenciaFin").ToString
|
|
cevent.CveProspecto = dr("CveProspecto").ToString.ToEntero
|
|
cevent.Prospecto = dr("Prospecto").ToString
|
|
cevent.CveTipoEvento = dr("Prospecto").ToString.ToEntero
|
|
|
|
'11/05/2018 - Evento Gasto Recurrente
|
|
cevent.CveTipoEvento = dr("CveTipoEvento").ToString.ToEntero
|
|
If cevent.CveTipoEvento = 10 Then
|
|
cevent.Importe = dr("Importe").ToString.ToDouble
|
|
End If
|
|
|
|
If cevent.CveEventoEstatus.ToString.ToEntero = 3 Then
|
|
cevent.backgroundColor = "#1BBC9B"
|
|
End If
|
|
|
|
'VERIFICAMOS SI TIENE O NO RECURRENCIA
|
|
If Not cevent.recurrenciatipo > 0 Then
|
|
|
|
'AGREGAMOS CUANDO NO ES RECURRENTE
|
|
Dim tFecha As DateTime = DateAdd(DateInterval.Month, -6, Date.Now)
|
|
'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL NO LO AGREGA
|
|
If dr("FechaFin").ToString.ToDateTime > tFecha Or dr("FechaInicio").ToString.ToDateTime > tFecha Then
|
|
Events.Add(cevent)
|
|
End If
|
|
Else
|
|
|
|
'EMPIEZA METODO PARA AGREGAR CUANDO SI ES RECURRENTE
|
|
|
|
Dim FinRecurrencia = cevent.recurrenciafin.ToEntero
|
|
Dim FI As DateTime, FF As DateTime, FT As DateTime
|
|
Dim DiasSemana = cevent.diassemana.Split(","c)
|
|
FI = cevent.start.ToDateTime
|
|
FF = cevent.end.ToDateTime
|
|
|
|
'OBTENEMOS LA FECHA TERMINO (FT) DE LA RECURRENCIA
|
|
Select Case FinRecurrencia
|
|
Case -1
|
|
FT = DateAdd(DateInterval.Year, 2, dr("FechaInicio").ToString.ToDateTime)
|
|
Case 0
|
|
FT = dr("RecurrenciaFin").ToString.ToDate
|
|
Case Is > 0
|
|
FinRecurrencia -= 1
|
|
Select Case cevent.recurrenciatipo
|
|
Case 1
|
|
FT = DateAdd(DateInterval.Hour, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
|
|
Case 2
|
|
FT = DateAdd(DateInterval.Day, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
|
|
Case 3
|
|
FT = DateAdd(DateInterval.WeekOfYear, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
|
|
FT = DateAdd(DateInterval.Day, (7 - Weekday(FT)).ToString.ToDouble, FT)
|
|
Case 4
|
|
FT = DateAdd(DateInterval.Month, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
|
|
Case 5
|
|
FT = DateAdd(DateInterval.Year, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
|
|
End Select
|
|
End Select
|
|
|
|
'SI ES TIPO SEMANAL Y DIASSEMANA TIENE VALORES CHECKEA ESTOS VALORES
|
|
Do
|
|
If DiasSemana.Length > 0 AndAlso DiasSemana(0) <> "" Then
|
|
For Each drDias As String In DiasSemana
|
|
Dim FIT = FI, FFT = FF
|
|
|
|
FIT = DateAdd(DateInterval.Day, (drDias.ToEntero - Weekday(FI)).ToString.ToDouble, FI)
|
|
FFT = DateAdd(DateInterval.Day, (drDias.ToEntero - Weekday(FF)).ToString.ToDouble, FF)
|
|
|
|
cevent = New CalendarEvent()
|
|
cevent.id = dr("CveEvento").ToString.ToEntero
|
|
cevent.title = dr("Asunto").ToString
|
|
cevent.description = dr("Descripcion").ToString
|
|
cevent.start = String.Format("{0:s}", FIT)
|
|
cevent.end = String.Format("{0:s}", FFT)
|
|
cevent.allDay = False
|
|
cevent.CveEventoEstatus = dr("CveEventoEstatus").ToString.ToEntero
|
|
cevent.cveagendatipo = dr("CveAgendaTipo").ToString
|
|
cevent.prioridad = dr("CvePrioridad").ToString.ToEntero
|
|
cevent.backgroundColor = dr("BackGroundColor").ToString
|
|
|
|
cevent.recurrenciatipo = dr("RecurrenciaTipo").ToString.ToEntero
|
|
cevent.frecuencia = dr("Frecuencia").ToString.ToEntero
|
|
cevent.diassemana = dr("DiasSemana").ToString
|
|
cevent.dia = dr("Dia").ToString.ToEntero
|
|
cevent.mes = dr("Mes").ToString.ToEntero
|
|
cevent.recurrenciafin = dr("RecurrenciaFin").ToString
|
|
cevent.CveProspecto = dr("CveProspecto").ToString.ToEntero
|
|
cevent.Prospecto = dr("Prospecto").ToString
|
|
|
|
'11/05/2018 - Evento Gasto Recurrente
|
|
cevent.CveTipoEvento = dr("CveTipoEvento").ToString.ToEntero
|
|
If cevent.CveTipoEvento = 10 Then
|
|
cevent.Importe = dr("Importe").ToString.ToDouble
|
|
End If
|
|
|
|
If cevent.CveEventoEstatus.ToString.ToEntero = 3 Then
|
|
cevent.backgroundColor = "#1BBC9B"
|
|
End If
|
|
|
|
'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL Y/0 SI LA FECHA INICIAL DE LA RECURRENCIA ES MENOR A LA FECHA QUE SE CREO EL EVENTO NO LO AGREGA
|
|
If FIT > DateAdd(DateInterval.Month, -6, Date.Now) And FIT >= dr("FechaInicio").ToString.ToDateTime Then
|
|
Events.Add(cevent)
|
|
End If
|
|
Next
|
|
Else
|
|
cevent = New CalendarEvent()
|
|
cevent.id = dr("CveEvento").ToString.ToEntero
|
|
cevent.title = dr("Asunto").ToString
|
|
cevent.description = dr("Descripcion").ToString
|
|
cevent.start = String.Format("{0:s}", FI)
|
|
cevent.end = String.Format("{0:s}", FF)
|
|
cevent.allDay = False
|
|
cevent.CveEventoEstatus = dr("CveEventoEstatus").ToString.ToEntero
|
|
cevent.cveagendatipo = dr("CveAgendaTipo").ToString
|
|
cevent.prioridad = dr("CvePrioridad").ToString.ToEntero
|
|
cevent.backgroundColor = dr("BackGroundColor").ToString
|
|
|
|
cevent.recurrenciatipo = dr("RecurrenciaTipo").ToString.ToEntero
|
|
cevent.frecuencia = dr("Frecuencia").ToString.ToEntero
|
|
cevent.diassemana = dr("DiasSemana").ToString
|
|
cevent.dia = dr("Dia").ToString.ToEntero
|
|
cevent.mes = dr("Mes").ToString.ToEntero
|
|
cevent.recurrenciafin = dr("RecurrenciaFin").ToString
|
|
cevent.CveProspecto = dr("CveProspecto").ToString.ToEntero
|
|
cevent.Prospecto = dr("Prospecto").ToString
|
|
|
|
'11/05/2018 - Evento Gasto Recurrente
|
|
cevent.CveTipoEvento = dr("CveTipoEvento").ToString.ToEntero
|
|
If cevent.CveTipoEvento = 10 Then
|
|
cevent.Importe = dr("Importe").ToString.ToDouble
|
|
End If
|
|
|
|
If cevent.CveEventoEstatus.ToString.ToEntero = 3 Then
|
|
cevent.backgroundColor = "#1BBC9B"
|
|
End If
|
|
|
|
'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL NO LO AGREGA
|
|
If FI > DateAdd(DateInterval.Month, -6, Date.Now) Then
|
|
Events.Add(cevent)
|
|
End If
|
|
End If
|
|
|
|
Select Case cevent.recurrenciatipo
|
|
Case 1
|
|
FI = DateAdd(DateInterval.Hour, cevent.frecuencia, FI)
|
|
FF = DateAdd(DateInterval.Hour, cevent.frecuencia, FF)
|
|
Case 2
|
|
FI = DateAdd(DateInterval.Day, cevent.frecuencia, FI)
|
|
FF = DateAdd(DateInterval.Day, cevent.frecuencia, FF)
|
|
Case 3
|
|
FI = DateAdd(DateInterval.WeekOfYear, cevent.frecuencia, FI)
|
|
FF = DateAdd(DateInterval.WeekOfYear, cevent.frecuencia, FF)
|
|
Case 4
|
|
FI = DateAdd(DateInterval.Month, cevent.frecuencia, FI)
|
|
FF = DateAdd(DateInterval.Month, cevent.frecuencia, FF)
|
|
Case 5
|
|
FI = DateAdd(DateInterval.Year, cevent.frecuencia, FI)
|
|
FF = DateAdd(DateInterval.Year, cevent.frecuencia, FF)
|
|
End Select
|
|
|
|
Loop Until FI > FT
|
|
End If
|
|
Next
|
|
Catch ex As Exception
|
|
GuardaLog(ex.ToString())
|
|
End Try
|
|
End If
|
|
|
|
End If
|
|
ObjEventos.Dispose()
|
|
Return Events
|
|
End Function
|
|
|
|
<WebMethod>
|
|
Public Function GetRepAcercamientos(CveEmpresa As Integer, CveVendedor As Integer, FechaInicio As DateTime, FechaFin As DateTime) As String
|
|
Dim Retorno = "[]"
|
|
Using ObjCRM As New ClsCRM
|
|
If ObjCRM.GetAcercamiento(CveEmpresa, CveVendedor:=CveVendedor, FechaInicio:=FechaInicio, FechaFin:="-1") Then
|
|
Retorno = ObjCRM.DtResultados.DataTableToJSONIPP()
|
|
End If
|
|
End Using
|
|
Return Retorno
|
|
End Function
|
|
|
|
<WebMethod>
|
|
Public Function GetRepAcercamientosProcesos(CveEmpresa As Integer, AgrupadoPor As Integer, CveTipoProceso As Integer, CveVendedor As Integer, CveMedioCaptacion As Integer, CveProbabilidadAcercamiento As Integer, FechaInicio As DateTime, FechaFin As DateTime) As String
|
|
Dim Retorno As New JObject()
|
|
' <asp:ListItem Value = "-1" Text="Ninguno" Selected="True"></asp: ListItem>
|
|
' <asp:ListItem Value="1" Text="Vendedor"></asp:ListItem>
|
|
'<asp:ListItem Value = "2" Text="Medio Captacion"></asp: ListItem>
|
|
' <asp:ListItem Value="3" Text="Probabilidad de Acercamiento"></asp:ListItem>
|
|
'<asp:ListItem Value = "4" Text="Fecha"></asp: ListItem>
|
|
Dim idgrupo2 = -1
|
|
Dim FechaI = FechaInicio.ToString("yyyy/MM/dd")
|
|
Dim FechaF = FechaFin.ToString("yyyy/MM/dd")
|
|
|
|
Select Case AgrupadoPor
|
|
Case 1
|
|
Retorno("Agrupado") = "Vendedor"
|
|
Case 2
|
|
Retorno("Agrupado") = "Medio Captación"
|
|
Case 3
|
|
Retorno("Agrupado") = "Probabilidad de Acercamiento"
|
|
Case 4
|
|
Retorno("Agrupado") = "Fecha"
|
|
End Select
|
|
|
|
Using ObjCRM As New ClsCRM
|
|
If ObjCRM.RepAcercamientosEtapas(CveEmpresa, CveTipoProceso, AgrupadoPor, idgrupo2, FechaI, FechaF, CveVendedor, CveMedioCaptacion, cveProbabilidadAcercamiento) Then
|
|
Dim Reporte = JArray.Parse(ObjCRM.DSResultados.Tables(0).DataTableToJSONIPP())
|
|
Dim Etapas = JArray.Parse(ObjCRM.DSResultados.Tables(1).DataTableToJSONIPP())
|
|
|
|
Dim Visible1 As Boolean = Etapas.Any(Function(etapa) etapa("Orden").ToString().ToEntero() = 0)
|
|
Dim Visible2 As Boolean = Etapas.Any(Function(etapa) etapa("Orden").ToString().ToEntero() = 1)
|
|
Dim Visible3 As Boolean = Etapas.Any(Function(etapa) etapa("Orden").ToString().ToEntero() = 2)
|
|
Dim Visible4 As Boolean = Etapas.Any(Function(etapa) etapa("Orden").ToString().ToEntero() = 3)
|
|
Dim Visible5 As Boolean = Etapas.Any(Function(etapa) etapa("Orden").ToString().ToEntero() = 4)
|
|
Dim Visible6 As Boolean = Etapas.Any(Function(etapa) etapa("Orden").ToString().ToEntero() = 5)
|
|
|
|
For Each Rep As JObject In Reporte
|
|
Rep("Visible1") = Visible1
|
|
Rep("Visible2") = Visible2
|
|
Rep("Visible3") = Visible3
|
|
Rep("Visible4") = Visible4
|
|
Rep("Visible5") = Visible5
|
|
Rep("Visible6") = Visible6
|
|
Next
|
|
|
|
Retorno("Reporte") = Reporte
|
|
Retorno("Etapas") = Etapas
|
|
End If
|
|
|
|
End Using
|
|
|
|
Return Retorno.ToString()
|
|
End Function
|
|
<WebMethod>
|
|
Public Function GetRepAcercamientosRechazos(CveEmpresa As Integer, CveVendedor As Integer, FechaInicio As DateTime, FechaFin As DateTime) As String
|
|
Dim Retorno = "[]"
|
|
Dim cveTipoProceso = -1
|
|
Dim idgrupo1 = 1
|
|
Dim idgrupo2 = -1
|
|
Dim FechaI = FechaInicio.ToString("yyyy/MM/dd")
|
|
Dim FechaF = FechaFin.ToString("yyyy/MM/dd")
|
|
Dim cveMedioCaptacion = -1
|
|
Dim cveProbabilidadAcercamiento = -1
|
|
Using ObjCRM As New ClsCRM
|
|
If ObjCRM.RepAcercamientosEtapas(CveEmpresa, cveTipoProceso, idgrupo1, idgrupo2, FechaI, FechaF, CveVendedor, cveMedioCaptacion, cveProbabilidadAcercamiento) Then
|
|
Retorno = ObjCRM.DtResultados.DataTableToJSONIPP()
|
|
End If
|
|
End Using
|
|
Return Retorno
|
|
End Function
|
|
#End Region
|
|
|
|
<WebMethod()>
|
|
Public Function AddPosicion(CveUsuario As Integer, Fecha As DateTime, Latitud As String, Longitud As String) As Boolean
|
|
Dim retorno = False
|
|
Dim sb As New StringBuilder()
|
|
|
|
sb.Append("INSERT INTO [dbo].[Sis_UsuariosPosiciones]")
|
|
sb.Append(" ([CveUsuario]")
|
|
sb.Append(" ,[Fecha]")
|
|
sb.Append(" ,[Posicion]")
|
|
sb.Append(" ,[FechaIng])")
|
|
sb.Append(" VALUES")
|
|
sb.Append($" ({CveUsuario}")
|
|
sb.Append($" ,CAST('{Fecha.ToString("yyyy-MM-dd HH:mm:ss")}' AS DATETIME) ")
|
|
sb.Append($" ,geography::STPointFromText('{$"POINT({Longitud} {Latitud})"}',4326)")
|
|
sb.Append($" ,CAST('{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}' AS DATETIME))")
|
|
|
|
Using ObjInventarios As New ClsInventarios
|
|
retorno = ObjInventarios.GetQuery(sb.ToString)
|
|
End Using
|
|
Return retorno
|
|
End Function
|
|
|
|
<WebMethod>
|
|
Public Function TestNotificaciones(CveUsuario As Integer, Titulo As String, Mensaje As String, TipoNotificacion As Integer) As String
|
|
Dim Retorno = "[]"
|
|
Dim context = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext(Of MyHub)()
|
|
'Dim Conexiones = MyHub.idsfromCveUsuario(CveUsuario)
|
|
context.Clients.All.sendNotificacionERP(Titulo, Mensaje, TipoNotificacion)
|
|
'context.Clients.All.addToCampanita("warning", "adsad", "warning", "")
|
|
'ClsSisNotificaciones.SendNotificacionERP(CveUsuario, Titulo, Mensaje, TipoNotificacion)
|
|
Return Retorno
|
|
End Function
|
|
End Class
|
|
|
|
Namespace WebServiceAppModels
|
|
|
|
Public Class WSUSER
|
|
Public Property CveUsuario As Integer
|
|
Public Property Usuario As String
|
|
Public Property CveEmpresa As Integer
|
|
Public Property Procesos As List(Of String)
|
|
Public Property Empresas As List(Of WsEmpresa)
|
|
Public Property Modulos As List(Of WsModulos)
|
|
Public Property Nombre As String
|
|
Public Property CveRol As Integer
|
|
Public Property Rol As String
|
|
Public Property CveSubProyecto As Integer
|
|
Public Property Contrasenia As String
|
|
|
|
Public Property TienePermisoOC As Boolean
|
|
Public Property TienePermisoPS As Boolean
|
|
|
|
End Class
|
|
Public Class WsEmpresa
|
|
Public Property CveEmpresa As Integer
|
|
Public Property Empresa As String
|
|
Public Property CveEncuestaCRM As Integer
|
|
Public Property Tipo_CentroCosto As Integer
|
|
End Class
|
|
Public Class WSPersonal
|
|
Public Property CvePersonal As Integer
|
|
Public Property CodigoNombreCompleto As String
|
|
Public Property CveClienteAsignado As Integer
|
|
Public Property CveTurno As Integer
|
|
Public Property CveDepartamento As Integer
|
|
Public Property CvePuesto As Integer
|
|
Public Property CveSubProyecto As Integer
|
|
Public Property CveProyecto As Integer
|
|
End Class
|
|
Public Class WSAsistencia
|
|
Public Property CveSubProyecto As Integer
|
|
Public Property CvePersonal As Integer
|
|
Public Property CveCliente As Integer
|
|
Public Property FechaAsistencia As Date
|
|
Public Property CveAsistenciasInasistencias As Integer
|
|
Public Property PorcentajePago As Double
|
|
Public Property HorasDobles As Double
|
|
Public Property HorasTriples As Double
|
|
Public Property CveMotivoHoraExtra As Integer
|
|
Public Property Observacion As String
|
|
Public Property CveUsuario As Integer
|
|
Public Property CveEmpresa As Integer
|
|
End Class
|
|
Public Class WsModulos
|
|
Public Property CveModulo As Integer
|
|
Public Property CvePadre As Integer
|
|
Public Property CvePlataforma As Integer
|
|
Public Property Modulo As String
|
|
Public Property Liga As String
|
|
Public Property Estilo As String
|
|
End Class
|
|
|
|
Public Class WsRepOCGet
|
|
Public Property Tipo As String
|
|
Public Property CveEmpresa As Integer
|
|
Public Property CveProyecto As Integer
|
|
Public Property CveSubProyecto As Integer
|
|
Public Property CveEstatus As Integer
|
|
Public Property CveUsuario As Integer
|
|
Public Property CveCliente As Integer
|
|
Public Property TipoBusqueda As Integer
|
|
Public Property Tick As DateTime
|
|
|
|
End Class
|
|
|
|
Public Class WsOCGetRep
|
|
Public Property EsDelUsuario As Integer
|
|
Public Property CveOrdenCompra As Integer
|
|
Public Property CveEstatus As Integer
|
|
Public Property Estatus As String
|
|
Public Property Descripcion As String
|
|
Public Property MonAbreviatura As String
|
|
Public Property Justificacion As String
|
|
Public Property RequiereCotizacion As Integer
|
|
Public Property FechaIng As DateTime
|
|
Public Property Fecha As DateTime
|
|
Public Property CveEmpresa As Integer
|
|
Public Property CveCliente As Integer
|
|
Public Property Cliente As String
|
|
Public Property CodigoAF As String
|
|
Public Property Total As Decimal
|
|
Public Property CveProyecto As Integer
|
|
Public Property Proyecto As String
|
|
Public Property CveSubProyecto As Integer
|
|
Public Property SubProyecto As String
|
|
Public Property CveUsuario As Integer
|
|
Public Property Folio As String
|
|
Public Property Lugar As String
|
|
Public Property Proveedor As String
|
|
Public Property Solicito As String
|
|
|
|
End Class
|
|
Public Class WsOCGetRep2
|
|
Public Property EsDelUsuario As Integer
|
|
Public Property CveOrdenCompra As Integer
|
|
Public Property CveEstatus As Integer
|
|
Public Property Estatus As String
|
|
Public Property Descripcion As String
|
|
Public Property MonAbreviatura As String
|
|
Public Property Justificacion As String
|
|
Public Property RequiereCotizacion As Boolean
|
|
Public Property FechaIng As DateTime
|
|
Public Property Fecha As DateTime
|
|
Public Property CveEmpresa As Integer
|
|
Public Property CveCliente As Integer
|
|
Public Property Cliente As String
|
|
Public Property CodigoAF As String
|
|
Public Property Total As Decimal
|
|
Public Property CveProyecto As Integer
|
|
Public Property Proyecto As String
|
|
Public Property CveSubProyecto As Integer
|
|
Public Property SubProyecto As String
|
|
Public Property CveUsuario As Integer
|
|
Public Property Folio As String
|
|
'Nuevos Campos
|
|
Public Property Lugar As String
|
|
Public Property Proveedor As String
|
|
Public Property Solicito As String
|
|
Public Property NombreCorto As String
|
|
|
|
|
|
|
|
End Class
|
|
Public Class WsOCEstatus
|
|
Public Property CveEstatusUsuarios As Integer
|
|
Public Property CveEstatus As Integer
|
|
Public Property FechaIng As DateTime
|
|
Public Property CveUsuario As Integer
|
|
Public Property Nombre As String
|
|
Public Property EstatusActivo As Integer
|
|
Public Property CveSuperior As Integer
|
|
Public Property Superior As Integer
|
|
Public Property LimiteInferior As Integer
|
|
Public Property LimiteSuperior As Integer
|
|
Public Property Estatus As String
|
|
Public Property Tipo As String
|
|
Public Property CveEmpresa As Integer
|
|
Public Property TipoTermino As Integer
|
|
Public Property EstatusSiguiente As String
|
|
Public Property CveEstatusSiguiente As Integer
|
|
Public Property Nivel As Integer
|
|
Public Property CveSubProyecto As Integer
|
|
Public Property SubProyecto As String
|
|
Public Property CveProyecto As Integer
|
|
Public Property Proyecto As String
|
|
End Class
|
|
|
|
Public Class WsOCGet
|
|
Public Property CveOC As Integer
|
|
Public Property CveEmpresa As Integer
|
|
Public Property CveUsuario As Integer
|
|
Public Property Tick As DateTime
|
|
|
|
End Class
|
|
|
|
Public Class WsFiltroEvento
|
|
Public Property CveUsuario As Integer
|
|
Public Property CveEmpresa As Integer
|
|
Public Property CveActivoFijo As Integer
|
|
Public Property CveIE As Integer
|
|
Public Property CveProspecto As Integer
|
|
Public Property CveCliente As Integer
|
|
Public Property CveOS As Integer
|
|
Public Property CveOC As Integer
|
|
Public Property CvePersonal As Integer
|
|
Public Property CveProveedor As Integer
|
|
Public Property CveCompra As Integer
|
|
Public Property CveVenta As Integer
|
|
Public FechaI As DateTime
|
|
Public FechaF As DateTime
|
|
Public Tick As DateTime
|
|
End Class
|
|
Public Class WsHistorial
|
|
Public Property CveOrdenCompra As Integer
|
|
Public Property Fecha As DateTime
|
|
Public Property CveConceptoHistorialOrdenCompra As Integer
|
|
Public Property ConceptoHistorialOrdenCompra As String
|
|
Public Property ValorAnterior As String
|
|
Public Property ValorActual As String
|
|
Public Property CveUsuario As Integer
|
|
Public Property Usuario As String
|
|
|
|
End Class
|
|
Public Class WsHistorialEstatus
|
|
Public Property CveOrdenCompra As Integer
|
|
Public Property Fecha As DateTime
|
|
Public Property Estatus As String
|
|
Public Property CveUsuario As Integer
|
|
Public Property Usuario As String
|
|
End Class
|
|
Public Class WsProveedor
|
|
Public Property CveProveedor As Integer
|
|
Public Property Codigo As String
|
|
Public Property Estatus As String
|
|
Public Property CveEmpresa As Integer
|
|
Public Property RazonSocial As String
|
|
Public Property NombreComercial As String
|
|
Public Property RFC As String
|
|
Public Property Direccion As String
|
|
Public Property ContactoMail As String
|
|
Public Property CveUsuario As Integer
|
|
End Class
|
|
Public Class WsUnidadMedida
|
|
Public Property CvePS As Integer
|
|
Public Property UnidadBase As Boolean
|
|
Public Property Consec As Integer
|
|
Public Property Cantidad As Double
|
|
Public Property UnidadMedida As String
|
|
Public Property UM As String
|
|
Public Property Precio As Double
|
|
Public Property CveUM As Integer
|
|
Public Property CveUnidadMedida As Integer
|
|
End Class
|
|
Public Class WsFolio
|
|
Public Property CveFolio As Integer
|
|
Public Property FolioActual As String
|
|
End Class
|
|
Public Class WsMoneda
|
|
Public Property CveMoneda As Integer
|
|
Public Property Moneda As String
|
|
Public Property Abreviatura As String
|
|
Public Property AbreviaturaSAT As String
|
|
Public Property Estatus As String
|
|
|
|
End Class
|
|
Public Class WsSucursal
|
|
Public Property CveSucursal As Integer
|
|
Public Property Sucursal As String
|
|
End Class
|
|
Public Class WsCliente
|
|
Public Property CveCliente As Integer
|
|
Public Property Nombre As String
|
|
Public Property NombreComercial As String
|
|
Public Property NombreCorto As String
|
|
Public Property Direccion As String
|
|
Public Property Colonia As String
|
|
Public Property Ciudad As String
|
|
Public Property Localidad As String
|
|
Public Property Estado As String
|
|
Public Property RFC As String
|
|
Public Property CP As String
|
|
Public Property Mail As String
|
|
Public Property NotificarA As String
|
|
Public Property RetIVA As Decimal
|
|
Public Property RetISR As Decimal
|
|
Public Property CveEmpresa As Integer
|
|
Public Property CveSucursal As Integer
|
|
Public Property Sucursal As String
|
|
Public Property CveMetodoPago As Integer
|
|
Public Property SubProyecto As String
|
|
Public Property CveSubProyecto As Integer
|
|
|
|
End Class
|
|
Public Class WsVenta
|
|
Public Property CveVenta As Integer
|
|
Public Property TipoDocto As String
|
|
Public Property Folio As String
|
|
Public Property Fecha As DateTime
|
|
Public Property Total As Decimal
|
|
Public Property Sucursal As String
|
|
Public Property CveCliente As Integer
|
|
Public Property Nombre As String
|
|
Public Property EstatusFactura As String
|
|
Public Property Usuario As String
|
|
|
|
End Class
|
|
Public Class WsPromocion
|
|
Public Property CvePromocion As Integer
|
|
Public Property Promocion As String
|
|
Public Property FechaInicio As DateTime
|
|
Public Property FechaFin As DateTime
|
|
Public Property CveSucursal As Integer
|
|
Public Property Estatus As Boolean
|
|
Public Property CveVendedor As Integer
|
|
Public Property CveCliente As Integer
|
|
Public Property CveMoneda As Integer
|
|
Public Property CveEmpresa As Integer
|
|
|
|
Public Property CveUsuario As Integer
|
|
|
|
End Class
|
|
Public Class WsPromocionDetalle
|
|
Public Property PS As String
|
|
Public Property AplicaRestriccionTexto As String
|
|
Public Property AplicaRestriccion As Boolean
|
|
Public Property HoraInicio As DateTime
|
|
Public Property HoraFin As DateTime
|
|
Public Property AplicaLunes As Boolean
|
|
Public Property AplicaMartes As Boolean
|
|
Public Property AplicaMiercoles As Boolean
|
|
Public Property AplicaJueves As Boolean
|
|
Public Property AplicaViernes As Boolean
|
|
Public Property AplicaSabado As Boolean
|
|
Public Property AplicaDomingo As Boolean
|
|
Public Property CvePS As Integer
|
|
Public Property Promocion As Double
|
|
Public Property PUAnterior As Double
|
|
Public Property PUPromocion As Double
|
|
Public Property TipoPromocion As Integer
|
|
|
|
|
|
End Class
|
|
Public Class WsVendedor
|
|
Public Property CveVendedor As Integer
|
|
Public Property Promocion As String
|
|
Public Property CveEmpresa As Integer
|
|
End Class
|
|
Public Class WsMetodoPago
|
|
Public Property CveMetodoPago As Integer
|
|
Public Property ClaveSAT As String
|
|
Public Property MetodoPago As String
|
|
|
|
End Class
|
|
Public Class WsRepBancos
|
|
Public Property CveEmpresa As Integer
|
|
Public Property CveCuenta As Integer
|
|
Public Property CveBanco As Integer
|
|
Public Property Banco As String
|
|
Public Property NumCuenta As String
|
|
Public Property Moneda As String
|
|
Public Property CveMoneda As Integer
|
|
Public Property FechaInicio As String
|
|
Public Property FechaFin As String
|
|
Public Property Opcion As Integer
|
|
Public Property SaldoInicial As Integer
|
|
Public Property Cargos As Decimal
|
|
Public Property Abonos As Decimal
|
|
Public Property Saldo As Decimal
|
|
End Class
|
|
Public Class WsRepCxC
|
|
Public Property GPO As String
|
|
Public Property Saldo As Decimal
|
|
Public Property vencido_1_7 As Decimal
|
|
Public Property vencido_8_30 As Decimal
|
|
Public Property vencido_30_mas As Decimal
|
|
Public Property vencido As Decimal
|
|
Public Property por_vencer_0_7 As Decimal
|
|
Public Property por_vencer_8_14 As Decimal
|
|
Public Property por_vencer_15_30 As Decimal
|
|
Public Property por_vencer_30_mas As Decimal
|
|
Public Property por_vencer As Decimal
|
|
Public Property Total As Decimal
|
|
Public Property CveCliente As Integer
|
|
|
|
Public Property vencido_1_30 As Decimal
|
|
Public Property vencido_31_60 As Decimal
|
|
Public Property vencido_61_90 As Decimal
|
|
Public Property vencido_90_mas As Decimal
|
|
|
|
Public Property por_vencer_0_30 As Decimal
|
|
|
|
Public Property CveMoneda As Integer
|
|
Public Property Moneda As String
|
|
|
|
|
|
End Class
|
|
Public Class WsRepCxP
|
|
Public Property GPO As String
|
|
Public Property Saldo As Decimal
|
|
Public Property vencido_1_7 As Decimal
|
|
Public Property vencido_8_30 As Decimal
|
|
Public Property vencido_30_mas As Decimal
|
|
Public Property vencido As Decimal
|
|
Public Property por_vencer_0_7 As Decimal
|
|
Public Property por_vencer_8_14 As Decimal
|
|
Public Property por_vencer_15_30 As Decimal
|
|
Public Property por_vencer_30_mas As Decimal
|
|
Public Property por_vencer As Decimal
|
|
Public Property Total As Decimal
|
|
Public Property CveProveedor As Integer
|
|
|
|
Public Property CveMoneda As Integer
|
|
Public Property Moneda As String
|
|
End Class
|
|
Public Class WsRepPS
|
|
Public Property GPO As String
|
|
Public Property Total As Decimal
|
|
Public Property CveProyecto As Integer
|
|
Public Property CveSubProyecto As Integer
|
|
Public Property CveClasificacion As Integer
|
|
Public Property CveMoneda As Integer
|
|
Public Property Moneda As String
|
|
End Class
|
|
Public Class WsIndicador
|
|
Public Property TotalBancos As Double
|
|
Public Property CxCTotal As Double
|
|
Public Property CxPTotal As Double
|
|
|
|
End Class
|
|
Public Class WsTipoCambio
|
|
Public Property CveTipoCambio As Integer
|
|
Public Property TipoCambio As Double
|
|
Public Property Fecha As Date
|
|
|
|
End Class
|
|
|
|
Public Class WsMovimientosMensualesCuenta
|
|
Public Property total As Double
|
|
Public Property mes1 As Double
|
|
Public Property mes2 As Double
|
|
Public Property mes3 As Double
|
|
Public Property mes4 As Double
|
|
Public Property mes5 As Double
|
|
Public Property mes6 As Double
|
|
Public Property mes7 As Double
|
|
Public Property mes8 As Double
|
|
Public Property mes9 As Double
|
|
Public Property mes10 As Double
|
|
Public Property mes11 As Double
|
|
Public Property mes12 As Double
|
|
End Class
|
|
Public Class WsVentaDetalle
|
|
Public Property CveVentaDetalle As Integer
|
|
Public Property CveVenta As Integer
|
|
Public Property FolioOC As String
|
|
Public Property Cantidad As Decimal
|
|
Public Property CveUnidadMedida As Integer
|
|
Public Property Abreviatura As String
|
|
Public Property CveUM As Integer
|
|
Public Property UM As String
|
|
Public Property CvePS As Integer
|
|
Public Property PS As String
|
|
Public Property PorcentajeIVA As Decimal
|
|
Public Property IVA As Decimal
|
|
Public Property RetIVA As Decimal
|
|
Public Property RetISR As Decimal
|
|
Public Property IEPS As Decimal
|
|
Public Property Descripcion As String
|
|
Public Property Importe As Decimal
|
|
Public Property Descuento As Decimal
|
|
Public Property Total As Decimal
|
|
Public Property TotalDescuento As Decimal
|
|
Public Property CveOrdenCompraPadre As Integer
|
|
Public Property Producto As String
|
|
Public Property CodigoPS As String
|
|
Public Property CveTipoPS As Integer
|
|
Public Property CveClasificacion As Integer
|
|
Public Property Clasificacion As String
|
|
Public Property CveActivoFijo As Integer
|
|
Public Property Observacion As String
|
|
Public Property Codigo As String
|
|
Public Property CodigoAF As String
|
|
Public Property TipoDato As String
|
|
Public Property Obs As String
|
|
Public Property CveProyecto As Integer
|
|
Public Property Proyecto As String
|
|
Public Property SubProyecto As String
|
|
Public Property CveSubProyecto As Integer
|
|
Public Property FolioOrdenCompraPadre As String
|
|
Public Property CveOrdenCompraHija As Integer
|
|
Public Property FolioOrdenCompraHija As String
|
|
Public Property CvePresupuestoEgreso As Integer
|
|
Public Property CveProgramaOperativo As Integer
|
|
Public Property CveUnidadAdministrativa As Integer
|
|
Public Property CveFuenteFinanciamiento As Integer
|
|
Public Property CveTipoGasto As Integer
|
|
Public Property CveClasificacionOG As Integer
|
|
Public Property IdCuentaPorEjercer As Integer
|
|
Public Property IdCuentaComprometido As Integer
|
|
Public Property CantidadDisponible As Integer
|
|
Public Property CveCompra As Integer
|
|
Public Property FolioCompra As String
|
|
Public Property ProductoOC As String
|
|
Public Property CveProveedor As Integer
|
|
Public Property CveMoneda As Integer
|
|
End Class
|
|
|
|
Public Class WsBitacora
|
|
Public Property Descripcion As String
|
|
Public Property CvePrioridad As Integer
|
|
Public Property Imagen1 As String
|
|
Public Property Extension As String
|
|
End Class
|
|
|
|
Public Class MVenta
|
|
Public Sub New()
|
|
CveVenta = -1
|
|
Total = 0
|
|
IVA = 0
|
|
SubTotal = 0
|
|
Fecha = DateTime.Now
|
|
FechaIng = DateTime.Now
|
|
End Sub
|
|
|
|
Public Property IDTempVenta As Integer
|
|
Public Property CveVenta As Integer
|
|
Public Property FolioFiscal As String
|
|
Public Property TipoDocto As String
|
|
Public Property Serie As String
|
|
Public Property Folio As Integer
|
|
Public Property SerieFolio As String
|
|
Public Property CveCliente As Integer
|
|
Public Property CveClienteSucursal As Integer?
|
|
Public Property SubTotal As Double
|
|
Public Property Descuento As Double
|
|
Public Property Amortizacion As Double
|
|
Public Property IVA As Double
|
|
Public Property RetIVA As Double
|
|
Public Property RetISR As Double
|
|
Public Property IEPS As Double
|
|
Public Property Total As Double
|
|
Public Property CveMoneda As Integer
|
|
Public Property TipoCambio As Double
|
|
Public Property CveMetodoPago As Integer
|
|
Public Property CondicionesPago As Integer
|
|
Public Property FormaPago As Integer
|
|
Public Property Fecha As DateTime
|
|
Public Property FechaIng As DateTime
|
|
Public Property MotivoDescuento As String
|
|
Public Property Observaciones As String
|
|
Public Property CveEstatusFactura As Integer
|
|
Public Property EstatusFactura As String
|
|
Public Property EnvioMail As String
|
|
Public Property SeTimbro As String
|
|
Public Property TelefonoGenerico As String
|
|
Public Property FechaEjecucion As DateTime
|
|
Public Property CveVendedor As Integer
|
|
Public Property Alfa1 As String
|
|
Public Property Alfa2 As String
|
|
Public Property Alfa3 As String
|
|
Public Property Num1 As Integer
|
|
Public Property Num2 As Integer
|
|
Public Property Num3 As Integer
|
|
Public Property Fech1 As DateTime
|
|
Public Property Fech2 As DateTime
|
|
Public Property Fech3 As DateTime
|
|
Public Property CveUsuario As Integer
|
|
Public Property Nombre As String
|
|
Public Property SelloCancelacion As String
|
|
Public Property FechaCancelacion As DateTime
|
|
Public Property TipoDocto1 As String
|
|
Public Property Saldo As Double
|
|
Public Property Pagado As Double
|
|
Public Property TipoEstatus As Integer
|
|
Public Property CveUsoCFDI As Integer
|
|
Public Property UsoCFDI As String
|
|
Public Property CveOS As Integer
|
|
Public Property CveContrato As Integer
|
|
Public Property CveEmpresa As Integer
|
|
Public Property Det_OrdenCompra As String
|
|
Public Property Det_FechaOrdenCompra As String
|
|
Public Property Otros As Double
|
|
Public Property CvePrePoliza As Integer
|
|
Public Property CPCliente As String
|
|
Public Property Telefono As String
|
|
Public Property ClienteRFC As String
|
|
Public Property ClienteNombre As String
|
|
Public Property MetodoPago As String
|
|
Public Property CorreoVendedor As String
|
|
Public Property FechaVencimiento As DateTime
|
|
Public Property Moneda As String
|
|
Public Property DatosCliente As String
|
|
Public Property ColoniaCliente As String
|
|
Public Property ClienteNoExt As String
|
|
Public Property ClienteNoInt As String
|
|
Public Property Municipio As String
|
|
Public Property Estado As String
|
|
Public Property Calle As String
|
|
Public Property NoExt As String
|
|
Public Property NoInt As String
|
|
Public Property Colonia As String
|
|
Public Property CP As String
|
|
Public Property Pais As String
|
|
Public Property Serie1 As String
|
|
Public Property Mail As String
|
|
Public Property ClienteDireccion As String
|
|
Public Property ClienteCodigo As String
|
|
Public Property ClienteCiudad As String
|
|
Public Property ClienteLocalidad As String
|
|
Public Property ClienteEstado As String
|
|
Public Property ClientePais As String
|
|
Public Property ClienteLugar As String
|
|
Public Property SucCliente As String
|
|
Public Property ClaveMetodoPagoSAT As String
|
|
Public Property Entrega As String
|
|
Public Property Vigencia As DateTime
|
|
Public Property SucClienteLocalidad As String
|
|
Public Property SucClienteCiudad As String
|
|
Public Property SucClienteEstado As String
|
|
Public Property SucClienteDireccion As String
|
|
Public Property SucClienteNoExt As String
|
|
Public Property SucClienteNoInt As String
|
|
Public Property SucClienteColonia As String
|
|
Public Property SucClienteCP As String
|
|
Public Property SucClienteCorreo As String
|
|
Public Property SucClienteTelefono As String
|
|
Public Property SucClientePais As String
|
|
Public Property CveVentaFacturada As Integer
|
|
Public Property SucursalCliente As String
|
|
Public Property VendedorCodigo As String
|
|
Public Property Ref As String
|
|
Public Property Abreviatura As String
|
|
Public Property EsDevolucionVenta As Boolean
|
|
Public Property UsuarioCreo As String
|
|
Public Property EnvioDepartamento As String
|
|
Public Property Inv_CveEstatusEntrega As Integer
|
|
Public Property Inv_EstatusEntrega As String
|
|
Public Property ImprimeNombreSucursal As Boolean
|
|
Public Property Vigencia1 As DateTime
|
|
Public Property CvePAC As Integer
|
|
Public Property CveSubProyecto As Integer
|
|
Public Property CveSubProyectoCobranza As Integer
|
|
Public Property CveSubProyectoEjecucion As Integer
|
|
Public Property CalleSubProyecto As String
|
|
Public Property NoExtSubProyecto As String
|
|
Public Property NoIntSubProyecto As String
|
|
Public Property ColoniaSubProyecto As String
|
|
Public Property LocalidadSubProyecto As String
|
|
Public Property MunicipioSubProyecto As String
|
|
Public Property EstadoSubProyecto As String
|
|
Public Property MunicipioSubProyecto1 As String
|
|
Public Property PaisSubProyecto As String
|
|
Public Property CPSubProyecto As String
|
|
Public Property SubProyecto As String
|
|
Public Property CveMetodoPago33 As Integer
|
|
Public Property CveFormaPago33 As Integer
|
|
Public Property MetodoPago33 As String
|
|
Public Property FormaPago33 As String
|
|
Public Property Version As String
|
|
Public Property TipoRelacion As String
|
|
End Class
|
|
|
|
Public Class MVentaProductos
|
|
Public Property IDTemp As Integer
|
|
Public Property IDTempVenta As Integer
|
|
Public Property CvePS As Integer
|
|
Public Property Cantidad As Double?
|
|
Public Property Obs As String
|
|
Public Property PS As String
|
|
Public Property Precio As Double
|
|
Public Property Descuento As Double
|
|
Public Property CveUnidadMedida As Integer
|
|
End Class
|
|
Public Class MMessage
|
|
Sub New()
|
|
Correcto = True
|
|
Mensajes = New List(Of String)
|
|
End Sub
|
|
Public Property Correcto As Boolean
|
|
Public Property Mensajes As List(Of String)
|
|
End Class
|
|
End Namespace
|
|
|