From d0c2f697ff824fca53978e03b3736a646f494ebc Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 7 Jan 2020 12:22:59 -0700 Subject: [PATCH 01/49] tres columnas opcionales para opcion de factura cliente --- General/SaldosIniciales.aspx.vb | 35 +++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb index 930cd697c..c16ccc7be 100644 --- a/General/SaldosIniciales.aspx.vb +++ b/General/SaldosIniciales.aspx.vb @@ -296,17 +296,17 @@ Partial Class General_SaldosIniciales Exit Sub End If - If RblFormato.SelectedValue = "4" Then - If Not dt.Columns(15).ColumnName = "ImpuestoLocal" Then - Alert("El nombre de la diesciseisava columna debe ser 'ImpuestoLocal'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If + 'If RblFormato.SelectedValue = "4" Then + ' If Not dt.Columns(15).ColumnName = "ImpuestoLocal" Then + ' Alert("El nombre de la diesciseisava columna debe ser 'ImpuestoLocal'. Favor de corregirlo", TipoMensaje.MsgError) + ' Exit Sub + ' End If - If Not dt.Columns(16).ColumnName = "Amort.Ant" Then - Alert("El nombre de la diescisieteava columna debe ser 'Amort.Ant'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If - End If + ' If Not dt.Columns(16).ColumnName = "Amort.Ant" Then + ' Alert("El nombre de la diescisieteava columna debe ser 'Amort.Ant'. Favor de corregirlo", TipoMensaje.MsgError) + ' Exit Sub + ' End If + 'End If ElseIf RblFormato.SelectedValue = "5" Then @@ -1356,8 +1356,8 @@ Partial Class General_SaldosIniciales Dim Folio As Integer = Row("Folio").ToString.ToEntero Dim Fecha As Date = Row("Fecha").ToString.ToDate Dim FechaVencimiento As Date = Row("Fecha Vencimiento").ToString.ToDate - Dim ImpuestoLocal As Double = Row("ImpuestoLocal").ToString.ToDouble - Dim Amortizacion As Double = Row("Amort.Ant").ToString.ToDouble + Dim ImpuestoLocal As Double = If(dt.Columns.Contains("ImpuestoLocal"), Row("ImpuestoLocal").ToString.ToDouble, 0) + Dim Amortizacion As Double = If(dt.Columns.Contains("Amort.Ant"), Row("Amort.Ant").ToString.ToDouble, 0) Dim SubTotal As Decimal = Row("SubTotal").ToString.ToDecimal Dim IVA As Decimal = Row("IVA").ToString.ToDecimal Dim Total As Decimal = Row("Total").ToString.ToDecimal @@ -1372,7 +1372,8 @@ Partial Class General_SaldosIniciales Dim CveVendedor As Integer = 0 Dim IEPS As Decimal = 0 'Row("IEPS").ToString.ToDecimal Dim CveClienteSucursal As Integer = 0 'Row("CveClienteSucursal").ToString.ToEntero - Dim ImpuestosLocales As Decimal = Row("ImpuestoLocal").ToString.ToDecimal + Dim ImpuestosLocales As Decimal = If(dt.Columns.Contains("ImpuestoLocal"), Row("ImpuestoLocal").ToString.ToDecimal, 0) + Dim FolioFiscal As String = If(dt.Columns.Contains("Folio Fiscal"), Row("Folio Fiscal").ToString, "") GuardaLog(Sucursal + "-" + Row("Folio").ToString) 'Temporalmente SE BORRARA @@ -1430,6 +1431,14 @@ Partial Class General_SaldosIniciales ErrorVentas = True Exit For End If + + If FolioFiscal IsNot "" Then + If Not ObjVentas.UpdateEstatusFactura(3, FolioFiscal, "", FechaVencimiento, CveVenta, CvePAC:=1) Then + ErrorVentas = True + Exit For + End If + End If + Dim ConceptoContable As Integer = 1 Dim ConceptoContablePago As Integer = 2 If TipoDocto = "Egs" Then From e989ef54ae15b54e4110ad21c7d44ecd163dfc71 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 7 Jan 2020 12:23:58 -0700 Subject: [PATCH 02/49] Revert "tres columnas opcionales para opcion de factura cliente" This reverts commit d0c2f697ff824fca53978e03b3736a646f494ebc. --- General/SaldosIniciales.aspx.vb | 35 ++++++++++++--------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb index c16ccc7be..930cd697c 100644 --- a/General/SaldosIniciales.aspx.vb +++ b/General/SaldosIniciales.aspx.vb @@ -296,17 +296,17 @@ Partial Class General_SaldosIniciales Exit Sub End If - 'If RblFormato.SelectedValue = "4" Then - ' If Not dt.Columns(15).ColumnName = "ImpuestoLocal" Then - ' Alert("El nombre de la diesciseisava columna debe ser 'ImpuestoLocal'. Favor de corregirlo", TipoMensaje.MsgError) - ' Exit Sub - ' End If + If RblFormato.SelectedValue = "4" Then + If Not dt.Columns(15).ColumnName = "ImpuestoLocal" Then + Alert("El nombre de la diesciseisava columna debe ser 'ImpuestoLocal'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If - ' If Not dt.Columns(16).ColumnName = "Amort.Ant" Then - ' Alert("El nombre de la diescisieteava columna debe ser 'Amort.Ant'. Favor de corregirlo", TipoMensaje.MsgError) - ' Exit Sub - ' End If - 'End If + If Not dt.Columns(16).ColumnName = "Amort.Ant" Then + Alert("El nombre de la diescisieteava columna debe ser 'Amort.Ant'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + End If ElseIf RblFormato.SelectedValue = "5" Then @@ -1356,8 +1356,8 @@ Partial Class General_SaldosIniciales Dim Folio As Integer = Row("Folio").ToString.ToEntero Dim Fecha As Date = Row("Fecha").ToString.ToDate Dim FechaVencimiento As Date = Row("Fecha Vencimiento").ToString.ToDate - Dim ImpuestoLocal As Double = If(dt.Columns.Contains("ImpuestoLocal"), Row("ImpuestoLocal").ToString.ToDouble, 0) - Dim Amortizacion As Double = If(dt.Columns.Contains("Amort.Ant"), Row("Amort.Ant").ToString.ToDouble, 0) + Dim ImpuestoLocal As Double = Row("ImpuestoLocal").ToString.ToDouble + Dim Amortizacion As Double = Row("Amort.Ant").ToString.ToDouble Dim SubTotal As Decimal = Row("SubTotal").ToString.ToDecimal Dim IVA As Decimal = Row("IVA").ToString.ToDecimal Dim Total As Decimal = Row("Total").ToString.ToDecimal @@ -1372,8 +1372,7 @@ Partial Class General_SaldosIniciales Dim CveVendedor As Integer = 0 Dim IEPS As Decimal = 0 'Row("IEPS").ToString.ToDecimal Dim CveClienteSucursal As Integer = 0 'Row("CveClienteSucursal").ToString.ToEntero - Dim ImpuestosLocales As Decimal = If(dt.Columns.Contains("ImpuestoLocal"), Row("ImpuestoLocal").ToString.ToDecimal, 0) - Dim FolioFiscal As String = If(dt.Columns.Contains("Folio Fiscal"), Row("Folio Fiscal").ToString, "") + Dim ImpuestosLocales As Decimal = Row("ImpuestoLocal").ToString.ToDecimal GuardaLog(Sucursal + "-" + Row("Folio").ToString) 'Temporalmente SE BORRARA @@ -1431,14 +1430,6 @@ Partial Class General_SaldosIniciales ErrorVentas = True Exit For End If - - If FolioFiscal IsNot "" Then - If Not ObjVentas.UpdateEstatusFactura(3, FolioFiscal, "", FechaVencimiento, CveVenta, CvePAC:=1) Then - ErrorVentas = True - Exit For - End If - End If - Dim ConceptoContable As Integer = 1 Dim ConceptoContablePago As Integer = 2 If TipoDocto = "Egs" Then From 3a5bbcb6b1cb43b1d8d276872222efe21f2f97d2 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 7 Jan 2020 16:24:47 -0700 Subject: [PATCH 03/49] correciones en saldos iniciales y agregando funcion de descuentos en Usados --- General/SaldosIniciales.aspx.vb | 33 +++++++++++++++++------------ Inventarios/RecepcionUsados.aspx.vb | 18 ++++++++++------ Ventas/PV.aspx | 3 +-- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb index 930cd697c..004b752d8 100644 --- a/General/SaldosIniciales.aspx.vb +++ b/General/SaldosIniciales.aspx.vb @@ -296,17 +296,17 @@ Partial Class General_SaldosIniciales Exit Sub End If - If RblFormato.SelectedValue = "4" Then - If Not dt.Columns(15).ColumnName = "ImpuestoLocal" Then - Alert("El nombre de la diesciseisava columna debe ser 'ImpuestoLocal'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If + 'If RblFormato.SelectedValue = "4" Then + ' If Not dt.Columns(15).ColumnName = "ImpuestoLocal" Then + ' Alert("El nombre de la diesciseisava columna debe ser 'ImpuestoLocal'. Favor de corregirlo", TipoMensaje.MsgError) + ' Exit Sub + ' End If - If Not dt.Columns(16).ColumnName = "Amort.Ant" Then - Alert("El nombre de la diescisieteava columna debe ser 'Amort.Ant'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If - End If + ' If Not dt.Columns(16).ColumnName = "Amort.Ant" Then + ' Alert("El nombre de la diescisieteava columna debe ser 'Amort.Ant'. Favor de corregirlo", TipoMensaje.MsgError) + ' Exit Sub + ' End If + 'End If ElseIf RblFormato.SelectedValue = "5" Then @@ -1356,8 +1356,8 @@ Partial Class General_SaldosIniciales Dim Folio As Integer = Row("Folio").ToString.ToEntero Dim Fecha As Date = Row("Fecha").ToString.ToDate Dim FechaVencimiento As Date = Row("Fecha Vencimiento").ToString.ToDate - Dim ImpuestoLocal As Double = Row("ImpuestoLocal").ToString.ToDouble - Dim Amortizacion As Double = Row("Amort.Ant").ToString.ToDouble + Dim ImpuestoLocal As Double = If(dt.Columns.Contains("ImpuestoLocal"), Row("ImpuestoLocal").ToString.ToDouble, 0.0) + Dim Amortizacion As Double = If(dt.Columns.Contains("Amort.Ant"), Row("Amort.Ant").ToString.ToDouble, 0.0) Dim SubTotal As Decimal = Row("SubTotal").ToString.ToDecimal Dim IVA As Decimal = Row("IVA").ToString.ToDecimal Dim Total As Decimal = Row("Total").ToString.ToDecimal @@ -1372,7 +1372,8 @@ Partial Class General_SaldosIniciales Dim CveVendedor As Integer = 0 Dim IEPS As Decimal = 0 'Row("IEPS").ToString.ToDecimal Dim CveClienteSucursal As Integer = 0 'Row("CveClienteSucursal").ToString.ToEntero - Dim ImpuestosLocales As Decimal = Row("ImpuestoLocal").ToString.ToDecimal + Dim ImpuestosLocales As Decimal = If(dt.Columns.Contains("ImpuestoLocal"), Row("ImpuestoLocal").ToString.ToDecimal, 0) + Dim FolioFiscal As String = If(dt.Columns.Contains("Folio Fiscal"), Row("Folio Fiscal").ToString, "") GuardaLog(Sucursal + "-" + Row("Folio").ToString) 'Temporalmente SE BORRARA @@ -1437,6 +1438,12 @@ Partial Class General_SaldosIniciales ConceptoContablePago = 91 End If + If FolioFiscal <> "" Then + If Not ObjVentas.UpdateVentaFolioFiscal(FolioFiscal, CveVenta, UsuarioActual.CveEmpresa) Then + ErrorVentas = True + Exit For + End If + End If 'PrePólizaDetalle If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, SubTotal, Folio.ToString, 4, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveClasificacion:=CveClasificacion, ImporteMX:=SubTotal, CveSubProyecto:=Sucursal.ToEntero) Then ErrorVentas = True : Exit For diff --git a/Inventarios/RecepcionUsados.aspx.vb b/Inventarios/RecepcionUsados.aspx.vb index 2034619c5..5f8a4181e 100644 --- a/Inventarios/RecepcionUsados.aspx.vb +++ b/Inventarios/RecepcionUsados.aspx.vb @@ -2442,13 +2442,17 @@ Partial Class Inventarios_RecepcionUsados Public Sub OnRblUsadosAjuste_Change(sender As Object, e As EventArgs) DdlAlmacen.Items.Clear() If RblUsadosAjuste.SelectedValue = "1" Then - CargaAjuste() - DivAjuste.Visible = True - 'Llenar el dropdownlist de almacén - DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 6) - LnkAgregarUsado.Visible = False - UppAcciones.Update() - + If DdlClientes.SelectedValue <> "-1" Then + CargaAjuste() + DivAjuste.Visible = True + 'Llenar el dropdownlist de almacén + DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 6) + LnkAgregarUsado.Visible = False + UppAcciones.Update() + Else + Alert("hace falta seleccionar un cliente") + RblUsadosAjuste.SelectedValue = "0" + End If Else DivAjuste.Visible = False 'Llenar el dropdownlist de almacén diff --git a/Ventas/PV.aspx b/Ventas/PV.aspx index f2660bbdf..656670d36 100644 --- a/Ventas/PV.aspx +++ b/Ventas/PV.aspx @@ -616,8 +616,7 @@ IEPS - Total <%--;--%> - Comandos + Total <%--;--%>Comandos From cc707621b02b7cade75e63b9c80e6a318d0b8a2f Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 7 Jan 2020 18:13:13 -0700 Subject: [PATCH 04/49] Agregando descuentos a la recepcion usados en base al cliente y la marca --- Inventarios/RecepcionUsados.aspx.vb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Inventarios/RecepcionUsados.aspx.vb b/Inventarios/RecepcionUsados.aspx.vb index 5f8a4181e..b8cd2b673 100644 --- a/Inventarios/RecepcionUsados.aspx.vb +++ b/Inventarios/RecepcionUsados.aspx.vb @@ -309,6 +309,14 @@ Partial Class Inventarios_RecepcionUsados ViewState("TmpDTAjustes") = value End Set End Property + Private Property DtPorcentajeMarcas As DataTable + Get + Return If(IsNothing(ViewState("DtPorcentajeMarcas")), Nothing, CType(ViewState("DtPorcentajeMarcas"), DataTable)) + End Get + Set(value As DataTable) + ViewState("DtPorcentajeMarcas") = value + End Set + End Property #End Region @@ -2447,6 +2455,7 @@ Partial Class Inventarios_RecepcionUsados DivAjuste.Visible = True 'Llenar el dropdownlist de almacén DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 6) + CargarDescuento() LnkAgregarUsado.Visible = False UppAcciones.Update() Else @@ -2549,6 +2558,13 @@ Partial Class Inventarios_RecepcionUsados End If End If + Dim MarcaPorcentaje As DataRow = DtPorcentajeMarcas.FiltroPrimero(String.Format("CveMarca = {0}", drPS("CveMarca").ToString)) + If MarcaPorcentaje IsNot Nothing Then + Dim Descuento As Decimal = MarcaPorcentaje("PorcentajeProducto").ToString.ToDecimal / 100 + Dim MontoDescuento As Decimal = PrecioSugerido * Descuento + PrecioSugerido -= MontoDescuento + End If + txtPrecio.Text = PrecioSugerido.FormatoNumero(2) TxtPUFactura.Text = PrecioSugerido.FormatoNumero(2) End If @@ -2717,6 +2733,14 @@ Partial Class Inventarios_RecepcionUsados End If ObjPS.Dispose() End Sub + + Protected Sub CargarDescuento() + Dim ObjPS As New ClsProductosServicios + If ObjPS.GetPorcentajeMarcas(DdlClientes.SelectedValue.ToEntero) Then + DtPorcentajeMarcas = ObjPS.DtResultados.Copy() + End If + ObjPS.Dispose() + End Sub #End Region End Class From 5da0c83784a9486078a80992ca741e0fc18060be Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 7 Jan 2020 18:25:26 -0700 Subject: [PATCH 05/49] Utilizando los tres Descuentos --- Inventarios/RecepcionUsados.aspx.vb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Inventarios/RecepcionUsados.aspx.vb b/Inventarios/RecepcionUsados.aspx.vb index b8cd2b673..113da0acf 100644 --- a/Inventarios/RecepcionUsados.aspx.vb +++ b/Inventarios/RecepcionUsados.aspx.vb @@ -2560,9 +2560,18 @@ Partial Class Inventarios_RecepcionUsados End If Dim MarcaPorcentaje As DataRow = DtPorcentajeMarcas.FiltroPrimero(String.Format("CveMarca = {0}", drPS("CveMarca").ToString)) If MarcaPorcentaje IsNot Nothing Then - Dim Descuento As Decimal = MarcaPorcentaje("PorcentajeProducto").ToString.ToDecimal / 100 - Dim MontoDescuento As Decimal = PrecioSugerido * Descuento + Dim PorcentajeProducto As Decimal = MarcaPorcentaje("PorcentajeProducto").ToString.ToDecimal / 100 + Dim MontoDescuento As Decimal = PrecioSugerido * PorcentajeProducto PrecioSugerido -= MontoDescuento + + Dim PorcentajeProducto2 As Decimal = MarcaPorcentaje("PorcentajeProducto2").ToString.ToDecimal / 100 + MontoDescuento = PrecioSugerido * PorcentajeProducto2 + PrecioSugerido -= MontoDescuento + + Dim PorcentajeProducto3 As Decimal = MarcaPorcentaje("PorcentajeProducto3").ToString.ToDecimal / 100 + MontoDescuento = PrecioSugerido * PorcentajeProducto3 + PrecioSugerido -= MontoDescuento + End If txtPrecio.Text = PrecioSugerido.FormatoNumero(2) From 12812ea546d52390e0783a8cf1e891d1935479de Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Tue, 7 Jan 2020 18:41:46 -0700 Subject: [PATCH 06/49] Facturacion de Entrega directa con NC --- Ventas/Ventas.aspx.vb | 53 +- asmx/WSSIGApp.asmx | 9738 +++++++++++++++++++++-------------------- 2 files changed, 4916 insertions(+), 4875 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index f40cfb01b..c3ead8cf2 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -6704,6 +6704,23 @@ Partial Class Ventas GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjFactura, TmpDT, ObjFactura.CveNCaVincular, ObjContPaq, ObjBancos, ObjOS, ObjEventos, ObjCGame, ObjClientes, EsNCAmortizacion:=EsNCAmortizacion) + 'Agregamos las OCs a la tabla + If ObjFactura.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso DTOrdenesCompraPS IsNot Nothing AndAlso DTOrdenesCompraPS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then + Dim CveVentaDetalle As Integer = 0 + Dim CveOrdenCompraDetalle As Integer = 0 + Dim Cantidad As Decimal = 0 + + For Each row As DataRow In TmpDT.Rows + Cantidad = row("Cantidad").ToString.ToDecimal + CveVentaDetalle = row("CveVentaDetalle").ToString.ToEntero + CveOrdenCompraDetalle = row("CveOrdenCompraDetalle").ToString.ToEntero + If Not ObjVentas.AgregarVentaOCDetalle(CveVentaDetalle, CveOrdenCompraDetalle, Cantidad) Then + ErrorList.Add("Ocurrió un Error al agregar el detalle de la Remision") + Exit For + End If + Next + End If + 'SI ES REFACTURACION Dim ObjNC As List(Of Object) = Nothing If ErrorList.Count = 0 Then @@ -6723,7 +6740,6 @@ Partial Class Ventas End If End If End If - End If End If @@ -6789,24 +6805,6 @@ Partial Class Ventas End If End If - 'Agregamos las OCs a la tabla - If DTOrdenesCompraPS IsNot Nothing AndAlso DTOrdenesCompraPS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then - Dim CveVentaDetalle As Integer = 0 - Dim CveOrdenCompraDetalle As Integer = 0 - Dim Cantidad As Decimal = 0 - - - For Each row As DataRow In TmpDT.Rows - Cantidad = row("Cantidad").ToString.ToDecimal - CveVentaDetalle = row("CveVentaDetalle").ToString.ToEntero - CveOrdenCompraDetalle = row("CveOrdenCompraDetalle").ToString.ToEntero - If Not ObjVentas.AgregarVentaOCDetalle(CveVentaDetalle, CveOrdenCompraDetalle, Cantidad) Then - ErrorList.Add("Ocurrió un Error al agregar el detalle de la Remision") - End If - Next - - End If - 'Agregamos las Cotizaciones a la tabla If DtCotizacionesPS IsNot Nothing AndAlso DtCotizacionesPS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then Dim CveVentaDetalle As Integer = 0 @@ -6828,8 +6826,6 @@ Partial Class Ventas Next End If - - 'Marcamos las ventas anteriores a febrero como surtidas - Ajuste Compu If ErrorList.Count = 0 Then If Not ObjVentas.MarcarRemisionesSinSurtir(ObjVentas.CveVenta) Then @@ -9037,7 +9033,7 @@ Partial Class Ventas #Region " GUARDAR - VENTA, PREPOLIZAS, INV, ESTIMACIONES, AC, NOTA DE CRÉDITO " - Private Sub GuardarVenta(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, factura As Modelos.Factura, TmpDTDetalle As DataTable, CveNCaVincular As Integer, + Private Sub GuardarVenta(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, factura As Modelos.Factura, ByRef TmpDTDetalle As DataTable, CveNCaVincular As Integer, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, Optional ByRef ObjOS As ClsOS = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, ByRef Optional ObjCGame As ClsCGame = Nothing, ByRef Optional ObjCliente As ClsClientes = Nothing, Optional EsNCAmortizacion As Boolean = False, Optional NCDescuento As Boolean = False) @@ -9108,8 +9104,8 @@ Partial Class Ventas PedidoContrato:=TxtPedidoContrato.Text, ObservacionesAlmacen:=TxtObsAlmacen.Text, CveSubProyecto:=factura.CveSubProyecto, CveSubProyectoCobranza:=factura.CveSubProyectoCobranza, CveSubProyectoEjecucion:=factura.CveSubProyectoEjecucion, CveFormaPago33:=factura.CveFormaPago33, CveMetodoPago33:=factura.CveMetodoPago33, CveUsoCFDI:=factura.CveUsoCFDI, OrdenCompra:=TxtOrdenCompra.Text, CveCuentaTerminal:=DdlCuentasTerminal.SelectedValue.ToEntero, CveTipoRelacion:=factura.CveTipoRelacion, ImpuestoLocal:=TotalImpuestoLocal, CveVentaRelacion:=(If(factura.CveVentaRelacion.ToEntero > 0, factura.CveVentaRelacion, -1)), ImporteRelacion:=(If(factura.ImporteRelacion <> Nothing, factura.ImporteRelacion, -1)), - CveTipoAmortizacionAnticipo:=factura.CveTipoAmortizacionAnticipo, CveEmpresaCRM:=CveEmpresaCRM, EsInterno:=EsInterno, CveAcercamientoCRM:=CveAcercamientoCRM, - DiasCredito:=factura.DiasCredito, EsDiasCreditoFijo:=factura.EsDiasCreditoFijo, AnticipoEspecial:=If(TrAntEspecial.Visible, ChkAntEspecial.Checked, False)) Then + CveTipoAmortizacionAnticipo:=factura.CveTipoAmortizacionAnticipo, CveEmpresaCRM:=CveEmpresaCRM, EsInterno:=EsInterno, CveAcercamientoCRM:=CveAcercamientoCRM, + DiasCredito:=factura.DiasCredito, EsDiasCreditoFijo:=factura.EsDiasCreditoFijo, AnticipoEspecial:=If(TrAntEspecial.Visible, ChkAntEspecial.Checked, False)) Then ErrorList.Add("Ocurrió un error al Generar la Venta.
Revise su factura y cualquier detalle comuníquese a Soporte Técnico") @@ -9171,7 +9167,7 @@ Partial Class Ventas End If End If - Dim TmpDr As DataRow = TmpDT.Select($"Consec = {Row("Consec").ToString}")(0) + Dim TmpDr As DataRow = TmpDTDetalle.Select($"Consec = {Row("Consec").ToString}")(0) TmpDr("CveVentaDetalle") = ObjVentas.CveVentaDetalle Try @@ -9342,7 +9338,7 @@ Partial Class Ventas Cantidad = DtPedidos2TmpDT.FiltroPrimeroValor("Cantidad", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToDecimal CvePS = DtPedidos2TmpDT.FiltroPrimeroValor("CvePS", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToEntero PU = DtPedidos2TmpDT.FiltroPrimeroValor("PU", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToDecimal - CveVentaDetalle = TmpDT.FiltroPrimeroValor("CveVentaDetalle", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToEntero + CveVentaDetalle = TmpDTDetalle.FiltroPrimeroValor("CveVentaDetalle", $"CveVentaDetallePedido2={row("CveVentaDetalle")}").ToEntero CveVentaDetallePadre = row("CveVentaDetalle").ToString.ToEntero If Not ObjVentas.AddVentaDetallePedido2(CveVentaDetalle, CveVentaDetallePadre, Cantidad) Then @@ -9393,6 +9389,7 @@ Partial Class Ventas End If End Sub + Private Sub GuardarVentaPrePolizas(ByRef ObjConta As ClsContabilidad, factura As Modelos.Factura, TmpDTDetalleMovimientos As DataTable, CveNCaVincular As Integer, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, Optional EsNCAmortizacion As Boolean = False, Optional NCDescuento As Boolean = False) @@ -18232,7 +18229,9 @@ Partial Class Ventas Exit Sub End If If String.IsNullOrEmpty(Vigencia.EsCancelable) Then - sb.Append("No encontrado
") + Alert("No se pudo encontrar el estatus de la factura en el SAT.", TipoMensaje.MsgAdvertencia) + Exit Sub + 'sb.Append("No encontrado
") Else sb.AppendFormat("{0}
", Vigencia.EsCancelable) End If diff --git a/asmx/WSSIGApp.asmx b/asmx/WSSIGApp.asmx index a1b647fbd..8190b8df9 100644 --- a/asmx/WSSIGApp.asmx +++ b/asmx/WSSIGApp.asmx @@ -1,4848 +1,4890 @@ -<%@ 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. -' _ - - - -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 - If CveEmpresa <> -1 Then - 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(Application("GlobalDTOCEstatusUsuarios"), DataTable), filtro.ToString, "", DataViewRowState.CurrentRows) - GlobalDTOCEstatusUsuarios = Dv.ToTable - Dv.Dispose() - Else - GlobalDTOCEstatusUsuarios = DirectCast(Application("GlobalDTOCEstatusUsuarios"), DataTable) - End If - End Get - Set(value As DataTable) - Application("GlobalDTOCEstatusUsuarios") = 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" - - 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 - - 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 - - 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 - - - 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" - - 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 - - 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 - - Public Function GetMetodosPago33() As String - Return GlobalDTVtaMetodoPago().ToJson() - End Function - - - Public Function GetFormasPago33() As String - Return GlobalDTVtaFormaPago().ToJson() - End Function - - 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 - - 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 - - - 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 - - - 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 - - - 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 - - - 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 - - - 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 - - - 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" - - 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" - - 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 - - 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("

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 += "
- " + S - Next - 'Alert(String.Format("No está autorizado a modificar el SubProyecto
{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" - - 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\", AppDomain.CurrentDomain.BaseDirectory, 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 - - 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 - - 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 - - - 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 - - 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" - - 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 - - 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" - - 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 - - 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 - - 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 - - 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 - - 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 - - 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 - - - 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 - - Public Function GetUM(CveEmpresa As Integer) As String - Return GlobalDTUnidadesMedida(CveEmpresa).ToJson - End Function - - -#End Region -#Region "V E N T A S" - - 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 - - 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 - - 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 - - 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 - - - - 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 - - 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 = Server.MapPath("/") - - 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, 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 SerieLote 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("SerieLote") = SerieLote - 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.FechaCP - 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" - - 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 - - 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 - - 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 - - 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 - - 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 - - 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 - - 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 - - - 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 - - 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\", AppDomain.CurrentDomain.BaseDirectory, 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 - - 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 - - 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 - - - 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 - - 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 - - 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 - - - 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 - - - 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 - - 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 - - - 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 - - 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 - - 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 {2}

", TipoLargo, Folio, Estatus) - strOpciones.Append("
") - strOpciones.Append("
") - strOpciones.Append(" Opciones ") - strOpciones.Append(" ") - - '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(" ", StrSupervisa) - 'si se acaba de supervisar y se necesita autorizar - If pCveEstatus = 2 Then - strOpciones.AppendFormat(" ", StrAutoriza) - strOpciones.AppendFormat(" ", StrReqCotiza) - End If - 'si se quiere cancelar - strOpciones.AppendFormat(" ", StrCancela) - - strOpciones.Append("
Supervisar
Autorizar
Autorizar con Cotización
Cancelar
") - strOpciones.Append("
") - strOpciones.Append("
") - - 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($" #{FolioOC} ") - 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(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - - strBody.Append("
Por medio del Presente Correo Electronico, solicito a usted tenga a bien emitir cotización

") - - strBody.Append("
") - strBody.AppendFormat("
Datos {0} ", "Cotización") - strBody.Append(" ") - strBody.Append(" ") - strBody.AppendFormat(" ", Empresa) - strBody.Append(" ") - strBody.Append(" ") - strBody.AppendFormat(" ", FechaEstimadaEntrega) - strBody.Append(" ") - strBody.Append(" ") - strBody.AppendFormat(" ", LugarEntrega) - strBody.Append(" ") - strBody.Append("
Empresa:{0}
Fecha Entrega:{0}  
Lugar Entrega:{0}  
") - strBody.Append("
") - strBody.Append("
") - 'Cargo el detalle - - strBody.Append("
") - strBody.Append("
") - strBody.Append(" Productos a Cotizar ") - strBody.Append(" ") - strBody.Append(" ") - - '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("", dr("Cantidad").ToString.FormatoNumero, dr("Abreviatura"), dr("PS"), dr("Obs")) - Next - - strBody.Append("
CantidadUnidadDescripciónObservación
{0}{1}{2}{3}
") - strBody.Append("
") - strBody.Append("
") - strBody.AppendFormat("
Capture la cotizacion AQUI
", ModExtensiones.Encripta(String.Format("CveCotizacion={0}", CveCotizacion))) - strBody.Append("
") - strBody.Append("") - 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(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - strBody.AppendFormat("
Datos {0} ", TipoLargo) - strBody.Append(" ") - strBody.Append(" ") - strBody.AppendFormat(" ", UrlSitio, objOC.CveOrdenCompra, objOC.Folio, objOC.Estatus) - strBody.Append(" ") - strBody.Append(" ") - strBody.AppendFormat(" ", objOC.Empresa) - strBody.Append(" ") - strBody.Append(" ") - strBody.AppendFormat(" ", objOC.Descripcion) - strBody.Append(" ") - strBody.Append(" ") - strBody.AppendFormat(" ", objOC.Justificacion) - strBody.Append(" ") - strBody.Append("
Folio:{2} Estatus: {3}
Empresa:{0}
Descripción:{0}
Justificación
") - strBody.Append("
") - strBody.Append("
") - 'Cargo el detalle - If IncluirDetalles = True Then - strBody.Append("
") - strBody.Append("
") - strBody.Append(" Opciones ") - strBody.Append(" ") - strBody.AppendFormat(" ", If(CveEmpresaActual = 66, "Proyecto", "Proyecto
SubProyecto")) - - 'verifico los permisos según el estatus - - If objOC.GetOrdenesDetalle(CveOrdenCompra) Then - For Each dr As DataRow In objOC.DtResultados.Rows - strBody.AppendFormat("", - 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("
CantidadUnidadProducto o ServicioObservacion{0}Activo FijoP.U.Total
{0}{1}{2}
{3}
{4}{5}
{6}
{7}{8}{9}
") - strBody.Append("
") - strBody.Append("
") - Else - strBody.Append("
") - strBody.Append("
") - strBody.Append(" Bitacora ") - strBody.Append(" ") - strBody.Append(" ") - strBody.Append(" ") - If LigaAdjunto <> "" Then strBody.AppendFormat(" ", LigaAdjunto) - strBody.Append(" ") - strBody.Append("
") - strBody.AppendFormat(" {0}", Bitacora) - strBody.Append("
El usuario agrego el siguiente archivo: Adjunto
") - strBody.Append("
") - strBody.Append("
") - End If - 'strBody.Append(Opciones) - strBody.Append(Opciones) - strBody.Append("") - 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 " - - 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" - - 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" - - 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 - - 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 - - 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 - - - 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 - - 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 - - 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 - - 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}", AppDomain.CurrentDomain.BaseDirectory, 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 - - 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}", AppDomain.CurrentDomain.BaseDirectory, 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 - - 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\", AppDomain.CurrentDomain.BaseDirectory, 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 - - 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 - - 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 - - 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 - - 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 - - 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 - - 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 - - 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 - - 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 - - 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 - -#End Region - - - 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 - - - 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 - +<%@ 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. +' _ + + + +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 + If CveEmpresa <> -1 Then + 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(Application("GlobalDTOCEstatusUsuarios"), DataTable), filtro.ToString, "", DataViewRowState.CurrentRows) + GlobalDTOCEstatusUsuarios = Dv.ToTable + Dv.Dispose() + Else + GlobalDTOCEstatusUsuarios = DirectCast(Application("GlobalDTOCEstatusUsuarios"), DataTable) + End If + End Get + Set(value As DataTable) + Application("GlobalDTOCEstatusUsuarios") = 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" + + 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 + + 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 + + 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 + + + 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" + + 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 + + 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 + + Public Function GetMetodosPago33() As String + Return GlobalDTVtaMetodoPago().ToJson() + End Function + + + Public Function GetFormasPago33() As String + Return GlobalDTVtaFormaPago().ToJson() + End Function + + 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 + + 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 + + + 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 + + + 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 + + + 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 + + + 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 + + + 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 + + + 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" + + 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" + + 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 + + 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("

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 += "
- " + S + Next + 'Alert(String.Format("No está autorizado a modificar el SubProyecto
{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" + + 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\", AppDomain.CurrentDomain.BaseDirectory, 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 + + 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 + + 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 + + + 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 + + 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" + + 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 + + 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" + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + + 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 + + Public Function GetUM(CveEmpresa As Integer) As String + Return GlobalDTUnidadesMedida(CveEmpresa).ToJson + End Function + + +#End Region +#Region "V E N T A S" + + 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 + + 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 + + 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 + + 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 + + + + 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 + + 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 = Server.MapPath("/") + + 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, 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 SerieLote 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("SerieLote") = SerieLote + 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" + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + + 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 + + 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\", AppDomain.CurrentDomain.BaseDirectory, 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 + + 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 + + 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 + + + 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 + + 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 + + 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 + + + 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 + + + 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 + + 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 + + + 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 + + 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 + + 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 {2}

", TipoLargo, Folio, Estatus) + strOpciones.Append("
") + strOpciones.Append("
") + strOpciones.Append(" Opciones ") + strOpciones.Append(" ") + + '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(" ", StrSupervisa) + 'si se acaba de supervisar y se necesita autorizar + If pCveEstatus = 2 Then + strOpciones.AppendFormat(" ", StrAutoriza) + strOpciones.AppendFormat(" ", StrReqCotiza) + End If + 'si se quiere cancelar + strOpciones.AppendFormat(" ", StrCancela) + + strOpciones.Append("
Supervisar
Autorizar
Autorizar con Cotización
Cancelar
") + strOpciones.Append("
") + strOpciones.Append("
") + + 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($" #{FolioOC} ") + 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(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + + strBody.Append("
Por medio del Presente Correo Electronico, solicito a usted tenga a bien emitir cotización

") + + strBody.Append("
") + strBody.AppendFormat("
Datos {0} ", "Cotización") + strBody.Append(" ") + strBody.Append(" ") + strBody.AppendFormat(" ", Empresa) + strBody.Append(" ") + strBody.Append(" ") + strBody.AppendFormat(" ", FechaEstimadaEntrega) + strBody.Append(" ") + strBody.Append(" ") + strBody.AppendFormat(" ", LugarEntrega) + strBody.Append(" ") + strBody.Append("
Empresa:{0}
Fecha Entrega:{0}  
Lugar Entrega:{0}  
") + strBody.Append("
") + strBody.Append("
") + 'Cargo el detalle + + strBody.Append("
") + strBody.Append("
") + strBody.Append(" Productos a Cotizar ") + strBody.Append(" ") + strBody.Append(" ") + + '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("", dr("Cantidad").ToString.FormatoNumero, dr("Abreviatura"), dr("PS"), dr("Obs")) + Next + + strBody.Append("
CantidadUnidadDescripciónObservación
{0}{1}{2}{3}
") + strBody.Append("
") + strBody.Append("
") + strBody.AppendFormat("
Capture la cotizacion AQUI
", ModExtensiones.Encripta(String.Format("CveCotizacion={0}", CveCotizacion))) + strBody.Append("
") + strBody.Append("") + 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(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + strBody.AppendFormat("
Datos {0} ", TipoLargo) + strBody.Append(" ") + strBody.Append(" ") + strBody.AppendFormat(" ", UrlSitio, objOC.CveOrdenCompra, objOC.Folio, objOC.Estatus) + strBody.Append(" ") + strBody.Append(" ") + strBody.AppendFormat(" ", objOC.Empresa) + strBody.Append(" ") + strBody.Append(" ") + strBody.AppendFormat(" ", objOC.Descripcion) + strBody.Append(" ") + strBody.Append(" ") + strBody.AppendFormat(" ", objOC.Justificacion) + strBody.Append(" ") + strBody.Append("
Folio:{2} Estatus: {3}
Empresa:{0}
Descripción:{0}
Justificación
") + strBody.Append("
") + strBody.Append("
") + 'Cargo el detalle + If IncluirDetalles = True Then + strBody.Append("
") + strBody.Append("
") + strBody.Append(" Opciones ") + strBody.Append(" ") + strBody.AppendFormat(" ", If(CveEmpresaActual = 66, "Proyecto", "Proyecto
SubProyecto")) + + 'verifico los permisos según el estatus + + If objOC.GetOrdenesDetalle(CveOrdenCompra) Then + For Each dr As DataRow In objOC.DtResultados.Rows + strBody.AppendFormat("", + 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("
CantidadUnidadProducto o ServicioObservacion{0}Activo FijoP.U.Total
{0}{1}{2}
{3}
{4}{5}
{6}
{7}{8}{9}
") + strBody.Append("
") + strBody.Append("
") + Else + strBody.Append("
") + strBody.Append("
") + strBody.Append(" Bitacora ") + strBody.Append(" ") + strBody.Append(" ") + strBody.Append(" ") + If LigaAdjunto <> "" Then strBody.AppendFormat(" ", LigaAdjunto) + strBody.Append(" ") + strBody.Append("
") + strBody.AppendFormat(" {0}", Bitacora) + strBody.Append("
El usuario agrego el siguiente archivo: Adjunto
") + strBody.Append("
") + strBody.Append("
") + End If + 'strBody.Append(Opciones) + strBody.Append(Opciones) + strBody.Append("") + 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 " + + 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" + + 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" + + 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 + + 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 + + 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 + + + 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 + + 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 + + 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 + + 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}", AppDomain.CurrentDomain.BaseDirectory, 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 + + 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}", AppDomain.CurrentDomain.BaseDirectory, 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 + + 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\", AppDomain.CurrentDomain.BaseDirectory, 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + + 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 + + + Public Function GetRepAcercamientosProcesos(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 + + 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 + + + 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 + + + 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 + From d2881e4f496e7025abf6d47c34e239c0802cc8d6 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 8 Jan 2020 08:39:20 -0700 Subject: [PATCH 07/49] aplicando descuentos --- Inventarios/RecepcionUsados.aspx.vb | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Inventarios/RecepcionUsados.aspx.vb b/Inventarios/RecepcionUsados.aspx.vb index 113da0acf..e85f433a3 100644 --- a/Inventarios/RecepcionUsados.aspx.vb +++ b/Inventarios/RecepcionUsados.aspx.vb @@ -2561,16 +2561,25 @@ Partial Class Inventarios_RecepcionUsados Dim MarcaPorcentaje As DataRow = DtPorcentajeMarcas.FiltroPrimero(String.Format("CveMarca = {0}", drPS("CveMarca").ToString)) If MarcaPorcentaje IsNot Nothing Then Dim PorcentajeProducto As Decimal = MarcaPorcentaje("PorcentajeProducto").ToString.ToDecimal / 100 - Dim MontoDescuento As Decimal = PrecioSugerido * PorcentajeProducto - PrecioSugerido -= MontoDescuento - Dim PorcentajeProducto2 As Decimal = MarcaPorcentaje("PorcentajeProducto2").ToString.ToDecimal / 100 - MontoDescuento = PrecioSugerido * PorcentajeProducto2 - PrecioSugerido -= MontoDescuento - Dim PorcentajeProducto3 As Decimal = MarcaPorcentaje("PorcentajeProducto3").ToString.ToDecimal / 100 - MontoDescuento = PrecioSugerido * PorcentajeProducto3 - PrecioSugerido -= MontoDescuento + + If PorcentajeProducto > 0 Then + + Dim MontoDescuento As Decimal = PrecioSugerido * PorcentajeProducto + PrecioSugerido -= MontoDescuento + + If PorcentajeProducto2 > 0 Then + + MontoDescuento = PrecioSugerido * PorcentajeProducto2 + PrecioSugerido -= MontoDescuento + + If PorcentajeProducto3 > 0 Then + MontoDescuento = PrecioSugerido * PorcentajeProducto3 + PrecioSugerido -= MontoDescuento + End If + End If + End If End If From 21bffb5bac258a987d3dbf1f3bd59a257a8fb63d Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 8 Jan 2020 10:55:50 -0700 Subject: [PATCH 08/49] reparando detalles al agregar ps en saldos iniciales y al abrir el modal en cat clasificaciones --- General/SaldosIniciales.aspx.vb | 9 +++++++-- Ventas/CatClasificaciones.aspx.vb | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb index 004b752d8..dd79a2a08 100644 --- a/General/SaldosIniciales.aspx.vb +++ b/General/SaldosIniciales.aspx.vb @@ -683,6 +683,7 @@ Partial Class General_SaldosIniciales DTPS = ObjPS.DtResultados End If + Dim NuevaClasificacion As Boolean = False For Each Row As DataRow In dt.Rows Dim Codigo As String = Row("Codigo").ToString @@ -718,8 +719,9 @@ Partial Class General_SaldosIniciales If ObjClas.AddClasificaciones(Clasificacion, "", -1, "-1", -1, "-1", -1, "-1", GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveCategoria", "").ToString.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - If ObjClas.GetClasificaciones() Then Application("GlobalDTClasificaciones") = ObjClas.DtResultados + GlobalDTClasificaciones(UsuarioActual.CveEmpresa) = Nothing CveClasificacion = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveClasificacion", $"Clasificacion = '{Clasificacion}'").ToString.ToEntero + NuevaClasificacion = True End If End If @@ -831,7 +833,7 @@ Partial Class General_SaldosIniciales 'If Not CveClasificacion2 > 0 AndAlso Clasificacion2 <> "" Then Alert("No se encontró la Serie: " + Clasificacion2, TipoMensaje.MsgAdvertencia) : ErrorPS = True : Exit For If CvePS > 0 Then - If Not ObjPS.UpdatePS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", CodigoBarras, Descripcion, Precio, 1, 1, False, 0, True, True, True, UsuarioActual.CveUsuario, CvePS, -1, -1, CveSATPS, + If Not ObjPS.UpdatePS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", CodigoBarras, Descripcion, Precio, -1, 1, False, 0, True, True, True, UsuarioActual.CveUsuario, CvePS, -1, -1, CveSATPS, CveTipoPS:=CveTipoPS, CveMarca:=CveMarca, CveMedida:=CveMedida, CveRinTamaño:=CveRinTamaño, CveModelo:=CveModelo, Litraje:=Litraje, IEPSPorcentaje:=IEPS, CveClasificacion2:=CveClasificacion2, CveTamaño:=CveTamaño) Then 'If Not ObjPS.UpdatePS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", CodigoBarras, Descripcion, 0, 1, 1, False, 0, True, True, True, UsuarioActual.CveUsuario, CvePS, -1, -1, CveSATPS, @@ -878,6 +880,9 @@ Partial Class General_SaldosIniciales UpDatos.Update() Else ObjPS.RollBack() + If NuevaClasificacion Then + GlobalDTClasificaciones(UsuarioActual.CveEmpresa) = Nothing + End If End If ObjPS.Dispose() ObjGral.Dispose() diff --git a/Ventas/CatClasificaciones.aspx.vb b/Ventas/CatClasificaciones.aspx.vb index 0f1bd5b3e..1714fc630 100644 --- a/Ventas/CatClasificaciones.aspx.vb +++ b/Ventas/CatClasificaciones.aspx.vb @@ -348,7 +348,9 @@ Partial Class CatClasificaciones TxtClasificacion.Text = "" TxtPrecioBaseCosto.Text = "" - DdlCategoria.SelectedIndex = 0 + If DdlCategoria.Items.Count > 0 Then + DdlCategoria.SelectedIndex = 0 + End If DdlSATPS.SelectedValue = "" DdlSATPS.SelectedText = "" LtlTituloModal.Text = "Agregar Clasificación" From 8deccde93296d2ff889191f06322c98b1569d787 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 8 Jan 2020 12:24:41 -0700 Subject: [PATCH 09/49] agregando validacion de un nuevo proceso --- Ventas/Ventas.aspx.vb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index df9cc6906..f84070629 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -14252,7 +14252,8 @@ Partial Class Ventas 'AGREGA PS ADICIONAL - If UsuarioActual.Empresa.Funcionalidad(561).ToString = "1" AndAlso GlobalDTPSAdicionales(CvePS, UsuarioActual.CveEmpresa).Rows.Count > 0 AndAlso Not SeActualiza Then + If UsuarioActual.Empresa.Funcionalidad(561).ToString = "1" AndAlso GlobalDTPSAdicionales(CvePS, UsuarioActual.CveEmpresa).Rows.Count > 0 AndAlso Not SeActualiza AndAlso Not UsuarioActual.TienePermisoProceso(284) Then + For Each Dr As DataRow In GlobalDTPSAdicionales(CvePS, UsuarioActual.CveEmpresa).Rows Dim CvePSAdicional As Integer = Dr("CvePSAdicional").ToString.ToEntero Dim DrPoliza As DataRow = TmpDT.NewRow() @@ -14334,6 +14335,8 @@ Partial Class Ventas TmpDT.Rows.Add(DrPoliza) End If Next + + End If Retorno = True From e0a648477387cf243675a5bad20afa245269be4a Mon Sep 17 00:00:00 2001 From: Rene Molina Date: Wed, 8 Jan 2020 12:24:57 -0700 Subject: [PATCH 10/49] -error correcion --- Ventas/ClientesAbonar.aspx.vb | 2 +- Ventas/Ventas.aspx.vb | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index e91c73d26..680aee283 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -459,7 +459,7 @@ Partial Class Ventas_ClientesAbonar TxtImporte.Text = "" TxtObservaciones.Text = "" If SumDescuentoProntoPago > 0.0 Then - GvCxC.Columns("DescuentoProntoPago").Visible = True + GvCxC.Columns(15).Visible = True End If Mov.Dispose() diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 0748e7778..857f74619 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -10259,7 +10259,9 @@ Partial Class Ventas If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" 'Nota cuando es Nota de crédiot, debe de tomar el devoluciones y rebajas If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then - IdCtaContable = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero + Dim CampoCuenta As String = "IdCuentaGasto" + If UsuarioActual.CveEmpresa.Contiene(80, 72, 146) Then CampoCuenta = "IdCuentaDescuento" + IdCtaContable = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor(CampoCuenta, String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero Else IdCtaContable = GlobalDTClasificaciones(ObjFactura.CveEmpresa).FiltroPrimeroValor("IdCuentaIngresos", String.Format("CveClasificacion = {0}", Row2("CveClasificacion"))).ToEntero End If @@ -13827,10 +13829,12 @@ Partial Class Ventas If DtPromociones.Rows.Count > 0 And DtPromociones IsNot Nothing Then Dim dr As DataRow = DtPromociones.FiltroPrimero($"CvePS = {CvePS}") - TipoPromo = dr("TipoPromocion").ToString.ToEntero - TotalPromocion = dr("PUPromocion").ToString.ToDecimal * TxtCantidad.Text.ToDecimal - PromocionPorcentaje = dr("Promocion").ToString.ToDecimal - CantMinima = dr("CantidadMinima").ToString.ToEntero + If dr IsNot Nothing Then + TipoPromo = dr("TipoPromocion").ToString.ToEntero + TotalPromocion = dr("PUPromocion").ToString.ToDecimal * TxtCantidad.Text.ToDecimal + PromocionPorcentaje = dr("Promocion").ToString.ToDecimal + CantMinima = dr("CantidadMinima").ToString.ToEntero + End If End If If TipoPromo = 1 Then 'Promocion por Importe $ From 6edd3406d107eda65d76c91a0d43a2e410c938c2 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 8 Jan 2020 13:39:34 -0700 Subject: [PATCH 11/49] validacion de contabilizacion --- Bancos/FluctuacionCambiaria.aspx.vb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Bancos/FluctuacionCambiaria.aspx.vb b/Bancos/FluctuacionCambiaria.aspx.vb index 64f05ff7c..3146fb542 100644 --- a/Bancos/FluctuacionCambiaria.aspx.vb +++ b/Bancos/FluctuacionCambiaria.aspx.vb @@ -315,6 +315,8 @@ Partial Class Bancos_FluctuacionCambiaria Dim Total As Decimal = 0 Dim Conta As New ClsContabilidad Conta.IniciaTransacSQL() + Dim ObjContPaq As New ClsContPAQi(UsuarioActual.Empresa) + ObjContPaq.IniciaTransacSQL() Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/Fluctua", 1, 0, 0, 1, TxtFecha.Text.ToDate, "Fluctuación", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Dim idCta As Integer = 0 Dim CveCuenta As Integer = 0 @@ -372,8 +374,19 @@ Partial Class Bancos_FluctuacionCambiaria End If Next + Dim SeContabilizo As Boolean = False + + Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1" + If AutoConta Then + If Conta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then + SeContabilizo = True + Else + Alert("Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError) + End If + End If + + If Not ErrorRegistrar And SeContabilizo Then - If Not ErrorRegistrar Then Conta.Commit() Alert(String.Format("La Fluctuación se ha generado
Ver Póliza", CvePrePoliza), TipoMensaje.MsgInformacion) CargaDatosCuentas() From ff3194d6205341b4759f8dfce6c34afae69232de Mon Sep 17 00:00:00 2001 From: Rene Molina Date: Wed, 8 Jan 2020 13:42:32 -0700 Subject: [PATCH 12/49] -global --- Bancos/ProveedoresAbonar.aspx.vb | 2 +- Ventas/CatVendedores.aspx.vb | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Bancos/ProveedoresAbonar.aspx.vb b/Bancos/ProveedoresAbonar.aspx.vb index c86542405..1ab731944 100644 --- a/Bancos/ProveedoresAbonar.aspx.vb +++ b/Bancos/ProveedoresAbonar.aspx.vb @@ -827,7 +827,7 @@ Partial Class Bancos_ProveedoresAbonar 'cheque - If DdlTipoTransaccion.SelectedValue = "1" Then FolioFijo = TxtFolio.Text.ToEntero + If DdlTipoTransaccion.SelectedValue = "1" AndAlso UsuarioActual.CveEmpresa.Contiene(13, 83) Then FolioFijo = TxtFolio.Text.ToEntero CvePrePoliza = ObjMov.AddPrePolizas("Bancos/ProveedoresAbonar", 2, ImporteSeleccionado, ImporteSeleccionado, GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimeroValor("CveMoneda", "CveCuenta = " & DdlCuenta.SelectedValue).ToEntero, TxtFechaDocumento.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjComp.ObtenerReglaFolio(DdlTipoTransaccion.SelectedValue, Nothing, UsuarioActual.CveEmpresa), CveTipoPoliza:=ObjMov.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, "-1", UsuarioActual.CveEmpresa)) diff --git a/Ventas/CatVendedores.aspx.vb b/Ventas/CatVendedores.aspx.vb index 0de634028..0b9743043 100644 --- a/Ventas/CatVendedores.aspx.vb +++ b/Ventas/CatVendedores.aspx.vb @@ -137,11 +137,12 @@ Partial Class Ventas_CatVendedores #Region "CARGA GLOBAL" Private Sub CargaGlobal() - Dim ObjVendedores As New ClsVtaVendedores - If ObjVendedores.GetVendedores(-1) Then - GlobalDTVendedores(-1) = ObjVendedores.DtResultados - End If - ObjVendedores.Dispose() + GlobalDTVendedores(UsuarioActual.CveEmpresa) = Nothing + 'Dim ObjVendedores As New ClsVtaVendedores + 'If ObjVendedores.GetVendedores(UsuarioActual.CveEmpresa) Then + ' GlobalDTVendedores(-1) = ObjVendedores.DtResultados + 'End If + 'ObjVendedores.Dispose() End Sub #End Region From 83d48e7a27cff9e699949f21b268013fbb1c250c Mon Sep 17 00:00:00 2001 From: Rene Molina Date: Wed, 8 Jan 2020 13:44:43 -0700 Subject: [PATCH 13/49] - --- Ventas/Ventas.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 9b858b8b5..76db0cc83 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -14256,7 +14256,7 @@ Partial Class Ventas 'AGREGA PS ADICIONAL - If UsuarioActual.Empresa.Funcionalidad(561).ToString = "1" AndAlso GlobalDTPSAdicionales(CvePS, UsuarioActual.CveEmpresa).Rows.Count > 0 AndAlso Not SeActualiza AndAlso Not UsuarioActual.TienePermisoProceso(284) Then + If UsuarioActual.Empresa.Funcionalidad(561).ToString = "1" AndAlso Not UsuarioActual.TienePermisoProceso(284) AndAlso GlobalDTPSAdicionales(CvePS, UsuarioActual.CveEmpresa).Rows.Count > 0 AndAlso Not SeActualiza Then For Each Dr As DataRow In GlobalDTPSAdicionales(CvePS, UsuarioActual.CveEmpresa).Rows Dim CvePSAdicional As Integer = Dr("CvePSAdicional").ToString.ToEntero From 3a103f74f364a047f4b8e49874d55635d48667b1 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 8 Jan 2020 15:47:59 -0700 Subject: [PATCH 14/49] correcion en un texto fijo --- Empresas/146/Formatos/Factura.rdlc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Empresas/146/Formatos/Factura.rdlc b/Empresas/146/Formatos/Factura.rdlc index 5be0b965e..8ba97fc21 100644 --- a/Empresas/146/Formatos/Factura.rdlc +++ b/Empresas/146/Formatos/Factura.rdlc @@ -963,7 +963,7 @@ - Régimen: Sociedad Anónima de Capital Variable; Condiciones de pago: + Régimen: Personas Físicas con Actividades Empresariales y Profesionales; Condiciones de pago: - ; Num. Cta Pago: - - - - =IIF(Parameters!NumCta.Value="0" Orelse Parameters!NumCta.Value="","No Identificado",Parameters!NumCta.Value) + ; - Por éste pagare prometo (emos) pagar incondicionalmente a la orden de Localización Precisa GPS de México SA de CV, a su vencimiento el + Por éste pagare prometo (emos) pagar incondicionalmente a la orden de VICTOR MANUEL RAMIREZ CASTILLO, a su vencimiento el - , en Hermosillo, Sonora o en el domicilio señalado a elección del acreedor o tenedor la cantidad de $ + , en Tijuana, Baja California o en el domicilio señalado a elección del acreedor o tenedor la cantidad de $ - ). Valor recibido a mi (nuestra) entera satisfacción. La falta de pago de éste documento a su vencimiento dará derecho a Localización Precisa GPS de México SA de CV o tenedor, desde el día siguiente a cobrar el 10% mensual de interes moratorios hasta su total liquidación y los gastos judiciales que se ocasionen. Lugar y Fecha de Suscripción: Hermosillo, Sonora a + ). Valor recibido a mi (nuestra) entera satisfacción. La falta de pago de éste documento a su vencimiento dará derecho a VICTOR MANUEL RAMIREZ CASTILLO o tenedor, desde el día siguiente a cobrar el 10% mensual de interes moratorios hasta su total liquidación y los gastos judiciales que se ocasionen. Lugar y Fecha de Suscripción: Tijuana, Baja California a @@ -73,9 +73,9 @@ Textbox3 0.93484in - 5.662in + 5.81465in 0.5cm - 2.24597in + 2.09332in 1 - - ; Método de Pago: - - - - =IIF(Parameters!MetodoPago.Value.ToString="","No Identificado",Parameters!MetodoPago.Value) - - ; - ). Valor recibido a mi (nuestra) entera satisfacción. La falta de pago de éste documento a su vencimiento dará derecho a VICTOR MANUEL RAMIREZ CASTILLO o tenedor, desde el día siguiente a cobrar el 10% mensual de interes moratorios hasta su total liquidación y los gastos judiciales que se ocasionen. Lugar y Fecha de Suscripción: Tijuana, Baja California a + ). Valor recibido a mi (nuestra) entera satisfacción. La falta de pago de éste documento a su vencimiento dará derecho a VICTOR MANUEL RAMIREZ CASTILLO o tenedor, desde el día siguiente a cobrar el 5% mensual de interes moratorios hasta su total liquidación y los gastos judiciales que se ocasionen. Lugar y Fecha de Suscripción: Tijuana, Baja California a - - - - - - Textbox15 - - - - - 1pt - - - - 1pt - - - - 1pt - - - - 1pt - - #ff1037 - Middle - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Parameters!UsoCFDI.Value - - - - - - - Textbox17 - - - 2pt - 2pt - 2pt - 2pt - - - - - - 1.56188cm @@ -3462,13 +3355,12 @@ - DsOC 6.91306cm 0.11468cm - 5.76188cm + 5.16188cm 14.34413cm 31 + + true + + + + + Uso CFDI: + + + + =Parameters!UsoCFDI.Value + + + + + + + + + Régime: + + + + Personas Físicas con Actividades Empresariales y Profesionales + + + + + + + + + Método de Pago: + + + + + + + + =IIF(Parameters!MetodoPago.Value.ToString="","No Identificado",Parameters!MetodoPago.Value) + + + + + + + + + + + Textbox10 + 0.99561in + 3.82301in + 0.62735in + 1.99164in + 37 + + + Top + + 25.59192cm @@ -35,6 +35,80 @@ + + +
+
+
+ + +
+
+
+ + +
+ + + + + + + +
+
+ Fecha Inicio: +
+
+
+ + + + +
+ + + + + + +
+
+ Fecha Fin: +
+
+
+ + + + +
+ + + + + + +
+
+
+
+ +
+
+
@@ -52,8 +126,13 @@
+ DataKeyNames="FolioFiscal,TipoDocto,ImporteTotal,Estatus,Fecha,Moneda,RFCReceptor,CveEmpresa,RutaXml,RFCEmisor,TipoDoctoTexto" OnRowDataBound="GVConciliacionemitidasSAT_RowDataBound"> + + + + + @@ -91,12 +170,13 @@ - + - + <%-- --%> + XML @@ -153,7 +233,6 @@ - + - + + diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index dea66b2a4..980e7ae74 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2575,11 +2575,13 @@ Partial Class Ventas If ObjPVenta.DtResultados.Rows.Count > 0 Then CveCorte = ObjPVenta.CveCorte LblEstatusCaja.Text = ObjPVenta.FechaInicial.ToShortDateString + LblTurno.Text = ObjPVenta.FechaInicial.ToShortDateString TrEstatusCaja.Visible = True BtnIniciarTurno.Visible = False LkbEstadodeCaja.Visible = True LkbIngreso.Visible = True LkbRetiro.Visible = True + UpTurno.Update() Else 'Ingresar un nuevo Turno RegistraScript("window.onload = function MuestraCorteCaja() { document.getElementById(""C_btnShow"").click(); }") From 81a7baa8bad9069793730546048b8a347219caea Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 10 Jan 2020 19:19:19 -0700 Subject: [PATCH 34/49] Porcentaje de retenciones --- App_Code/ClsClientes.vb | 8 +- Ventas/Clientes.aspx | 11962 +++++++++++++++++++------------------- Ventas/Clientes.aspx.vb | 29 +- 3 files changed, 6059 insertions(+), 5940 deletions(-) diff --git a/App_Code/ClsClientes.vb b/App_Code/ClsClientes.vb index cb1e95310..a268761f6 100644 --- a/App_Code/ClsClientes.vb +++ b/App_Code/ClsClientes.vb @@ -568,7 +568,7 @@ Public Class ClsClientes Optional ObservacionRevsion As String = "-1", Optional ReferenciaFiscal As String = "-1", Optional Celular As String = "-1", Optional ExtOtros As String = "-1", Optional CveUsoCFDI As Integer = -1, Optional CveFormaPago33 As Integer = -1, Optional CveMetodoPago33 As Integer = -1, Optional DesglosaIEPS As Boolean = True, Optional AplicaComercioExterior As Boolean = False, Optional CveTipoOperacion As Integer = -1, Optional CvePedimento As Integer = -1, Optional CveIncoterm As Integer = -1, Optional CvePais As Integer = -1, Optional CveEstado As Integer = -1, Optional CveMunicipio As Integer = -1, Optional CveColonia As Integer = -1, Optional CveMotivoTraslado As Integer = 0, Optional NumRegIdTrib As String = "", Optional ComExtEstado As String = "-1", Optional ComExtMunicipio As String = "-1", Optional ComExtColonia As String = "-1", Optional RequiereOC As Boolean = False, - Optional LT As String = "0", Optional LG As String = "0", Optional EsDistribuidor As Boolean = False, Optional TipoCliente As Integer = 1, Optional CargoUsado As Boolean = False, Optional BonificacionUsado As Boolean = False) As Boolean + Optional LT As String = "0", Optional LG As String = "0", Optional EsDistribuidor As Boolean = False, Optional TipoCliente As Integer = 1, Optional CargoUsado As Boolean = False, Optional BonificacionUsado As Boolean = False, Optional CveTipoRetencion As Integer = 0) As Boolean Dim Retorno As Boolean = False @@ -702,6 +702,7 @@ Public Class ClsClientes .Add("@TipoCliente", SqlDbType.Int).Value = TipoCliente .Add("@CargoUsado", SqlDbType.Bit).Value = CargoUsado .Add("@BonificacionUsado", SqlDbType.Bit).Value = BonificacionUsado + .Add("@CveTipoRetencion", SqlDbType.TinyInt).Value = CveTipoRetencion .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue End With @@ -747,7 +748,7 @@ Public Class ClsClientes Optional AplicaComercioExterior As Boolean = False, Optional CveTipoOperacion As Integer = -1, Optional CvePedimento As Integer = -1, Optional CveIncoterm As Integer = -1, Optional CvePais As Integer = -1, Optional CveEstado As Integer = -1, Optional CveMunicipio As Integer = -1, Optional CveColonia As Integer = -1, Optional CveMotivoTraslado As Integer = 0, Optional NumRegIdTrib As String = "-1", Optional ComExtEstado As String = "-1", Optional ComExtMunicipio As String = "-1", Optional ComExtColonia As String = "-1", Optional ApellidoPaternoPF As String = "-1", Optional ApellidoMaternoPF As String = "-1", Optional NombresPF As String = "-1", Optional RequiereOC As Boolean = False, - Optional LT As String = "0", Optional LG As String = "0", Optional EsDistribuidor As Boolean = False, Optional TipoCliente As Integer = 1, Optional CargoUsado As Boolean = False, Optional BonificacionUsado As Boolean = False) As Boolean + Optional LT As String = "0", Optional LG As String = "0", Optional EsDistribuidor As Boolean = False, Optional TipoCliente As Integer = 1, Optional CargoUsado As Boolean = False, Optional BonificacionUsado As Boolean = False, Optional CveTipoRetencion As Integer = 0) As Boolean Dim Retorno As Boolean = False @@ -896,7 +897,8 @@ Public Class ClsClientes .Add("@EsDistribuidor", SqlDbType.Bit).Value = EsDistribuidor .Add("@TipoCliente", SqlDbType.Int).Value = TipoCliente .Add("@CargoUsado", SqlDbType.Bit).Value = CargoUsado - .Add("@BonificacionUsado", SqlDbType.Bit).Value = BonificacionUsado + .Add("@BonificacionUsado", SqlDbType.Bit).Value = BonificacionUsado + .Add("@CveTipoRetencion", SqlDbType.TinyInt).Value = CveTipoRetencion End With Try SqlAdapter.Fill(Data) diff --git a/Ventas/Clientes.aspx b/Ventas/Clientes.aspx index 37c043e47..fc0a5dbb1 100644 --- a/Ventas/Clientes.aspx +++ b/Ventas/Clientes.aspx @@ -1,1490 +1,1542 @@ -<%@ Page Title="Ventas - Clientes" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="Clientes.aspx.vb" Inherits="Clientes" %> - -<%@ Register Assembly="TimePicker" Namespace="MKB.TimePicker" TagPrefix="cc1" %> -<%@ Register Assembly="eWorld.UI" Namespace="eWorld.UI" TagPrefix="ew" %> - - - - - - -
  • - Registrar Venta - Registrar Cotización -
  • - -
  • +<%@ Page Title="Ventas - Clientes" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="Clientes.aspx.vb" Inherits="Clientes" %> + +<%@ Register Assembly="TimePicker" Namespace="MKB.TimePicker" TagPrefix="cc1" %> +<%@ Register Assembly="eWorld.UI" Namespace="eWorld.UI" TagPrefix="ew" %> + + + + + + +
  • + Registrar Venta + Registrar Cotización +
  • + +
  • Conciliar - -
  • - - - -
  • - -
  • -
    -
    - - - - -
  • - -
  • -
    -
    - - -
  • - -
  • -
    -
    - - -
  • - -
  • -
    -
    - - - -
  • - Agregar Cuenta Bancaria -
  • -
    -
    - - - -
  • - -
  • -
    -
    - - -
  • - -
  • -
    -
    - - - - -
  • - -
  • -
    -
    - - - -
  • - -
  • -
    -
    - - - -
  • - -
  • -
    -
    - - - -
  • - -
  • -
    -
    - - - -
  • - -
  • -
    -
    - - - -
  • - -
  • -
    - - - -
    - -
    - -   - - - - - -
      -
    • -
    • -
    • - -
    • -
    -
    -
    - - - - - - - -
    -
    -
    -
    -
    - - Datos de Emisión -
    -
    -
    -
    -
    -
    - -
    - -
    - - - - -
    - -
    -
    - - - - -
    -
    - - - - -
    -
    - - - - -
    -
    - - -
    - - - - -
    -
    - - -
    -
    - - - -
    -
    - - - - -
    -
    -
    -
    - - -
    -
    -
    -
    - - -
    -
    -
    -
    - - - - -
    -
    - - - -
    -
    - - - - -
    -
    - - - - -
    -
    - - - - -
    -
    - - - - - -
    -
    - - - - - - -
    -
    -
    -
    - - - - - -
    -
    -
    - - - -
    -
    -
    -
    -
    - - Datos del Cliente -
    -
    -
    -
    -
    -
    -
    -
    - - -
    -
    -
    -
    - - - - -
    -
    -
    -
    - - -
    -
    -
    - -
    - -
    -
    - - - -
    -
    - -
    -
    -
    - - -
    -
    -
    -
    - - -
    - - - -
    - -
    - - - - - -
    -
    - - - - - -
    -
    - - -
    -
    - - -
    -
    - - - - -
    -
    - - -
    -
    - - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - -
    -
    - - -
    - -
    - - -
    - -
    - - Frecuente - No Frecuente - - -
    -
    - - -
    -
    - - -
    -
    -
    -
    - - <%-- Marcar el Cliente como Frecuente --%> -
    -
    -
    -
    - - Registrar -
    -
    -
    -
    -
    -
    -
    -
    - - - - -
    - -
    -
    -
    -
    -
    - -
    -
    -
    -
    - - Sucursales y/o Departamentos -
    -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - -
    Sucursal y/o DepartamentoComandos
       -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Periodo Facturación: - - - - - - - - -
    Imprime Nombre Sucursal: -
    - -
    -
    -
    -
    - -
    -
    -
    -
    - - Direcciones de envío -
    -
    -
    - -
    -
    -
    -
    - - - - + + + + + +
  • + +
  • +
    +
    + + + + +
  • + +
  • +
    +
    + + +
  • + +
  • +
    +
    + + +
  • + +
  • +
    +
    + + + +
  • + Agregar Cuenta Bancaria +
  • +
    +
    + + + +
  • + +
  • +
    +
    + + +
  • + +
  • +
    +
    + + + + +
  • + +
  • +
    +
    + + + +
  • + +
  • +
    +
    + + + +
  • + +
  • +
    +
    + + + +
  • + +
  • +
    +
    + + + +
  • + +
  • +
    +
    + + + +
  • + +
  • +
    + + + +
    + + + +   + + + + + +
      +
    • +
    • +
    • + +
    • +
    +
    +
    + + + + + + + +
    +
    +
    +
    +
    + + Datos de Emisión +
    +
    +
    +
    +
    +
    + +
    + +
    + + + + +
    + +
    +
    + + + + +
    +
    + + + + +
    +
    + + + + +
    +
    + + +
    + + + + +
    +
    + + +
    +
    + + + +
    +
    + + + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + + + +
    +
    + + + +
    +
    + + + + +
    +
    + + + + +
    +
    + + + + +
    +
    + + + + + +
    +
    + + + + + + +
    +
    +
    +
    + + + + + +
    +
    +
    + + + +
    +
    +
    +
    +
    + + Datos del Cliente +
    +
    +
    +
    +
    +
    +
    +
    + + +
    +
    +
    +
    + + + + +
    +
    +
    +
    + + +
    +
    +
    + +
    + +
    +
    + + + +
    +
    + +
    +
    +
    + + +
    +
    +
    +
    + + +
    + + + +
    + +
    + + + + + +
    +
    + + + + + +
    +
    + + +
    +
    + + +
    +
    + + + + +
    +
    + + +
    +
    + + + + +
    + +
    + + + +
    + +
    + + + +
    + +
    + + + +
    + +
    + + +
    +
    + + +
    + +
    + + +
    + +
    + + Frecuente + No Frecuente + + +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + <%-- Marcar el Cliente como Frecuente --%> +
    +
    +
    +
    + + Registrar +
    +
    +
    +
    +
    +
    +
    +
    + + + + +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + Sucursales y/o Departamentos +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + +
    Sucursal y/o DepartamentoComandos
       +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Periodo Facturación: + + + + + + + + +
    Imprime Nombre Sucursal: +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + + Direcciones de envío +
    +
    +
    + +
    +
    +
    +
    + + + + Sucursal/Depto - - -
    - -
    -
    -
    - - + + + +
    + +
    +
    +
    + + Contacto - - -
    - -
    -
    -
    - - + + + +
    + +
    +
    +
    + + Ciudad - - -
    - -
    -
    -
    - - - - - - - - - - -
    -
    -
    + + + +
    + +
    +
    + + + + + + + + + + + + + +
    Condiciones Entrega: - -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - -
    -
    -
    -
    -
    - - Resumen -
    -
    -
    -
    -
    -
    -
    -
    -
    + + +
    + +
    + +
    +
    + +
    +
    +
    + + Contable +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + Registros Contables +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + + + +
    +
    + +
    + +
    + + + + + +
    +
    + + +
    + +
    + + + + + +
    +
    + + + +
    + +
    + + + + + +
    +
    + + +
    + +
    + + + + + +
    +
    + + +
    + +
    + + + + + +
    +
    + + + + +
    + +
    + + + + + +
    +
    +
    + +
    + + + + + +
    +
    +
    + +
    + + + + + +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + +
    +
    +
    +
    +
    + + Resumen +
    +
    +
    +
    +
    +
    +
    +
    +
    Cantidad de Ventas: -
    -
    - - -
    -
    -
    -
    + +
    +
    + + +
    +
    +
    +
    Total Vendido: -
    -
    - - -
    -
    - -
    -
    + +
    +
    + + +
    +
    + +
    +
    Venta Mínima: -
    -
    - -
    -
    -
    -
    + +
    +
    + +
    +
    +
    +
    Promedio de Ventas: -
    -
    - -
    -
    -
    -
    + +
    +
    + +
    +
    +
    +
    Venta Máxima: -
    -
    - - -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    - - Historial de Ventas -
    -
    -
    - " - style="display: inline-block; margin-right: -20px; width: 150px;" /> - " - style="margin-top: -3px; float: inherit;" class="btn btn-circle btn-sm label-info"> -
    -
    -
    -
    -
    -
    - - - - - - - - - -
    -
    -
    - - - - - - - - - - - - - - - - Factura - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Remision - - - - - - - - Reenviar - - - - - - - - - - - - - -
    -
    - -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - Resumen -
    -
    -
    -
    -
    -
    -
    -
    -
    + +
    +
    + + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + + Historial de Ventas +
    +
    +
    + " + style="display: inline-block; margin-right: -20px; width: 150px;" /> + " + style="margin-top: -3px; float: inherit;" class="btn btn-circle btn-sm label-info"> +
    +
    +
    +
    +
    +
    + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + + + Factura + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Remision + + + + + + + + Reenviar + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + Resumen +
    +
    +
    +
    +
    +
    +
    +
    +
    Cantidad de Cotizaciones: -
    -
    - -
    -
    -
    -
    + +
    +
    + +
    +
    +
    +
    Factor de Cotizaciones VS Ventas: -
    -
    + +
    +
     % -
    -
    -
    -
    - -
    - -
    -
    -
    -
    - - Cotizaciones -
    - -
    -
    - " - style="display: inline-block; margin-right: -20px; width: 150px;" /> - " - style="margin-top: -3px; float: inherit;" class="btn btn-circle btn-sm label-info"> -
    -
    - -
    -
    - - - - - - - - - - -
    -
    - -
    -
    -
    - - - - - Cotización - - - - - - - - - - - - - - - - - - - - - - - - - Folio Venta - - - - - - - - - - Reenviar - - - - - - + +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + + Cotizaciones +
    + +
    +
    + " + style="display: inline-block; margin-right: -20px; width: 150px;" /> + " + style="margin-top: -3px; float: inherit;" class="btn btn-circle btn-sm label-info"> +
    +
    + +
    +
    + + + + + + + + + + +
    +
    + +
    +
    +
    + + + + + Cotización + + + + + + + + + + + + + + + + + + + + + + + + + Folio Venta + + + + + + + + + + Reenviar + + + + + + <%-- - --%> - - Crear O.S. - + --%> + + Crear O.S. + <%--Crear O.S.--%> - - - - - - - - -
    -
    -
    - -
    -
    -
    -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - - Parametros -
    -
    - -
    -
    -
    - - -
    -
    - -
    - -
    - -
    - - - - <%-- --%> - -
    - -
    - - - - -
    - -
    - - - - -
    - -
    -
    -
    - -
    + + + + + + + + +
    +
    +
    + +
    +
    +
    +
    +
    + + + + + + + + +
    +
    + +
    +
    +
    + + Parametros +
    +
    + +
    +
    +
    + + +
    +
    + +
    + +
    + +
    + + + + <%-- --%> + +
    + +
    + + + + +
    + +
    + + + + +
    + +
    +
    +
    + +
       +     +    +    +    +    -
    - + +
    +   +   +   +   +   +   -
    -
    - -
    -
    - - -
    -
    -
    - - - -
    - - - - - - - -
    - -
    - - -
    -
    -
    -
    - -
    + +
    +
    + +
    +
    + + +
    +
    +
    + + + +
    + + + + + + + +
    + +
    + + +
    +
    +
    +
    + +
       +     +    +    +    +    -
    - + +
    +   +   +   +   +   +   -
    -
    -
    -
    - - -
    - + +
    +
    +
    +
    + + +
    + <%-- @@ -1537,48 +1589,48 @@ - --%> -
    - -
    - -
    - - <%----%> - -
    - -
    -
    -
    - - - - <%----%> - -
    -
    - -
    -
    - - -
    -
    -
    - - -
    - - <%----%> - -
    - -
    - - -
    - + --%> +
    + +
    + +
    + + <%----%> + +
    + +
    +
    +
    + + + + <%----%> + +
    +
    + +
    +
    + + +
    +
    +
    + + +
    + + <%----%> + +
    + +
    + + +
    + <%--
    @@ -1600,708 +1652,716 @@
    -
    --%> - -
    - - <%----%> - -
    - -
    -
    - - <%----%> - -
    - -
    - - <%----%> - -
    -
    - -
    - - - -
    -
    - -
    - - - -
    -
    -
    - -
    -
    -
    -
    - - Estado de Cuenta -
    -
    - -
    -
    -
    +
    --%> + +
    + + <%----%> + +
    + +
    +
    + + <%----%> + +
    + +
    + + <%----%> + +
    +
    + +
    + + + +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    +
    + + Estado de Cuenta +
    +
    + +
    +
    +
    <%-- Cuentas por Cobrar Anticipos / NC - --%> - -
    -
    - -
    - - - - - - -
    -
    -
    - -
    - - - - - - -
    -
    -
    -
    -
    - -
    - - - - - - -
    -
    -
    - -
    - - - - - - -
    -
    -
    - -
    -
    - - - - - -
    - -
    - - - - - - - - - + --%> + +
    +
    + +
    + + + + + + +
    +
    +
    + +
    + + + + + + +
    +
    +
    +
    +
    + +
    + + + + + + +
    +
    +
    + +
    + + + + + + +
    +
    +
    + +
    +
    + + + + + +
    + +
    + + + + + + + + + <%-- - --%> -
    -
    -
    -
    - -
    -
    -
    -
    - -    -
    -
    - - - - -
    -
    -
    - -
    -
    - -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    -
    -
    -
    -
    - - CxC Activas -
    -
    -
    - - - - - - - - - - -
    -
    -
    -
    -
    -
    + --%> +
    +
    +
    +
    + +
    +
    +
    +
    + +    +
    +
    + + + + +
    +
    +
    + +
    +
    + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    +
    +
    +
    + + CxC Activas +
    +
    +
    + + + + + + + + + + +
    +
    +
    +
    +
    +
    Pago múltiples facturas Pagar múltiples facturas      -
    -
    - - - - - - - - - - - - - - + +
    +
    + + + + + + + + + + + + + +   - - - - + + + + +   - - - - + + + + +   - - - - - - - - - - - - - - - - <%----%> - - - - - - - - -
    -
    - -
    - - -
    -
    -
    - - Historial de CxC -
    -
    -
    - - - - - - - - - - -
    -
    -
    - -
    -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    -
    -
    -
    -
    - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + <%----%> + + + + + + + + +
    +
    + +
    + + +
    +
    +
    + + Historial de CxC +
    +
    +
    + + + + + + + + + + +
    +
    +
    + +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    +
    +
    +
    + + + + + + + + + + + + +   - - - - + + + + +   - - - - + + + + +   - - - - - - - - - - - - -
    -
    -
    - - - - - - - - - - - - - - - - - -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    - -
    -
    -
    - - Anticipo del Cliente -
    -
    -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - -
    -
    -
    - -
    -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    - -
    -
    -
    - - Anticipo del Cliente Historial -
    -
    -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - -
    - -
    - -
    -
    -
    - -
    -
    - -
    -
    - - - - - - - - - - - - - - - - - - -
    -
    -
    - - Cuentas Bancarias - -
    - -
    - - - -
    - -
    -
    - - - - - - - - - - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - -
    -
    -
    - - Cobros Realizados -
    -
    -
    - - - - - - - - - - -
    -
    -
    -
    -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    - -
    - - - - - - - - - - - - - - - + + + + + + + + + + + + + +
    +
    +
    +
    + + + + + + + + +
    + + + + + + + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    + +
    +
    +
    + + Anticipo del Cliente +
    +
    +
    + + + + + + + + + + +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    + +
    +
    +
    + + Anticipo del Cliente Historial +
    +
    +
    + + + + + + + + + + +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + +
    + +
    + +
    +
    +
    + +
    +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    +
    +
    + + Cuentas Bancarias + +
    + +
    + + + +
    + +
    +
    + + + + + + + + + + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    + + Cobros Realizados +
    +
    +
    + + + + + + + + + + +
    +
    +
    +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    + +
    + + + + + + + + + + + + + + +   - - - - - - - - - - Archivos - - - - - - - Reenviar Complemento - + + + + + + + + + + + Archivos + + + + + + + Reenviar Complemento + <%-- - --%> - - - - - - - - -
    -
    - -
    -
    -
    -
    -
    - - - - - - - - - -

    No Facturadas

    - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -

    Facturadas

    - - - - Folio - - - - + --%> + + + + + + + + +
    +
    + +
    +
    + +
    + + + + + + + + + + +

    No Facturadas

    + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +

    Facturadas

    + + + + Folio + + + + <%-- Solicitó @@ -2313,1202 +2373,1215 @@ - --%> - - - - - - - - - - - - - - - -
    -
    - - - - -
    -

    Cuentas y Equipos

    - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    -
    - -
    - - - - - - - -
    -
    - - - -
    -
    -
    -
    -
    - - FEMSA -
    -
    -
    -
    -
    -
    -
    -
    - -
    - -
    -
    - -
    - - -
    -
    - -
    - -
    - - -
    -
    - -
    - -
    - - -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    - - Detallista -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    - -
    - - -
    -
    - -
    - -
    - - -
    -
    - -
    - -
    - - -
    -
    - -
    - -
    - - -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    - - 7Eleven -
    -
    -
    -
    -
    -
    -
    -
    - -
    - -
    - - -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    - - FORD -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    - -
    - - -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    - - Impuestos Locales -
    -
    -
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    - - COMERCIO EXTERIOR -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    - -
    - -
    - - -
    - -
    - -
    -
    - -
    - - -
    - -
    -
    - -
    - -
    - -
    -
    - -
    - -
    - - -
    - -
    - -
    - -
    - -
    -
    - -
    -
    - -
    - -
    - - -
    - -
    - -
    - -
    - -
    -
    - -
    -
    - -
    -
    - - -
    - -
    - -
    -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    -
    -
    -
    -
    -
    - -
    - - - -
    -
    -
    -
    -
    - - Ventas -
    -
    -
    -
    -
    -
    -
    -
    - -
    - -
    - - -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - ACTIVO FIJO ASIGNADO -
    -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - -
    -
    -
    -
    -
    -
    -
    - - - -
    -
    -
    - - Personal Asignado -
    -
    -
    -
    -
    -
    -
    -
    - - - - N° - - - - - - Personal - -   - - - - Genero - -   - - - - Turno - -   - - - - Departamento - -   - - - - Puesto - -   - - - - Estatus - - - - - - - - - -
    -
    -
    -
    -
    -
    -
    -
    - - Consultar Asistencias -
    -
    -
    -
    -
    -
    -
    -
    -
    + --%> + + + + + + + + + + + + + + + + + + + + + +
    +

    Cuentas y Equipos

    + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    +
    + + + + + + + + + + + + + + +
    +
    +
    +
    +
    + + FEMSA +
    +
    +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + + +
    +
    + +
    + +
    + + +
    +
    + +
    + +
    + + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + Detallista +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    + +
    + + +
    +
    + +
    + +
    + + +
    +
    + +
    + +
    + + +
    +
    + +
    + +
    + + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + 7Eleven +
    +
    +
    +
    +
    +
    +
    +
    + +
    + +
    + + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + FORD +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    + +
    + + +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + Impuestos Locales +
    +
    +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    + + COMERCIO EXTERIOR +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    + +
    + + +
    + +
    + +
    +
    + +
    + + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + + +
    + +
    + +
    + +
    + +
    +
    + +
    +
    + +
    + +
    + + +
    + +
    + +
    + +
    + +
    +
    + +
    +
    + +
    +
    + + +
    + +
    + +
    +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    +
    +
    +
    +
    +
    + +
    + + + +
    +
    +
    +
    +
    + + Ventas +
    +
    +
    +
    +
    +
    +
    +
    + +
    + +
    + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + ACTIVO FIJO ASIGNADO +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + +
    +
    +
    +
    +
    +
    +
    + + + +
    +
    +
    + + Personal Asignado +
    +
    +
    +
    +
    +
    +
    +
    + + + + N° + + + + + + Personal + +   + + + + Genero + +   + + + + Turno + +   + + + + Departamento + +   + + + + Puesto + +   + + + + Estatus + + + + + + + + + +
    +
    +
    +
    +
    +
    +
    +
    + + Consultar Asistencias +
    +
    +
    +
    +
    +
    +
    +
    +
    Fecha Inicial: -
    - - - - - - - - - - -
    -
    -
    + +
    + + + + + + + + + + +
    +
    +
    Fecha Final: -
    - - - - - - - - - - -
    -
    -
    - -
    -
    - -
    - - - - - Fecha - - - - - - Asistencia - -   - - - - % Pago - - - - - - Horas Dobles - - - - - - Horas Triples - - - - - - Motivo Horas Extras - -   - - - - Observaciones - -   - - - - - - - -
    -
    -
    -
    -
    - -
    -
    - - - - +
    +
    +
    + + + + + + + - - - - - - -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    -
    -
    - - Contratos Activos -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    -
    - - - - -
    - - - - - - - - -
    Clasificación Contratado Avance Faltante Avance Por Facturar
    -
    - - - - - - - - - - - - -
    -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - - Historial de Contratos -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    -
    - - - - -
    - - - - - - - - -
    Clasificación Contratado Avance Faltante Avance Por Facturar
    -
    - - - - - - - - - - - - - -
    -
    -
    -
    -
    - -
    -
    - - - -
    -
    -
    -
    -
    - - Sistema -
    -
    -
    -
    -
    -
    -
    -
    + --%> + + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    +
    +
    + + Contratos Activos +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    + + + + +
    + + + + + + + + +
    Clasificación Contratado Avance Faltante Avance Por Facturar
    +
    + + + + + + + + + + + + +
    +
    +
    +
    +
    + +
    +
    + +
    +
    +
    + + Historial de Contratos +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    + + + + +
    + + + + + + + + +
    Clasificación Contratado Avance Faltante Avance Por Facturar
    +
    + + + + + + + + + + + + + +
    +
    +
    +
    +
    + +
    +
    + + + +
    +
    +
    +
    +
    + + Sistema +
    +
    +
    +
    +
    +
    +
    +
    Estado: - -
    -
    + + +
    +
    Fecha de Captura: - -
    -
    + + +
    +
    Usuario Capturó: - -
    -
    -
    -
    - - - -
    -
    -
    -
    - - Acceso a Portal del Cliente -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    + + +
    +
    +
    +
    + + + +
    +
    +
    +
    + + Acceso a Portal del Cliente +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    Usuario Activo: - - - -
    - + + + + +
    + Usuario: -
    -
    -
    + +
    +
    +
    Enviar Activación: - - -
    -
    + + + +
    +
    Desactivar Usuario: - -
    -
    - -
    -
    - - - Permisos Admin: - - - - - - - - + + + + + +
    +
    + + + Permisos Admin: +
    - - - -
    + + + + + + + <%-- --%> + --%> <%-- --%> - - - - - - - - - + --%> + + + + + + + + + <%-- --%> + --%> <%----%> - - -
    + + + + - - -
    - - - - +
    + + + + - - -
    - - -
    -
    -
    - - -
    -
    -
    -
    -
    -
    -
    - -
    - - - -
    -
    -
    -
    -
    - - Usuarios del Portal -
    -
    -
    -
    -
    -
    -
    - - - - -
    - - - - - + +
    - + --%> + +
    + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    +
    + + Usuarios del Portal +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + - + - - - - - - - - - - - - + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - -
    + Nombre - - - - + + + + + Correo/Usuario - - - - Compras - CxP - Anticip - R.H. - O.S. - Cotiza- - Sist - - - - - + + + + + Compras + CxP + Anticip + R.H. + O.S. + Cotiza- + Sist + + + + + Fecha - - - - + + + + + Usuario - - - Comandos
    - - - - - - - - - - - - - - - - -     - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + +
    Comandos
    + + + + + + + + + + + + + + + + +     + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- @@ -3524,2458 +3597,2479 @@ - --%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + --%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      -
    -
    - - -   + + + + +     - - - -
    -
    - - -
    -
    -
    -
    -
    -
    -
    -
    - - - - - <%-- ---------------------------- --%> - <%-- Documentacion --%> - <%-- ---------------------------- --%> - - -
    - -
    - - -
    -
    -
    - - Documentación del Cliente -
    -
    -
    -
    -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + +
    + + +
    + + + +
    +
    +
    +
    +
    + + +
    + + + <%-- ---------------------------- --%> + <%-- Documentacion --%> + <%-- ---------------------------- --%> + + +
    + +
    + + +
    +
    +
    + + Documentación del Cliente +
    +
    +
    +
    +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- - --%> -
    -
    - - -
    -
    - - - - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    -
    -
    - -
    -
    -
    -
    -
    - - - -
    -
    -
    - -
    -
    - -
    -
    - <%-- ---------------------------- --%> - <%-- Documentacion Fin --%> - <%-- ---------------------------- --%> - - - - - -
    -
    -
    - - -
    -
    -
    -
    + --%> + + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + + +
    + + + +
    +
    + + + + <%-- ---------------------------- --%> + <%-- Documentacion Fin --%> + <%-- ---------------------------- --%> + + + + + +
    +
    +
    + + +
    +
    +
    +
    Fecha Inicio: -
    -
    -
    - - - - -
    - - - - -
    -
    + +
    +
    +
    + + + + +
    + + + + +
    +
    Fecha Fin: -
    -
    -
    - - - - -
    - - - - -
    - -
    - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    -
    -
    -
    - -
    -
    -
    - - -
    -
    - - - - - - - - - - - - - - - -
    -
    -
    -
    - -
    -
    - - - - - - - -
    -
    -
    -
    -
    - - Usados resumen -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - + + +
    +
    + + + + +
    + + + + +
    + +
    + +
    + +
    + + + +
    + +
    + + + +
    + +
    + + + +
    + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + +
    +
    +
    +
    + + + + + + + + + + +
    +
    +
    +
    +
    + + Usados resumen +
    +
    +
    +
    +
    +
    +
    + + + + +
    Puntos -
    Importe Cargo
    + + + + + + + - - - - + + + + + + - - - -
    Puntos +
    Importe Cargo $ - - -
    Importe Bonificación + +
    Importe Bonificación $ - - -
    - -
    -
    - - -
    -
    -
    -
    - - -
    -
    - - -
    -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    -
    - -
    - -
    - - -
    -
    -
    - - -
    -
    -
    -
    + + + + + + + + + + + + + +
    +
    +
    +
    + + +
    +
    + + +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    + +
    + +
    + + +
    +
    +
    + + +
    +
    +
    +
    Fecha Inicio: -
    -
    -
    - - - - -
    - - - - -
    -
    + +
    +
    +
    + + + + +
    + + + + +
    +
    Fecha Fin: -
    -
    -
    - - - - -
    - - - - -
    -
    -
    -
    - -
    -
    -
    - - - - - - - - - - - - - - - - + +
    +
    +
    + + + + +
    + + + + +
    +
    +
    +
    + +
    +
    +
    + + + + + + + + + + + + + + + + <%-- - --%> - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    + --%> + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    <%--
    -
    --%> - -
    - -
    - - -
    -
    -
    -
    - - - - - - - - - - - - -
    - - - - - - - - -
    - - +
    +
    + + <%-- MODAL BITACORA --%> + - <%-- FIN MODAL BITACORA --%> - - <%-- MODAL SUCURSAL --%> - - - <%-- MODAL DIRECCION ENVIO --%> - +
    +
    + <%-- FIN MODAL BITACORA --%> + + <%-- MODAL SUCURSAL --%> + + + <%-- MODAL DIRECCION ENVIO --%> + - <%-- FIN MODAL DIRECCION ENVIO--%> - - <%-- MODAL COMPARACION--%> - - <%-- FIN MODAL COMPARACION--%> - - <%-- MODAL IMPORTAR SALDOS --%> - + <%-- FIN MODAL IMPORTAR SALDOS --%> + + <%-- MODAL AGREGAR CUENTA EQUIPO --%> + + <%-- FIN MODAL AGREGAR CUENTA --%> + + <%-- MODAL CARGA DOCUMENTOS CLIENTE CXC --%> + + <%-- FIM MODAL CARGA DOCUMENTOS CXC --%> + + <%-- MODAL VISITAS CXC --%> + + + + + + + <%--MODAL ACTUALIZAR PERSONA FISICA--%> + + + + + + +
    + +
    + +
    +
    +
    + <%-- FIN MODAL MODIFICAR PRECIOS PS --%> + + + + + + + + + + - - + + + - - - + + + diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb index 93b3af6a2..fae874fcf 100644 --- a/Ventas/Clientes.aspx.vb +++ b/Ventas/Clientes.aspx.vb @@ -820,6 +820,10 @@ Partial Class Clientes UpFiscalContable.Update() End If + If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then + DivTipoRetenciones.Visible = True + End If + If Request("CveEmpresaCRM") IsNot Nothing AndAlso IsNumeric(Request("CveEmpresaCRM")) AndAlso Request("CveEmpresaCRM").ToEntero > 0 Then ViewState("CveEmpresaCRM") = Request("CveEmpresaCRM") CargaDatosCRM() @@ -1374,7 +1378,8 @@ Partial Class Clientes TxtGiro.Text = ObjClientes.Giro DdlPrecioLista.SelectedValue = ObjClientes.CvePrecioLista.ToString TxtCC.Text = ObjClientes.NotificarA - ChkMail.Checked = ObjClientes.EnviarFactura + ChkMail.Checked = ObjClientes.EnviarFactura + DdlTipoRetencion.SelectedValueExist(ObjClientes.DtResultados(0)("CveTipoRetencion").ToString) TxtRetIVA.Text = ObjClientes.RetIVA.ToString TxtRetISR.Text = ObjClientes.RetISR.ToString ChkRetIVAFletesAcarreos.Checked = ObjClientes.RetieneIVAFletes @@ -2411,7 +2416,7 @@ Partial Class Clientes CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero, CveMetodoPago33:=DdlMetodoPago33.SelectedValue.ToEntero, DesglosaIEPS:=ChkDesglosarIEPS.Checked, AplicaComercioExterior:=ChkAplicaComercioExterior.Checked, CveTipoOperacion:=DdlTipoOperacion.SelectedValue.ToEntero, CvePedimento:=DdlClavePedimento.SelectedValue.ToEntero, CveIncoterm:=DdlIncoterm.SelectedValue.ToEntero, CvePais:=DdlPais.SelectedValue.ToEntero, CveEstado:=DdlEstado.SelectedValue.ToEntero, CveMunicipio:=DdlMunicipio.SelectedValue.ToEntero, CveColonia:=DdlColonia.SelectedValue.ToEntero, CveMotivoTraslado:=IIf(DdlMotivoTraslado.SelectedValue = "-1", "0", DdlMotivoTraslado.SelectedValue).ToString().ToEntero, NumRegIdTrib:=IIf(TxtNumRegIdTrib.Text = "", "-1", TxtNumRegIdTrib.Text).ToString(), ComExtEstado:=IIf(TxtComExtEstado.Text = "", "-1", TxtComExtEstado.Text).ToString(), ComExtMunicipio:=IIf(TxtComExtMunicipio.Text = "", "-1", TxtComExtMunicipio.Text).ToString(), ComExtColonia:=IIf(TxtComExtColonia.Text = "", "-1", TxtComExtColonia.Text).ToString(), RequiereOC:=ChkRequiereOC.Checked, LT:=LT, LG:=LG, EsDistribuidor:=ChkEsDistribuidor.Checked, - TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, CargoUsado:=ChkCargoUsado.Checked, BonificacionUsado:=ChkBonificacionUsado.Checked) Then + TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, CargoUsado:=ChkCargoUsado.Checked, BonificacionUsado:=ChkBonificacionUsado.Checked, CveTipoRetencion:=DdlTipoRetencion.SelectedValue.ToEntero()) Then ViewState("CveCliente") = ObjClientes.CveCliente @@ -2505,7 +2510,8 @@ Partial Class Clientes AplicaComercioExterior:=ChkAplicaComercioExterior.Checked, CveTipoOperacion:=DdlTipoOperacion.SelectedValue.ToEntero, CvePedimento:=DdlClavePedimento.SelectedValue.ToEntero, CveIncoterm:=DdlIncoterm.SelectedValue.ToEntero, CvePais:=DdlPais.SelectedValue.ToEntero, CveEstado:=DdlEstado.SelectedValue.ToEntero, CveMunicipio:=DdlMunicipio.SelectedValue.ToEntero, CveColonia:=DdlColonia.SelectedValue.ToEntero, CveMotivoTraslado:=IIf(DdlMotivoTraslado.SelectedValue = "-1", "0", DdlMotivoTraslado.SelectedValue).ToString().ToEntero, NumRegIdTrib:=IIf(TxtNumRegIdTrib.Text = "", "-1", TxtNumRegIdTrib.Text).ToString(), ComExtEstado:=IIf(TxtComExtEstado.Text = "", "-1", TxtComExtEstado.Text).ToString(), ComExtMunicipio:=IIf(TxtComExtMunicipio.Text = "", "-1", TxtComExtMunicipio.Text).ToString(), ComExtColonia:=IIf(TxtComExtColonia.Text = "", "-1", TxtComExtColonia.Text).ToString(), - ApellidoPaternoPF:=IIf(TxtApellidoPaterno.Text = "", "-1", TxtApellidoPaterno.Text).ToString(), ApellidoMaternoPF:=IIf(TxtApellidoMaterno.Text = "", "-1", TxtApellidoMaterno.Text).ToString(), NombresPF:=IIf(TxtNombres.Text = "", "-1", TxtNombres.Text).ToString(), RequiereOC:=ChkRequiereOC.Checked, LT:=LT, LG:=LG, EsDistribuidor:=ChkEsDistribuidor.Checked, TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, CargoUsado:=ChkCargoUsado.Checked, BonificacionUsado:=ChkBonificacionUsado.Checked) Then + ApellidoPaternoPF:=IIf(TxtApellidoPaterno.Text = "", "-1", TxtApellidoPaterno.Text).ToString(), ApellidoMaternoPF:=IIf(TxtApellidoMaterno.Text = "", "-1", TxtApellidoMaterno.Text).ToString(), NombresPF:=IIf(TxtNombres.Text = "", "-1", TxtNombres.Text).ToString(), + RequiereOC:=ChkRequiereOC.Checked, LT:=LT, LG:=LG, EsDistribuidor:=ChkEsDistribuidor.Checked, TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, CargoUsado:=ChkCargoUsado.Checked, BonificacionUsado:=ChkBonificacionUsado.Checked, CveTipoRetencion:=DdlTipoRetencion.SelectedValue.ToEntero()) Then ObjClientes.LimpiaImpuestosLocales(CveCliente) @@ -9935,5 +9941,22 @@ Partial Class Clientes End Sub #End Region + Protected Sub DdlTipoRetencion_SelectedIndexChanged(sender As Object, e As EventArgs) + Select Case DdlTipoRetencion.SelectedValue + Case "1" 'Arrendamiento + TxtRetIVA.Text = "10" + TxtRetISR.Text = "10" + Case "2" 'Servicios Profesionales + TxtRetIVA.Text = "10" + TxtRetISR.Text = "10" + Case "3" 'Fletes + TxtRetIVA.Text = "4" + TxtRetISR.Text = "4" + Case "4" 'Servicios + TxtRetIVA.Text = "6" + TxtRetISR.Text = "6" + End Select + UpFiscalContable.Update() + End Sub End Class From c22c696de823d015b77a178cd18ab9514eb002c8 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Sat, 11 Jan 2020 10:43:06 -0700 Subject: [PATCH 35/49] agregando kilometraje a la interfaz de ventas, solo aparece si es empresa llantera --- Ventas/Ventas.aspx | 8 +++++++- Ventas/Ventas.aspx.vb | 14 +++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index a57297234..6fa1b3ceb 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -3239,7 +3239,13 @@ - + + Kilometraje  + + + + +
    diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 980e7ae74..1765b3c67 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2522,7 +2522,8 @@ Partial Class Ventas DivMesesSinIntereses.Visible = True DivDdlCuentaTarjetaCredito.Attributes.Add("class", "col-md-4") DivContadoOtros.Visible = True - + TrKilometraje.Visible = True + TrKilometrajeTxt.Visible = True End If End If @@ -3841,7 +3842,7 @@ Partial Class Ventas HdnIVAOriginal.Value = TxtIVA.Text TxtPedidoContrato.Text = DbRowVenta("PedidoContrato").ToString TxtPedidoContrato.Enabled = False - + TxtKilometraje.Text = DbRowVenta("Kilometraje").ToString HdnAmortizacion.Value = LblAmort.Text.ToDouble.ToString HdnSubTotalDescuestos.Value = (TxtSubTotal.Text.Replace(",", "").ToDouble - LblDescuentos.Text.Replace(",", "").ToDouble - LblAmortizacion.Text.Trim.Replace(",", "").ToDouble - TxtRetISR.Text.Replace(",", "").ToDouble).FormatoNumero(2) @@ -9123,7 +9124,8 @@ Partial Class Ventas CveMetodoPago33:=factura.CveMetodoPago33, CveUsoCFDI:=factura.CveUsoCFDI, OrdenCompra:=TxtOrdenCompra.Text, CveCuentaTerminal:=DdlCuentasTerminal.SelectedValue.ToEntero, CveTipoRelacion:=factura.CveTipoRelacion, ImpuestoLocal:=TotalImpuestoLocal, CveVentaRelacion:=(If(factura.CveVentaRelacion.ToEntero > 0, factura.CveVentaRelacion, -1)), ImporteRelacion:=(If(factura.ImporteRelacion <> Nothing, factura.ImporteRelacion, -1)), CveTipoAmortizacionAnticipo:=factura.CveTipoAmortizacionAnticipo, CveEmpresaCRM:=CveEmpresaCRM, EsInterno:=EsInterno, CveAcercamientoCRM:=CveAcercamientoCRM, - DiasCredito:=factura.DiasCredito, EsDiasCreditoFijo:=factura.EsDiasCreditoFijo, AnticipoEspecial:=If(TrAntEspecial.Visible, ChkAntEspecial.Checked, False)) Then + DiasCredito:=factura.DiasCredito, EsDiasCreditoFijo:=factura.EsDiasCreditoFijo, AnticipoEspecial:=If(TrAntEspecial.Visible, ChkAntEspecial.Checked, False), + Kilometraje:=If(TrKilometrajeTxt.Visible AndAlso IsNumeric(TxtKilometraje.Text), TxtKilometraje.Text.ToDouble, -1)) Then ErrorList.Add("Ocurrió un error al Generar la Venta.
    Revise su factura y cualquier detalle comuníquese a Soporte Técnico") @@ -16404,7 +16406,9 @@ Partial Class Ventas If Not ObjVentas.UpdateVentas(TxtSubTotal.Text.ToDecimal, LblDescuentos.Text.ToDecimal, TxtIVA.Text.ToDecimal, TxtIEPS.Text.ToDecimal, TxtTotal.Text.ToDecimal, Moneda, TipoCambio, TxtFecha.Text.Trim.ToDate, TxtObsFact.Text.Trim, UsuarioActual.CveEmpresa, CveVenta, 0, 0, Vigencia:=TxtFechaVencimientoCotizacion.Text.Trim.ToDate, CondicionesPago:=If(RBLPago.SelectedValue = "2", 0, 1), - PedidoContrato:=TxtPedidoContrato.Text, AtencionA:=TxtAtencionA.Text.Trim, CveMetodoPago33:=DdlMetodoPago33.SelectedValue.ToEntero, CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero, TipoDocto:="Rem", CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, OrdenCompra:=TxtOrdenCompra.Text, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal) Then + PedidoContrato:=TxtPedidoContrato.Text, AtencionA:=TxtAtencionA.Text.Trim, CveMetodoPago33:=DdlMetodoPago33.SelectedValue.ToEntero, + CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero, TipoDocto:="Rem", CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, + OrdenCompra:=TxtOrdenCompra.Text, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal, Kilometraje:=If(TrKilometrajeTxt.Visible AndAlso IsNumeric(TxtKilometraje.Text), TxtKilometraje.Text.ToDouble, -1)) Then OcurrioError = True End If @@ -22076,7 +22080,7 @@ Partial Class Ventas Vigencia:=TxtFechaVencimientoCotizacion.Text.Trim.ToDate, CondicionesPago:=If(RBLPago.SelectedValue = "2", 0, 1), PedidoContrato:=TxtPedidoContrato.Text, AtencionA:=TxtAtencionA.Text.Trim, CveMetodoPago33:=DdlMetodoPago33.SelectedValue.ToEntero, CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero, CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, OrdenCompra:=TxtOrdenCompra.Text, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal, - TipoDocto:=DdlTipoComprobante.SelectedValue) Then + TipoDocto:=DdlTipoComprobante.SelectedValue, Kilometraje:=If(TrKilometrajeTxt.Visible AndAlso IsNumeric(TxtKilometraje.Text), TxtKilometraje.Text.ToDouble, -1)) Then MensajeError = "Ocurrió un error al actualizar la información de la cotización" OcurrioError = True End If From d91c296e09235e2c3544457a6e42fd372c73ecac Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Sat, 11 Jan 2020 12:35:44 -0700 Subject: [PATCH 36/49] columna ps se cambio por CodigoPS --- Ventas/ProductosServicios.aspx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ventas/ProductosServicios.aspx b/Ventas/ProductosServicios.aspx index c0a918e0c..e18481707 100644 --- a/Ventas/ProductosServicios.aspx +++ b/Ventas/ProductosServicios.aspx @@ -410,11 +410,11 @@
    - + - + From bdbdff0f9c0f35b8616fa37c955c9630cafae098 Mon Sep 17 00:00:00 2001 From: Rene Molina Date: Sat, 11 Jan 2020 12:45:00 -0700 Subject: [PATCH 37/49] - --- Contabilidad/RegPrePoliza.aspx | 3 + Contabilidad/RegPrePoliza.aspx.vb | 62 +++++++-- Inventarios/RecepcionEntrega.aspx.vb | 182 +++++++++++---------------- Planeacion/CatSubProyectos.aspx.vb | 6 +- 4 files changed, 135 insertions(+), 118 deletions(-) diff --git a/Contabilidad/RegPrePoliza.aspx b/Contabilidad/RegPrePoliza.aspx index 2836aea82..88e35e479 100644 --- a/Contabilidad/RegPrePoliza.aspx +++ b/Contabilidad/RegPrePoliza.aspx @@ -373,6 +373,9 @@ +
    +
    +
    diff --git a/Contabilidad/RegPrePoliza.aspx.vb b/Contabilidad/RegPrePoliza.aspx.vb index 623229efd..e6580a22f 100644 --- a/Contabilidad/RegPrePoliza.aspx.vb +++ b/Contabilidad/RegPrePoliza.aspx.vb @@ -794,6 +794,18 @@ Partial Class ContabilidadC_RegPrePoliza e.Row.FCLinkButton("ImgBancos").CssClass = "btn btn-circle btn-sm green" End If End If + + If e.Row.DataKey("CveConcepto").ToEntero.Contiene(17) Then + e.Row.FCDropDownList("DdlProveedores").Visible = True + e.Row.FCDropDownList("DdlProveedores").DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) + e.Row.FCDropDownList("DdlProveedores").DataBind() + e.Row.FCDropDownList("DdlProveedores").Items.Insert(0, New ListItem(" - ", "-1")) + + 'If CveTipoTransaccion > 0 And CveCuenta > 0 And Folio.Length > 0 And ImporteDocumento > 0 And Beneficiario.Length > 0 Then + ' e.Row.FCLinkButton("ImgPagoCompra").CssClass = "btn btn-circle btn-sm green" + 'End If + End If + End If End Sub @@ -854,15 +866,20 @@ Partial Class ContabilidadC_RegPrePoliza If ObjIE.GetBancosIE(CveIE, -1, -1, "-1", -1, "-1", "-1", -1, -1, -1, -1, -1, MinFecha, MaxFecha, MinFecha, MaxFecha, MinFecha, MaxFecha, -1, -1, UsuarioActual.CveEmpresa) Then FolioIE = ObjIE.Folio End If - End If - - + End If + + + Dim CveProveedor As Integer = -1 + Dim CveCompra As Integer = -1 'inserto las compras que voy a pagarDdlSaldos For Each gvr As GridViewRow In GvMov.Rows If gvr.DataKey("IDCuenta").ToEntero > 0 Then IdCtaContable = gvr.DataKey("IDCuenta") End If + CveProveedor = gvr.DataKey("CveProveedor").ToEntero + CveCompra = gvr.DataKey("CveCompra").ToEntero + CveConcepto = gvr.DataKey("CveConcepto").ToEntero If gvr.DataKey("TipoMovto").ToDouble <> 0 Then Importe = gvr.FCTextBox("TxtAbono").Text.ToDouble @@ -870,6 +887,11 @@ Partial Class ContabilidadC_RegPrePoliza Else Importe = gvr.FCTextBox("TxtCargo").Text.ToDouble TipoMovto = False + End If + 'Registra pago de compra + If CveConcepto = 17 Then + CveProveedor = gvr.FCDropDownList("DdlProveedores").SelectedValue.ToEntero + CveCompra = gvr.FCDropDownList("DdlCompras").SelectedValue.ToEntero End If If CveConcepto = 41 Then @@ -890,7 +912,7 @@ Partial Class ContabilidadC_RegPrePoliza If Importe <> 0 Then If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Importe, gvr.FCLiteral("LtlReferencia").Text, gvr.DataKey("CveConcepto").ToEntero, gvr.FCTextBox("TxtConcepto").Text, TxtFecha.Text.ToDate, IdCtaContable, -1, CveSubProyecto:=gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero, CveIE:=CveIE, - CveProveedor:=gvr.DataKey("CveProveedor").ToEntero, CveCompra:=gvr.DataKey("CveCompra").ToEntero, + CveProveedor:=CveProveedor, CveCompra:=CveCompra, CvePersonal:=gvr.DataKey("CvePersonal").ToEntero, CveClasificacion:=gvr.DataKey("CveClasificacion").ToEntero, ImporteMX:=Importe, CveTipoGasto:=gvr.FCDropDownList("DdlTipoGasto").SelectedValue.ToEntero, CveCliente:=gvr.DataKey("CveCliente").ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=If(gvr.DataKey("TC").ToString.ToDouble > 0, gvr.DataKey("TC").ToString.ToDouble, 1), @@ -1560,10 +1582,34 @@ Partial Class ContabilidadC_RegPrePoliza Protected Sub LnkComplementoPago_Click(sender As Object, e As EventArgs) GeneraTimbre(CvePrePoliza) - End Sub + End Sub #End Region - - - + + + + Protected Sub DdlProveedores_SelectedIndexChanged1(sender As Object, e As EventArgs) + Dim ddl As DropDownList = CType(sender, DropDownList) + Dim ddl2 As DropDownList = DirectCast(ddl.BindingContainer, GridViewRow).FCDropDownList("DdlCompras") + CargaCompras2(ddl.SelectedValue.ToEntero, ddl2) + End Sub + + Private Sub CargaCompras2(CveProveedor As Integer, ddl As DropDownList) + + Dim ObjCompras As New ClsCompras + + ddl.ClearSelection() + If ObjCompras.GetCompras(-1, "-1", "-1", CveProveedor, -1, UsuarioActual.CveEmpresa) Then + ddl.DataSource = ObjCompras.DtResultados.FiltraParametros("Saldo > 0") + ddl.DataBind() + ddl.Items.Insert(0, New ListItem(" - ", "-1")) + ddl.Visible = True + Else + ddl.DataSource = Nothing + ddl.DataBind() + ddl.Items.Insert(0, New ListItem(" - ", "-1")) + + End If + ObjCompras.Dispose() + End Sub End Class diff --git a/Inventarios/RecepcionEntrega.aspx.vb b/Inventarios/RecepcionEntrega.aspx.vb index 4d3cf4f62..1194c521b 100644 --- a/Inventarios/RecepcionEntrega.aspx.vb +++ b/Inventarios/RecepcionEntrega.aspx.vb @@ -1868,112 +1868,7 @@ Partial Class Inventarios_RecepcionEntrega End If ' TERMINA: GARANTIAS - ' COMIENZA: VIRTUAL - If TipoDocto.Contiene("Ing") AndAlso UsuarioActual.Empresa.Funcionalidad(573) = "1" Then - Dim DtPSVirtual As New DataTable("DtTamanios") - DtPSVirtual.Columns.Add(New DataColumn("CvePS", GetType(Integer))) - DtPSVirtual.Columns.Add(New DataColumn("Cantidad", GetType(Decimal))) - DtPSVirtual.Columns.Add(New DataColumn("PU", GetType(Decimal))) - DtPSVirtual.Columns.Add(New DataColumn("CveUM", GetType(Integer))) - - Dim DtTamanios As DataTable = Nothing - - If ObjAcumuladores.TamañoGet(-1, UsuarioActual.CveEmpresa) Then - DtTamanios = ObjAcumuladores.DtResultados.Copy() - End If - - Dim CveConceptoMovimientoVirtual As Integer = -1 - Dim CveAlmacenVirtual As Integer = -1 - Dim CveMovimientoRelacionadoVirtual As Integer = -1 - Dim ValidaVirtual As Boolean = False - - If TipoMovimiento = 1 Then - For Each GvRow As GridViewRow In GvDatos.Rows - If GvRow.RowType = DataControlRowType.DataRow Then - - If GvRow.datakey("CveTamaño").tostring.toentero > 0 Then - ValidaVirtual = True ' si tiene tamaño, debe de tener virtual - Dim drr As DataRow = DtTamanios.FiltroPrimero(String.Format("CveTamaño={0}", GvRow.DataKey("CveTamaño"))) - If drr IsNot Nothing Then - - Dim CvePSCargo = drr("CvePSCargo").ToString().ToEntero() - Dim Row As DataRow = DtPSVirtual.NewRow() - Row("CvePS") = CvePSCargo - Row("Cantidad") = GvRow.FCTextBox("TbCantidadF").Text.ToDecimal() - Row("PU") = 0 - Row("CveUM") = GvRow.DataKey("CveUM").ToEntero() - - DtPSVirtual.Rows.Add(Row) - End If - - End If - - End If - Next - CveConceptoMovimientoVirtual = 3 - CveAlmacenVirtual = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 24).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero() - - ElseIf TipoMovimiento = 2 Then - ValidaVirtual = True - Dim CveMovimientoSalidaDev As Integer = -1 - If ObjInventario.GetInv_Mov(CveVentaSurtir, UsuarioActual.CveEmpresa) Then - Dim RowMovimiento As DataRow = ObjInventario.DtResultados.FiltroPrimero("CvePS IS NULL AND CveTipoAlmacen = 24 AND CveConcepto = 3 AND CveVenta > 0") - CveMovimientoSalidaDev = RowMovimiento("CveMovimiento").ToString().ToEntero() - CveAlmacenVirtual = RowMovimiento("CveAlmacen").ToString().ToEntero() - CveMovimientoRelacionadoVirtual = CveMovimientoSalidaDev - Else - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar el movimiento. Por favor vuelva a intentar." - End If - - 'CARGA CONCEPTOS DEVUELTOS EN LA VENTA - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalidaDev, UsuarioActual.CveEmpresa) Then - DtPSVirtual = ObjInventario.DtResultados.Copy() - Else - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los movimientos de devolución. Por favor vuelva a intentar." - End If - CveConceptoMovimientoVirtual = 18 - End If - - If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 AndAlso CveAlmacenVirtual > 0 AndAlso CveConceptoMovimientoVirtual > 0 Then - CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, - Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveMovimientoRelacionado:=CveMovimientoRelacionadoVirtual, Modulo:="RE/G6") - FolioVirtual = ObjInventario.Folio - - If CveMovimientoVirtual > 0 Then - For Each RowUsado As DataRow In DtPSVirtual.Rows - Dim CvePS = RowUsado("CvePS").ToString().ToEntero() - Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() - Dim PU As Double = RowUsado("PU").ToString().ToDouble() - Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - Next - Else - ErrorMovInv = True - End If - - Else - If ValidaVirtual Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar el movimiento en almacen virtual. Por favor vuelva a intentar." - - End If - End If - - If DtPSVirtual.Rows.Count = 0 AndAlso ValidaVirtual = True Then - ErrorMovInv = True - TextoError = "No se tienen productos para el almacen virtual." - End If - End If - - ' TERMINA: VIRTUAL If Not ErrorMovInv Then Dim ConceptoMovimiento = 3 @@ -2316,8 +2211,81 @@ Partial Class Inventarios_RecepcionEntrega End If End If - 'AGREGA BITACORA A VENTA - If Not ErrorMovInv Then + ' COMIENZA: VIRTUAL + If TipoDocto.Contiene("Ing", "Dev") AndAlso UsuarioActual.Empresa.Funcionalidad(573) = "1" AndAlso CveMovimiento > 0 Then + Dim DtPSVirtual As New DataTable("DtTamanios") + + If ObjInventario.GetMovimientosDetalleVirtual(CveMovimiento, UsuarioActual.CveEmpresa) Then + DtPSVirtual = ObjInventario.DtResultados + End If + + ' + 'DtPSVirtual.Columns.Add(New DataColumn("CvePS", GetType(Integer))) + 'DtPSVirtual.Columns.Add(New DataColumn("Cantidad", GetType(Decimal))) + 'DtPSVirtual.Columns.Add(New DataColumn("PU", GetType(Decimal))) + 'DtPSVirtual.Columns.Add(New DataColumn("CveUM", GetType(Integer))) + + 'Dim DtTamanios As DataTable = Nothing + + 'If ObjAcumuladores.TamañoGet(-1, UsuarioActual.CveEmpresa) Then + ' DtTamanios = ObjAcumuladores.DtResultados.Copy() + 'End If + + Dim CveConceptoMovimientoVirtual As Integer = -1 + Dim CveAlmacenVirtual As Integer = -1 + Dim CveMovimientoRelacionadoVirtual As Integer = CveMovimiento + Dim ValidaVirtual As Boolean = False + + If TipoMovimiento = 1 Then + CveConceptoMovimientoVirtual = 36 + CveAlmacenVirtual = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 24).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero() + + ElseIf TipoMovimiento = 2 Then + ValidaVirtual = True + CveConceptoMovimientoVirtual = 37 + End If + + If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 AndAlso CveAlmacenVirtual > 0 AndAlso CveConceptoMovimientoVirtual > 0 Then + CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, + Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveMovimientoRelacionado:=CveMovimientoRelacionadoVirtual, Modulo:="RE/G6") + FolioVirtual = ObjInventario.Folio + + If CveMovimientoVirtual > 0 Then + For Each RowUsado As DataRow In DtPSVirtual.Rows + Dim CvePS = RowUsado("CvePS").ToString().ToEntero() + Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() + Dim PU As Double = RowUsado("PU").ToString().ToDouble() + Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1) Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." + Exit For + End If + Next + Else + ErrorMovInv = True + End If + + Else + If ValidaVirtual Then + ErrorMovInv = True + TextoError = "Ocurrió un error al procesar el movimiento en almacen virtual. Por favor vuelva a intentar." + + End If + End If + + If DtPSVirtual.Rows.Count = 0 AndAlso ValidaVirtual = True Then + ErrorMovInv = True + TextoError = "No se tienen productos para el almacen virtual." + End If + End If + + ' TERMINA: VIRTUAL + + + 'AGREGA BITACORA A VENTA + If Not ErrorMovInv Then Dim MensajeBitacora = If(TipoMovimiento = 1, "Surtida", "Devuelta") If Not ObjEventos.AddEventoBitacora(String.Format("Venta {2} en Folio: {1}", CveMovimiento, Folio, MensajeBitacora), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVentaSurtir) Then ErrorMovInv = True diff --git a/Planeacion/CatSubProyectos.aspx.vb b/Planeacion/CatSubProyectos.aspx.vb index 0c13a7096..217c9a811 100644 --- a/Planeacion/CatSubProyectos.aspx.vb +++ b/Planeacion/CatSubProyectos.aspx.vb @@ -119,7 +119,7 @@ Partial Class CatSubProyectos Public Sub CargaDatos() Dim ObjSub As New ClsSubProyectos - If ObjSub.GetSubProyectos() Then + If ObjSub.GetSubProyectos(UsuarioActual.CveEmpresa) Then GvDatos.DataSource = ObjSub.DtResultados.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}") GvDatos.DataBind() End If @@ -204,7 +204,7 @@ Partial Class CatSubProyectos If ObjSubProyectos.RemoveSubProyecto(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then GvDatos.EditIndex = -1 ViewState("DTSubProyectos") = ObjSubProyectos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - GlobalDTSubProyectos(-1) = ObjSubProyectos.DtResultados + GlobalDTSubProyectos(UsuarioActual.CveEmpresa) = ObjSubProyectos.DtResultados Alert("El SubProyecto se eliminó correctamente.", TipoMensaje.MsgInformacion) End If @@ -232,7 +232,7 @@ Partial Class CatSubProyectos If ObjSubProyectos.UpdateSubProyectoSegNeg(CveSubProyecto, CveSegmento, UsuarioActual.CveEmpresa) Then GvDatos.EditIndex = -1 ViewState("DTSubProyectos") = ObjSubProyectos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - GlobalDTSubProyectos(-1) = ObjSubProyectos.DtResultados + GlobalDTSubProyectos(UsuarioActual.CveEmpresa) = ObjSubProyectos.DtResultados Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion) Else ErrorSubProyecto = True From bd7392cfc45ecea8f34db8c183470323864b9beb Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Sat, 11 Jan 2020 15:35:53 -0700 Subject: [PATCH 38/49] drop down list ahora es dropdownlost opcionalmente --- OC/OC.aspx | 9 +++++---- OC/OC.aspx.vb | 55 +++++++++++++++++++++++++++++---------------------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/OC/OC.aspx b/OC/OC.aspx index b0716cdc0..c42828217 100644 --- a/OC/OC.aspx +++ b/OC/OC.aspx @@ -286,11 +286,12 @@
    - + <%-- - - - + --%> + + <%-- + --%>
    diff --git a/OC/OC.aspx.vb b/OC/OC.aspx.vb index 4f6b6aaae..46881c301 100644 --- a/OC/OC.aspx.vb +++ b/OC/OC.aspx.vb @@ -476,6 +476,7 @@ Partial Class OC Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then + CargaDatosAgregarPS() 'MODALIDAD MULTIEMPRESA CveEmpresaActual = UsuarioActual.CveEmpresa @@ -754,7 +755,6 @@ Partial Class OC UPPDetalle.Update() PermisosPagina() - RegistraScript("$get('HdnWidth').value = $('#C_Tab_TabC_DivConceptosContenido').width();") End If Me.Form.DefaultButton = "" @@ -1294,7 +1294,7 @@ Partial Class OC HplCompraContabilizada.Text = "No" End If - DdlProveedores.SelectedValueExist(objOC.CveProveedor.ToString) + DdlProveedores.ddl.SelectedValueExist(objOC.CveProveedor.ToString) 'CARGAMOS LA SUCURSAL SI NO EXISTE SE AGREGA MATRIZ Dim CveProveedorSucursal As Integer = IIf(objOC.CveProveedorSucursal.ToEntero = -1, 0, objOC.CveProveedorSucursal.ToEntero).ToString.ToEntero @@ -1330,7 +1330,7 @@ Partial Class OC lblFolio.Text = "REQ " + objOC.Folio.ToString lblTipoPadreHijo.Text = "OC" ChkCotizacion.Visible = True - DdlProveedores.SelectedValueExist(objOC.CveProveedor.ToString) + DdlProveedores.ddl.SelectedValueExist(objOC.CveProveedor.ToString) If objOC.CveProveedorSucursal.ToEntero > 0 Then DivProveedorSucursal.Visible = True @@ -1494,14 +1494,14 @@ Partial Class OC 'Permisos, para cambiar el proveedor en una OC If objOC.Tipo.ToUpper = "OC" AndAlso UsuarioActual.TienePermisoProceso(111) Then DdlProveedores.Enabled = True - DdlProveedores.SelectedValueExist(objOC.CveProveedor.ToString) + DdlProveedores.ddl.SelectedValueExist(objOC.CveProveedor.ToString) DdlIVA.Enabled = True ImgCambiaProv.Visible = True UPProv.Update() End If If DdlProveedores.SelectedValue <> objOC.CveProveedor.ToString Then - DdlProveedores.Items.Insert(1, New ListItem(GlobalDTCompProveedores(CveEmpresaActual).FiltroPrimeroValor("RazonSocial", $"CveProveedor = {objOC.CveProveedor}"), objOC.CveProveedor.ToString)) + 'DdlProveedores.Items.Insert(1, New ListItem(GlobalDTCompProveedores(CveEmpresaActual).FiltroPrimeroValor("RazonSocial", $"CveProveedor = {objOC.CveProveedor}"), objOC.CveProveedor.ToString)) End If CargaCotizaciones(CveOrdenCompra) @@ -1741,9 +1741,16 @@ Partial Class OC CboUnidadMedida.DataBind() End Sub Private Sub CargaProveedores() - DdlProveedores.DataSource = GlobalDTCompProveedores(CveEmpresaActual) - DdlProveedores.DataBind() - DdlProveedores.Items.Insert(0, New ListItem("Seleccione", "-1")) + If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then + DdlProveedores.setEsWebService(True) + DdlProveedores.Attributes.Add("metodo", "getproveedores") + Else + + GlobalDTCompProveedores(UsuarioActual.CveEmpresa) = Nothing + DdlProveedores.DataSource = GlobalDTCompProveedores(CveEmpresaActual) + DdlProveedores.DataBind() + End If + 'DdlProveedores.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlProveedorCot.DataSource = GlobalDTCompProveedores(CveEmpresaActual) DdlProveedorCot.DataBind() @@ -1755,7 +1762,7 @@ Partial Class OC Private Sub CargaProveedorSucursal() DdlProveedores.DataSource = GlobalDTCompProveedores(CveEmpresaActual) DdlProveedores.DataBind() - DdlProveedores.Items.Insert(0, New ListItem("Seleccione", "-1")) + 'DdlProveedores.Items.Insert(0, New ListItem("Seleccione", "-1")) UPProv.Update() : UPPEmp.Update() End Sub Private Sub CargaEstatusOC() @@ -2614,7 +2621,7 @@ Partial Class OC If Not TieneError Then Fecha = Now CveProveedor = DdlProveedores.SelectedValue.ToEntero - ProveedorNombre = DdlProveedores.SelectedItem.Text + ProveedorNombre = DdlProveedores.SelectedText SerieFolio = $"OC: {Folio}" If DtInvOCDiferencias.FiltraParametros("ConceptoSalida IN (0,1) AND Diferencia <> 0 ").Rows.Count > 0 Then @@ -2952,12 +2959,12 @@ Partial Class OC 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(), + 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, UsuarioActual.CveUsuario, CveOrdenCompra, - CvePresupuestoEgreso:=dr("CvePresupuestoEgreso").ToString.ToEntero, Descuento:=dr("Descuento").ToString.ToDouble, - IEPSPS:=dr("IEPSPS").ToString.ToDouble, IEPSPSIVA:=dr("IEPSPSIVA").ToString.ToDouble, IVA:=dr("IVA").ToString.ToDouble, - RetIVA:=dr("RetIVA").ToString.ToDouble, RetISR:=dr("RetISR").ToString.ToDouble, Total:=dr("Total").ToString.ToDouble, + CvePresupuestoEgreso:=dr("CvePresupuestoEgreso").ToString.ToEntero, Descuento:=dr("Descuento").ToString.ToDouble, + IEPSPS:=dr("IEPSPS").ToString.ToDouble, IEPSPSIVA:=dr("IEPSPSIVA").ToString.ToDouble, IVA:=dr("IVA").ToString.ToDouble, + RetIVA:=dr("RetIVA").ToString.ToDouble, RetISR:=dr("RetISR").ToString.ToDouble, Total:=dr("Total").ToString.ToDouble, CveContratoDetalle:=dr("CveContratoDetalle").ToString.ToEntero, IVAPorcentaje:=dr("IVAPorcentaje").ToString.ToDouble, RetIVAPorcentaje:=dr("RetIVAPorcentaje").ToString.ToDouble, RetISRPorcentaje:=dr("RetISRPorcentaje").ToString.ToDouble, IEPSPSPorcentaje:=dr("IEPSPSPorcentaje").ToString.ToDouble, IEPSPSIVAPorcentaje:=dr("IEPSPSIVAPorcentaje").ToString.ToDouble) Then @@ -4724,7 +4731,7 @@ Partial Class OC ChkEventoPrioridad.Checked = False RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal") - CargaEventoBitacoraTemp() + CargaEventoBitacoraTemp() End Sub @@ -4880,7 +4887,7 @@ Partial Class OC Dim DtPara As DataTable = GlobalDTUsuarios(DdlSAUsuario.SelectedValue.ToString.ToEntero, CveEmpresaActual) Param.Add(DtPara.Rows(0)("Correo").ToString()) 'Para Param.Add("Solicitud de anticipo de Orden de Compra") 'Asunto - Param.Add(GeneraCorreoAnticipo(lblFolio.Text, DtPara.Rows(0)("Nombre").ToString(), String.Format("http://sig.adssistemas.mx/OI/EventoDetalle.aspx?CveTipoEvento=1&CveEvento={0}", CveEvento), TxtSAImporte.Text, DdlProveedores.SelectedItem.Text)) + Param.Add(GeneraCorreoAnticipo(lblFolio.Text, DtPara.Rows(0)("Nombre").ToString(), String.Format("http://sig.adssistemas.mx/OI/EventoDetalle.aspx?CveTipoEvento=1&CveEvento={0}", CveEvento), TxtSAImporte.Text, DdlProveedores.SelectedText)) Param.Add(String.Format("{0}PDF\OC-{1}.pdf", UsuarioActual.Empresa.Ruta, CveOrdenCompra)) Dim Hilo As New Threading.Thread(AddressOf MandaCorreoAnticipo) Hilo.Start(Param) @@ -4894,7 +4901,7 @@ Partial Class OC Dim DtPara As DataTable = GlobalDTUsuarios(Dr("CveUsuarioPara").ToString.ToEntero, CveEmpresaActual) Param.Add(DtPara.Rows(0)("Correo").ToString()) 'Para Param.Add("Solicitud de anticipo de Orden de Compra Cancelada") 'Asunto - Param.Add(GeneraCorreoAnticipo(lblFolio.Text, DtPara.Rows(0)("Nombre").ToString(), String.Format("http://sig.s/OI/EventoDetalle.aspx?CveTipoEvento=1&CveEvento={0}", Dr("CveEvento").ToString.ToEntero), "", DdlProveedores.SelectedItem.Text)) + Param.Add(GeneraCorreoAnticipo(lblFolio.Text, DtPara.Rows(0)("Nombre").ToString(), String.Format("http://sig.s/OI/EventoDetalle.aspx?CveTipoEvento=1&CveEvento={0}", Dr("CveEvento").ToString.ToEntero), "", DdlProveedores.SelectedText)) Param.Add(String.Format("{0}PDF\OC-{1}.pdf", UsuarioActual.Empresa.Ruta, CveOrdenCompra)) Dim Hilo As New Threading.Thread(AddressOf MandaCorreoAnticipo) Hilo.Start(Param) @@ -5118,7 +5125,7 @@ Partial Class OC Return CveEmpresaActual = 66 End Function - Protected Sub DdlProveedores_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProveedores.SelectedIndexChanged + Protected Sub DdlProveedores_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProveedores.selectedindexchange Dim Objeto As New ClsCompProveedores DdlProveedorSucursal.Items.Clear() @@ -5191,7 +5198,7 @@ Partial Class OC PnlUsuarioAsignado.Visible = False - RVProveedores.Enabled = False + 'RVProveedores.Enabled = False 'Si NO requiere cotizacion y el estatus siguiente es el final, If TipoOC.ToUpper = "REQ" Then @@ -5203,7 +5210,7 @@ Partial Class OC If ChkCotizacion.Checked = False AndAlso CboE.SelectedValue.ToEntero.Contiene(CveEstatusFinalOK) AndAlso TipoOS = False Then BtnGuardar.Text = "Guardar y Generar OC" : uppOpciones.Update() - RVProveedores.Enabled = True + 'RVProveedores.Enabled = True If CveEmpresaActual.Contiene(13, 83, 72) Then PnlUsuarioAsignado.Visible = True @@ -5228,7 +5235,7 @@ Partial Class OC If CveEstatus <> CveEstatusFinalError Then RegistraScript("$get('divCE').style.display='';PosicionaObjeto('C_CboE','divCE'); ") End If Else - RVProveedores.Enabled = True + 'RVProveedores.Enabled = True End If @@ -5959,7 +5966,7 @@ Partial Class OC Private Function ReadExcelFile(ByVal flatFilePath As String, ByVal firstRowHasHeaders As Boolean) As DataTable SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) - Dim excelFile As ExcelFile = excelFile.Load(flatFilePath) + Dim excelFile As ExcelFile = ExcelFile.Load(flatFilePath) Dim unnamed As Integer = 0 Dim cols As Integer @@ -6392,7 +6399,7 @@ Partial Class OC Dim CveProveedorPrevio As String = DdlProveedores.SelectedValue Dim CveProveedorSucursalPrevio As String = DdlProveedorSucursal.SelectedValue CargaProveedores() - DdlProveedores.SelectedValueExist(CveProveedorPrevio) + DdlProveedores.ddl.SelectedValueExist(CveProveedorPrevio) DdlProveedores_SelectedIndexChanged(DdlProveedores, EventArgs.Empty) If DdlProveedorSucursal.Visible Then DdlProveedorSucursal.SelectedValueExist(CveProveedorSucursalPrevio) From a709004fabe46953d3f68250f389470c5a4ec466 Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Sat, 11 Jan 2020 15:36:32 -0700 Subject: [PATCH 39/49] --- Ventas/RepConciliacionEmitidosSat.aspx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Ventas/RepConciliacionEmitidosSat.aspx b/Ventas/RepConciliacionEmitidosSat.aspx index 1409c9839..fa07791c0 100644 --- a/Ventas/RepConciliacionEmitidosSat.aspx +++ b/Ventas/RepConciliacionEmitidosSat.aspx @@ -148,6 +148,11 @@ + + + + + From 61981273d782aaa579121ea3b921e9bdda0cc67e Mon Sep 17 00:00:00 2001 From: Rene Molina Date: Sat, 11 Jan 2020 15:36:57 -0700 Subject: [PATCH 40/49] - --- App_Code/ClsAcumuladores.vb | 13 +++++++------ Inventarios/RecepcionEntrega.aspx.vb | 10 +++++----- Ventas/PV.aspx.vb | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/App_Code/ClsAcumuladores.vb b/App_Code/ClsAcumuladores.vb index 614160d81..1dfccab76 100644 --- a/App_Code/ClsAcumuladores.vb +++ b/App_Code/ClsAcumuladores.vb @@ -477,20 +477,21 @@ Public Class ClsAcumuladores End Try Return Retorno - End Function - + End Function + #End Region - + #Region " FOLIOS GARANTÍA " - - Public Function FoliosGarantiaGet(CveFolioGarantia As Integer, CveEmpresa As Integer) As Boolean + + Public Function FoliosGarantiaGet(CveFolioGarantia As Integer, CveEmpresa As Integer, Optional Estatus As Integer = -1) As Boolean Dim Retorno As Boolean = False 'Data = New DataTable SqlDataAdapter("PA_Acum_FoliosGarantiaGet") With SqlAdapter.SelectCommand.Parameters - .Add("@CveFolioGarantia", SqlDbType.Int).Value = CveFolioGarantia + .Add("@CveFolioGarantia", SqlDbType.Int).Value = CveFolioGarantia + .Add("@Estatus", SqlDbType.Int).Value = Estatus .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa End With diff --git a/Inventarios/RecepcionEntrega.aspx.vb b/Inventarios/RecepcionEntrega.aspx.vb index 1194c521b..a0e7499ff 100644 --- a/Inventarios/RecepcionEntrega.aspx.vb +++ b/Inventarios/RecepcionEntrega.aspx.vb @@ -2235,14 +2235,14 @@ Partial Class Inventarios_RecepcionEntrega Dim CveAlmacenVirtual As Integer = -1 Dim CveMovimientoRelacionadoVirtual As Integer = CveMovimiento Dim ValidaVirtual As Boolean = False + CveAlmacenVirtual = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 24).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero() If TipoMovimiento = 1 Then - CveConceptoMovimientoVirtual = 36 - CveAlmacenVirtual = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 24).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero() + CveConceptoMovimientoVirtual = 37 ElseIf TipoMovimiento = 2 Then ValidaVirtual = True - CveConceptoMovimientoVirtual = 37 + CveConceptoMovimientoVirtual = 36 End If If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 AndAlso CveAlmacenVirtual > 0 AndAlso CveConceptoMovimientoVirtual > 0 Then @@ -2302,7 +2302,7 @@ Partial Class Inventarios_RecepcionEntrega RegistraScript("playsonidito('beep-07.wav')") Dim Msg As New StringBuilder - Msg.AppendFormat("Movimiento Salida: {1}", CveMovimiento, Folio) + Msg.AppendFormat("Movimiento {2}: {1}", CveMovimiento, Folio, If(TipoMovimiento = 1, "Salida", "Entrada")) Msg.AppendFormat("
    Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento))) If CveMovimientoEntrada > 0 Then @@ -2323,7 +2323,7 @@ Partial Class Inventarios_RecepcionEntrega End If If CveMovimientoVirtual > 0 Then - Msg.AppendFormat("

    Movimiento de Salida del Almacen Virtual: ") + Msg.AppendFormat("

    {0} Almacen Virtual: ", If(TipoMovimiento = 1, "Salida", "Entrada")) Msg.AppendFormat("{1}", CveMovimientoVirtual, FolioVirtual) Msg.AppendFormat("
    Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoVirtual))) End If diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index e00126eae..9b317a159 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -5018,7 +5018,7 @@ Partial Class PV Private Sub CargaAjuste() Dim ObjAcum As New ClsAcumuladores - If ObjAcum.FoliosGarantiaGet(-1, UsuarioActual.CveEmpresa) Then + If ObjAcum.FoliosGarantiaGet(-1, UsuarioActual.CveEmpresa, 1) Then DdlFolioGarantia.DataSource = ObjAcum.DtResultados DdlFolioGarantia.Items.Insert(0, New ListItem("Seleccione", "-1")) End If From 2a0079aba97569fe6278be6fbcad3e3b47c8cce0 Mon Sep 17 00:00:00 2001 From: Rene Molina Date: Sun, 12 Jan 2020 21:33:58 -0700 Subject: [PATCH 41/49] cambios --- App_Code/modExtensiones.vb | 4 ++-- OC/OC.aspx | 10 ++++++---- OC/OC.aspx.vb | 30 ++++++++++++++++++++-------- Ventas/Ventas.aspx | 9 +++------ Ventas/Ventas.aspx.vb | 41 ++++++++++++++++++++++---------------- 5 files changed, 57 insertions(+), 37 deletions(-) diff --git a/App_Code/modExtensiones.vb b/App_Code/modExtensiones.vb index 9832061b6..2a531ef0d 100644 --- a/App_Code/modExtensiones.vb +++ b/App_Code/modExtensiones.vb @@ -54,8 +54,8 @@ Namespace Extensiones ' BaseDatos = CType(System.Web.HttpContext.Current.Session("UsuarioSIG"), Usuario).Empresa.BaseDatosNombre 'End If - - Return String.Format("Data Source=192.168.0.2;Initial Catalog={0};User Id=JCaudillo;Password=JCau127*953;pooling=True; Min Pool Size=10;Application Name=SIG;", BaseDatos) + Return ConfigurationManager.ConnectionStrings("Conexion").ConnectionString + ' Return String.Format("Data Source=192.168.0.2;Initial Catalog={0};User Id=JCaudillo;Password=JCau127*953;pooling=True; Min Pool Size=10;Application Name=SIG;", BaseDatos) End Function diff --git a/OC/OC.aspx b/OC/OC.aspx index c42828217..bd735893c 100644 --- a/OC/OC.aspx +++ b/OC/OC.aspx @@ -289,7 +289,7 @@ <%-- --%> - + <%-- --%> @@ -2556,9 +2556,11 @@
    - - - + <%----%> + + +<%-- + --%>
    diff --git a/OC/OC.aspx.vb b/OC/OC.aspx.vb index 46881c301..fb5de5bea 100644 --- a/OC/OC.aspx.vb +++ b/OC/OC.aspx.vb @@ -1741,20 +1741,25 @@ Partial Class OC CboUnidadMedida.DataBind() End Sub Private Sub CargaProveedores() - If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then + If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then DdlProveedores.setEsWebService(True) - DdlProveedores.Attributes.Add("metodo", "getproveedores") + DdlProveedores.Attributes.Add("data-metodo", "getproveedores") + DdlProveedores.SelectedText = "Seleccione" + DdlProveedores.SelectedValue = "-1" + DdlProveedorCot.setEsWebService(True) + DdlProveedorCot.Attributes.Add("data-metodo", "getproveedores") Else - GlobalDTCompProveedores(UsuarioActual.CveEmpresa) = Nothing DdlProveedores.DataSource = GlobalDTCompProveedores(CveEmpresaActual) DdlProveedores.DataBind() + DdlProveedores.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) + + DdlProveedorCot.DataSource = GlobalDTCompProveedores(CveEmpresaActual) + DdlProveedorCot.DataBind() + DdlProveedorCot.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If - 'DdlProveedores.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlProveedorCot.DataSource = GlobalDTCompProveedores(CveEmpresaActual) - DdlProveedorCot.DataBind() - DdlProveedorCot.Items.Insert(0, New ListItem("Seleccione", "-1")) UPProv.Update() : UPPEmp.Update() End Sub @@ -2105,6 +2110,8 @@ Partial Class OC Return True End If + + 'SI ES REQUISICION, NO REQUIERE COTIZACION Y ES ESTATUSFINALOK... ENTONCES DEBE DE TENER UN PROVEEDOR SELECCIONADO Y LOS PRECIOS CAPTURADOS 'If (TipoOC = "REQ" And ChkCotizacion.Checked = False And CboE.SelectedValue.ToEntero = CveEstatusFinalOK) OrElse TipoOC = "OC" Then ' If Not UsuarioActual.TienePermisoProceso(179) Then 'PERMISO PARA GENERAR CON O @@ -2222,6 +2229,13 @@ Partial Class OC TieneError = True End If + 'Valida que tenga proveedore + If (EsNuevo = True AndAlso TipoOC.ToUpper = "OC"4) AndAlso DdlProveedores.SelectedValue.ToEntero() <= 0 Then + Alert("Debe seleccionar un proveedor.", TipoMensaje.MsgAdvertencia) + TieneError = True + End If + + 'VALIDA QUE ANTES DE QUE PUEDA MANDARLA A SUPERVISADA SE TIENE QUE SELECCIONAR UN PROVEEDOR If UsuarioActual.Empresa.Funcionalidad(565) = "1" Then If (TipoOC.ToUpper = "REQ" And CboE.SelectedValue.ToEntero.Contiene(CveEstatusSupervisada, CveEstatusFinalOK)) AndAlso DdlProveedores.SelectedValue.ToEntero() <= 0 Then @@ -5966,7 +5980,7 @@ Partial Class OC Private Function ReadExcelFile(ByVal flatFilePath As String, ByVal firstRowHasHeaders As Boolean) As DataTable SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) - Dim excelFile As ExcelFile = ExcelFile.Load(flatFilePath) + Dim excelFile As ExcelFile = excelFile.Load(flatFilePath) Dim unnamed As Integer = 0 Dim cols As Integer diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 6fa1b3ceb..3af333051 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -812,7 +812,7 @@ - +
    Turno: @@ -3240,11 +3240,8 @@ - Kilometraje  - - - - + Kilometraje  +
    diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 1765b3c67..2563cc7b9 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2523,7 +2523,8 @@ Partial Class Ventas DivDdlCuentaTarjetaCredito.Attributes.Add("class", "col-md-4") DivContadoOtros.Visible = True TrKilometraje.Visible = True - TrKilometrajeTxt.Visible = True + TrPedido.Visible = False + ' TrKilometrajeTxt.Visible = True End If End If @@ -2582,8 +2583,9 @@ Partial Class Ventas LkbEstadodeCaja.Visible = True LkbIngreso.Visible = True LkbRetiro.Visible = True - UpTurno.Update() + UpTurno.Visible = True Else + UpTurno.Visible = False 'Ingresar un nuevo Turno RegistraScript("window.onload = function MuestraCorteCaja() { document.getElementById(""C_btnShow"").click(); }") End If @@ -6462,22 +6464,27 @@ Partial Class Ventas End If 'Valida si en caso de que el detalle tenga llantas o polizas se agreguén kilometraje/serie en la parte de observaciones(solo para el caso de empresas llanteras) If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then + + If txtkilometraje.text.toentero = 0 Then + Alert("No se ha especificado el kilometraje.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + If TxtObsFact.Text = "" Then Dim FaltaObservacion As Integer = -1 - For Each PS As GridViewRow In GvPS.Rows - Dim PsRenglon As GridViewRow = PS - Dim CveClasificacion As Integer = PsRenglon.DataKey("CveClasificacion").ToEntero - If CveClasificacion = 20345 Or CveClasificacion = 20342 Then - FaltaObservacion = CveClasificacion - Exit For - End If - Next + 'For Each PS As GridViewRow In GvPS.Rows + ' Dim PsRenglon As GridViewRow = PS + ' Dim CveClasificacion As Integer = PsRenglon.DataKey("CveClasificacion").ToEntero + ' If CveClasificacion = 20345 Or CveClasificacion = 20342 Then + ' FaltaObservacion = CveClasificacion + ' Exit For + ' End If + ' + FaltaObservacion = TmpDT.FiltroPrimeroValor("CveClasificacion", "CveClasificacion = 20345").ToEntero + If FaltaObservacion = 20345 Then Alert("No se ha especificado la serie para la poliza en la sección de Observaciones", TipoMensaje.MsgAdvertencia) Exit Sub - ElseIf FaltaObservacion = 20342 Then - Alert("No se ha especificado el kilometraje para la llanta en el sección de Observaciones", TipoMensaje.MsgAdvertencia) - Exit Sub End If End If End If @@ -9125,7 +9132,7 @@ Partial Class Ventas CveVentaRelacion:=(If(factura.CveVentaRelacion.ToEntero > 0, factura.CveVentaRelacion, -1)), ImporteRelacion:=(If(factura.ImporteRelacion <> Nothing, factura.ImporteRelacion, -1)), CveTipoAmortizacionAnticipo:=factura.CveTipoAmortizacionAnticipo, CveEmpresaCRM:=CveEmpresaCRM, EsInterno:=EsInterno, CveAcercamientoCRM:=CveAcercamientoCRM, DiasCredito:=factura.DiasCredito, EsDiasCreditoFijo:=factura.EsDiasCreditoFijo, AnticipoEspecial:=If(TrAntEspecial.Visible, ChkAntEspecial.Checked, False), - Kilometraje:=If(TrKilometrajeTxt.Visible AndAlso IsNumeric(TxtKilometraje.Text), TxtKilometraje.Text.ToDouble, -1)) Then + Kilometraje:=TxtKilometraje.Text.todouble) Then ErrorList.Add("Ocurrió un error al Generar la Venta.
    Revise su factura y cualquier detalle comuníquese a Soporte Técnico") @@ -14276,7 +14283,7 @@ Partial Class Ventas 'AGREGA PS ADICIONAL - If UsuarioActual.Empresa.Funcionalidad(561).ToString = "1" AndAlso Not UsuarioActual.TienePermisoProceso(284) AndAlso GlobalDTPSAdicionales(CvePS, UsuarioActual.CveEmpresa).Rows.Count > 0 AndAlso Not SeActualiza Then + If UsuarioActual.Empresa.Funcionalidad(561).ToString = "1" AndAlso Not UsuarioActual.TienePermisoProceso(285) AndAlso GlobalDTPSAdicionales(CvePS, UsuarioActual.CveEmpresa).Rows.Count > 0 AndAlso Not SeActualiza Then For Each Dr As DataRow In GlobalDTPSAdicionales(CvePS, UsuarioActual.CveEmpresa).Rows Dim CvePSAdicional As Integer = Dr("CvePSAdicional").ToString.ToEntero @@ -16408,7 +16415,7 @@ Partial Class Ventas Vigencia:=TxtFechaVencimientoCotizacion.Text.Trim.ToDate, CondicionesPago:=If(RBLPago.SelectedValue = "2", 0, 1), PedidoContrato:=TxtPedidoContrato.Text, AtencionA:=TxtAtencionA.Text.Trim, CveMetodoPago33:=DdlMetodoPago33.SelectedValue.ToEntero, CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero, TipoDocto:="Rem", CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, - OrdenCompra:=TxtOrdenCompra.Text, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal, Kilometraje:=If(TrKilometrajeTxt.Visible AndAlso IsNumeric(TxtKilometraje.Text), TxtKilometraje.Text.ToDouble, -1)) Then + OrdenCompra:=TxtOrdenCompra.Text, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal, Kilometraje:=TxtKilometraje.Text.ToDouble) Then OcurrioError = True End If @@ -22080,7 +22087,7 @@ Partial Class Ventas Vigencia:=TxtFechaVencimientoCotizacion.Text.Trim.ToDate, CondicionesPago:=If(RBLPago.SelectedValue = "2", 0, 1), PedidoContrato:=TxtPedidoContrato.Text, AtencionA:=TxtAtencionA.Text.Trim, CveMetodoPago33:=DdlMetodoPago33.SelectedValue.ToEntero, CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero, CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, OrdenCompra:=TxtOrdenCompra.Text, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal, - TipoDocto:=DdlTipoComprobante.SelectedValue, Kilometraje:=If(TrKilometrajeTxt.Visible AndAlso IsNumeric(TxtKilometraje.Text), TxtKilometraje.Text.ToDouble, -1)) Then + TipoDocto:=DdlTipoComprobante.SelectedValue, Kilometraje:=TxtKilometraje.Text.ToDouble) Then MensajeError = "Ocurrió un error al actualizar la información de la cotización" OcurrioError = True End If From e4f0e0375c92ea176c905142dc7c7b4c297e5120 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Mon, 13 Jan 2020 09:22:07 -0700 Subject: [PATCH 42/49] --- Ventas/Ventas.aspx | 15 +++++++++++++-- Ventas/Ventas.aspx.vb | 16 ++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 92bbd2874..688e063f4 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -1359,9 +1359,20 @@ Ret. IVA: - + + -  (%) +  (%) + + + + + + + + + + diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index dea66b2a4..905c05980 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -4734,6 +4734,8 @@ Partial Class Ventas End If ViewState("CargoUsado") = ObjCliente.CargoUsados + DdlTipoRetencion.SelectedValueExist(ObjCliente.DtResultados(0)("CveTipoRetencion").ToString) + Dim dr As DataRow = Nothing dr = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal = 1 And Estatus = 'Activo' AND CveEmpresa = " & UsuarioActual.CveEmpresa) If dr IsNot Nothing Then @@ -23978,5 +23980,19 @@ Partial Class Ventas Return Retorno End Function + Protected Sub DdlTipoRetencion_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim PorcentajeRetencion As Decimal = 0 + Select Case DdlTipoRetencion.SelectedValue + Case "1" 'Arrendamiento + PorcentajeRetencion = 10 + Case "2" 'Servicios Profesionales + PorcentajeRetencion = 10 + Case "3" 'Fletes + PorcentajeRetencion = 4 + Case "4" 'Servicios + PorcentajeRetencion = 6 + End Select + + End Sub End Class \ No newline at end of file From 838d26f641e6a323f95838c5b8cd56e4efa260fb Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Mon, 13 Jan 2020 10:04:26 -0700 Subject: [PATCH 43/49] --- Ventas/Ventas.aspx | 5 +++-- Ventas/Ventas.aspx.vb | 28 ++++++++++++++-------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 2ff6dbdb5..65c6a5138 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -1372,7 +1372,7 @@  (%) - +<%-- @@ -1380,7 +1380,8 @@ - + --%> + diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 0560c68a9..48155a9b4 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -4737,7 +4737,7 @@ Partial Class Ventas End If ViewState("CargoUsado") = ObjCliente.CargoUsados - DdlTipoRetencion.SelectedValueExist(ObjCliente.DtResultados(0)("CveTipoRetencion").ToString) + 'DdlTipoRetencion.SelectedValueExist(ObjCliente.DtResultados(0)("CveTipoRetencion").ToString) Dim dr As DataRow = Nothing dr = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal = 1 And Estatus = 'Activo' AND CveEmpresa = " & UsuarioActual.CveEmpresa) @@ -23986,19 +23986,19 @@ Partial Class Ventas Return Retorno End Function - Protected Sub DdlTipoRetencion_SelectedIndexChanged(sender As Object, e As EventArgs) - Dim PorcentajeRetencion As Decimal = 0 - Select Case DdlTipoRetencion.SelectedValue - Case "1" 'Arrendamiento - PorcentajeRetencion = 10 - Case "2" 'Servicios Profesionales - PorcentajeRetencion = 10 - Case "3" 'Fletes - PorcentajeRetencion = 4 - Case "4" 'Servicios - PorcentajeRetencion = 6 - End Select + 'Protected Sub DdlTipoRetencion_SelectedIndexChanged(sender As Object, e As EventArgs) + ' Dim PorcentajeRetencion As Decimal = 0 + ' Select Case DdlTipoRetencion.SelectedValue + ' Case "1" 'Arrendamiento + ' PorcentajeRetencion = 10 + ' Case "2" 'Servicios Profesionales + ' PorcentajeRetencion = 10 + ' Case "3" 'Fletes + ' PorcentajeRetencion = 4 + ' Case "4" 'Servicios + ' PorcentajeRetencion = 6 + ' End Select - End Sub + 'End Sub End Class \ No newline at end of file From caa4d2d04d318bfe7e9bbcf12dd37abf75981619 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 13 Jan 2020 11:09:00 -0700 Subject: [PATCH 44/49] =?UTF-8?q?agregando=20mensaje=20de=20validaci=C3=B3?= =?UTF-8?q?n=20al=20kardex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Inventarios/Kardex.aspx | 8 ++++++++ OC/OC.aspx.vb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Inventarios/Kardex.aspx b/Inventarios/Kardex.aspx index 3390e698d..e2c88ea88 100644 --- a/Inventarios/Kardex.aspx +++ b/Inventarios/Kardex.aspx @@ -161,6 +161,10 @@ + + + +
    @@ -175,6 +179,10 @@ + + + +
    diff --git a/OC/OC.aspx.vb b/OC/OC.aspx.vb index 46881c301..d557bfdb9 100644 --- a/OC/OC.aspx.vb +++ b/OC/OC.aspx.vb @@ -1745,10 +1745,10 @@ Partial Class OC DdlProveedores.setEsWebService(True) DdlProveedores.Attributes.Add("metodo", "getproveedores") Else - GlobalDTCompProveedores(UsuarioActual.CveEmpresa) = Nothing DdlProveedores.DataSource = GlobalDTCompProveedores(CveEmpresaActual) DdlProveedores.DataBind() + DdlProveedores.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) End If 'DdlProveedores.Items.Insert(0, New ListItem("Seleccione", "-1")) From 8ae43be3f03ce9bfd19d18f07951e3c65a3ec3b8 Mon Sep 17 00:00:00 2001 From: Rene Molina Date: Mon, 13 Jan 2020 11:17:21 -0700 Subject: [PATCH 45/49] -oc. cambioa dropdownlos, ddlproveedores --- App_Code/ClsContabilidad.vb | 1 + Ashx/SIGWeb.ashx | 4 ++-- Inventarios/TraspasoAlmacen.aspx.vb | 6 +++--- OC/OC.aspx | 2 +- OC/OC.aspx.vb | 14 ++++++++++++-- Ventas/Ventas.aspx.vb | 11 ++++++++--- 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb index 8f89239ca..597854f57 100644 --- a/App_Code/ClsContabilidad.vb +++ b/App_Code/ClsContabilidad.vb @@ -5768,6 +5768,7 @@ Public Class ClsContabilidad .Add("@Opcion", SqlDbType.Int).Value = Opcion .Add("@Valor", SqlDbType.Int).Direction = ParameterDirection.Output .Add("@MsgSalida", SqlDbType.VarChar, 100).Direction = ParameterDirection.Output + .Add("@MsgPrePolizaSalida", SqlDbType.VarChar, 800).Direction = ParameterDirection.Output .Add("@Diferencia", SqlDbType.Float).Direction = ParameterDirection.Output End With diff --git a/Ashx/SIGWeb.ashx b/Ashx/SIGWeb.ashx index a1d1c9720..faf915fda 100644 --- a/Ashx/SIGWeb.ashx +++ b/Ashx/SIGWeb.ashx @@ -247,13 +247,13 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState 'ObjProveedores.Dispose() Dim dt As DataTable = DirectCast(context.Application(AppNombre), DataTable).FiltraParametros($"CveEmpresa = {CveEmpresa}") If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then - DtRetorno = dt.FiltraParametros($"RazonSocial like '%{Name}%'") + DtRetorno = dt.FiltraParametros($"NombreCortoProveedor like '%{Name}%'") End If End If If DtRetorno IsNot Nothing AndAlso DtRetorno.Rows.Count > 0 Then DtRetorno.Columns("CveProveedor").ColumnName = "id" - DtRetorno.Columns("RazonSocial").ColumnName = "text" + DtRetorno.Columns("NombreCortoProveedor").ColumnName = "text" retorno = JsonConvert.SerializeObject(DtRetorno).ToString context.Response.Write(retorno) Else diff --git a/Inventarios/TraspasoAlmacen.aspx.vb b/Inventarios/TraspasoAlmacen.aspx.vb index ccc628c7f..33aa8f9b5 100644 --- a/Inventarios/TraspasoAlmacen.aspx.vb +++ b/Inventarios/TraspasoAlmacen.aspx.vb @@ -804,7 +804,7 @@ Partial Class Inventarios_TraspasoAlmacen Dim CveAlmacenVirtual As Integer = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 24).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero() - CveMovimientoVirtualSalida = ObjInventario.AddMovimiento(CveAlmacenVirtual, 3, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="TA/V", CveMovimientoRelacionado:=CveMovimientoSalida) + CveMovimientoVirtualSalida = ObjInventario.AddMovimiento(CveAlmacenVirtual, 37, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="TA/V", CveMovimientoRelacionado:=CveMovimientoSalida) FolioVirtualSalida = ObjInventario.Folio Dim dtvirtual As DataTable = Nothing @@ -829,11 +829,11 @@ Partial Class Inventarios_TraspasoAlmacen 'AGREGAMOS LA ENTRADA If Not ChkTransitorio.Checked Then 'SI NO ES TRANSITORIO SE HACE LA RECEPCION DE INMEDIATO If Not ErrorMovInv Then - Dim TipoMovimientoEntrada = 9 + Dim TipoMovimientoEntrada = 36 AlmacenEntrada = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.ToEntero) CveMovimientoEntrada = ObjInventario.AddMovimiento(AlmacenEntrada, TipoMovimientoEntrada, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, "-1"), - CveAlmacenDestino:=If(ChkTransitorio.Checked, DdlAlmacenDestino.SelectedValue.ToEntero, -1), CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="TA/G") + CveAlmacenDestino:=If(ChkTransitorio.Checked, DdlAlmacenDestino.SelectedValue.ToEntero, -1), CveMovimientoRelacionado:=CveMovimientoEntrada, Modulo:="TA/G") FolioEntrada = ObjInventario.Folio If CveMovimientoEntrada <= 0 Then TextoError = "Ocurrió un error al generar el movimiento de entrada" diff --git a/OC/OC.aspx b/OC/OC.aspx index bd735893c..edde3253c 100644 --- a/OC/OC.aspx +++ b/OC/OC.aspx @@ -289,7 +289,7 @@ <%-- --%> - + <%-- --%> diff --git a/OC/OC.aspx.vb b/OC/OC.aspx.vb index fb5de5bea..d77b1c6be 100644 --- a/OC/OC.aspx.vb +++ b/OC/OC.aspx.vb @@ -1294,7 +1294,12 @@ Partial Class OC HplCompraContabilizada.Text = "No" End If - DdlProveedores.ddl.SelectedValueExist(objOC.CveProveedor.ToString) + DdlProveedores.SelectedValue = objOC.CveProveedor.ToString + If DdlProveedores.SelectedValue.ToEntero > 0 Then + DdlProveedores.SelectedText = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltraParametros($"CveProveedor = {objOC.CveProveedor}").Rows(0)("RazonSocial").ToString + Else + DdlProveedores.SelectedText = "-" + End If 'CARGAMOS LA SUCURSAL SI NO EXISTE SE AGREGA MATRIZ Dim CveProveedorSucursal As Integer = IIf(objOC.CveProveedorSucursal.ToEntero = -1, 0, objOC.CveProveedorSucursal.ToEntero).ToString.ToEntero @@ -1330,7 +1335,12 @@ Partial Class OC lblFolio.Text = "REQ " + objOC.Folio.ToString lblTipoPadreHijo.Text = "OC" ChkCotizacion.Visible = True - DdlProveedores.ddl.SelectedValueExist(objOC.CveProveedor.ToString) + DdlProveedores.SelectedValue = objOC.CveProveedor.ToString + If DdlProveedores.SelectedValue.ToEntero > 0 Then + DdlProveedores.SelectedText = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltraParametros($"CveProveedor = {objOC.CveProveedor}").Rows(0)("RazonSocial").ToString + Else + DdlProveedores.SelectedText = "-" + End If If objOC.CveProveedorSucursal.ToEntero > 0 Then DivProveedorSucursal.Visible = True diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 2563cc7b9..f9c28d63c 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -6466,8 +6466,13 @@ Partial Class Ventas If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then If txtkilometraje.text.toentero = 0 Then - Alert("No se ha especificado el kilometraje.", TipoMensaje.MsgAdvertencia) - Exit Sub + 'cuando es la clasificacion de llantas + Dim FaltaObservacion As Integer = TmpDT.FiltroPrimeroValor("CveClasificacion", "CveClasificacion = 20342").ToEntero + If FaltaObservacion = 20342 Then + Alert("No se ha especificado el kilometraje.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If If TxtObsFact.Text = "" Then @@ -6481,7 +6486,7 @@ Partial Class Ventas ' End If ' FaltaObservacion = TmpDT.FiltroPrimeroValor("CveClasificacion", "CveClasificacion = 20345").ToEntero - + 'cuando es la clasificacion de polizas If FaltaObservacion = 20345 Then Alert("No se ha especificado la serie para la poliza en la sección de Observaciones", TipoMensaje.MsgAdvertencia) Exit Sub From 27d04a32b61602aabd8ca8fc2310684a094d27c4 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 13 Jan 2020 13:58:39 -0700 Subject: [PATCH 46/49] agregando formatos de entradas.rdlc y salidas.rdlc a la 146 --- Compras/PopUpVerFactura.aspx.vb | 4 +- Empresas/146/Formatos/Factura.rdlc | 128 +++++++++++++++++++++++++++-- Empresas/80/Formatos/Entradas.rdlc | 6 ++ 3 files changed, 129 insertions(+), 9 deletions(-) diff --git a/Compras/PopUpVerFactura.aspx.vb b/Compras/PopUpVerFactura.aspx.vb index afd814184..74cb73e65 100644 --- a/Compras/PopUpVerFactura.aspx.vb +++ b/Compras/PopUpVerFactura.aspx.vb @@ -1471,7 +1471,7 @@ Partial Class PopUpVerFactura If Archivo.Exists Then 'IMPRESION ESPECIAL SALIDA DE COMPUPROVEEDORES y VSH - If UsuarioActual.CveEmpresa.Contiene(1, 72, 80, 119, 4, 145) Then + If UsuarioActual.CveEmpresa.Contiene(1, 72, 80, 119, 4, 145, 146) Then Dim CiudadSucursal As String = "" Dim DomicilioSucursal As String = "" Dim DomicilioCliente As String = String.Format("{0} #{1}, {2}, Col. {3}, CP: {4}, {5}, {6}", DtMovimientos(0)("SucClienteDireccion").ToString, DtMovimientos(0)("SucClienteNoExt").ToString, DtMovimientos(0)("SucClienteNoInt").ToString, DtMovimientos(0)("SucClienteColonia"), DtMovimientos(0)("SucClienteCP").ToString, DtMovimientos(0)("SucClienteCiudad"), DtMovimientos(0)("SucClientePais").ToString) @@ -1487,7 +1487,7 @@ Partial Class PopUpVerFactura End If - If UsuarioActual.CveEmpresa.Contiene(72, 80) Then + If UsuarioActual.CveEmpresa.Contiene(72, 80, 146) Then params.Add(New ReportParameter("Fecha", String.Format("{0} {1}", FechaHora.ToDate.ToString("yyyy-MM-dd"), FechaHora.ToDateTime.ToString("HH:mm:ss")))) params.Add(New ReportParameter("SucursalCliente", DtMovimientos(0)("SucCliente").ToString)) diff --git a/Empresas/146/Formatos/Factura.rdlc b/Empresas/146/Formatos/Factura.rdlc index 593500dc1..ed8648fc9 100644 --- a/Empresas/146/Formatos/Factura.rdlc +++ b/Empresas/146/Formatos/Factura.rdlc @@ -1749,19 +1749,22 @@ - 2.12527cm + 1.34132cm - 2.02474cm + 1.32237cm - 10.17786cm + 2.53649cm + + + 8.96945cm 2.52862cm - 3.15415cm + 3.27979cm @@ -1776,7 +1779,7 @@ - Cantidad + Cant. + + + + + + Textbox1 + + + #ff1037 + 2pt + 2pt + 2pt + 2pt + + + + @@ -1973,7 +2012,7 @@ =Fields!Cantidad.Value @@ -2041,6 +2080,48 @@ + + + + true + true + + + + + =Fields!Codigo.Value + + + + + + + Codigo + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + @@ -2225,6 +2306,38 @@ + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + @@ -2336,6 +2449,7 @@ + @@ -2355,7 +2469,7 @@ 5.75246cm 0.11468cm 1.07241cm - 20.01064cm + 19.97804cm 26