--Impresion servicios de construccion
--API E189 --FIX Metas vendedores
This commit is contained in:
@@ -7641,6 +7641,26 @@ Public Class ClsPaginas
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
'SOLO FORMATO DE STIMULSOFT Y COMPLEMENTO DE SERVICIOS DE CONSTRUCCION
|
||||
If UsuarioActual.Empresa.Funcionalidad(707) = "1" AndAlso Vta.CveComplementoTimbrado = 9 AndAlso Not String.IsNullOrEmpty(Vta.ComplementoSAT) Then
|
||||
Dim settings As New JsonSerializerSettings
|
||||
settings.NullValueHandling = NullValueHandling.Ignore
|
||||
Dim pc As Modelos.MParcialesConstruccion = JsonConvert.DeserializeObject(Of Modelos.MParcialesConstruccion)(Vta.ComplementoSAT, settings)
|
||||
|
||||
If pc IsNot Nothing Then
|
||||
params.Add(New ReportParameter("SC_NumPerLicoAut", pc.NumPerLicoAut))
|
||||
params.Add(New ReportParameter("SC_Calle", pc.Calle))
|
||||
params.Add(New ReportParameter("SC_NoExterior", pc.NoExterior))
|
||||
params.Add(New ReportParameter("SC_NoInterior", pc.NoInterior))
|
||||
params.Add(New ReportParameter("SC_Colonia", pc.Colonia))
|
||||
params.Add(New ReportParameter("SC_Localidad", pc.Localidad))
|
||||
params.Add(New ReportParameter("SC_Referencia", pc.Referencia))
|
||||
params.Add(New ReportParameter("SC_Municipio", pc.Municipio))
|
||||
params.Add(New ReportParameter("SC_Estado", pc.Estado))
|
||||
params.Add(New ReportParameter("SC_CodigoPostal", pc.CodigoPostal))
|
||||
End If
|
||||
End If
|
||||
|
||||
If NombreArchivo = "FacturaUSA" Then
|
||||
Dim DtBaseTotales As DataTable = Vta.DtDeduccion.Clone()
|
||||
|
||||
|
||||
@@ -325,6 +325,26 @@ Public Class ClsProductosServicios
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
Public Function GetPS_APIMarcasStock(CveEmpresa As Integer) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
|
||||
DataAdapter("PA_Inv_APIMarcasStockGet")
|
||||
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
||||
End With
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
|
||||
Retorno = True
|
||||
Catch ex As SqlException
|
||||
OnError("Ocurrió un error al consultar el stock.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||
End Try
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
Public Function GetPSSimplificado(CveEmpresa As Integer) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
|
||||
|
||||
216
Ashx/E189.ashx
Normal file
216
Ashx/E189.ashx
Normal file
@@ -0,0 +1,216 @@
|
||||
<%@ WebHandler Language="VB" Class="E189" %>
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
Imports System.Data
|
||||
Imports System.IO
|
||||
Imports Newtonsoft.Json
|
||||
Imports Newtonsoft.Json.Linq
|
||||
Imports Extensiones
|
||||
|
||||
Public Class E189 : Implements IHttpHandler, System.Web.SessionState.IRequiresSessionState
|
||||
|
||||
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
|
||||
Get
|
||||
Return False
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private ReadOnly Property CveEmpresa As Integer = 189
|
||||
Private ReadOnly Property CveUsuario As Integer = 100
|
||||
Private ReadOnly Property NombreCadena As String = "Conexion"
|
||||
|
||||
Public ReadOnly Property EsProduccion As Boolean
|
||||
Get
|
||||
If IsNothing(System.Configuration.ConfigurationManager.AppSettings("EsProduccion")) Then
|
||||
Return False
|
||||
Else
|
||||
Return (System.Configuration.ConfigurationManager.AppSettings("EsProduccion").ToString() = "1")
|
||||
End If
|
||||
End Get
|
||||
End Property
|
||||
|
||||
|
||||
#Region "V A L I D A - D A T O S"
|
||||
Private Function ValidaUsuarioSistema(CveUsuario As Integer, CveEmpresa As Integer) As Usuario
|
||||
Dim UsuarioActual As Usuario = Nothing
|
||||
Dim NombreCadena As String = ClsPaginas.GlobalNombreCadenaConexion(CveEmpresa)
|
||||
Dim ObjUsuarios As New ClsSisUsuarioAutenticacion(NombreCadena:=NombreCadena)
|
||||
UsuarioActual = ObjUsuarios.GetUsuarioDetalle(100, CveEmpresa)
|
||||
If UsuarioActual IsNot Nothing Then
|
||||
HttpContext.Current.Session("UsuarioSIG") = UsuarioActual
|
||||
'CreaObjetoEmpresa(UsuarioActual)
|
||||
End If
|
||||
ObjUsuarios.Dispose()
|
||||
|
||||
Return UsuarioActual
|
||||
End Function
|
||||
|
||||
'Private Sub CreaObjetoEmpresa(ByRef UsuarioActual As Usuario)
|
||||
' Dim ObjEmpresa As New ClsSisEmpresas()
|
||||
' If ObjEmpresa.GetEmpresas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1") Then
|
||||
' If ObjEmpresa.GetEmpresasFuncionalidades(UsuarioActual.CveEmpresa) Then
|
||||
' Dim dttmp As Data.DataTable = ObjEmpresa.DtResultados
|
||||
|
||||
' Dim EmpresasFuncionalidades As New HybridDictionary
|
||||
' For Each Row As Data.DataRow In dttmp.Rows
|
||||
' EmpresasFuncionalidades.Add(Convert.ToInt32(Row("CveFuncionalidad")), Row("Valor").ToString)
|
||||
' Next
|
||||
' ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades)
|
||||
' End If
|
||||
|
||||
' UsuarioActual.Empresa = ObjEmpresa.Empresa
|
||||
|
||||
' End If
|
||||
' ObjEmpresa.Dispose()
|
||||
'End Sub
|
||||
#End Region
|
||||
|
||||
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
|
||||
Dim retorno As String = ""
|
||||
Dim MsgLog As New StringBuilder
|
||||
MsgLog.AppendLine("Inicia Petición.")
|
||||
Try
|
||||
Dim Metodo As String = If(context.Request("Metodo") = Nothing, "", context.Request("Metodo").ToString())
|
||||
MsgLog.AppendLine(Metodo)
|
||||
|
||||
If Metodo = "Stock" Then
|
||||
context.Response.ContentType = "application/json"
|
||||
retorno = ConsultaDatos(context)
|
||||
End If
|
||||
|
||||
context.Response.Write(retorno)
|
||||
|
||||
Catch ex As Exception
|
||||
context.Response.ContentType = "text/html"
|
||||
MsgLog.AppendLine("Error de procesamiento:" & ex.Message)
|
||||
|
||||
Dim respuesta As New AuthMessage
|
||||
respuesta.ErrorMessage = New ResponseMsgError() With {.message = "La solicitud no se pudo procesar."}
|
||||
respuesta.IsSuccess = False
|
||||
respuesta.StatusCode = 200
|
||||
retorno = JsonConvert.SerializeObject(respuesta.ErrorMessage)
|
||||
context.Response.Write(retorno)
|
||||
|
||||
End Try
|
||||
MsgLog.ToString.GuardaLogAD("LogE119")
|
||||
End Sub
|
||||
|
||||
|
||||
Private Function ConsultaDatos(ByVal context As HttpContext) As String
|
||||
Dim Respuesta As New ResponseMsg
|
||||
Dim RespuestaError As New ResponseMsgError
|
||||
Dim TieneError As Boolean = False
|
||||
|
||||
Dim productos As JArray = Nothing
|
||||
|
||||
Using ObjInventario As New ClsProductosServicios
|
||||
If ObjInventario.GetPS_APIMarcasStock(189) AndAlso ObjInventario.DtResultados IsNot Nothing Then
|
||||
productos = JArray.Parse(ObjInventario.DtResultados.DataTableToJSONIPP())
|
||||
Else
|
||||
RespuestaError.message = "no se pudo obtener los datos"
|
||||
TieneError = True
|
||||
End If
|
||||
End Using
|
||||
|
||||
If TieneError Then
|
||||
context.Response.StatusCode = 200
|
||||
Return JsonConvert.SerializeObject(RespuestaError)
|
||||
Else
|
||||
context.Response.StatusCode = 200
|
||||
Try
|
||||
Return New JObject(New JProperty("productos", productos)).ToString()
|
||||
Catch ex As Exception
|
||||
RespuestaError.message = "Ocurrió un error al generar la petición"
|
||||
Return JsonConvert.SerializeObject(RespuestaError)
|
||||
End Try
|
||||
|
||||
End If
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Private Class ResponseMsg
|
||||
Sub New()
|
||||
status = "success"
|
||||
End Sub
|
||||
Public Property status As String
|
||||
Public Property data As Object
|
||||
Public Property message As String
|
||||
End Class
|
||||
|
||||
Private Class ResponseMsgError
|
||||
Sub New()
|
||||
status = "error"
|
||||
End Sub
|
||||
Public Property status As String
|
||||
Public Property message As String
|
||||
End Class
|
||||
|
||||
Private Class AuthMessage
|
||||
Public Property IsSuccess As Boolean
|
||||
Public Property ErrorMessage As ResponseMsgError
|
||||
Public Property StatusCode As Integer
|
||||
End Class
|
||||
|
||||
'Private Function ActualizarExistenciasJson(Todos As Boolean) As String
|
||||
' Dim payload = New JObject()
|
||||
|
||||
' Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0
|
||||
|
||||
' Dim DtPS As DataTable = Nothing
|
||||
' Using ObjPS As New ClsProductosServicios
|
||||
' If ObjPS.GetExistenciasEmpresa("-1", CveEmpresa) Then
|
||||
' DtPS = ObjPS.DtResultados.Copy()
|
||||
' End If
|
||||
' End Using
|
||||
|
||||
' If DtPS IsNot Nothing Then
|
||||
' payload.Add(New JProperty("stock", GenerarPayloadExistencias(DtPS)))
|
||||
' End If
|
||||
|
||||
' Return payload.ToString()
|
||||
'End Function
|
||||
|
||||
|
||||
|
||||
Private Function Parametros(Cadena As String) As Hashtable
|
||||
Dim P1() As String = Cadena.Split("&"c)
|
||||
Dim Tmp As String
|
||||
Dim P2() As String
|
||||
|
||||
Dim URLParametros As New Hashtable
|
||||
|
||||
For Each Tmp In P1
|
||||
P2 = Tmp.Replace("%26%", "&").Split("="c)
|
||||
URLParametros.Add(P2(0).ToString.ToUpper, P2(1))
|
||||
Next
|
||||
Return URLParametros
|
||||
End Function
|
||||
|
||||
Private Shared Function IsValidJson(ByVal strInput As String) As Boolean
|
||||
If String.IsNullOrWhiteSpace(strInput) Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
strInput = strInput.Trim()
|
||||
|
||||
If (strInput.StartsWith("{") AndAlso strInput.EndsWith("}")) OrElse (strInput.StartsWith("[") AndAlso strInput.EndsWith("]")) Then
|
||||
|
||||
Try
|
||||
Dim obj As JToken = JToken.Parse(strInput)
|
||||
Return True
|
||||
Catch jex As JsonReaderException
|
||||
Console.WriteLine(jex.Message)
|
||||
Return False
|
||||
Catch ex As Exception
|
||||
Console.WriteLine(ex.ToString())
|
||||
Return False
|
||||
End Try
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Function
|
||||
|
||||
End Class
|
||||
@@ -168,11 +168,7 @@
|
||||
<asp:DropDownList ID="DdlVendedores" runat="server" DataTextField="Vendedor" DataValueField="CveVendedor" CssClass="form-control input-sm select2me" Width="100%"></asp:DropDownList>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="display: flex; align-items: center; margin-bottom: 10px;" id="Div3" runat="server" visible="false">
|
||||
<div class="col-md-2 truncate">Marca</div>
|
||||
<div class="col-md-4">
|
||||
<asp:DropDownList ID="DdlMarcas" runat="server" DataTextField="Marca" DataValueField="CveMarca" CssClass="form-control input-sm select2me" Width="100%"></asp:DropDownList>
|
||||
</div>
|
||||
<div class="row" style="display: flex; align-items: center; margin-bottom: 10px;">
|
||||
<div class="col-md-2 truncate">Mes y Año</div>
|
||||
<div class="col-md-4">
|
||||
<div class="input-group input-sm input-small date date-picker " data-date-format="dd/mm/yyyy" style="width: 95px !important; padding: 0px;">
|
||||
@@ -185,6 +181,12 @@
|
||||
<ajax:CalendarExtender runat="server" ID="CEFechaI" TargetControlID="TxtFechaI" PopupButtonID="ImgFechaI" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="display: flex; align-items: center; margin-bottom: 10px;" id="Div3" runat="server" visible="false">
|
||||
<div class="col-md-2 truncate">Marca</div>
|
||||
<div class="col-md-10">
|
||||
<asp:DropDownList ID="DdlMarcas" runat="server" DataTextField="Marca" DataValueField="CveMarca" CssClass="form-control input-sm select2me" Width="100%"></asp:DropDownList>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="display: flex; align-items: center; margin-bottom: 10px;" id="Div2" runat="server" visible="false">
|
||||
<div class="col-md-2">Clasificación Superior</div>
|
||||
<div class="col-md-10">
|
||||
|
||||
@@ -44,7 +44,6 @@ Partial Class CatMetasVendedores
|
||||
GvDatos.Columns(1).Visible = False
|
||||
GvDatos.Columns(2).Visible = False
|
||||
GvDatos.Columns(3).Visible = False
|
||||
GvDatos.Columns(4).Visible = False
|
||||
|
||||
DivLblSucursal.Visible = False
|
||||
DivSucursal.Visible = False
|
||||
@@ -109,13 +108,15 @@ Partial Class CatMetasVendedores
|
||||
End Sub
|
||||
|
||||
Protected Sub LnkAgregar_Click() Handles LnkAgregar.Click
|
||||
BtnAgregarMetaVendedor.Text = "Agregar"
|
||||
ResetDatosSeleccionadosModal()
|
||||
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD"))
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnAgregarMetaVendedor_Click(sender As Object, e As EventArgs) Handles BtnAgregarMetaVendedor.Click
|
||||
|
||||
Dim CveVendedor As Integer = DdlVendedores.SelectedValue.ToEntero()
|
||||
Dim Fecha As Date = MinFecha
|
||||
Dim Fecha As Date = TxtFechaI.Text.ToDate()
|
||||
Dim CveMarca As Integer = -1
|
||||
Dim CveClasificacionSuperior As Integer = -1
|
||||
Dim CveClasificacion As Integer = -1
|
||||
@@ -128,14 +129,13 @@ Partial Class CatMetasVendedores
|
||||
Alert(String.Format("Falta Seleccionar {0}{1}{2}", If(DdlVendedores.SelectedValue.ToEntero > 0, "", "Vendedor, "), If(DdlMarcas.SelectedValue.ToEntero > 0, "", "Marca, "), If(TxtFechaI.Text <> "", "", "Fecha, ")))
|
||||
Exit Sub
|
||||
End If
|
||||
Fecha = TxtFechaI.Text.ToDate()
|
||||
CveClasificacionSuperior = DdlClasificacionSup.SelectedValue.ToEntero
|
||||
CveClasificacion = DdlClasificacion.SelectedValue.ToEntero
|
||||
CveMarca = DdlMarca.SelectedValue.ToEntero
|
||||
|
||||
Else
|
||||
If Not (DdlVendedores.SelectedValue.ToEntero > 0) Then
|
||||
Alert("Falta Seleccionar el vendedor")
|
||||
If Not (DdlVendedores.SelectedValue.ToEntero > 0 AndAlso TxtFechaI.Text <> "") Then
|
||||
Alert(String.Format("Falta Seleccionar {0}{1}", If(DdlVendedores.SelectedValue.ToEntero > 0, "", "Vendedor, "), If(TxtFechaI.Text <> "", "", "Fecha, ")))
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
@@ -177,11 +177,10 @@ Partial Class CatMetasVendedores
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
CveMetaVendedor = GvRow.DataKey("CveMeta").ToEntero
|
||||
DdlVendedores.SelectedValue = GvRow.DataKey("CveVendedor")
|
||||
TxtFechaI.Text = GvRow.DataKey("MesAño")
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
||||
|
||||
TxtFechaI.Text = GvRow.DataKey("MesAño")
|
||||
|
||||
DdlClasificacionSup.SelectedValueExist(GvRow.DataKey("CveClasificacionSup"))
|
||||
DdlClasificacion.SelectedValueExist(GvRow.DataKey("CveClasificacion"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user