diff --git a/App_Code/ClsAcumuladores.vb b/App_Code/ClsAcumuladores.vb index 614160d81..c243c6058 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 @@ -753,7 +754,21 @@ Public Class ClsAcumuladores SqlAdapter.Fill(Data) Retorno = True Catch ex As SqlException - OnError("Ocurrió un al agregar la garantia detalle. ", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + OnError("Ocurrió un al obtener la garantía detalle. ", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function GetGarantiasPolizaVirtual(CveVenta As Integer) As Boolean + Dim Retorno As Boolean = False + SqlDataAdapter("PA_Acum_GarantiasPolizaVirtualGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un al obtener la información de poliza virtual.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) End Try Return Retorno End Function diff --git a/App_Code/ClsClientes.vb b/App_Code/ClsClientes.vb index 2b603bb68..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) @@ -1581,6 +1583,22 @@ Public Class ClsClientes Try SqlAdapter.Fill(Data) Retorno = True + Catch Ex1 As SqlException + + If Ex1.Message.Contains("Número: 2627;") Then + Alert("El Nuevo Cliente no se guardo debido a que actualmente se encuentra registrado", TipoMensaje.MsgAdvertencia) + + ElseIf Ex1.Message.Contains("Número: 2601;") Then + If Ex1.Message.Contains("UN_ClientesRFCEmpresa") Then + Alert("Ya existe un cliente registrado con el mismo RFC.", TipoMensaje.MsgAdvertencia) + End If + + If Ex1.Message.Contains("IND_Clientes_Codigo") Then + Alert("Ya existe un cliente registrado con el mismo Código.", TipoMensaje.MsgAdvertencia) + End If + Else + Me.OnError("Ocurrió un error al Intentar guardar el Nuevo Cliente.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If Catch ex As Exception OnError("Ocurrió un error al agregar el cliente", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) End Try 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/App_Code/ClsGenerales.vb b/App_Code/ClsGenerales.vb index 79167e0a2..d64782ccb 100644 --- a/App_Code/ClsGenerales.vb +++ b/App_Code/ClsGenerales.vb @@ -133,6 +133,24 @@ Public Class ClsGenerales End With End Sub + Public Function RepConciliacionSatDetalleGET(cveEmpresa As Int32, tipoDocto As String, fechaI As String, fechaF As String, RegistroEn As Integer) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_RepConciliacionSatDetalleGET", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = cveEmpresa + .Add("@TipoDocto", SqlDbType.VarChar).Value = tipoDocto + .Add("@RegistroEn", SqlDbType.Int).Value = RegistroEn + .Add("@FechaI", SqlDbType.VarChar).Value = fechaI + .Add("@FechaF", SqlDbType.VarChar).Value = fechaF + End With + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los registros de Conciliaciones SAT.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return retorno + End Function Public Function RepConciliacionSatGET(cveEmpresa As Int32, tipoDocto As String, fechaI As String, fechaF As String) As Boolean Dim retorno As Boolean = False diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 150011e9b..761bcfd3e 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -3985,9 +3985,11 @@ Public Class ClsPaginas PaginaDict.Add("/Contabilidad/RepBalanzaComprobacion.aspx".ToUpper(), 344) PaginaDict.Add("/Contabilidad/CatCuentasSIG.aspx".ToUpper(), 405) PaginaDict.Add("/Contabilidad/RepIEPS.aspx".ToUpper(), 714) - PaginaDict.Add("/Contabilidad/CatPeriodosBloqueo.aspx".ToUpper(), 677) + PaginaDict.Add("/Contabilidad/CatPeriodosBloqueo.aspx".ToUpper(), 677) + PaginaDict.Add("/Contabilidad/CatClasificacionPorcentaje.aspx".ToUpper(), 752) + #End Region - 'CONTABILIDAD2 + 'CONTABILIDAD2 #Region "Contabilidad2" PaginaDict.Add("/Contabilidad2/RepAnexoCatalogo.aspx".ToUpper(), 580) PaginaDict.Add("/Contabilidad2/RepBalanzaComprobacion.aspx".ToUpper(), 582) diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 955f487b8..25fb3c073 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -317,7 +317,7 @@ Public Class ClsVentas Optional ObservacionesAlmacen As String = "", Optional CveSubProyecto As Integer = -1, Optional CveSubProyectoEjecucion As Integer = -1, Optional CveSubProyectoCobranza As Integer = -1, Optional CveFormaPago33 As Integer = -1, Optional CveMetodoPago33 As Integer = -1, Optional CveUsoCFDI As Integer = -1, Optional OrdenCompra As String = "-1", Optional CveCuentaTerminal As Integer = -1, Optional CveTipoRelacion As Integer = -1, Optional ImpuestoLocal As Double = 0, Optional CveTipoAmortizacionAnticipo As Integer = -1, Optional CveVentaRelacion As Integer = -1, Optional ImporteRelacion As Decimal = -1, Optional CveEmpresaCRM As Integer = -1, Optional EsInterno As Integer = -1, Optional CveAcercamientoCRM As Integer = -1, - Optional DiasCredito As Integer = 0, Optional EsDiasCreditoFijo As Boolean = False, Optional AnticipoEspecial As Boolean = False) As Boolean + Optional DiasCredito As Integer = 0, Optional EsDiasCreditoFijo As Boolean = False, Optional AnticipoEspecial As Boolean = False, Optional Kilometraje As Double = 0) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_VentasAdd") @@ -403,6 +403,7 @@ Public Class ClsVentas .Add("@DiasCredito", SqlDbType.Int).Value = DiasCredito .Add("@EsDiasCreditoFijo", SqlDbType.Bit).Value = EsDiasCreditoFijo .Add("@AnticipoEspecial", SqlDbType.Bit).Value = AnticipoEspecial + .Add("@Kilometraje", SqlDbType.Float).Value = Kilometraje .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue End With @@ -430,7 +431,8 @@ Public Class ClsVentas Fecha As Date, Observaciones As String, CveEmpresa As Integer, CveVenta As Integer, CveMetodoPago As Integer, FormaPago As Integer, Optional TipoDocto As String = "Cot", Optional Vigencia As Date = MinFecha, Optional CondicionesPago As Integer = -1, Optional AtencionA As String = "-1", Optional PedidoContrato As String = "-1", Optional CveFormaPago33 As Integer = -1, Optional CveMetodoPago33 As Integer = -1, - Optional CveCliente As Integer = -1, Optional CveClienteSucursal As Integer = -1, Optional OrdenCompra As String = "-1", Optional RetIVA As Double = -1, Optional RetISR As Double = -1) As Boolean + Optional CveCliente As Integer = -1, Optional CveClienteSucursal As Integer = -1, Optional OrdenCompra As String = "-1", Optional RetIVA As Double = -1, + Optional RetISR As Double = -1, Optional Kilometraje As Double = 0) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_VentasUpdate") @@ -460,6 +462,7 @@ Public Class ClsVentas .Add("@CveCliente", SqlDbType.Int).Value = CveCliente .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal .Add("@OrdenCompra", SqlDbType.VarChar).Value = OrdenCompra + .Add("@Kilometraje", SqlDbType.Float).Value = Kilometraje End With Try @@ -2674,6 +2677,45 @@ Public Class ClsVentas Return OnError End Function + Public Function GetFacturasCanceladasPendientesWS(RFC As String, CveEmpresa As Integer, Optional showalert As Boolean = True) As Boolean + Dim retorno As Boolean = False + Try + + Dim objServicio As Cancelacion.CancelacionSoapClient = New Cancelacion.CancelacionSoapClient() + Dim resp As Cancelacion.StructCancel = objServicio.ObtienePendientes(RFC, "UserTest", "1234567890") + If resp.Estado = 0 Then + Dim XmlPendientes As String = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(resp.Xml)) + Dim theReader As IO.StringReader = New IO.StringReader(XmlPendientes) + Dim theDataSet As DataSet = New DataSet() + theDataSet.ReadXml(theReader) + + If theDataSet.Tables(0).Rows(0)("Uuid").ToString() <> "null" Then + Dim sb = New StringBuilder() + + For Each item As DataRow In theDataSet.Tables(0).Rows + sb.AppendFormat("{0};", item("Uuid").ToString()) + Next + + If GetFacturasCanceladasPendientes(sb.ToString(), CveEmpresa) Then + retorno = True + End If + + Else + If showalert Then + Alert("No se encontraron cancelaciones pendientes", ModExtensiones.TipoMensaje.MsgError) + End If + End If + Else + Alert("Error al obtener cancelaciones pendientes: " & resp.Descripcion, ModExtensiones.TipoMensaje.MsgError) + End If + + Catch ex As Exception + retorno = False + Me.OnError("Error al obtener cancelaciones pendientes: ", ex, "") + End Try + Return retorno + End Function + Public Function UpdateVentaFacturas(CveFactura As Integer, CveVenta As Integer, CveEmpresa As Integer) As Boolean Dim OnError As Boolean = False diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index fea43d93f..6df87817e 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -368,7 +368,7 @@ Namespace Modelos End If Timbre = New CFDITimbre End Sub - Public Sub New(UsuarioActual As Usuario, CveVenta As Integer, CveEmpresa As Integer, Optional DirectorioServidor As String = "") + Public Sub New(UsuarioActual As Usuario, CveVenta As Integer, CveEmpresa As Integer, Optional DirectorioServidor As String = "", Optional EsCancelacion As Boolean = False) Me.UsuarioActual = UsuarioActual Me.CveVenta = CveVenta Me.CveEmpresa = CveEmpresa @@ -393,7 +393,7 @@ Namespace Modelos Me.DtDetalle = ObjVentas.DtResultados.Copy() End If ObjVentas.Dispose() - IniciaValoresVentas() + IniciaValoresVentas(EsCancelacion) If String.IsNullOrEmpty(DirectorioServidor) Then DirectorioServidor = HttpContext.Current.Server.MapPath("/") End If @@ -446,7 +446,7 @@ Namespace Modelos Me.IEPS = 0 Me.CveAlmacenTraspasoOrigen = 0 End Sub - Private Sub IniciaValoresVentas() + Private Sub IniciaValoresVentas(Optional EsCancelacion As Boolean = False) If CveVenta > 0 AndAlso CveEmpresa > 0 Then Me.DtAnticipos = New DataTable() Me.DtAntNCVinculadas = New DataTable() @@ -492,6 +492,10 @@ Namespace Modelos Me.DtNCVinculadas = ObjVentas.DtResultados.Copy() End If + If TipoDocto.Contiene("Ant") AndAlso EsCancelacion Then + EsNCAmortizacion = True + End If + If ObjVentas.GetVentasAntNC(-1, CveVenta, AplicaAmortizacion:=EsNCAmortizacion) Then Me.DtAnticipos = ObjVentas.DtResultados.Copy() End If @@ -2333,7 +2337,7 @@ Namespace Modelos Exit Select End If - If ObjFactura.TipoDocto.Contiene("Ing", "Egs") AndAlso ValorMultiplicador = -1 Then + If ObjFactura.TipoDocto.Contiene("Ing", "Egs", "Ant") AndAlso ValorMultiplicador = -1 Then For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows If row2("CveConceptoContable").ToString().ToEntero = 11 Then importeMovimiento = row2("Importe").ToString().ToDecimal * ValorMultiplicador '- ((row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal / row2.DataKey("TotalAnticipo").ToDecimal) * row2.DataKey("IVAAnticipo").ToDecimal) @@ -2344,7 +2348,10 @@ Namespace Modelos CveSubProyectoContabilizar = CveSubProyectoVenta If importeMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=row2("CveVenta").ToString().ToEntero, CveVentaAmortizacion:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=importeMovimiento * tipoCambio, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=SeContabiliza) Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, + CveVenta:=ObjFactura.CveVenta, CveVentaAmortizacion:=row2("CveVenta").ToString().ToEntero, CveCliente:=ObjFactura.CveCliente, + CveIE:=CveIEAnticipo, ImporteMX:=importeMovimiento * tipoCambio, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, + CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=SeContabiliza) Then ErrorPrepoliza = True Exit For Else 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/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/Bancos/ConciliacionesBancarias.aspx.vb b/Bancos/ConciliacionesBancarias.aspx.vb index f84d6bdb4..6e71943d2 100644 --- a/Bancos/ConciliacionesBancarias.aspx.vb +++ b/Bancos/ConciliacionesBancarias.aspx.vb @@ -613,6 +613,7 @@ Partial Class Bancos_ConciliacionesBancariasaspx params.Add(New ReportParameter("SaldoFinalLibros", SaldoFinalLibros.FormatoNumero)) Dim SaldoFinalContabilidad As Double = 0 + Dim SaldoFinalContabilidadComplementaria As Double = 0 If DdlCuenta.SelectedValue.ToEntero > 0 Then Dim CveCuenta As Integer = 0 Dim CveCuentaComplementaria As Integer = 0 @@ -636,7 +637,7 @@ Partial Class Bancos_ConciliacionesBancariasaspx If CveCuentaComplementaria > 0 Then If ObjConta.GetMovimientosAuxiliaresCatalogo(CveCuentaComplementaria, txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, CveMoneda, "-1", UsuarioActual.CveEmpresa, "1") Then If ObjConta.DtResultados.Rows.Count > 1 Then - SaldoFinalContabilidad += ObjConta.DtResultados.Rows(1)("SaldoActual").ToString.ToDouble + SaldoFinalContabilidadComplementaria = ObjConta.DtResultados.Rows(1)("SaldoActual").ToString.ToDouble End If End If End If @@ -644,6 +645,7 @@ Partial Class Bancos_ConciliacionesBancariasaspx End If params.Add(New ReportParameter("SaldoFinalContabilidad", (SaldoFinalContabilidad.FormatoNumero))) + params.Add(New ReportParameter("SaldoFinalContabilidadComplementaria", (SaldoFinalContabilidadComplementaria.FormatoNumero))) params.Add(New ReportParameter("Diferencia", (SaldoFinalLibros - SaldoFinalContabilidad).FormatoNumero)) If Imagen.Exists Then 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() diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb index 79d753686..1027f7906 100644 --- a/Bancos/IE.aspx.vb +++ b/Bancos/IE.aspx.vb @@ -2322,7 +2322,9 @@ Partial Class Bancos_IE ElseIf CveProveedor > 0 Then CveConceptoCompra = 21 'Pago a Proveedor/CAncelacion Anticipos CveConceptoContable = 30 'Bancos - CvePlantillaPoliza = 7 + CvePlantillaPoliza = 7 + ElseIf CveCliente > 0 Then + CvePlantillaPoliza = 11 End If End If 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/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 9b80eb72f..12ec62f2a 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -13594,35 +13594,40 @@ Partial Class Compras_Compras ' guardardevolucion(ObjInventario, cvecompra, subtotal, Now.ToDate) 'End Sub Protected Sub BtnVinculaDevolucion_Click(sender As Object, e As EventArgs) - Dim subtotaldevolucion As Double = 0 - Dim realizadevolucion As Boolean = False + Try + Dim subtotaldevolucion As Double = 0 + Dim realizadevolucion As Boolean = False + + + 'Calculo los subtotales para comparar con la NC + Dim cantidad As Double = 0.0 + + For Each Dr As GridViewRow In GVDevolucion.Rows + cantidad = Dr.FCTextBox("TxtCantidad").Text.ToDouble + If cantidad > 0 Then + realizadevolucion = True + subtotaldevolucion += Dr.DataKey("PU").ToString.ToDouble * cantidad + End If + Next + + 'si no esta vinculado a nc simplemente me lo brinco + If realizadevolucion Then + 'si el subtotal es iwal a la nc lo guardo si no marco error + If TxtSubTotal.Text.ToDouble > subtotaldevolucion - 1 AndAlso TxtSubTotal.Text.ToDouble < subtotaldevolucion + 1 Then + + VinculaDevolucion() + + Else + Alert("El Total de la NC debe ser igual al total de la devolucion", TipoMensaje.MsgAdvertencia) + End If + Else + Alert("No se ha seleccionado nada para la devolución. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + End If + Catch ex As Exception + OnError("Ocurrió un error al realizar la vinculación", ex) + End Try - 'Calculo los subtotales para comparar con la NC - Dim cantidad As Double = 0.0 - - For Each Dr As GridViewRow In GVDevolucion.Rows - cantidad = Dr.FCTextBox("TxtCantidad").Text.ToDouble - If cantidad > 0 Then - realizadevolucion = True - subtotaldevolucion += Dr.DataKey("PU").ToString.ToDouble * cantidad - End If - Next - - 'si no esta vinculado a nc simplemente me lo brinco - If realizadevolucion Then - 'si el subtotal es iwal a la nc lo guardo si no marco error - If TxtSubTotal.Text.ToDouble > subtotaldevolucion - 1 AndAlso TxtSubTotal.Text.ToDouble < subtotaldevolucion + 1 Then - - VinculaDevolucion() - - Else - Alert("El Total de la NC debe ser igual al total de la devolucion", TipoMensaje.MsgAdvertencia) - End If - Else - Alert("No se ha seleccionado nada para la devolución. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - End If - End Sub Private Sub VinculaDevolucion() @@ -13685,7 +13690,7 @@ Partial Class Compras_Compras GvOC1.DataSource = DTOCTemp Dim DTCVEOCS As DataTable = DTOCTemp.FiltraParametros("", "", {"CveOrdenCompra"}) - If DTCVEOCS.Rows.Count > 1 Then + If DTCVEOCS IsNot Nothing AndAlso DTCVEOCS.Rows.Count > 1 Then GvOC1.Columns(0).Visible = True Else GvOC1.Columns(0).Visible = False 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/Contabilidad/CatClasificacionPorcentaje.aspx b/Contabilidad/CatClasificacionPorcentaje.aspx new file mode 100644 index 000000000..728874eca --- /dev/null +++ b/Contabilidad/CatClasificacionPorcentaje.aspx @@ -0,0 +1,137 @@ +<%@ Page Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="CatClasificacionPorcentaje.aspx.vb" Inherits="Contabilidad_CatClasificacionPorcentaje" %> + +<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> + + + + + + + + Catálogo de Clasificacion Porcentaje + + + + +
  • + +
  • + +
    +
    +
    + + + + + + + + + + + + + <%----%> + + +
    + +   +
    +
    + + + +
    + + + + + +
    + + +
    + + + +
    +
    +
    + + diff --git a/Contabilidad/CatClasificacionPorcentaje.aspx.vb b/Contabilidad/CatClasificacionPorcentaje.aspx.vb new file mode 100644 index 000000000..4c7f79bc3 --- /dev/null +++ b/Contabilidad/CatClasificacionPorcentaje.aspx.vb @@ -0,0 +1,150 @@ +Imports System.Data +Imports Extensiones +Imports Microsoft.Reporting.WebForms + +Partial Class Contabilidad_CatClasificacionPorcentaje + Inherits ClsPaginas + + Private Property DtClasificacionPorcentaje As DataTable + Get + Return CType(ViewState("DtClasificacionPorcentaje"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtClasificacionPorcentaje") = value + End Set + End Property + + Private Property CveClasificacion As Integer + Get + Return CType(ViewState("CveClasificacion"), Integer) + End Get + Set(value As Integer) + ViewState("CveClasificacion") = value + End Set + End Property + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + If Not Page.IsPostBack Then + + CargaDatos() + CargaContPaq() + + End If + End Sub + + Protected Sub CargaDatos() + Dim ObjGenerales As New ClsGenerales + If ObjGenerales.GetClasificacionPorcentaje(UsuarioActual.CveEmpresa, CveClasificacionPorcentaje:=-1, CveClasificacion:=-1, PorcentajeIVA:=-1, Opcion:=2) Then + GvDatos.DataSource = ObjGenerales.DtResultados + DtClasificacionPorcentaje = ObjGenerales.DtResultados + End If + ObjGenerales.Dispose() + GvDatos.DataBind() + + DdlClasificaciones.Items.Add(New ListItem("Seleccione", "-1")) + DdlClasificaciones.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) + DdlClasificaciones.DataBind() + + End Sub + + Protected Sub CargaContPaq() + Dim Empresa As DataTable = GlobalDTEmpresas(UsuarioActual.CveEmpresa) + Dim Servidor As String = Empresa.FiltroPrimeroValor("ServerContPAQi") + Dim BD As String = Empresa.FiltroPrimeroValor("BDContPAQi") + Dim Usuario As String = Empresa.FiltroPrimeroValor("UsrContPAQi") + Dim Contra As String = Empresa.FiltroPrimeroValor("PwdContPAQi") + + Dim ObjPaq As New ClsContPAQi(Servidor, BD, Usuario, Contra) + + DdlIdCtaIVAXAcreditar.Items.Add(New ListItem("Seleccione una cuenta", "-1")) + DdlIdCtaIVAAcreditable.Items.Add(New ListItem("Seleccione una cuenta", "-1")) + DdlIdCtaIVAXTrasladar.Items.Add(New ListItem("Seleccione una cuenta", "-1")) + DdlIdCtaIVATrasladado.Items.Add(New ListItem("Seleccione una cuenta", "-1")) + DdlIdCtaIVANoAcreditable.Items.Add(New ListItem("Seleccione una cuenta", "-1")) + + If ObjPaq.GetCuentas(-1, "-1", -1, IdPadre:=-1) Then + DdlIdCtaIVAXAcreditar.DataSource = ObjPaq.DtResultados + DdlIdCtaIVAAcreditable.DataSource = ObjPaq.DtResultados + DdlIdCtaIVAXTrasladar.DataSource = ObjPaq.DtResultados + DdlIdCtaIVATrasladado.DataSource = ObjPaq.DtResultados + DdlIdCtaIVANoAcreditable.DataSource = ObjPaq.DtResultados + End If + ObjPaq.Dispose() + DdlIdCtaIVAXAcreditar.DataBind() + DdlIdCtaIVAAcreditable.DataBind() + DdlIdCtaIVAXTrasladar.DataBind() + DdlIdCtaIVATrasladado.DataBind() + DdlIdCtaIVANoAcreditable.DataBind() + End Sub + + Protected Sub BtnAgregarMotivo_Click(sender As Object, e As EventArgs) Handles BtnAgregarClas.Click + BtnAgregarTiposDModal.Text = "Agregar" + BtnEditarTiposDModal.Visible = False + BtnAgregarTiposDModal.Visible = True + TxtPorcentajeIva.Text = "" + UpModalTiposD.Update() + RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD")) + End Sub + + Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles BtnAgregarTiposDModal.Click 'esta funcion es la que agrega un nuevo motivo de baja se activa con el boton "Agregar" de la ventana modal" + Dim ObjGenerales As New ClsGenerales + If BtnAgregarTiposDModal.Text = "Agregar" Then + If ObjGenerales.AddClasificacionPorcentaje(DdlClasificaciones.SelectedValue, TxtPorcentajeIva.Text.ToDouble, DdlIdCtaIVAXAcreditar.SelectedValue, DdlIdCtaIVAAcreditable.SelectedValue, + DdlIdCtaIVAXTrasladar.SelectedValue, DdlIdCtaIVATrasladado.SelectedValue, UsuarioActual.CveEmpresa) Then + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD")) + Alert("Clasificación porcentaje agregado correctamente") + If ObjGenerales.GetClasificacionPorcentaje(-1) Then + GlobalDTClasificacionPorcentaje(-1) = ObjGenerales.DtResultados + End If + CargaDatos() + CargaContPaq() + UpDatos.Update() + End If + ElseIf BtnAgregarTiposDModal.Text = "Actualizar" Then + If ObjGenerales.UpdateClasificacionPorcentaje(CveClasificacion, DdlClasificaciones.SelectedValue, TxtPorcentajeIva.Text.ToDouble, DdlIdCtaIVAXAcreditar.SelectedValue, + DdlIdCtaIVAAcreditable.SelectedValue, DdlIdCtaIVAXTrasladar.SelectedValue, DdlIdCtaIVATrasladado.SelectedValue) Then + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD")) + Alert("Clasificación porcentaje actualizado correctamente") + If ObjGenerales.GetClasificacionPorcentaje(-1) Then + GlobalDTClasificacionPorcentaje(-1) = ObjGenerales.DtResultados + End If + CargaDatos() + CargaContPaq() + UpDatos.Update() + End If + End If + ObjGenerales.Dispose() + End Sub + + Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting + Dim objgenerales As New ClsGenerales + If objgenerales.RemoveClasificacionPorcentaje(GvDatos.DataKeys(e.RowIndex).Value.ToString) Then + Alert("la clasificación porcentaje se eliminó correctamente") + If objgenerales.GetClasificacionPorcentaje(-1) Then + GlobalDTClasificacionPorcentaje(-1) = objgenerales.DtResultados + End If + CargaDatos() + CargaContPaq() + UpDatos.Update() + End If + objgenerales.Dispose() + End Sub + + Public Sub GvDatos_RowEditing(sender As Object, e As EventArgs) + BtnAgregarTiposDModal.Text = "Actualizar" + + Dim renglon As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + DdlClasificaciones.SelectedValue = If(renglon.DataKey("CveClasificacion").ToString IsNot "", renglon.DataKey("CveClasificacion"), "-1") + TxtPorcentajeIva.Text = renglon.DataKey("PorcentajeIVA") + DdlIdCtaIVAXAcreditar.SelectedValue = If(renglon.DataKey("IdCtaIVAXAcreditar").ToString IsNot "", renglon.DataKey("IdCtaIVAXAcreditar"), "-1") + DdlIdCtaIVAAcreditable.SelectedValue = If(renglon.DataKey("IdCtaIVAAcreditable").ToString IsNot "", renglon.DataKey("IdCtaIVAAcreditable"), "-1") + DdlIdCtaIVAXTrasladar.SelectedValue = If(renglon.DataKey("IdCtaIVAXTrasladar").ToString IsNot "", renglon.DataKey("IdCtaIVAXTrasladar"), "-1") + DdlIdCtaIVATrasladado.SelectedValue = If(renglon.DataKey("IdCtaIVATrasladado").ToString IsNot "", renglon.DataKey("IdCtaIVATrasladado"), "-1") + DdlIdCtaIVANoAcreditable.SelectedValue = If(renglon.DataKey("IdCtaIVANoAcreditable").ToString IsNot "", renglon.DataKey("IdCtaIVANoAcreditable"), "-1") + + BtnEditarTiposDModal.Visible = False + BtnAgregarTiposDModal.Visible = True + UpModalTiposD.Update() + RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD")) + End Sub +End Class 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/Empresas/146/Formatos/Factura.rdlc b/Empresas/146/Formatos/Factura.rdlc index 5be0b965e..ed8648fc9 100644 --- a/Empresas/146/Formatos/Factura.rdlc +++ b/Empresas/146/Formatos/Factura.rdlc @@ -23,9 +23,9 @@ Textbox3 1.37762in - 5.662in + 5.81465in 0.5cm - 2.24597in + 2.09332in @@ -73,9 +73,9 @@ Textbox3 0.93484in - 5.662in + 5.81465in 0.5cm - 2.24597in + 2.09332in 1 - - true - true - - - - - Régimen: Sociedad Anónima de Capital Variable; Condiciones de pago: - - - - =IIF(Parameters!CondicionPago.Value.ToString="","No Identificado",Parameters!CondicionPago.Value) - - - - ; Método de Pago: - - - - =IIF(Parameters!MetodoPago.Value.ToString="","No Identificado",Parameters!MetodoPago.Value) - - - - ; Num. Cta Pago: - - - - =IIF(Parameters!NumCta.Value="0" Orelse Parameters!NumCta.Value="","No Identificado",Parameters!NumCta.Value) - - - - - - 2pt - 2pt - 2pt - 2pt - - true true @@ -1045,7 +977,7 @@ 2.54119in 0.25in 3.69856in - 25 + 24 @@ -1104,7 +1036,7 @@ - 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 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 + + + + + + Textbox1 + + + #ff1037 + 2pt + 2pt + 2pt + 2pt + + + + @@ -2041,7 +2012,7 @@ =Fields!Cantidad.Value @@ -2109,6 +2080,48 @@ + + + + true + true + + + + + =Fields!Codigo.Value + + + + + + + Codigo + + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + @@ -2293,6 +2306,38 @@ + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + @@ -2404,6 +2449,7 @@ + @@ -2423,8 +2469,8 @@ 5.75246cm 0.11468cm 1.07241cm - 20.01064cm - 27 + 19.97804cm + 26 @@ -2463,7 +2509,7 @@ 5.662in 0.21567in 2.26391in - 28 + 27 @@ -2748,7 +2794,7 @@ 5.73412in 0.34081in 2.19818in - 29 + 28 @@ -2862,7 +2908,7 @@ 14.56464cm 0.6cm 5.58343cm - 30 + 29 @@ -2876,7 +2922,13 @@ 3.33888cm - 11.00525cm + 3.672cm + + + 3.83158cm + + + 3.48541cm @@ -2928,10 +2980,58 @@ 2pt - 2 + 3 + + + + + true + true + + + + + + + + + + + + Textbox74 + + + + + + + + + + + + + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + @@ -2986,7 +3086,7 @@ - + true true @@ -3005,19 +3105,34 @@ - Textbox127 + Textbox67 + + + + + + + + + + White + Middle 2pt 2pt 2pt 2pt + 3 + + @@ -3049,7 +3164,7 @@ + @@ -3079,7 +3194,7 @@ - + true true @@ -3098,19 +3213,25 @@ - Textbox131 + Textbox70 + White + + White + Middle 2pt 2pt 2pt 2pt + 3 + + @@ -3118,14 +3239,14 @@ - + true true - Uso CFDI: + Orden de compra: - Textbox15 + Textbox39 + @@ -3172,14 +3293,14 @@ - + true true - =Parameters!UsoCFDI.Value + =IIF(Parameters!OrdenCompra.Value = "-1","",Parameters!OrdenCompra.Value) - Textbox17 + Textbox71 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + fecha de vencimiento: + + + + + + + Textbox40 + + + #ff1037 + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Parameters!Vencimiento.Value + + + + + + + Textbox78 @@ -3236,7 +3429,7 @@ + @@ -3266,7 +3459,7 @@ - + true true @@ -3285,20 +3478,25 @@ - Textbox133 + Textbox72 + White + - Top + White + Middle 2pt 2pt 2pt 2pt + 3 + + @@ -3330,7 +3528,7 @@ + @@ -3360,7 +3558,7 @@ - + true true @@ -3379,20 +3577,25 @@ - Textbox135 + Textbox73 + White + - Top + White + Middle 2pt 2pt 2pt 2pt + 3 + + @@ -3447,10 +3650,12 @@ 2pt - 2 + 4 + + @@ -3459,6 +3664,8 @@ + + @@ -3476,8 +3683,8 @@ 6.91306cm 0.11468cm 5.76188cm - 14.34413cm - 31 + 14.32787cm + 30 @@ -3520,7 +3727,7 @@ 0.04404in 0.36457in 7.87931in - 32 + 31 @@ -4022,7 +4229,7 @@ 0.05568cm 2.97096cm 20.1554cm - 33 + 32 =Microsoft.VisualBasic.Interaction.IIF(First(Fields!SerieFolio.Value, "DataSet4") <> "", False, True) @@ -4036,11 +4243,10 @@ Embedded VISTAPREVIA22 FitProportional - 0cm 19.87567cm 18.27471cm 0.33541cm - 34 + 33 =IIf(Parameters!CveVenta.Value > 0, True,False) @@ -4056,9 +4262,9 @@ FitProportional 1.19556cm 0.14361cm - 1.67893cm + 1.22745cm 4.7959cm - 35 + 34 @@ -4104,7 +4310,7 @@ 0.04515in 0.37389in 4.70134in - 36 + 35 @@ -4115,11 +4321,108 @@ 2pt + + 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 + 36 + + + Top + + 25.59192cm - LCP Sara Eduwiges Ruíz Félix + CP Sara Eduwiges Ruíz Félix HTML + + true + true + + + + + SALDO FINAL SEGUN CONTABILIDAD COMPLEMENTARIA: + + + + + + + + + + + + + + + + Textbox2 + 11.06042cm + 0.42362cm + 477.16077pt + 19 + + =IIF(Parameters!SaldoFinalContabilidadComplementaria.Value = 0,true,false) + + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!SaldoFinalContabilidadComplementaria.Value + + + + + + + + + + + + + + + + Textbox2 + 11.06042cm + 16.83317cm + 0.42362cm + 84.80665pt + 20 + + =IIF(Parameters!SaldoFinalContabilidadComplementaria.Value = 0,true,false) + + + + 2pt + 2pt + 2pt + 2pt + + - 6.69322in + 6.6828in - - -
  • - 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 d2d59eace..d3d25173e 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) @@ -3912,7 +3918,7 @@ Partial Class Clientes Gracias por la atención brindada al presente.
    Reciba un cordial saludo.

    ESTE CORREO SE GENERO EN FORMA AUTOMATICA.", TxtNombreComercial.Text, UsuarioActual.Empresa.Empresa) - Dim Hilo As New System.Threading.Thread(Sub() MandaCorreoEstadoCuenta(File, TxtCobranzaCorreo.Text, $"Estado Actual de Cartera {UsuarioActual.Empresa.Empresa}", Cuerpo, GuardarBitacora:=True)) + Dim Hilo As New System.Threading.Thread(Sub() MandaCorreoEstadoCuenta(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Me.CveCliente, File, TxtCobranzaCorreo.Text, $"Estado Actual de Cartera {UsuarioActual.Empresa.Empresa}", Cuerpo, GuardarBitacora:=True)) Hilo.Start() Alert("El correo se envió con éxito", TipoMensaje.MsgInformacion) Catch ex As Exception @@ -3979,7 +3985,7 @@ Partial Class Clientes End If End If End Sub - Private Sub MandaCorreoEstadoCuenta(File As Byte(), Para As String, Asunto As String, Body As String, Optional GuardarBitacora As Boolean = False) + Private Sub MandaCorreoEstadoCuenta(CveUsuario As Integer, CveEmpresa As Integer, CveCliente As Integer, File As Byte(), Para As String, Asunto As String, Body As String, Optional GuardarBitacora As Boolean = False) Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para) 'a.GuardaLog() @@ -3992,7 +3998,7 @@ Partial Class Clientes If Envio AndAlso GuardarBitacora Then Using ObjBitacora As New ClsOIEventos - ObjBitacora.AddEventoBitacora("Se envió correo con el estado de cuenta del cliente", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCliente:=Me.CveCliente) + ObjBitacora.AddEventoBitacora("Se envió correo con el estado de cuenta del cliente", "", CveUsuario, CveEmpresa, CveCliente:=CveCliente) End Using End If @@ -9934,6 +9940,6 @@ Partial Class Clientes Acum.Dispose() End Sub -#End Region +#End Region End Class diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index e91c73d26..f32552f6c 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(14).Visible = True End If Mov.Dispose() 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 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 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 @@
    - + - + diff --git a/Ventas/RepCancelacionesPorAtender.aspx.cs b/Ventas/RepCancelacionesPorAtender.aspx.cs index 0ef2f8207..98c4074f8 100644 --- a/Ventas/RepCancelacionesPorAtender.aspx.cs +++ b/Ventas/RepCancelacionesPorAtender.aspx.cs @@ -27,39 +27,49 @@ public partial class Ventas_RepCancelacionesPorAtender : ClsPaginas } private void CargarPendientes() { - Cancelacion.CancelacionSoapClient objServicio = new Cancelacion.CancelacionSoapClient(); - Cancelacion.StructCancel resp = objServicio.ObtienePendientes(UsuarioActual.Empresa.RFC, "UserTest", "1234567890"); - if (resp.Estado == 0) + + //Cancelacion.CancelacionSoapClient objServicio = new Cancelacion.CancelacionSoapClient(); + //Cancelacion.StructCancel resp = objServicio.ObtienePendientes(UsuarioActual.Empresa.RFC, "UserTest", "1234567890"); + //if (resp.Estado == 0) + //{ + // string XmlPendientes = DecodeBase64(resp.Xml); + // StringReader theReader = new StringReader(XmlPendientes); + // DataSet theDataSet = new DataSet(); + // theDataSet.ReadXml(theReader); + // if (theDataSet.Tables[0].Rows[0]["Uuid"].ToString() != "null") + // { + // var sb = new StringBuilder(); + // foreach (DataRow item in theDataSet.Tables[0].Rows) + // { + // sb.AppendFormat("{0};", item["Uuid"].ToString()); + // } + // var ObjVentas = new ClsVentas(); + // if (ObjVentas.GetFacturasCanceladasPendientes(sb.ToString(), UsuarioActual.CveEmpresa)) + // { + // GvDatos.DataSource = ObjVentas.DtResultados; + // } + // ObjVentas.Dispose(); + // } + // else + // { + // GvDatos.DataSource = null; + // Alert("No se encontraron cancelaciones pendientes"); + // } + //} + //else + //{ + // GvDatos.DataSource = null; + // Alert("Error al obtener cancelaciones pendientes: " + resp.Descripcion, ModExtensiones.TipoMensaje.MsgError); + //} + using (ClsVentas ObjVentas = new ClsVentas()) { - string XmlPendientes = DecodeBase64(resp.Xml); - StringReader theReader = new StringReader(XmlPendientes); - DataSet theDataSet = new DataSet(); - theDataSet.ReadXml(theReader); - if (theDataSet.Tables[0].Rows[0]["Uuid"].ToString() != "null") + if (ObjVentas.GetFacturasCanceladasPendientesWS(UsuarioActual.Empresa.RFC, UsuarioActual.CveEmpresa)) { - var sb = new StringBuilder(); - foreach (DataRow item in theDataSet.Tables[0].Rows) - { - sb.AppendFormat("{0};", item["Uuid"].ToString()); - } - var ObjVentas = new ClsVentas(); - if (ObjVentas.GetFacturasCanceladasPendientes(sb.ToString(), UsuarioActual.CveEmpresa)) - { - GvDatos.DataSource = ObjVentas.DtResultados; - } - ObjVentas.Dispose(); - } - else - { - GvDatos.DataSource = null; - Alert("No se encontraron cancelaciones pendientes"); + GvDatos.DataSource = ObjVentas.DtResultados; } } - else - { - GvDatos.DataSource = null; - Alert("Error al obtener cancelaciones pendientes: " + resp.Descripcion, ModExtensiones.TipoMensaje.MsgError); - } + + GvDatos.DataBind(); UPDatos.Update(); } @@ -153,9 +163,8 @@ public partial class Ventas_RepCancelacionesPorAtender : ClsPaginas private string DecodeBase64(string strXMLCodificado) { try - { - byte[] decbuff = Convert.FromBase64String(strXMLCodificado); - return System.Text.Encoding.UTF8.GetString(decbuff); + { + return System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(strXMLCodificado)); } catch { diff --git a/Ventas/RepConciliacionEmitidosSat.aspx b/Ventas/RepConciliacionEmitidosSat.aspx index 753022003..fa07791c0 100644 --- a/Ventas/RepConciliacionEmitidosSat.aspx +++ b/Ventas/RepConciliacionEmitidosSat.aspx @@ -8,16 +8,16 @@ text-align: left; } - .GVConciliacionemitidasSAT tr th:nth-child(6) { + .GVConciliacionemitidasSAT tr th:nth-child(7) { text-align: center; } - .GVConciliacionemitidasSAT tr td:nth-child(6) { + .GVConciliacionemitidasSAT tr td:nth-child(7) { text-align: right; } - .GVConciliacionemitidasSAT tr th:nth-child(7), - .GVConciliacionemitidasSAT tr td:nth-child(7) { + .GVConciliacionemitidasSAT tr th:nth-child(8), + .GVConciliacionemitidasSAT tr td:nth-child(8) { text-align: center; } @@ -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"> + + + + + @@ -69,6 +148,11 @@ + + + + + @@ -91,12 +175,13 @@ - + - + <%-- --%> + XML @@ -153,7 +238,6 @@ - + - + + diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 0748e7778..6f7cd833e 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2522,7 +2522,9 @@ Partial Class Ventas DivMesesSinIntereses.Visible = True DivDdlCuentaTarjetaCredito.Attributes.Add("class", "col-md-4") DivContadoOtros.Visible = True - + TrKilometraje.Visible = True + TrPedido.Visible = False + ' TrKilometrajeTxt.Visible = True End If End If @@ -2575,12 +2577,15 @@ 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.Visible = True Else + UpTurno.Visible = False 'Ingresar un nuevo Turno RegistraScript("window.onload = function MuestraCorteCaja() { document.getElementById(""C_btnShow"").click(); }") End If @@ -3839,7 +3844,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) @@ -4108,6 +4113,7 @@ Partial Class Ventas 'Sección Detalle DdlMoneda.Enabled = False + DdlTipoRetencion.Enabled = False TxtFechaEjecucion.ReadOnly = True ImgCalendarFechaEje.Enabled = False 'DdlSucursalEjecucion.Enabled = False @@ -4696,6 +4702,9 @@ Partial Class Ventas ViewState("ClienteRetIVA") = ObjCliente.RetIVA / 100 ViewState("ClienteRetISR") = ObjCliente.RetISR / 100 + DdlTipoRetencion.SelectedValueExist(ObjCliente.DtResultados(0)("CveTipoRetencion").ToString) + DdlTipoRetencion_SelectedIndexChanged(DdlTipoRetencion, EventArgs.Empty) + ViewState("RetIVAFletes") = ObjCliente.RetieneIVAFletes If ObjCliente.RetieneIVAFletes Then TrRetIVA.Style.Add("display", "") @@ -5611,6 +5620,9 @@ Partial Class Ventas 'LO NO PERMITIDO MODIFICAR e.Row.FCDropDownList("DdlUnidadMedida").Enabled = False + If UsuarioActual.CveEmpresa = 119 Then + e.Row.FCTextBox("TxtCantidad").Enabled = False + End If 'e.Row.FCDropDownList("DdlClasificacion").Enabled = False 'e.Row.FCDropDownLost("DdlPS").Enabled = False @@ -5914,6 +5926,20 @@ Partial Class Ventas Dim TotalCalculableImpuestosIVA As Decimal = 0 TotalCalculableImpuestosIVA = TotalCalculableImpuestos * (1 + TmpDT.Rows(e.RowIndex)("PorcentajeIEPS").ToString.ToDecimal) + Dim ClienteRetIVA = Me.ClienteRetIVA + If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then + If DdlTipoRetencion.SelectedValue.Contiene("1", "2") Then + ClienteRetIVA = 0.1D + ElseIf DdlTipoRetencion.SelectedValue.Contiene("3") Then + ClienteRetIVA = 0.04D + ElseIf DdlTipoRetencion.SelectedValue.Contiene("4") Then + ClienteRetIVA = 0.06D + End If + + LblRetIVA.Text = (ClienteRetIVA * 100).FormatoNumero + DdlTipoRetencion.Visible = True + End If + TmpDT.Rows(e.RowIndex)("CveUM") = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida").SelectedValue.ToEntero TmpDT.Rows(e.RowIndex)("UM") = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida").SelectedItem.Text @@ -6456,22 +6482,32 @@ 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 + '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 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 + '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 - 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 @@ -6704,6 +6740,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 +6776,6 @@ Partial Class Ventas End If End If End If - End If End If @@ -6789,24 +6841,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 +6862,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 @@ -7579,10 +7611,10 @@ Partial Class Ventas End Function - Private Sub CreaObjetosVenta(Optional VistaPrevia As Boolean = False) + Private Sub CreaObjetosVenta(Optional VistaPrevia As Boolean = False, Optional EsCancelacion As Boolean = False) If Me.CveVenta > 0 AndAlso NuevaFactura <> 1 Then - ObjFactura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa) + ObjFactura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=EsCancelacion) Else ObjFactura = New Modelos.Factura End If @@ -7723,15 +7755,21 @@ Partial Class Ventas 'CONVERTIR REMISION - TIPO MONEDA -DOLARES A PESOS If (ObjFactura.CveMoneda = 2 AndAlso ObjFactura.ConvertirPesos = True AndAlso ObjFactura.TipodeComprobante = "Ingresos" AndAlso RemisionesLista.Count > 0) Then + Dim TotalCalculableImpuestos, TotalCalculableImpuestosIVA As Decimal For Each Row As DataRow In TmpDT.Rows - Row("PU") = Math.Round(Row("PU").ToString.ToDouble * ObjFactura.TipoCambio, 6) + Row("PU") = Math.Round(Row("PU").ToString.ToDecimal * ObjFactura.TipoCambio, 6) + Row("Descuento") = Math.Round(Row("Descuento").ToString.ToDouble * ObjFactura.TipoCambio, NumeroDecimales) + + TotalCalculableImpuestos = (Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal) - Row("Descuento").ToString.ToDecimal + TotalCalculableImpuestosIVA = TotalCalculableImpuestos * (1 + Row("PorcentajeIEPS").ToString.ToDecimal) + Row("IVA") = Row("PorcentajeIVA") + Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestosIVA, NumeroDecimales) + Row("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, NumeroDecimales) + Row("ImporteRetISR") = Math.Round(ClienteRetISR * TotalCalculableImpuestos, NumeroDecimales) + Row("ImporteIEPS") = Math.Round(Row("PorcentajeIEPS").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) + Row("IEPS") = Row("ImporteIEPS") Row("Total") = Math.Round(Row("Cantidad").ToString.ToDouble * Row("PU").ToString.ToDouble, NumeroDecimales) Row("TotalImporte") = Math.Round(Row("Cantidad").ToString.ToDouble * Row("PU").ToString.ToDouble, NumeroDecimales) - Row("Descuento") = Math.Round(Row("Descuento").ToString.ToDouble * ObjFactura.TipoCambio, NumeroDecimales) - Row("ImporteRetIVA") = Math.Round(Row("ImporteRetIVA").ToString.ToDouble * ObjFactura.TipoCambio, NumeroDecimales) - Row("ImporteRetISR") = Math.Round(Row("ImporteRetISR").ToString.ToDouble * ObjFactura.TipoCambio, NumeroDecimales) - Row("ImporteIVA") = Math.Round(Row("ImporteIVA").ToString.ToDouble * ObjFactura.TipoCambio, NumeroDecimales) - Row("ImporteIEPS") = Math.Round(Row("ImporteIEPS").ToString.ToDouble * ObjFactura.TipoCambio, NumeroDecimales) Next Dim ImpuestosLocales As Double = 0 @@ -7799,21 +7837,28 @@ Partial Class Ventas 'CONVERTIR REMISION - TIPO MONEDA -DOLARES A PESOS REGISTRO DIRECTO SIN VENTA ElseIf (EditoRemision = False AndAlso ObjFactura.CveMoneda = 2 AndAlso ObjFactura.ConvertirPesos = True) Then + + Dim TotalCalculableImpuestos, TotalCalculableImpuestosIVA As Decimal For Each Row As DataRow In TmpDT.Rows - Row("PU") = Math.Round(Row("PU").ToString.ToDouble * ObjFactura.TipoCambio, 6) + Row("PU") = Math.Round(Row("PU").ToString.ToDecimal * ObjFactura.TipoCambio, 6) + Row("Descuento") = Math.Round(Row("Descuento").ToString.ToDouble * ObjFactura.TipoCambio, NumeroDecimales) + + TotalCalculableImpuestos = (Row("Cantidad").ToString.ToDecimal * Row("PU").ToString.ToDecimal) - Row("Descuento").ToString.ToDecimal + TotalCalculableImpuestosIVA = TotalCalculableImpuestos * (1 + Row("PorcentajeIEPS").ToString.ToDecimal) + Row("IVA") = Row("PorcentajeIVA") + Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestosIVA, NumeroDecimales) + Row("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, NumeroDecimales) + Row("ImporteRetISR") = Math.Round(ClienteRetISR * TotalCalculableImpuestos, NumeroDecimales) + Row("ImporteIEPS") = Math.Round(Row("PorcentajeIEPS").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) + Row("IEPS") = Row("ImporteIEPS") Row("Total") = Math.Round(Row("Cantidad").ToString.ToDouble * Row("PU").ToString.ToDouble, NumeroDecimales) Row("TotalImporte") = Math.Round(Row("Cantidad").ToString.ToDouble * Row("PU").ToString.ToDouble, NumeroDecimales) - Row("Descuento") = Math.Round(Row("Descuento").ToString.ToDouble * ObjFactura.TipoCambio, NumeroDecimales) - Row("ImporteRetIVA") = Math.Round(Row("ImporteRetIVA").ToString.ToDouble * ObjFactura.TipoCambio, NumeroDecimales) - Row("ImporteRetISR") = Math.Round(Row("ImporteRetISR").ToString.ToDouble * ObjFactura.TipoCambio, NumeroDecimales) - Row("ImporteIVA") = Math.Round(Row("ImporteIVA").ToString.ToDouble * ObjFactura.TipoCambio, NumeroDecimales) - Row("ImporteIEPS") = Math.Round(Row("ImporteIEPS").ToString.ToDouble * ObjFactura.TipoCambio, NumeroDecimales) Next Dim ImpuestosLocales As Double = 0 For Each gvr As GridViewRow In GvImpuestosLocales2.Rows If gvr.RowType = DataControlRowType.DataRow Then - gvr.FCTextBox("TxtImpuestoLocalPS").Text = (gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble * ObjFactura.TipoCambio).FormatoNumero + gvr.FCTextBox("TxtImpuestoLocalPS").Text = (gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDecimal * ObjFactura.TipoCambio).FormatoNumero ImpuestosLocales += Math.Round(gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble * ObjFactura.TipoCambio, NumeroDecimales) End If Next @@ -9037,7 +9082,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 +9153,9 @@ 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), + 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") @@ -9171,7 +9217,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 +9388,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 +9439,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) @@ -10259,7 +10306,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 +13876,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 $ @@ -14194,6 +14245,20 @@ Partial Class Ventas Row("PorcentajeIVA") = DrPS("IVA") End If + Dim ClienteRetIVA = Me.ClienteRetIVA + If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then + If DdlTipoRetencion.SelectedValue.Contiene("1", "2") Then + ClienteRetIVA = 0.1D + ElseIf DdlTipoRetencion.SelectedValue.Contiene("3") Then + ClienteRetIVA = 0.04D + ElseIf DdlTipoRetencion.SelectedValue.Contiene("4") AndAlso DrPS("CveTipoPS").ToString().ToEntero() = 1 Then + ClienteRetIVA = 0.06D + End If + + LblRetIVA.Text = (ClienteRetIVA * 100).FormatoNumero + DdlTipoRetencion.Visible = True + End If + Row("IVA") = Row("PorcentajeIVA") Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestosIVA, NumeroDecimales) Row("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, NumeroDecimales) @@ -14255,7 +14320,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 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 Dim DrPoliza As DataRow = TmpDT.NewRow() @@ -14337,6 +14403,8 @@ Partial Class Ventas TmpDT.Rows.Add(DrPoliza) End If Next + + End If Retorno = True @@ -15354,6 +15422,7 @@ Partial Class Ventas If UsuarioActual.Empresa.Funcionalidad(575) = "1" Then CveConceptoSalidaAlmacen = 40 CveAlmacenParaSalida = CveAlmacenSalida + AplicaMovimientoDetalleEntrada = True ''Le damos salida normal 'If ConSalida Then ' GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenSalida, 40, CveMoneda, CveVenta, AplicaMovimientoDetalleEntrada:=AplicaMovimientoDetalleEntrada, MovimientoPrePoliza:=True, ObjConta:=ObjConta) > 0 @@ -15380,7 +15449,7 @@ Partial Class Ventas 'Le damos entrada al general por traspaso If Not OcurrioError Then - GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 9, CveMoneda, CveRemision, CveMovimientoRelacionado:=CveMovimientoSalidaPorTraspaso) > 0 + GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 9, CveMoneda, CveRemision, CveMovimientoRelacionado:=CveMovimientoSalidaPorTraspaso, AplicaMovimientoDetalleEntrada:=AplicaMovimientoDetalleEntrada) > 0 If Not GeneroMovimientoAlmacen Then OcurrioError = True @@ -15398,7 +15467,7 @@ Partial Class Ventas End If If Not OcurrioError Then - GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenParaSalida, CveConceptoSalidaAlmacen, CveMoneda, ObjFactura.CveVenta, MovimientoPrePoliza:=True, ObjConta:=ObjConta) > 0 + GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenParaSalida, CveConceptoSalidaAlmacen, CveMoneda, ObjFactura.CveVenta, AplicaMovimientoDetalleEntrada:=AplicaMovimientoDetalleEntrada, MovimientoPrePoliza:=True, ObjConta:=ObjConta) > 0 If Not GeneroMovimientoAlmacen Then OcurrioError = True @@ -15523,6 +15592,12 @@ Partial Class Ventas Dim OcurrioError As Boolean = False Dim ContadorMovtosDetalles = 0 + 'If Not AplicaMovimientoDetalleEntrada Then + ' Dim rowa As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen={0}", CveAlmacen)) + ' If Not IsNothing(rowa) AndAlso rowa("CveTipoAlmacen").ToString() = "10" Then + ' AplicaMovimientoDetalleEntrada = True + ' End If + 'End If 'Creamos el movimiento Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, ConceptoEntrada, CveMoneda, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, CveMovimientoRelacionado:=CveMovimientoRelacionado, Modulo:="Vta/E4") @@ -16261,7 +16336,7 @@ Partial Class Ventas Next 'ACTIVA CAMBIO DE CLIENTE - SI NO TIENE NADA FACTURADO - If Not CantidadFacturadaRemision > 0 Then + If Not CantidadFacturadaRemision > 0 AndAlso UsuarioActual.TienePermisoProceso(284) Then HlCliente.Attributes.Remove("class") HlCliente.Attributes.Add("class", "Texto") TxtCodigo.ReadOnly = False @@ -16375,7 +16450,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:=TxtKilometraje.Text.ToDouble) Then OcurrioError = True End If @@ -18237,6 +18314,10 @@ Partial Class Ventas Exit Sub End If If String.IsNullOrEmpty(Vigencia.EsCancelable) Then + If Not String.IsNullOrEmpty(FolioFiscal) Then + Alert("No se pudo encontrar el estatus de la factura en el SAT.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If sb.Append("No encontrado
    ") Else sb.AppendFormat("{0}
    ", Vigencia.EsCancelable) @@ -18396,7 +18477,8 @@ Partial Class Ventas CancelarRefacturada() End If - CreaObjetosVenta() + CreaObjetosVenta(EsCancelacion:=True) + Dim resp As Modelos.Factura.MCancelacionVentaMensaje = Nothing If ObjFactura IsNot Nothing AndAlso ObjFactura.CveVenta > 0 Then @@ -18414,9 +18496,6 @@ Partial Class Ventas End If ObjFactura.CveAlmacenDevolucion = CveAlmacenDevolucion - If ChkDevAlm.Checked Then - ObjFactura.CveAlmacenDevolucion = CveAlmacenDevolucion - End If resp = ObjFactura.CancelarFactura(ChkDevAlm.Checked, ListaRemisionesCancelar) End If @@ -22043,7 +22122,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:=TxtKilometraje.Text.ToDouble) Then MensajeError = "Ocurrió un error al actualizar la información de la cotización" OcurrioError = True End If @@ -23515,12 +23594,15 @@ Partial Class Ventas End If For Each drow As DataRow In TmpDT.Rows - For Each drow2 As DataRow In DTCvePSCostos.Rows - If drow("CvePS").ToString.ToEntero = drow2("CvePSCargo").ToString.ToEntero Then - drow("Eliminar") = 1 - Exit For - End If - Next + If DTCvePSCostos IsNot Nothing Then + For Each drow2 As DataRow In DTCvePSCostos.Rows + If drow("CvePS").ToString.ToEntero = drow2("CvePSCargo").ToString.ToEntero Then + drow("Eliminar") = 1 + Exit For + End If + Next + End If + Next Dim TmpDTView As New DataView(TmpDT) @@ -23817,10 +23899,12 @@ Partial Class Ventas CargaRNC() RegistraScript("$('#ModalAplicarRemisionesNC').modal({backdrop: 'static', keyboard: false });") End Sub + +#Region "P O L I Z A - V I R T U A L" Protected Sub GeneraPolizaVentaWS(ObjFactura As Modelos.Factura) Dim DtUsados As DataTable = Nothing Dim ObjAcum As New ClsAcumuladores - If ObjAcum.GetGarantiasDetalle(ObjFactura.CveVenta) Then + If ObjAcum.GetGarantiasPolizaVirtual(ObjFactura.CveVenta) Then DtUsados = ObjAcum.DtResultados.Copy() End If ObjAcum.Dispose() @@ -23850,8 +23934,8 @@ Partial Class Ventas obj.sale_id = String.Format("{0}{1}{2}", ObjFactura.Serie, ObjFactura.Folio, ObjFactura.CveVenta) 'DATOS DEL PRODUCTO - obj.product_code = Row("Code17").ToString() - obj.product_unique_code = "" 'se indique el código único de la batería. + obj.product_code = Row("IdProductoPolizaVirtual").ToString() + obj.product_unique_code = Row("SerieLote").ToString() 'se indique el código único de la batería. (SERIE LOTE) obj.product_sale_type = "01 " 'VENTA Dim FechaUsado As DateTime = Row("FechaAjuste").ToString().ToDateTime() @@ -23944,5 +24028,39 @@ Partial Class Ventas Return Retorno End Function +#End Region + + Protected Sub DdlTipoRetencion_SelectedIndexChanged(sender As Object, e As EventArgs) + If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then + If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 Then + For Each RowServicio As DataRow In TmpDT.Rows + Dim ClienteRetIVA = Me.ClienteRetIVA + If DdlTipoRetencion.SelectedValue.Contiene("1", "2") Then + ClienteRetIVA = 0.1D + ElseIf DdlTipoRetencion.SelectedValue.Contiene("3") Then + ClienteRetIVA = 0.04D + ElseIf DdlTipoRetencion.SelectedValue.Contiene("4") AndAlso RowServicio("CveTipoPS").ToString().ToEntero() = 1 Then + ClienteRetIVA = 0.06D + End If + + Dim TotalCalculableImpuestos As Decimal = (RowServicio("Cantidad").ToString().ToDecimal() * RowServicio("PU").ToString().ToDecimal()) - RowServicio("Descuento").ToString().ToDecimal() + RowServicio("ImporteRetIVA") = (TotalCalculableImpuestos * ClienteRetIVA).RoundSQL() + RowServicio("PorcentajeRetIVA") = ClienteRetIVA + + Next + TxtRetIVA.Text = TmpDT.SUM("ImporteRetIVA").ToDecimal().FormatoNumero(2) + Dim PorcentajeRetIVA = (TmpDT.MAX("PorcentajeRetIVA").ToDecimal() * 100) + LblRetIVA.Text = PorcentajeRetIVA.FormatoNumero(2) + If PorcentajeRetIVA > 0 Then + DdlTipoRetencion.Visible = True + End If + + GvPS.DataSource = TmpDT + GvPS.DataBind() + + UpPS.Update() + End If + End If + End Sub End Class \ No newline at end of file diff --git a/asmx/WSSIGApp.asmx b/asmx/WSSIGApp.asmx index a1b647fbd..b675f7c84 100644 --- a/asmx/WSSIGApp.asmx +++ b/asmx/WSSIGApp.asmx @@ -1,4848 +1,4925 @@ -<%@ 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, AgrupadoPor As Integer, CveTipoProceso As Integer, CveVendedor As Integer, CveMedioCaptacion As Integer, CveProbabilidadAcercamiento As Integer, FechaInicio As DateTime, FechaFin As DateTime) As String + Dim Retorno As New JObject() + ' + ' + ' + ' + ' + Dim idgrupo2 = -1 + Dim FechaI = FechaInicio.ToString("yyyy/MM/dd") + Dim FechaF = FechaFin.ToString("yyyy/MM/dd") + + Select Case AgrupadoPor + Case 1 + Retorno("Agrupado") = "Vendedor" + Case 2 + Retorno("Agrupado") = "Medio Captación" + Case 3 + Retorno("Agrupado") = "Probabilidad de Acercamiento" + Case 4 + Retorno("Agrupado") = "Fecha" + End Select + + Using ObjCRM As New ClsCRM + If ObjCRM.RepAcercamientosEtapas(CveEmpresa, CveTipoProceso, AgrupadoPor, idgrupo2, FechaI, FechaF, CveVendedor, CveMedioCaptacion, cveProbabilidadAcercamiento) Then + Dim Reporte = JArray.Parse(ObjCRM.DSResultados.Tables(0).DataTableToJSONIPP()) + Dim Etapas = JArray.Parse(ObjCRM.DSResultados.Tables(1).DataTableToJSONIPP()) + + Dim Visible1 As Boolean = Etapas.Any(Function(etapa) etapa("Orden").ToString().ToEntero() = 0) + Dim Visible2 As Boolean = Etapas.Any(Function(etapa) etapa("Orden").ToString().ToEntero() = 1) + Dim Visible3 As Boolean = Etapas.Any(Function(etapa) etapa("Orden").ToString().ToEntero() = 2) + Dim Visible4 As Boolean = Etapas.Any(Function(etapa) etapa("Orden").ToString().ToEntero() = 3) + Dim Visible5 As Boolean = Etapas.Any(Function(etapa) etapa("Orden").ToString().ToEntero() = 4) + Dim Visible6 As Boolean = Etapas.Any(Function(etapa) etapa("Orden").ToString().ToEntero() = 5) + + For Each Rep As JObject In Reporte + Rep("Visible1") = Visible1 + Rep("Visible2") = Visible2 + Rep("Visible3") = Visible3 + Rep("Visible4") = Visible4 + Rep("Visible5") = Visible5 + Rep("Visible6") = Visible6 + Next + + Retorno("Reporte") = Reporte + Retorno("Etapas") = Etapas + End If + + End Using + + Return Retorno.ToString() + End Function + + 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 +