diff --git a/App_Code/CFDITimbre.vb b/App_Code/CFDITimbre.vb index 71e8e6a3a..68086bdba 100644 --- a/App_Code/CFDITimbre.vb +++ b/App_Code/CFDITimbre.vb @@ -590,7 +590,7 @@ End Class Public Class CFDICartaPorteAutoTransporte - Public Property PermSCT As String = "" + Public Property PermisoSCT As String = "" Public Property NumPermisoSCT As String = "" Public Property NombreSeguroResponsabilidadCivil As String = "" Public Property PolizaSeguroResponsabilidadCivil As String = "" diff --git a/App_Code/ClsClasificaciones.vb b/App_Code/ClsClasificaciones.vb index 7c7e28372..7432b8d52 100644 --- a/App_Code/ClsClasificaciones.vb +++ b/App_Code/ClsClasificaciones.vb @@ -140,6 +140,24 @@ Public Class ClsClasificaciones Return Retorno End Function + Public Function GetClasificacion2ProductoServicio(CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Clasificacion2ProductoServicioGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As SqlException + OnError("Ocurrió un error al consultar las Clasificaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetClasificacionesComprobaciones(CveEmpresa As Integer, Optional Opcion As Integer = 1, Optional TipoComprobacion As Integer = -1) As Boolean Dim Retorno As Boolean = False diff --git a/App_Code/ClsClientes.vb b/App_Code/ClsClientes.vb index 23ef846b9..9845e2643 100644 --- a/App_Code/ClsClientes.vb +++ b/App_Code/ClsClientes.vb @@ -1463,7 +1463,7 @@ Public Class ClsClientes #Region "D I R E C C I O N D E E N V I O " Public Function DireccionEnvioAdd(CveCliente As Integer, EnvioDireccion As String, EnvioNoExt As String, EnvioNoInt As String, EnvioColonia As String, EnvioCiudad As String, EnvioEstado As String, EnvioCP As Integer, EnvioContacto As String, CveUsuario As Integer, Estatus As Integer, Optional CveClienteSucursal As Integer = -1, Optional EnvioDepartamento As String = "-1", Optional EnvioTel As String = "-1", - Optional CvePais As Integer = -1, Optional CveEstado As Integer = -1, Optional CveMunicipio As Integer = -1, Optional CveLocalidad As Integer = -1, Optional CveColonia As Integer = -1) As Integer + Optional CvePais As Integer = -1, Optional CveEstado As Integer = -1, Optional CveMunicipio As Integer = -1, Optional CveLocalidad As Integer = -1, Optional CveColonia As Integer = -1, Optional CveEmpresa As Integer = -1) As Integer Dim Retorno As Integer = -1 DataAdapter("PA_Vta_ClientesDireccionesEnvioAdd") @@ -1488,6 +1488,7 @@ Public Class ClsClientes .Add("@CveMunicipio", SqlDbType.Int).Value = CveMunicipio .Add("@CveLocalidad", SqlDbType.Int).Value = CveLocalidad .Add("@CveColonia", SqlDbType.Int).Value = CveColonia + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveDireccionEnvio", SqlDbType.Int).Direction = ParameterDirection.Output End With diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb index ab161ebc8..9f6902b8d 100644 --- a/App_Code/ClsContabilidad.vb +++ b/App_Code/ClsContabilidad.vb @@ -6543,6 +6543,47 @@ Public Class ClsContabilidad Return Retorno End Function +#Region "F L U C T U A C I O N - C A M B I A R I A" + Public Function UpdateVentaTCValuacion(CveVenta As Integer, TCValuacion As Decimal) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_VentasTCValuacionUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@TCValuacion", SqlDbType.Decimal).Value = TCValuacion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al actualizar el tipo de cambio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdateCompraTCValuacion(CveCompra As Integer, TCValuacion As Decimal) As Boolean + Dim Retorno = False + + DataAdapter("PA_Conta_ComprasTCValuacionUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCompra", SqlDbType.Int).Value = CveCompra + .Add("@TCValuacion", SqlDbType.Decimal).Value = TCValuacion + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + Me.OnError("Ocurrió un error al actualizar el tipo de cambio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region #Region "IDisposable Support" ' IDisposable diff --git a/App_Code/ClsGenerales.vb b/App_Code/ClsGenerales.vb index 6649955fd..1f953f6de 100644 --- a/App_Code/ClsGenerales.vb +++ b/App_Code/ClsGenerales.vb @@ -1734,7 +1734,7 @@ Public Class ClsGenerales Return Retorno - End Function + End Function Public Function GetTipoCambio(CveTipoCambio As Integer, Fecha As Date) As Boolean Dim Retorno = False @@ -1754,6 +1754,26 @@ Public Class ClsGenerales Return Retorno End Function + Public Function GetTipoCambioUltimaFluctuacion(CveTipoCambio As Integer, Fecha As Date, Optional Top As Integer = 1000) As Boolean + Dim Retorno = False + + DataAdapter("PA_Gral_TipoCambioUltimaFluctuacionGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveTipoCambio", SqlDbType.Int).Value = CveTipoCambio + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@Top", SqlDbType.Int).Value = Top + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Tipo de Cambio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function Public Function GetTiposCambio(FechaInicio As Date, FechaFin As Date) As Boolean Dim Retorno = False @@ -3617,8 +3637,7 @@ Public Class ClsGenerales Public Function AddGralTimbre(TipoDocto As String, CveSubProyecto As Integer, Fecha As DateTime, CveUsuario As Integer, CveEmpresa As Integer, Optional Serie As String = "-1", Optional Folio As Integer = -1, Optional Estatus As Integer = 0, - Optional CveEntregaAlmacen As Integer = -1, - Optional AplicaCP As Boolean = False) As Integer + Optional CveEntregaAlmacen As Integer = -1, Optional AplicaCP As Boolean = False) As Integer Dim Retorno As Integer = -1 DataAdapter("PA_Gral_TimbreAdd") @@ -3663,7 +3682,7 @@ Public Class ClsGenerales With SqlAdapter.SelectCommand.Parameters .Add("@CveTimbre", SqlDbType.Int).Value = CveTimbre .Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto - .Add("@FechaI", SqlDbType.Date).Value = FechaI + .Add("@FechaI", SqlDbType.Date).Value = FechaI .Add("@FechaF", SqlDbType.Date).Value = FechaF .Add("@Estatus", SqlDbType.Int).Value = Estatus .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa @@ -3770,7 +3789,8 @@ Public Class ClsGenerales End Function - Public Function AddInvEntregaAlmacenRuta(CveSubProyecto As Integer, CveDireccionOrigen As Integer, CveDireccionDestino As Integer, CveMovimientoAlmacen As Integer, CveChofer As Integer, CveCamion As Integer, FechaEntrega As Date, FechaLlegada As DateTime, Tipo As String, Orden As Integer, Estatus As Integer, Distancia As Integer) As Integer + Public Function AddInvEntregaAlmacenRuta(CveSubProyecto As Integer, CveDireccionOrigen As Integer, CveDireccionDestino As Integer, CveMovimientoAlmacen As Integer, CveChofer As Integer, CveCamion As Integer, FechaEntrega As Date, FechaLlegada As DateTime, Tipo As String, + FolioReferencia As String, Referencia As String, FechaLimite As Date, Orden As Integer, Estatus As Integer, Distancia As Integer) As Integer Dim Retorno As Integer = -1 DataAdapter("PA_Inv_EntregaAlmacenRutaAdd") @@ -3784,10 +3804,17 @@ Public Class ClsGenerales .Add("@CveCamion", SqlDbType.Int).Value = CveCamion .Add("@FechaEntrega", SqlDbType.DateTime).Value = FechaEntrega .Add("@FechaLlegada", SqlDbType.DateTime).Value = FechaLlegada - .Add("@Orden", SqlDbType.Int).Value = Orden .Add("@Tipo", SqlDbType.VarChar).Value = Tipo + .Add("@Orden", SqlDbType.Int).Value = Orden + .Add("@FolioReferencia", SqlDbType.VarChar).Value = FolioReferencia + .Add("@Referencia", SqlDbType.VarChar).Value = Referencia .Add("@Estatus", SqlDbType.VarChar).Value = Estatus .Add("@Distancia", SqlDbType.Int).Value = Distancia + + .Add("@FechaLimite", SqlDbType.DateTime).Value = FechaLimite + + + .Add("@CveEntregaAlmacen", SqlDbType.Int).Direction = ParameterDirection.Output End With @@ -3826,6 +3853,28 @@ Public Class ClsGenerales Return Retorno End Function + Public Function AsignaEntregaAlmacenRuta(CveCamion As Integer, CveChofer As Integer, FechaEntrega As Date, CveEntregaAlmacen As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Inv_EntregaAlmacenRutaAsignar") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCamion", SqlDbType.Int).Value = CveCamion + .Add("@CveChofer", SqlDbType.Int).Value = CveChofer + .Add("@FechaEntrega", SqlDbType.DateTime).Value = FechaEntrega + .Add("@CveEntregaAlmacen", SqlDbType.Int).Value = CveEntregaAlmacen + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la entrega almacen", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function GetInvEntregaAlmacenRuta(CveSubProyecto As Integer, FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, Opcion As Integer, Optional Estatus As Integer = -1) As Boolean Dim Retorno As Boolean = False diff --git a/App_Code/ClsMovimientos.vb b/App_Code/ClsMovimientos.vb index c0ab586d4..50259e4c7 100644 --- a/App_Code/ClsMovimientos.vb +++ b/App_Code/ClsMovimientos.vb @@ -241,7 +241,7 @@ Public Class ClsMovimientos Gpo As Integer, CveResponsable As Integer, TipoCambio As Integer, Optional TCEspecifico As Double = -1, Optional TipoDocto As String = "-1", Optional FechaVI As String = "-1", Optional FechaVF As String = "-1", Optional FechaCorte As Date = Nothing, Optional EstatusCliente As Integer = -1, Optional CveUsuarioConsulta As Integer = -1, - Optional CveCobranzaEstatus As Integer = -1, Optional CveClienteClasificacion As Integer = -1, Optional TipoCliente As Integer = -1, Optional AplicaAnticiposPagados As Integer = 1) As Boolean + Optional CveCobranzaEstatus As Integer = -1, Optional CveClienteClasificacion As Integer = -1, Optional TipoCliente As Integer = -1, Optional AplicaAnticiposPagados As Integer = 1, Optional CveMoneda As Integer = -1) As Boolean Dim Retorno As Boolean = False 'Data = New DataTable @@ -274,7 +274,8 @@ Public Class ClsMovimientos .Add("@CveCobranzaEstatus", SqlDbType.Int).Value = CveCobranzaEstatus .Add("@CveClienteClasificacion", SqlDbType.Int).Value = CveClienteClasificacion .Add("@TipoCliente", SqlDbType.Int).Value = TipoCliente - .Add("@AplicaAnticiposPagados", SqlDbType.Int).Value = AplicaAnticiposPagados + .Add("@AplicaAnticiposPagados", SqlDbType.Int).Value = AplicaAnticiposPagados + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda End With Try diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index cbbd3d9bf..1bc365482 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -127,6 +127,47 @@ Public Class ClsPaginas End Set End Property + Public ReadOnly Property GlobalTipoCambioUltimaFluctuacion(Optional Fecha As Date = MinFecha) As MTipoCambioFluctuacion + Get + + If Application("GlobalTipoCambioUltimaFluctuacion") Is Nothing Then + Dim ObjGral As New ClsGenerales + If ObjGral.GetTipoCambioUltimaFluctuacion(-1, Now) AndAlso ObjGral.DtResultados.Rows.Count > 0 Then + Application("GlobalTipoCambioUltimaFluctuacion") = ObjGral.DtResultados.Copy() + Else + Application("GlobalTipoCambioUltimaFluctuacion") = Nothing + End If + ObjGral.Dispose() + End If + + Dim fluctuacion = New MTipoCambioFluctuacion() With { + .TCFluctuacion = 0, + .FechaFluctuacion = MinFecha + } + + 'sino tiene dato lo recargo por si ya esta insertado + If Fecha = MinFecha Then Fecha = Now + + If Application("GlobalTipoCambioUltimaFluctuacion") IsNot Nothing Then + + Dim dr = DirectCast(Application("GlobalTipoCambioUltimaFluctuacion"), DataTable).FiltroPrimero(String.Format("Fecha = '{0}'", Fecha)) + If dr IsNot Nothing Then + fluctuacion.TCFluctuacion = dr("TCFluctuacion").ToString().ToDecimal() + fluctuacion.FechaFluctuacion = dr("FechaFluctuacion").ToString().ToDateTime() + End If + + Return fluctuacion + Else + Return fluctuacion + End If + + End Get + End Property + + Public Class MTipoCambioFluctuacion + Public Property TCFluctuacion As Decimal + Public Property FechaFluctuacion As DateTime + End Class Public Property GlobalTipoCambioEuro(Optional Fecha As Date = MinFecha) As Double Get If GlobalTipoCambioEuro <= 0 Then @@ -4947,6 +4988,7 @@ Public Class ClsPaginas PaginaDict.Add("/Inventarios/CatUnidades.aspx".ToUpper(), 2056) PaginaDict.Add("/Inventarios/EntregaAlmacenRuta.aspx".ToUpper(), 1320) PaginaDict.Add("/Inventarios/RepEntregaAlmacenRuta.aspx".ToUpper(), 1319) + PaginaDict.Add("/Inventarios/CartaPorteManual.aspx".ToUpper(), 1321) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 7f68a1c1b..1f4db56e7 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -5080,202 +5080,203 @@ Namespace Modelos If Not ErrorCancelar AndAlso RealizarDevolucionAlmacen Then 'REALIZA DEVOLUCION A LAS SALIDAS PENDIENTES - For Each RowMovimiento As DataRow In DtSalidas.Rows - Dim CveConceptoMovimiento As Integer = -1 - Dim CveAlmacenMovimiento As Integer = -1 + If ObjFactura.TipoDocto <> "Rem" Then + For Each RowMovimiento As DataRow In DtSalidas.Rows + Dim CveConceptoMovimiento As Integer = -1 + Dim CveAlmacenMovimiento As Integer = -1 - Dim CveMovimientoDevolucion As Integer = 0 - Dim Folio As Integer = 0 + Dim CveMovimientoDevolucion As Integer = 0 + Dim Folio As Integer = 0 - Select Case RowMovimiento("CveConcepto").ToString().ToEntero() - Case 3 - CveConceptoMovimiento = 18 'DEVOLUCION DEL CLIENTE - CveAlmacenMovimiento = RowMovimiento("CveAlmacen").ToString().ToEntero() - Case 40 - CveConceptoMovimiento = 41 'DEVOLUCIÓN DEL CLIENTE DIRECTA - CveAlmacenMovimiento = RowMovimiento("CveAlmacen").ToString().ToEntero() - Case 18 - CveConceptoMovimiento = 3 'DEVOLUCIÓN DEL CLIENTE DIRECTA - CveAlmacenMovimiento = RowMovimiento("CveAlmacen").ToString().ToEntero() - ''SI TIENE REMISIONES RELACIONADAS - 'If DtRemisionesFacturadas.Rows.Count > 0 Then - ' Dim RowRemision As DataRow = DtExistencias.FiltroPrimero($"CveMovimiento = {RowMovimiento("CveMovimiento").ToString()}") + Select Case RowMovimiento("CveConcepto").ToString().ToEntero() + Case 3 + CveConceptoMovimiento = 18 'DEVOLUCION DEL CLIENTE + CveAlmacenMovimiento = RowMovimiento("CveAlmacen").ToString().ToEntero() + Case 40 + CveConceptoMovimiento = 41 'DEVOLUCIÓN DEL CLIENTE DIRECTA + CveAlmacenMovimiento = RowMovimiento("CveAlmacen").ToString().ToEntero() + Case 18 + CveConceptoMovimiento = 3 'DEVOLUCIÓN DEL CLIENTE DIRECTA + CveAlmacenMovimiento = RowMovimiento("CveAlmacen").ToString().ToEntero() + ''SI TIENE REMISIONES RELACIONADAS + 'If DtRemisionesFacturadas.Rows.Count > 0 Then + ' Dim RowRemision As DataRow = DtExistencias.FiltroPrimero($"CveMovimiento = {RowMovimiento("CveMovimiento").ToString()}") - ' Dim CveRemision As Integer = RowRemision("CveRemision").ToString().ToEntero() + ' Dim CveRemision As Integer = RowRemision("CveRemision").ToString().ToEntero() - ' Dim CancelarRemision As Boolean = (ListaRemisionesCancelar IsNot Nothing) AndAlso (ListaRemisionesCancelar.Any(Function(CveRemisionCancelar) CveRemisionCancelar = CveRemision)) + ' Dim CancelarRemision As Boolean = (ListaRemisionesCancelar IsNot Nothing) AndAlso (ListaRemisionesCancelar.Any(Function(CveRemisionCancelar) CveRemisionCancelar = CveRemision)) - ' 'SI LA REMISION SE VA A CANCELAR DEBE REGRESAR AL ALMACEN GENERAL - ' If CancelarRemision Then - ' CveAlmacenDevolucion = RowRemision("CveAlmacenDevolucion").ToString().ToEntero() - ' Else - ' CveAlmacenDevolucion = RowMovimiento("CveAlmacen").ToString().ToEntero() - ' End If + ' 'SI LA REMISION SE VA A CANCELAR DEBE REGRESAR AL ALMACEN GENERAL + ' If CancelarRemision Then + ' CveAlmacenDevolucion = RowRemision("CveAlmacenDevolucion").ToString().ToEntero() + ' Else + ' CveAlmacenDevolucion = RowMovimiento("CveAlmacen").ToString().ToEntero() + ' End If - 'Else - ' CveAlmacenDevolucion = RowMovimiento("CveAlmacen").ToString().ToEntero() - 'End If - End Select + 'Else + ' CveAlmacenDevolucion = RowMovimiento("CveAlmacen").ToString().ToEntero() + 'End If + End Select - 'SI TIENE SALDO PENDIENTE POR DEVOLVER GENERA UN MOVIMIENTO DE DEVOLUCION - If ObjFactura.SaldoAlmacen <> 0 Then - 'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN) - CveMovimientoDevolucion = ObjInventario.AddMovimiento(CveAlmacenMovimiento, CveConceptoMovimiento, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, Observaciones:="", Guia:="", CveContrato:=CveContrato, CveAlmacenDestino:=-1, Modulo:="Mod/CV1") - Folio = ObjInventario.Folio + 'SI TIENE SALDO PENDIENTE POR DEVOLVER GENERA UN MOVIMIENTO DE DEVOLUCION + If ObjFactura.SaldoAlmacen <> 0 Then + 'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN) + CveMovimientoDevolucion = ObjInventario.AddMovimiento(CveAlmacenMovimiento, CveConceptoMovimiento, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, Observaciones:="", Guia:="", CveContrato:=CveContrato, CveAlmacenDestino:=-1, Modulo:="Mod/CV1") + Folio = ObjInventario.Folio - If CveMovimientoDevolucion > 0 Then - For Each Dr As DataRow In DtExistencias.FiltraParametros($"CveMovimiento = {RowMovimiento("CveMovimiento").ToString()}").Rows + If CveMovimientoDevolucion > 0 Then + For Each Dr As DataRow In DtExistencias.FiltraParametros($"CveMovimiento = {RowMovimiento("CveMovimiento").ToString()}").Rows - Dim FechaCaducidad As Date = MinFecha - If Not String.IsNullOrEmpty(Dr("FechaCaducidad").ToString()) Then - If IsDate(Dr("FechaCaducidad")) Then - FechaCaducidad = Dr("FechaCaducidad").ToString().ToDate() + Dim FechaCaducidad As Date = MinFecha + If Not String.IsNullOrEmpty(Dr("FechaCaducidad").ToString()) Then + If IsDate(Dr("FechaCaducidad")) Then + FechaCaducidad = Dr("FechaCaducidad").ToString().ToDate() + End If + End If + + Dim CveVentaDetalleRemision As Integer = -1 + If CveConceptoMovimiento = 41 Then + CveVentaDetalleRemision = Dr("CveVentaDetalleRemision").ToString.ToEntero() + End If + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoDevolucion, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, -1, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, FechaCaducidad:=FechaCaducidad, CveVentaDetalleRemision:=CveVentaDetalleRemision) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar." + Exit For + End If + Next + Else + MensajeError = "Ocurrió un error al agregar el movimiento" + ErrorCancelar = True + End If + + 'GENERA PREPOLIZA DEL MOVIMIENTO DE DEVOLUCION + If Not ErrorCancelar Then + Dim DtCostos As DataTable = Nothing + Dim ValorInventario As Decimal = 0 + If ObjInventario.GetMovimientosDetalle(CveMovimientoDevolucion, UsuarioActual.CveEmpresa) Then + DtCostos = ObjInventario.DtResultados + + Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) + Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {CveAlmacenMovimiento}").ToEntero + Dim IdCtaContable As Integer = 0 + If tmpCostos.Rows.Count > 0 Then + + Dim Multiplicador As Decimal = -1D + If ObjFactura.TipoDocto = "Dev" Then + Multiplicador = 1D + End If + + If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then + Dim Fecha As Date = Now + Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString.ToEntero + Dim ClienteNombre As String = ObjVentas.DtResultados(0)("ClienteNombre").ToString + Dim SerieFolio As String = ObjVentas.DtResultados(0)("SerieFolio").ToString + Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundAD() + Dim TotalCostoAcumulado As Decimal = 0 + Dim cont As Integer = 1 + + Dim CvePrePolizaDev As Integer = ObjConta.AddPrePolizas("Modelos/RecepcionEntrega", 4, TotalCosto, TotalCosto, 1, Fecha, ClienteNombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + 'SE AGREGA MOVIMIENTO SEPARADO POR LA CUENTA DE VENTAS (ER) + For Each RowInv As DataRow In tmpCostos.Rows + ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundAD() + TotalCostoAcumulado += ValorInventario + + 'CUANDO ES EL ÚLTIMO MOVIMIENTO Y HAY DIFERENCIAS EN LOS IMPORTES + If cont = DtCostos.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then + ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado) + End If + + IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + + If Not ErrorCancelar Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaDev, False, Multiplicador * ValorInventario, SerieFolio, 69, SerieFolio, Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimientoDevolucion, CveSubProyecto:=ObjFactura.CveSubProyecto, ImporteMX:=Multiplicador * ValorInventario, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero) Then + ErrorCancelar = True + End If + End If + + cont += 1 + Next + + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaDev, True, Multiplicador * TotalCosto, SerieFolio, 68, SerieFolio, Fecha, IdCtaContableAlmacen, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimientoDevolucion, CveSubProyecto:=ObjFactura.CveSubProyecto, ImporteMX:=Multiplicador * TotalCosto) Then + ErrorCancelar = True + End If + + 'AUTOCONTA - EL MOVIMIENTO 1 ES EL DE VENTA + + Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1" + + If UsuarioActual.CveEmpresa = 119 AndAlso ObjFactura.TipoDocto.Contiene("Ant", "Rem", "RNC", "Cot", "Ped", "Pd2", "PA", "Egs", "Dev") Then + AutoConta = False + End If + + If AutoConta And Not ErrorCancelar Then + + If IdCtaContable > 0 Then + If Not ObjConta.ContabilizarPrePoliza(CvePrePolizaDev, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjAC) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al contabilizar la prepoliza." + End If + Else + Alert(String.Format("No se puede contabilizar ya que falta asignación de las cuentas contables"), TipoMensaje.MsgAdvertencia) + End If + + End If + + Else + ErrorCancelar = True + MensajeError = "Ocurrió un Error al ingresar las prepolizas" + End If End If End If + End If - Dim CveVentaDetalleRemision As Integer = -1 - If CveConceptoMovimiento = 41 Then - CveVentaDetalleRemision = Dr("CveVentaDetalleRemision").ToString.ToEntero() - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoDevolucion, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, -1, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, FechaCaducidad:=FechaCaducidad, CveVentaDetalleRemision:=CveVentaDetalleRemision) Then + 'AGREGA BITACORA A VENTA + If Not ErrorCancelar AndAlso RealizarDevolucionAlmacen AndAlso CveMovimientoDevolucion > 0 Then + Dim MensajeBitacora = "Devuelta" + If Not ObjEventos.AddEventoBitacora(String.Format("Venta {2} en Folio: {1}", CveMovimientoDevolucion, Folio, MensajeBitacora), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVenta) Then + MensajeError = "Ocurrió un error al agregar la bitacora." ErrorCancelar = True - MensajeError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar." - Exit For + End If + End If + + Else + 'SI EXISTE UNA DEVOLUCION PREVIAMENTE HECHA UTILIZAR COMO REFERENCIA + If DtDevPrevias IsNot Nothing AndAlso DtDevPrevias.Rows.Count > 0 Then + CveMovimientoDevolucion = DtDevPrevias.FiltroPrimeroValor("CveMovimiento", $"CveConcepto = {CveConceptoMovimiento}").ToEntero() + End If + + End If + + + 'DEVOLUCION REMISION - REGRESA LAS EXISTENCIAS A ENTREGA POR ADELANTADO SI LA FACTURA VIENE DE REMISION + 'SI ES DEVOLUCION DEL CLIENTE DEBE REGRESAR A ENTREGA POR ADELANTADO + If Not ErrorCancelar AndAlso CveConceptoMovimiento = 18 AndAlso RevivirRemisiones Then + If Not GeneraMovimientosEntregaPorAdelantadoRemision(CveMovimientoDevolucion, ObjVentas, ObjInventario, DtDevRem, ListaRemisionesCancelar) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al generar los movimientos de devolución a remisión" + End If + End If + + If DtVirtuales IsNot Nothing Then + For Each RowVirtual As DataRow In DtVirtuales.Rows + 'REALIZA LA DEVOLUCION AL ALMACEN VIRTUAL + If Not ErrorCancelar AndAlso Not GeneraMovimientosVirtuales(CveVenta, CveMovimientoDevolucion, RowVirtual("CveMovimiento").ToString().ToEntero(), ObjInventario) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al cargar los datos de devolución. Por favor vuelva a intentar." End If Next - Else - MensajeError = "Ocurrió un error al agregar el movimiento" - ErrorCancelar = True End If - 'GENERA PREPOLIZA DEL MOVIMIENTO DE DEVOLUCION - If Not ErrorCancelar Then - Dim DtCostos As DataTable = Nothing - Dim ValorInventario As Decimal = 0 - If ObjInventario.GetMovimientosDetalle(CveMovimientoDevolucion, UsuarioActual.CveEmpresa) Then - DtCostos = ObjInventario.DtResultados - - Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) - Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {CveAlmacenMovimiento}").ToEntero - Dim IdCtaContable As Integer = 0 - If tmpCostos.Rows.Count > 0 Then - - Dim Multiplicador As Decimal = -1D - If ObjFactura.TipoDocto = "Dev" Then - Multiplicador = 1D - End If - - If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then - Dim Fecha As Date = Now - Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString.ToEntero - Dim ClienteNombre As String = ObjVentas.DtResultados(0)("ClienteNombre").ToString - Dim SerieFolio As String = ObjVentas.DtResultados(0)("SerieFolio").ToString - Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundAD() - Dim TotalCostoAcumulado As Decimal = 0 - Dim cont As Integer = 1 - - Dim CvePrePolizaDev As Integer = ObjConta.AddPrePolizas("Modelos/RecepcionEntrega", 4, TotalCosto, TotalCosto, 1, Fecha, ClienteNombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - 'SE AGREGA MOVIMIENTO SEPARADO POR LA CUENTA DE VENTAS (ER) - For Each RowInv As DataRow In tmpCostos.Rows - ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundAD() - TotalCostoAcumulado += ValorInventario - - 'CUANDO ES EL ÚLTIMO MOVIMIENTO Y HAY DIFERENCIAS EN LOS IMPORTES - If cont = DtCostos.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then - ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado) - End If - - IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - - If Not ErrorCancelar Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaDev, False, Multiplicador * ValorInventario, SerieFolio, 69, SerieFolio, Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimientoDevolucion, CveSubProyecto:=ObjFactura.CveSubProyecto, ImporteMX:=Multiplicador * ValorInventario, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero) Then - ErrorCancelar = True - End If - End If - - cont += 1 - Next - - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaDev, True, Multiplicador * TotalCosto, SerieFolio, 68, SerieFolio, Fecha, IdCtaContableAlmacen, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimientoDevolucion, CveSubProyecto:=ObjFactura.CveSubProyecto, ImporteMX:=Multiplicador * TotalCosto) Then - ErrorCancelar = True - End If - - 'AUTOCONTA - EL MOVIMIENTO 1 ES EL DE VENTA - - Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1" - - If UsuarioActual.CveEmpresa = 119 AndAlso ObjFactura.TipoDocto.Contiene("Ant", "Rem", "RNC", "Cot", "Ped", "Pd2", "PA", "Egs", "Dev") Then - AutoConta = False - End If - - If AutoConta And Not ErrorCancelar Then - - If IdCtaContable > 0 Then - If Not ObjConta.ContabilizarPrePoliza(CvePrePolizaDev, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjAC) Then - ErrorCancelar = True - MensajeError = "Ocurrió un error al contabilizar la prepoliza." - End If - Else - Alert(String.Format("No se puede contabilizar ya que falta asignación de las cuentas contables"), TipoMensaje.MsgAdvertencia) - End If - - End If - - Else - ErrorCancelar = True - MensajeError = "Ocurrió un Error al ingresar las prepolizas" - End If - End If - End If + If ErrorCancelar Then + Exit For End If - 'AGREGA BITACORA A VENTA - If Not ErrorCancelar AndAlso RealizarDevolucionAlmacen AndAlso CveMovimientoDevolucion > 0 Then - Dim MensajeBitacora = "Devuelta" - If Not ObjEventos.AddEventoBitacora(String.Format("Venta {2} en Folio: {1}", CveMovimientoDevolucion, Folio, MensajeBitacora), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVenta) Then - MensajeError = "Ocurrió un error al agregar la bitacora." - ErrorCancelar = True - End If - End If - - Else - 'SI EXISTE UNA DEVOLUCION PREVIAMENTE HECHA UTILIZAR COMO REFERENCIA - If DtDevPrevias IsNot Nothing AndAlso DtDevPrevias.Rows.Count > 0 Then - CveMovimientoDevolucion = DtDevPrevias.FiltroPrimeroValor("CveMovimiento", $"CveConcepto = {CveConceptoMovimiento}").ToEntero() - End If - - End If - - - 'DEVOLUCION REMISION - REGRESA LAS EXISTENCIAS A ENTREGA POR ADELANTADO SI LA FACTURA VIENE DE REMISION - 'SI ES DEVOLUCION DEL CLIENTE DEBE REGRESAR A ENTREGA POR ADELANTADO - If Not ErrorCancelar AndAlso CveConceptoMovimiento = 18 AndAlso RevivirRemisiones Then - If Not GeneraMovimientosEntregaPorAdelantadoRemision(CveMovimientoDevolucion, ObjVentas, ObjInventario, DtDevRem, ListaRemisionesCancelar) Then - ErrorCancelar = True - MensajeError = "Ocurrió un error al generar los movimientos de devolución a remisión" - End If - End If - - If DtVirtuales IsNot Nothing Then - For Each RowVirtual As DataRow In DtVirtuales.Rows - 'REALIZA LA DEVOLUCION AL ALMACEN VIRTUAL - If Not ErrorCancelar AndAlso Not GeneraMovimientosVirtuales(CveVenta, CveMovimientoDevolucion, RowVirtual("CveMovimiento").ToString().ToEntero(), ObjInventario) Then - ErrorCancelar = True - MensajeError = "Ocurrió un error al cargar los datos de devolución. Por favor vuelva a intentar." - End If - Next - End If - - If ErrorCancelar Then - Exit For - End If - - Next - + Next + End If 'SI EXISTEN HAY EXISTENCIA EN (ENTREGA POR ADELANTADO) SE TIENE QUE REGRESAR AL ALMACEN ORGINAL (GENERAL,SIN COSTO) - If Not ErrorCancelar AndAlso ListaRemisionesCancelar IsNot Nothing AndAlso ListaRemisionesCancelar.Count > 0 Then + If Not ErrorCancelar AndAlso ObjFactura.TipoDocto <> "Rem" AndAlso ListaRemisionesCancelar IsNot Nothing AndAlso ListaRemisionesCancelar.Count > 0 Then 'VERIFICA LOS MOVIMIENTOS DE DEVOLUCION YA GENERADOS QUE TENGAN EXISTENCIA EN (ENTREGA POR ADELANTADO) If Not ErrorCancelar Then @@ -5314,6 +5315,40 @@ Namespace Modelos End If + 'CANCELACION DE MOVIMIENTOS DE REMISION + If Not ErrorCancelar AndAlso ObjFactura.TipoDocto = "Rem" AndAlso RealizarDevolucionAlmacen Then + Dim CveAlmacenGeneral As Integer = 0 + Dim DtMovRemision As DataTable = Nothing + 'VERIFICA LOS MOVIMIENTOS DE DEVOLUCION YA GENERADOS QUE TENGAN EXISTENCIA EN (ENTREGA POR ADELANTADO) + If Not ErrorCancelar Then + If ObjInventario.GetInv_Mov(CveVenta, UsuarioActual.CveEmpresa) Then + DtMovRemision = ObjInventario.DtResultados.FiltraParametros("CveTipoAlmacen = 10") + CveAlmacenGeneral = ObjInventario.DtResultados.FiltroPrimeroValor("CveAlmacen", "CveTipoAlmacen = 1").ToString().ToEntero() + Else + ErrorCancelar = True + MensajeError = "Ocurrió un error al cargar los datos de devolución. Por favor vuelva a intentar." + End If + End If + + 'DEBE REGRESAR LA EXISTENCIA DE (ENTREGA POR ADELANTADO) AL ALMACEN ORGINAL (GENERAL,SIN COSTO) + If Not ErrorCancelar AndAlso DtMovRemision IsNot Nothing AndAlso DtMovRemision.Rows.Count > 0 Then + + Dim DtDevMovs = DtMovRemision.FiltraParametros("", DistinctColumns:={"CveMovimiento", "CveAlmacen"}) + + For Each RowDevolucion As DataRow In DtDevMovs.Rows + CveAlmacen = RowDevolucion("CveAlmacen").ToString().ToEntero() + + If Not CancelarMovimientosRemision(CveVenta, CveAlmacen, CveAlmacenGeneral, DtMovRemision.FiltraParametros($"CveMovimiento={RowDevolucion("CveMovimiento")} AND CvePS > 0"), ObjVentas, ObjInventario) Then + ErrorCancelar = True + MensajeError = "Ocurrió un error al cancelar los movimientos de la remisión." + Exit For + End If + Next + + End If + + End If + 'VERIFICAR MOVIMIENTOS DE APARTADOS If Not ErrorCancelar Then If Not GeneraMovimientosApartados(ObjInventario) Then diff --git a/App_Code/Timbrado.vb b/App_Code/Timbrado.vb index 19d241d77..c075709d5 100644 --- a/App_Code/Timbrado.vb +++ b/App_Code/Timbrado.vb @@ -2171,7 +2171,7 @@ Public Class Timbrado If Carta.FiguraTransporte.AutoTransporte IsNot Nothing Then - cfdi.CartaPorteAutotransporte(Carta.FiguraTransporte.AutoTransporte.PermSCT, Carta.FiguraTransporte.AutoTransporte.NumPermisoSCT) + cfdi.CartaPorteAutotransporte(Carta.FiguraTransporte.AutoTransporte.PermisoSCT, Carta.FiguraTransporte.AutoTransporte.NumPermisoSCT) cfdi.CartaPorteIdentificacionVehicular(Carta.FiguraTransporte.AutoTransporte.Vehiculo.ConfigVehicular, Carta.FiguraTransporte.AutoTransporte.Vehiculo.PlacaVM, Carta.FiguraTransporte.AutoTransporte.Vehiculo.AnioModeloVM) @@ -3918,8 +3918,8 @@ Public Class Timbrado ComCartaPorte.FiguraTransporte.CveTransporte = ProfactCartaPorte.c_CveTransporte.Item02 ComCartaPorte.Mercancias.AutotransporteFederal = New ProfactCartaPorte.CartaPorteMercanciasAutotransporteFederal - If Carta.FiguraTransporte.AutoTransporte.PermSCT <> "" Then - ComCartaPorte.Mercancias.AutotransporteFederal.PermSCT = CType([Enum].Parse(GetType(ProfactCartaPorte.c_TipoPermiso), Carta.FiguraTransporte.AutoTransporte.PermSCT), ProfactCartaPorte.c_TipoPermiso) + If Carta.FiguraTransporte.AutoTransporte.PermisoSCT <> "" Then + ComCartaPorte.Mercancias.AutotransporteFederal.PermSCT = CType([Enum].Parse(GetType(ProfactCartaPorte.c_TipoPermiso), Carta.FiguraTransporte.AutoTransporte.PermisoSCT), ProfactCartaPorte.c_TipoPermiso) End If ComCartaPorte.Mercancias.AutotransporteFederal.NumPermisoSCT = Carta.FiguraTransporte.AutoTransporte.NumPermisoSCT 'pendiente RMF diff --git a/App_Code/Timbres.vb b/App_Code/Timbres.vb index e77192c72..4183d3016 100644 --- a/App_Code/Timbres.vb +++ b/App_Code/Timbres.vb @@ -119,7 +119,8 @@ Public Class Timbres Dim Distancia As Integer = 1 Dim ObjGrales As New ClsGenerales - If ObjGrales.GetGralTimbre(CveTimbre, "-1", FI, FF, 0, UsuarioActual.CveEmpresa, -1) Then + + If ObjGrales.GetGralTimbre(CveTimbre, Obj.TipoDocto, FI, FF, 0, UsuarioActual.CveEmpresa, -1) Then If ObjGrales.DtResultados.Rows.Count = 1 Then Dim DtMovimientos As DataTable = Nothing @@ -136,6 +137,13 @@ Public Class Timbres Timbre.Comprobante.Serie = Obj.Serie Timbre.Comprobante.Folio = Obj.Folio.ToString + If drT("FolioFiscalRelacionado").ToString <> "" Then + + Timbre.CFDIRelacionados.TipoRelacion = "05" + Timbre.CFDIRelacionados.UUID.Add(drT("FolioFiscalRelacionado").ToString) + + End If + If ObjGrales.GetGralMovimientosDetalleTimbre(CveTimbre, UsuarioActual.CveEmpresa) Then DtMovimientos = ObjGrales.DtResultados Else @@ -154,7 +162,7 @@ Public Class Timbres If AplicaCP Then - CartaPorte.FiguraTransporte.AutoTransporte.PermSCT = drT("TipoPermisoSCT").ToString '"TPAF01" + CartaPorte.FiguraTransporte.AutoTransporte.PermisoSCT = drT("ClaveTipoPermisoSCT").ToString '"TPAF01" CartaPorte.FiguraTransporte.AutoTransporte.NumPermisoSCT = drT("NumPermisoSCT").ToString CartaPorte.FiguraTransporte.AutoTransporte.NombreSeguroResponsabilidadCivil = drT("NombreAseguradora").ToString CartaPorte.FiguraTransporte.AutoTransporte.PolizaSeguroResponsabilidadCivil = drT("NumPolizaSeguro").ToString @@ -166,8 +174,6 @@ Public Class Timbres CartaPorte.FiguraTransporte.AutoTransporte.Vehiculo.PlacaVM = drT("Placa").ToString CartaPorte.FiguraTransporte.AutoTransporte.Vehiculo.AnioModeloVM = drT("Anio").ToString.ToEntero - CPCliente = drT("CPCliente").ToString.ToEntero - Dim DomOrigen As CFDICartaPorteDomicilio = Nothing DomOrigen = New CFDICartaPorteDomicilio With {.Calle = drT("DirOriCalle").ToString, @@ -192,14 +198,14 @@ Public Class Timbres Dim Ubica As New CFDICartaPorteUbicacion Ubica.TipoEstacion = "" - Ubica = New CFDICartaPorteUbicacion With {.TipoUbicacion = "Origen", .IDUbicacion = "OR000001", .RFCRemitenteDestinatario = UsuarioActual.Empresa.RFC,'UsuarioActual.Empresa.RFC, + Ubica = New CFDICartaPorteUbicacion With {.TipoUbicacion = "Origen", .IDUbicacion = "OR000001", .RFCRemitenteDestinatario = drT("RemitenteRFC").ToString, .FechaHoraSalidaLlegada = FechaSalida.ToString("yyyy-MM-ddTHH:mm:ss"),' "2021-08-23T11:13:01", - .NombreRemitenteDestinatario = UsuarioActual.Empresa.Empresa, + .NombreRemitenteDestinatario = drT("RemitenteNombre").ToString, .Domicilio = DomOrigen} CartaPorte.Ubicaciones.Add(Ubica) - Ubica = New CFDICartaPorteUbicacion With {.TipoUbicacion = "Destino", .IDUbicacion = "DE000001", .RFCRemitenteDestinatario = UsuarioActual.Empresa.RFC,'UsuarioActual.Empresa.RFC,'"CAMJ841219I33", + Ubica = New CFDICartaPorteUbicacion With {.TipoUbicacion = "Destino", .IDUbicacion = "DE000001", .RFCRemitenteDestinatario = drT("DestinatarioRFC").ToString, .FechaHoraSalidaLlegada = FechaLlegada.ToString("yyyy-MM-ddTHH:mm:ss"), - .NombreRemitenteDestinatario = UsuarioActual.Empresa.Empresa, + .NombreRemitenteDestinatario = drT("DestinatarioNombre").ToString, .Domicilio = DomDestino, .DistanciaRecorrida = Distancia} @@ -303,27 +309,27 @@ Public Class Timbres If UsuarioActual.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} + .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 = ""} '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}) - Timbre.Conceptos.Add(concepto) i += 1 Next + Else + TieneError = True + _MsgError.AppendLine("timbrado son detalle de productos") End If End If @@ -334,7 +340,9 @@ Public Class Timbres End If ObjGrales.Dispose() - + Else + Timbre = Nothing + _MsgError.AppendLine("Consultar datos de timbrado") End If Return Timbre End Function diff --git a/Ashx/SIGWeb.ashx b/Ashx/SIGWeb.ashx index 9250a2f5f..a0b88fb36 100644 --- a/Ashx/SIGWeb.ashx +++ b/Ashx/SIGWeb.ashx @@ -117,11 +117,13 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState Case "sendMailLPM" context.Response.Write(sendMailLPM(context)) Case "getSATColomias" - getSATColonias(context) - Case "GetFilesDirectory" + getSatColonias(context) + Case "GetFilesDirectory" GetFilesDirectory(context) Case "Getetiquetas" Getetiquetas(context) + Case "cancelarRemision" + cancelarRemision(context) End Select Catch ex As Exception ex.GuardaLog(ex.Message) @@ -1599,4 +1601,47 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState Return retorno End Function #End Region + +#Region "C A N C E L A R - R E M I S I O N" + Private Function cancelarRemision(ByVal context As HttpContext) As String + Dim retorno As String = "" + + Dim CveVenta As Integer = IfNull(context.Request("CveVenta"), "-1").ToString().ToEntero() + + If CveVenta > 0 Then + Dim usuario As Usuario = UsuarioActual(context) + If usuario IsNot Nothing AndAlso usuario.CveEmpresa > 0 Then + Dim CveAlmacenDevolucion As Integer = 0 + + Using ObjInv As New ClsInventarios + If ObjInv.GetInv_Mov(CveVenta, usuario.CveEmpresa) Then + If ObjInv.DtResultados.Rows.Count > 0 Then + CveAlmacenDevolucion = ObjInv.DtResultados.FiltroPrimeroValor("CveAlmacen", "CveConcepto IN (3,40)").ToEntero() + End If + End If + End Using + + Dim ObjFacturaCancelacion As New Modelos.Factura(usuario, CveVenta, usuario.CveEmpresa, EsCancelacion:=True) + ObjFacturaCancelacion.CveAlmacenDevolucion = CveAlmacenDevolucion + + If ObjFacturaCancelacion.TipoDocto = "Rem" Then + Dim respuesta = ObjFacturaCancelacion.CancelarFactura(True, New List(Of Integer)) + If respuesta IsNot Nothing Then + retorno = JsonConvert.SerializeObject(respuesta) + End If + End If + + End If + + End If + + If Not String.IsNullOrEmpty(retorno) Then + context.Response.Write(retorno) + Else + context.Response.Write("[]") + End If + + Return retorno + End Function +#End Region End Class \ No newline at end of file diff --git a/Bancos/FluctuacionCambiaria.aspx b/Bancos/FluctuacionCambiaria.aspx index 93673c3d1..19dc04717 100644 --- a/Bancos/FluctuacionCambiaria.aspx +++ b/Bancos/FluctuacionCambiaria.aspx @@ -1,593 +1,600 @@ -<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="FluctuacionCambiaria.aspx.vb" Inherits="Bancos_FluctuacionCambiaria" %> - - - - - - - - - - Fluctuación Cambiaria - - - - - - -
-
-
- - -
-
- -
-
- - - - -
- - - - - - -
-
-
TC:
-
-
- -
- -
-
-
-
-
-
- -
-
-
-
-
- - - - - - - -
-
-
-

PÉRDIDA

-
- -
- MXN - - - -
-
-
-
-
-
-

GANANCIA

-
- -
-
-
- MXN - - - -
-
-
-
-
-
-
-
-

-
- -
-
-
- MXN - - - -
-
-
-
-
-
-
-
-
-
- - +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="FluctuacionCambiaria.aspx.vb" Inherits="Bancos_FluctuacionCambiaria" %> + + + + + + + + + + Fluctuación Cambiaria + + + + + + +
+
+
+ + +
+
+ +
+ + +
+ +
+ + +
+
+
TC:
+
+
+ +
+ +
+
+
+
+
+
+ +
+
+
+
+
+ + + + + + + +
+
+
+

PÉRDIDA

+
+ +
+ MXN + + + +
+
+
+
+
+
+

GANANCIA

+
+ +
+
+
+ MXN + + + +
+
+
+
+
+
+
+
+

+

+
+ +
+
+
+ MXN + + + +
+
+
+
+
+
+
+
+
+
+ +
- +
- - - - -
- -
- - - - - -
- -
- + + + +
-
- - - - -
- - - - - - - - - - - <%----%> -
-
- - - - -
-
-
-

PÉRDIDA

-
- -
- MXN - - - -
-
-
-
-
-
-

GANANCIA

-
- -
-
-
- MXN - - - -
-
-
-
-
-
-
-
-

-
- -
-
-
- MXN - - - -
-
-
-
-
-
-
-
-
- - -
+
+ + + + + +
+ +
+ +
+ + + + + + +
+ + + + + + + + + + + <%----%> +
+
+ + + + +
+
+
+

PÉRDIDA

+
+ +
+ MXN + + + +
+
+
+
+
+
+

GANANCIA

+
+ +
+
+
+ MXN + + + +
+
+
+
+
+
+
+
+

+

+
+ +
+
+
+ MXN + + + +
+
+
+
+
+
+
+
+
+ + +
-
- - - - -
- -
- - - - - -
- - - -
- +
+ + + +
-
- -
- - - - - - - - - - - - - - - - - - - - - -
+
+ + + + + +
+ + + +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + +
+
+ + + +
-
- - - - -
- -
- - - - - -
- - - -
- +
+ + + +
-
- - - -
- + + + + + +
+ + + +
+ +
+ + + + + +
+ - - - - - - - - - - - - - - -
-
- - - - - - - -
+ Banco,NumCuenta,CveCuentaComplementaria,Saldo" + EmptyDataText="No se Encontraron Cuentas Bancarias." ToolTip="Listado de Cuentas Bancarias" + CssClass="table table-hover table-striped ScrollAD mysmallbtn" GridLines="None"> + + + + + + + + + + + + + + +
+
+ + + + + + + +
-
- - - - -
+
+ + + + +
-
- +
+ - - - -
+ + + +
-
- +
+
- -
- - - - - - - - - - - - - - - - - - - - -
-
-
- - - - -
+
-
- + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + + + +
+ +
+ - - - -
- - - -
- -
-
-
- - - - - - - - - - - - - -
-
- - - -
-
- -
- - - - -
- -
- - - - - -
+ + + +
-
- -
-
- -
- - -
- -
- - - - - - - - - - - - - - - - - - - - - + +
+ +
+
+
+ + + + + + + + + + + + + +
+
+ + + +
+
+ +
+ + + + +
+ +
+ + + + + +
+ + +
+ +
+
+ +
+ + +
+
+ + + + + + + + + + + + + +
+
+ + + + + + diff --git a/Bancos/FluctuacionCambiaria.aspx.vb b/Bancos/FluctuacionCambiaria.aspx.vb index bbc74193e..720450601 100644 --- a/Bancos/FluctuacionCambiaria.aspx.vb +++ b/Bancos/FluctuacionCambiaria.aspx.vb @@ -2,10 +2,18 @@ Option Strict On Imports System.Data +Imports System.Globalization Imports Extensiones Partial Class Bancos_FluctuacionCambiaria Inherits ClsPaginas + + Public ReadOnly Property FechaUltimoDiaMes() As DateTime + Get + Return New DateTime(DdlAnio.SelectedValue.ToEntero(), DdlMes.SelectedValue.ToEntero(), 1).AddMonths(1).AddDays(-1) + End Get + End Property + #Region "PROPIEDADES" Private Property LblTotal() As String Get @@ -19,7 +27,7 @@ Partial Class Bancos_FluctuacionCambiaria Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then - + CargaFechas() CargarCentrosDeCosto(Nothing, DdlSubproyectoBancos, Nothing, LblSubProyectoBancos, "") CargarCentrosDeCosto(Nothing, DdlsubProyectoVentas, Nothing, LblSubProyectoVentas, "") CargarCentrosDeCosto(Nothing, DdlSubProyectoCompras, Nothing, LblSubProyectoCompras, "") @@ -32,6 +40,27 @@ Partial Class Bancos_FluctuacionCambiaria End Sub #Region "CARGAS" + Private Sub CargaFechas() + 'Año actual + DdlAnio.Items.Add(New ListItem(Now.Year.ToString(), Now.Year.ToString())) + 'Año Anterior + DdlAnio.Items.Add(New ListItem(Now.AddYears(-1).Year.ToString(), Now.AddYears(1).Year.ToString())) + + For i = 1 To 12 + Dim fecha = New DateTime(DdlAnio.SelectedValue.ToEntero(), i, 1) + Dim mes = fecha.ToString("MMMM", CultureInfo.GetCultureInfo("es-MX")) + Dim mesStr = Char.ToUpper(mes(0)) + mes.Substring(1) + + DdlMes.Items.Add(New ListItem(mesStr, i.ToString())) + Next + + Dim UltimaFluctuacion = GlobalTipoCambioUltimaFluctuacion(Now) + If UltimaFluctuacion IsNot Nothing Then + DdlMes.SelectedValueExist(UltimaFluctuacion.FechaFluctuacion.Month) + DdlMes.SelectedValueExist(UltimaFluctuacion.FechaFluctuacion.Year) + End If + + End Sub Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click CargaTipoCambio() @@ -47,36 +76,52 @@ Partial Class Bancos_FluctuacionCambiaria Private Sub CargaTipoCambio() Dim ObjGenerales As New ClsGenerales - ObjGenerales.GetTipoCambio(-1, TxtFecha.Text.ToDate) + ObjGenerales.GetTipoCambio(-1, FechaUltimoDiaMes) If ObjGenerales.DtResultados.Rows.Count > 0 Then LtTipoCambioActual.Text = ObjGenerales.DtResultados.Rows(0)("TipoCambio").ToString - TxtConceptoFluctuacion.Text = "Fluctuación a " & TxtFecha.Text + TxtConceptoFluctuacion.Text = "Fluctuación a " & FechaUltimoDiaMes.ToShortDateString() End If ObjGenerales.Dispose() End Sub Private Sub CargaUltimaFluctuacion() - Dim Obj As New ClsBancos - If Obj.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then - Dim dt As DataTable = Obj.DtResultados.FiltraParametros("TipoFluctuacion = 1", "Fecha DESC") - If dt.Rows.Count > 0 Then - LtlUltimaFluctuacion.Text = String.Format("Ultima Fluctuación : {0}", dt.Rows(0)("Fecha").ToString.ToDate.ToShortDateString) - 'si la ultima fluctuacion es mayor o igual al fin de mes anterior, entonces pon la fecha actual - If dt.Rows(0)("Fecha").ToString.ToDate >= Now.AddMonths(-1).LastDayOfMonth Then - TxtFecha.Text = Now.ToShortDateString - Else - TxtFecha.Text = Now.AddMonths(-1).LastDayOfMonth.ToShortDateString() - End If - End If + 'Dim Obj As New ClsBancos + 'If Obj.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + ' Dim dt As DataTable = Obj.DtResultados.FiltraParametros("TipoFluctuacion = 1", "Fecha DESC") + ' If dt.Rows.Count > 0 Then + ' LtlUltimaFluctuacion.Text = String.Format("Ultima Fluctuación : {0}", dt.Rows(0)("Fecha").ToString.ToDate.ToShortDateString) + ' 'si la ultima fluctuacion es mayor o igual al fin de mes anterior, entonces pon la fecha actual + ' If dt.Rows(0)("Fecha").ToString.ToDate >= Now.AddMonths(-1).LastDayOfMonth Then + ' TxtFecha.Text = Now.ToShortDateString + ' Else + ' TxtFecha.Text = Now.AddMonths(-1).LastDayOfMonth.ToShortDateString() + ' End If + ' End If + 'End If + 'Obj.Dispose() + + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(Now) + + If UltimaFluctuacion IsNot Nothing Then + LtlUltimaFluctuacion.Text = String.Format("Ultima Fluctuación : {0}", UltimaFluctuacion.FechaFluctuacion.ToShortDateString) + 'si la ultima fluctuacion es mayor o igual al fin de mes anterior, entonces pon la fecha actual + If UltimaFluctuacion.FechaFluctuacion >= Now.AddMonths(-1).LastDayOfMonth Then + DdlMes.SelectedValueExist(Now.Month) + DdlAnio.SelectedValueExist(Now.Year) + Else + DdlMes.SelectedValueExist(Now.AddMonths(-1).Month) + DdlAnio.SelectedValueExist(Now.AddMonths(-1).Year) + 'TxtFecha.Text = Now.AddMonths(-1).LastDayOfMonth.ToShortDateString() + End If End If - Obj.Dispose() + CargaTipoCambio() End Sub Private Sub CargaDatosCompra() Dim ObjBancos As New ClsBancos 'LblTotalCompras.Text = "0.00" - If ObjBancos.GetFluctuaciones(TxtFecha.Text.ToDate, 1, UsuarioActual.CveEmpresa) Then + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 1, UsuarioActual.CveEmpresa) Then GvCompras.DataSource = ObjBancos.DtResultados 'LblTotalCompras.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero Dim Perdida As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion < 0 ") @@ -110,7 +155,7 @@ Partial Class Bancos_FluctuacionCambiaria Private Sub CargaDatosVentas() Dim ObjBancos As New ClsBancos LblTotalVentas.Text = "0.00" - If ObjBancos.GetFluctuaciones(TxtFecha.Text.ToDate, 2, UsuarioActual.CveEmpresa) Then + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 2, UsuarioActual.CveEmpresa) Then GvVentas.DataSource = ObjBancos.DtResultados Dim Perdida As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion < 0") @@ -142,7 +187,7 @@ Partial Class Bancos_FluctuacionCambiaria Private Sub CargaDatosCuentas() Dim ObjBancos As New ClsBancos LblTotalBancos.Text = "0.00" - If ObjBancos.GetFluctuaciones(TxtFecha.Text.ToDate, 4, UsuarioActual.CveEmpresa) Then + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 4, UsuarioActual.CveEmpresa) Then Dim DtTemp As DataTable = ObjBancos.DtResultados.Copy Dim TCCierreFluctuacion As Decimal = LtTipoCambioActual.Text.ToDecimal Dim TotAcumulado As Decimal = 0 @@ -151,7 +196,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim Total As Decimal = 0 Dim CveCuentaExtranjera As Integer = Dr("CveCuentaExtranjera").ToString.ToEntero If CveCuentaExtranjera > 0 Then - If Conta.GetMovimientosAuxiliaresCatalogo(CveCuentaExtranjera, MinFecha, TxtFecha.Text.ToDate, 2, "-1", UsuarioActual.CveEmpresa, "1") Then + If Conta.GetMovimientosAuxiliaresCatalogo(CveCuentaExtranjera, MinFecha, FechaUltimoDiaMes, 2, "-1", UsuarioActual.CveEmpresa, "1") Then If Conta.DtResultados.Rows.Count > 1 Then Total = Conta.DtResultados.Rows(1)("SaldoActual").ToString.ToDecimal End If @@ -162,7 +207,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim SaldoActualContabilidad As Decimal = 0 Dim CveCuentaComplementaria As Integer = Dr("CveCuentaComplementaria").ToString.ToEntero If CveCuentaComplementaria > 0 Then - If Conta.GetMovimientosAuxiliaresCatalogo(CveCuentaComplementaria, MinFecha, TxtFecha.Text.ToDate, 2, "-1", UsuarioActual.CveEmpresa, "1") Then + If Conta.GetMovimientosAuxiliaresCatalogo(CveCuentaComplementaria, MinFecha, FechaUltimoDiaMes, 2, "-1", UsuarioActual.CveEmpresa, "1") Then If Conta.DtResultados.Rows.Count > 1 Then SaldoActualContabilidad = Conta.DtResultados.Rows(1)("SaldoActual").ToString.ToDecimal End If @@ -189,7 +234,7 @@ Partial Class Bancos_FluctuacionCambiaria Private Sub CargaDatosDeudores() Dim ObjBancos As New ClsBancos LblTotalDeudores.Text = "0.00" - If ObjBancos.GetFluctuaciones(TxtFecha.Text.ToDate, 5, UsuarioActual.CveEmpresa) Then + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 5, UsuarioActual.CveEmpresa) Then GvDeudores.DataSource = ObjBancos.DtResultados LblTotalDeudores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero Else @@ -203,7 +248,7 @@ Partial Class Bancos_FluctuacionCambiaria Private Sub CargaDatosAcreedores() Dim ObjBancos As New ClsBancos LblTotalAcreedores.Text = "0.00" - If ObjBancos.GetFluctuaciones(TxtFecha.Text.ToDate, 6, UsuarioActual.CveEmpresa) Then + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 6, UsuarioActual.CveEmpresa) Then GvAcreedores.DataSource = ObjBancos.DtResultados LblTotalAcreedores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero Else @@ -217,7 +262,7 @@ Partial Class Bancos_FluctuacionCambiaria Private Sub CargaDatosFiliales() Dim ObjBancos As New ClsBancos LblTotalAcreedores.Text = "0.00" - If ObjBancos.GetFluctuaciones(TxtFecha.Text.ToDate, 7, UsuarioActual.CveEmpresa) Then + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 7, UsuarioActual.CveEmpresa) Then GvFiliales.DataSource = ObjBancos.DtResultados.FiltraParametros("Saldo > 0") LblTotalAcreedores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero Else @@ -237,15 +282,17 @@ Partial Class Bancos_FluctuacionCambiaria Dim Total As Decimal = 0 Dim Conta As New ClsContabilidad Conta.IniciaTransacSQL() - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaC", 1, 0, 0, 1, TxtFecha.Text.ToDate, TxtConceptoCompras.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaC", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoCompras.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim idCta As Integer = 0 - Dim CveCuenta As Integer = 0 + Dim CveCuentaPerdida, CveCuentaGanancia As Integer Dim idCtaPerdida, IdCtaGanancia As Integer + Dim TipoMovto As Boolean = False Dim CveConceptoContable As Integer = 0 - Dim CveCuentaComplementaria As Integer = 55175 - Dim IdCtaComplementaria As Integer = 1248 + Dim IdCtaComplementaria As Integer = 0 + Dim ErrorRegistrar As Boolean = False CveCuentaPerdida = 0 '55379 @@ -257,19 +304,17 @@ Partial Class Bancos_FluctuacionCambiaria Total = LblTotal.ToDecimal If Total > 0 Then CveConceptoContable = 64 - CveCuenta = CveCuentaGanancia idCta = IdCtaGanancia TipoMovto = True Else CveConceptoContable = 65 - CveCuenta = CveCuentaPerdida idCta = idCtaPerdida TipoMovto = False End If + Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal() - - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Compras", CveConceptoContable, "Fluctuación Compras", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubProyectoCompras.SelectedValue.ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Compras", CveConceptoContable, "Fluctuación Compras", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveSubProyecto:=DdlSubProyectoCompras.SelectedValue.ToEntero) Then ErrorRegistrar = True End If @@ -279,12 +324,18 @@ Partial Class Bancos_FluctuacionCambiaria Total = gvr.DataKey("Fluctuacion").ToDecimal 'si es pérdida o ganancia - + IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero() 'movimiento de complementaria - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), 201, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, ImporteMX:=Total, ImporteME:=Total, CveCuenta:=CveCuentaComplementaria) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), 201, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, ImporteMX:=Total, ImporteME:=Total) Then ErrorRegistrar = True Exit For + End If + + If Not Conta.UpdateCompraTCValuacion(gvr.DataKey("CveCompra").ToEntero, TCValuacion:=TCUltimaFluctuacion) Then + ErrorRegistrar = True + Exit For End If + Next If Not ErrorRegistrar Then @@ -311,16 +362,18 @@ Partial Class Bancos_FluctuacionCambiaria Dim idCtaPerdida, IdCtaGanancia As Integer Dim TipoMovto As Boolean = False Dim CveConceptoContable As Integer = 0 - Dim CveCuentaComplementaria As Integer = 54141 - Dim IdCtaComplementaria As Integer = 70 + Dim IdCtaComplementaria As Integer = 0 Dim ErrorRegistrar As Boolean = False CveCuentaPerdida = 0 '55379 CveCuentaGanancia = 0 ' 55382 idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227 IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230 - Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias - + Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias + + Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal() + '' + Total = LblTotalVentas.Text.ToDecimal If Total > 0 Then CveConceptoContable = 64 @@ -341,7 +394,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim Conta As New ClsContabilidad Conta.IniciaTransacSQL() - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaV", 1, 0, 0, 1, TxtFecha.Text.ToDate, TxtConceptoVentas.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaV", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoVentas.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Ventas", CveConceptoContable, "Fluctuación Ventas", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlsubProyectoVentas.SelectedValue.ToEntero) Then ErrorRegistrar = True @@ -353,14 +406,21 @@ Partial Class Bancos_FluctuacionCambiaria For Each gvr As GridViewRow In GvVentas.Rows Total = -gvr.DataKey("Fluctuacion").ToDecimal + IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero() + If gvr.DataKey("CveIE").ToEntero > 0 AndAlso gvr.DataKey("CveVenta").ToEntero < 0 Then CveConconceptoCliente = 226 Else CveConconceptoCliente = 203 End If + If Not Conta.UpdateVentaTCValuacion(gvr.DataKey("CveVenta").ToEntero, TCValuacion:=TCUltimaFluctuacion) Then + ErrorRegistrar = True + Exit For + End If + 'movimiento de complementaria - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, gvr.DataKey("SerieFolio"), CveConconceptoCliente, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=TC, ImporteMX:=Total, ImporteME:=Total, CveCuenta:=CveCuentaComplementaria, CveIE:=gvr.DataKey("CveIE").ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, gvr.DataKey("SerieFolio"), CveConconceptoCliente, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=TC, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then ErrorRegistrar = True Exit For End If @@ -395,9 +455,9 @@ Partial Class Bancos_FluctuacionCambiaria Dim CveConceptoContable As Integer = 0 Dim ErrorRegistrar As Boolean = False Dim TCCierreFluctuacion As Decimal = LtTipoCambioActual.Text.ToDecimal - Dim MesTCtexto As String = String.Format("{0} TC:{1}", TxtFecha.Text.ToDate.ToString("MMMM-yyyy"), TCCierreFluctuacion) + Dim MesTCtexto As String = String.Format("{0} TC:{1}", FechaUltimoDiaMes.ToString("MMMM-yyyy"), TCCierreFluctuacion) - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaB", 1, 0, 0, 1, TxtFecha.Text.ToDate, TxtConceptoBancos.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaB", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoBancos.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) CveCuentaPerdida = 0 ' 55379 @@ -477,7 +537,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim Total As Decimal = 0 Dim Conta As New ClsContabilidad Dim Banco As New ClsBancos(Conta.IniciaTransacSQL()) - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaDD", 1, 0, 0, 1, TxtFecha.Text.ToDate, TxtConceptoDeudores.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaDD", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoDeudores.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Dim idCta As Integer = 0 Dim CveCuenta As Integer = 0 Dim CveCuentaPerdida, CveCuentaGanancia As Integer @@ -494,7 +554,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim TCCierreFluctuacion As Decimal = LtTipoCambioActual.Text.ToDecimal Total = LblTotalAcreedores.Text.ToDecimal - Dim ConceptoFluctuacion As String = String.Format("Fluctuación Filiales {0} ", TxtFecha.Text) + Dim ConceptoFluctuacion As String = String.Format("Fluctuación Filiales {0} ", FechaUltimoDiaMes) Dim CveConconceptoDeudores As Integer = 256 @@ -553,7 +613,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim Banco As New ClsBancos(Conta.IniciaTransacSQL()) Dim ObjContPaq As New ClsContPAQi(UsuarioActual.Empresa) ObjContPaq.IniciaTransacSQL() - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaFilial", 1, 0, 0, 1, TxtFecha.Text.ToDate, TxtConceptoFiliales.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaFilial", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoFiliales.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Dim idCta As Integer = 0 Dim CveCuenta As Integer = 0 Dim CveCuentaPerdida, CveCuentaGanancia As Integer @@ -572,7 +632,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim TCCierreFluctuacion As Decimal = LtTipoCambioActual.Text.ToDecimal Total = LblTotalAcreedores.Text.ToDecimal - Dim ConceptoFluctuacion As String = String.Format("Fluctuación Filiales {0} ", TxtFecha.Text) + Dim ConceptoFluctuacion As String = String.Format("Fluctuación Filiales {0} ", FechaUltimoDiaMes) 'saco las cuentas de pérdida y ganancia For Each gvr As GridViewRow In GvFiliales.Rows @@ -646,7 +706,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim Total As Decimal = 0 Dim Conta As New ClsContabilidad Conta.IniciaTransacSQL() - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaA", 1, 0, 0, 1, TxtFecha.Text.ToDate, TxtConceptoAcreedores.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaA", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoAcreedores.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Dim idCta As Integer = 0 Dim CveCuenta As Integer = 0 Dim CveCuentaPerdida, CveCuentaGanancia As Integer diff --git a/Bancos/PopIECompras.aspx.vb b/Bancos/PopIECompras.aspx.vb index 719648f77..654746115 100644 --- a/Bancos/PopIECompras.aspx.vb +++ b/Bancos/PopIECompras.aspx.vb @@ -637,7 +637,7 @@ Partial Class Bancos_PopIECompras CveMonedaCompra = dr("CveMoneda").ToString.ToEntero CveMonedaFiltros = dr("CveMoneda").ToString.ToEntero SerieFolio = dr("SerieFolio").ToString - TipoCambioOriginal = dr("TipoCambio").ToString.ToDecimal + TipoCambioOriginal = dr("TipoCambioOriginal").ToString.ToDecimal NombreProveedor = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("RazonSocial", String.Format("CveProveedor = {0}", CveProveedor)) CveSubProyecto = dr("CveSubProyecto").ToString.ToEntero @@ -1474,6 +1474,14 @@ Partial Class Bancos_PopIECompras Dim CveCuentaContabilizacion As Long = 1 Dim CuentasContablesInvalidasSIG As New StringBuilder + Dim FechaPago As Date = TxtFechaDocumento.Text.ToDate() + 'VERIFICA SI SE ESTA PAGANDO EN EL MISMO MES DE LA FACTURA + Dim PagoMismoMes As Boolean = True + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso (FechaDocumento < FechaPago) AndAlso ((FechaDocumento.Month < FechaPago.Month AndAlso FechaDocumento.Year = FechaPago.Year) OrElse (FechaDocumento.Year < FechaPago.Year)) Then + PagoMismoMes = False + End If + Dim TCUltimaFluctuacion As Decimal = 1 + 'Tipos de cambio segun metodo de pago If CveMoneda = 1 AndAlso CveMonedaCompra = 1 Then 'Si la venta viene en Pesos y se va a pagar en Pesos tipoCambioPago = 1 @@ -1491,6 +1499,13 @@ Partial Class Bancos_PopIECompras tipoCambioPago = TxtTipoCambio.Text.ToDecimal tipoCambioCompra = 1 PorcentajePago = ImportePagado.ToString.ToDecimal / MovimientoPagar.Total + End If + + Dim UltimaFluctuacion = GlobalTipoCambioUltimaFluctuacion(TxtFechaDocumento.Text.ToDate) + If UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion < TxtFechaDocumento.Text.ToDate Then + TCUltimaFluctuacion = UltimaFluctuacion.TCFluctuacion + End If End If Select Case RBLContado.SelectedValue @@ -1569,17 +1584,17 @@ Partial Class Bancos_PopIECompras ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL - TimpocambioGeneral = tipoCambioCompra + TimpocambioGeneral = If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) CveIE = rw.DataKey("CveIE").ToString.ToEntero If CveMonedaCompra <> 1 Then @@ -1617,17 +1632,17 @@ Partial Class Bancos_PopIECompras ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL - TimpocambioGeneral = tipoCambioCompra + TimpocambioGeneral = If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) CveIE = rw.DataKey("CveIE").ToString.ToEntero If CveMonedaCompra <> 1 Then @@ -1640,14 +1655,14 @@ Partial Class Bancos_PopIECompras IdCtaContable = CtaProveedor End If - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=tipoCambioCompra) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If If CveMonedaCompra <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then IdCtaContable = IdCtaContComplementaria If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioCompra - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If End If @@ -1664,13 +1679,13 @@ Partial Class Bancos_PopIECompras ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL @@ -1686,14 +1701,14 @@ Partial Class Bancos_PopIECompras IdCtaContable = CtaProveedor End If - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=tipoCambioCompra) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, ConceptoContable, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If If CveMonedaCompra <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then IdCtaContable = IdCtaContComplementaria If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioCompra - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If End If @@ -1710,13 +1725,13 @@ Partial Class Bancos_PopIECompras ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal / tipoCambioPago - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal * tipoCambioPago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL @@ -1731,14 +1746,14 @@ Partial Class Bancos_PopIECompras IdCtaContable = CtaProveedor End If - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, 275, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, rw.DataKey("CveVenta").ToEntero, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=tipoCambioCompra) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, TxtObservaciones.Text, 275, ConceptoMovimiento, Fecha, IdCtaContable, -1, -1, rw.DataKey("CveVenta").ToEntero, CveCompra, -1, -1, CveProveedor:=CveProveedor2, ImporteMX:=ImporteMX, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If If CveMonedaCompra = 2 Then IdCtaContable = IdCtaContComplementaria If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, rw.DataKey("CveVenta").ToEntero, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioCompra - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, rw.DataKey("CveVenta").ToEntero, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If End If @@ -1755,17 +1770,17 @@ Partial Class Bancos_PopIECompras ImporteMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal / tipoCambioPago - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 1 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal * tipoCambioPago ImporteMX = ImporteMovimiento ElseIf CveMoneda = 2 AndAlso CveMonedaCompra = 2 Then ImporteMovimiento = ImportePagado.ToString.ToDecimal - ImporteMX = ImporteMovimiento * tipoCambioCompra + ImporteMX = ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If ImporteMovimiento = ImporteMovimiento.RoundSQL ImporteMX = ImporteMX.RoundSQL - TimpocambioGeneral = tipoCambioCompra + TimpocambioGeneral = If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) End If If CveMonedaCompra = 1 Then @@ -1773,7 +1788,7 @@ Partial Class Bancos_PopIECompras Else IdCtaContable = IdCtaContComplementaria If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * tipoCambioCompra - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, CveConceptoContableComplementaria, ConceptoMovimiento, Fecha, IdCtaContable, -1, CveIE, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor2, CvePersonal:=CvePersonal, ImporteMX:=ImporteMovimiento * If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) - ImporteMovimiento, ImporteME:=ImporteMovimiento, TipoCambio:=If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion)) Then MsgError = "No se pudo insertar la póliza" End If ImporteMX = ImporteMovimiento @@ -1797,7 +1812,7 @@ Partial Class Bancos_PopIECompras Funcionalidad = 313 ConceptoContable = 248 ElseIf MovimientoPagar.ConceptoRetIVA = 5 Then - Funcionalidad = 578 + Funcionalidad = 577 ConceptoContable = 285 End If @@ -2557,9 +2572,10 @@ Partial Class Bancos_PopIECompras IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) TimpocambioGeneral = TCImpuestos + Dim tipoCambioCompraValuacion As Decimal = If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioCompra If tipoCambioPago < tipoCambioCompra AndAlso CveMonedaCompra = 2 Then - ImporteMovimiento = ((MovimientoPagar.Total * PorcentajePago) * tipoCambioPago) - ((MovimientoPagar.Total * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en la venta + ImporteMovimiento = ((MovimientoPagar.Total * PorcentajePago) * tipoCambioPago) - ((MovimientoPagar.Total * PorcentajePago) * tipoCambioCompraValuacion) 'Añadimos la diferencia de ganancia en la venta ImporteMovimiento -= ((MovimientoPagar.IVA * PorcentajePago) * TCImpuestos) - ((MovimientoPagar.IVA * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el IVA ImporteMovimiento += ((MovimientoPagar.RetIVA * PorcentajePago) * TCImpuestos) - ((MovimientoPagar.RetIVA * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el RetIVA ImporteMovimiento += ((MovimientoPagar.RetISR * PorcentajePago) * TCImpuestos) - ((MovimientoPagar.RetISR * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el RetISR @@ -2581,9 +2597,10 @@ Partial Class Bancos_PopIECompras If CveMoneda <> 1 OrElse CveMonedaCompra <> 1 Then IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioPago, tipoCambioCompra) + Dim tipoCambioCompraValuacion As Decimal = If(PagoMismoMes, tipoCambioCompra, TCUltimaFluctuacion) '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioCompra If tipoCambioPago > tipoCambioCompra AndAlso CveMonedaCompra = 2 Then - ImporteMovimiento = ((MovimientoPagar.Total * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.Total * PorcentajePago) * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta + ImporteMovimiento = ((MovimientoPagar.Total * PorcentajePago) * tipoCambioCompraValuacion) - ((MovimientoPagar.Total * PorcentajePago) * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta ImporteMovimiento -= ((MovimientoPagar.IVA * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.IVA * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA ImporteMovimiento += ((MovimientoPagar.RetIVA * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.RetIVA * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetIVA ImporteMovimiento += ((MovimientoPagar.RetISR * PorcentajePago) * tipoCambioCompra) - ((MovimientoPagar.RetISR * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR diff --git a/Bancos/PopIEVentas.aspx.vb b/Bancos/PopIEVentas.aspx.vb index 0467778a7..57ab71324 100644 --- a/Bancos/PopIEVentas.aspx.vb +++ b/Bancos/PopIEVentas.aspx.vb @@ -1513,20 +1513,30 @@ Partial Class Bancos_PopIEVentas Dim CuentasContablesInvalidasSIG As New StringBuilder Dim TipoCambioFluctuacion As Decimal = 1 Dim FechaUltimaFluctuacion As Date = MinFecha - If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then - If ObjIE.DtResultados.Rows.Count > 0 Then - Dim tFecha As Date = TxtFechaDocumento.Text.ToDate - Dim strFecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) - Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & strFecha & "#", "Fecha DESC") - If drr IsNot Nothing Then - FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate - TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal - End If - End If + Dim tFecha As Date = TxtFechaDocumento.Text.ToDate + + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha) + + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion < tFecha Then + FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion + TipoCambioFluctuacion = UltimaFluctuacion.TCFluctuacion + End If End If + 'If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + ' If ObjIE.DtResultados.Rows.Count > 0 Then + + ' Dim strFecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) + ' Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & strFecha & "#", "Fecha DESC") + ' If drr IsNot Nothing Then + ' FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate + ' TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal + ' End If + ' End If + 'End If If CveMoneda = 1 AndAlso CveMonedaVenta = 1 Then 'Si la venta viene en Pesos y se va a pagar en Pesos tipoCambioPago = 1 diff --git a/Bancos/ProveedoresAbonar.aspx.vb b/Bancos/ProveedoresAbonar.aspx.vb index 8e950e3fc..1ba70513e 100644 --- a/Bancos/ProveedoresAbonar.aspx.vb +++ b/Bancos/ProveedoresAbonar.aspx.vb @@ -924,20 +924,31 @@ Partial Class Bancos_ProveedoresAbonar Dim TipoCambioFluctuacion As Decimal = 1 Dim FechaUltimaFluctuacion As Date = MinFecha - If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then - If ObjIE.DtResultados.Rows.Count > 0 Then - Dim tFecha As Date = TxtFechaDocumento.Text.ToDate - Dim FechaC As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) - Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & FechaC & "#", "Fecha DESC") - If drr IsNot Nothing Then - FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate - TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal - End If + Dim tFecha As Date = TxtFechaDocumento.Text.ToDate + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha) + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion < tFecha Then + FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion + TipoCambioFluctuacion = UltimaFluctuacion.TCFluctuacion End If End If + 'If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + ' If ObjIE.DtResultados.Rows.Count > 0 Then + ' Dim tFecha As Date = TxtFechaDocumento.Text.ToDate + ' Dim FechaC As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) + ' Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & FechaC & "#", "Fecha DESC") + + ' If drr IsNot Nothing Then + ' FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate + ' TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal + ' End If + + ' End If + 'End If + Dim DttPlantilla As DataTable = Nothing If ObjMov.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPoliza) Then @@ -1055,7 +1066,7 @@ Partial Class Bancos_ProveedoresAbonar Funcionalidad = 313 ConceptoContable = 248 ElseIf gvr.DataKey("CveRetIVAConcepto").ToEntero = 5 Then - Funcionalidad = 578 + Funcionalidad = 577 ConceptoContable = 285 End If diff --git a/Bancos/RepProgramarRecursos.aspx.vb b/Bancos/RepProgramarRecursos.aspx.vb index 9d3ad6219..7e53e652a 100644 --- a/Bancos/RepProgramarRecursos.aspx.vb +++ b/Bancos/RepProgramarRecursos.aspx.vb @@ -654,7 +654,7 @@ Partial Class Bancos_RepProgramarRecursos ObjUsuarios.Dispose() End Sub Private Sub EnviaCorreoNotificacion() - If UsuarioActual.CveEmpresa = 13 Then + If UsuarioActual.CveEmpresa.Contiene(13, 83) Then Dim strBody As New StringBuilder Try diff --git a/Bin/GoCfdi.dll b/Bin/GoCfdi.dll index 9ccff8cbe..72be2e8c0 100644 Binary files a/Bin/GoCfdi.dll and b/Bin/GoCfdi.dll differ diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 4384944a1..7c8ceedc8 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -8626,7 +8626,7 @@ Partial Class Compras_Compras Dim IndicePrimero As Integer = 0 For Each dRow As DataRow In TmpDT.Rows - If Boolean.Parse(dRow("AplicaIEPS").ToString) Then + If Boolean.Parse(dRow("AplicaIEPS").ToString) And dRow("IEPSPS").ToString.ToDecimal > 0 Then IndicePrimero = IndiceContador Exit For End If diff --git a/Compras/PopUpVerFactura.aspx.vb b/Compras/PopUpVerFactura.aspx.vb index 9d667c877..bbeb59cd2 100644 --- a/Compras/PopUpVerFactura.aspx.vb +++ b/Compras/PopUpVerFactura.aspx.vb @@ -1437,7 +1437,7 @@ Partial Class PopUpVerFactura DescargarArchivoPDFTraslado(Archivo, Path) Else If Exten = "pdf" Then - Dim ObjTimbres As New Timbres("Rec", cvetimbre, UsuarioActual) + Dim ObjTimbres As New Timbres(Parametros("TIPODOCTO").ToString, cvetimbre, UsuarioActual) GeneraPDFFactura(ObjTimbres.ObjFactura) Archivo = New System.IO.FileInfo(Path) diff --git a/Compras/RepComprasAF.aspx b/Compras/RepComprasAF.aspx index 07177fb93..875cfda95 100644 --- a/Compras/RepComprasAF.aspx +++ b/Compras/RepComprasAF.aspx @@ -81,7 +81,7 @@
Grupo:
- + diff --git a/Compras/RepComprasAF.aspx.vb b/Compras/RepComprasAF.aspx.vb index a9c856c3a..f6dae6e0f 100644 --- a/Compras/RepComprasAF.aspx.vb +++ b/Compras/RepComprasAF.aspx.vb @@ -90,9 +90,22 @@ Partial Class Compras_RepComprasAF DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") DdlClasificacion.DataBind() - DdlClasificacion2.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") + + Dim ObjClasificacion As New ClsClasificaciones + + If ObjClasificacion.GetClasificacion2ProductoServicio(UsuarioActual.CveEmpresa) Then + DdlClasificacion2.DataSource = ObjClasificacion.DtResultados + Else + DdlClasificacion2.DataSource = Nothing + End If + + + ObjClasificacion.Dispose() DdlClasificacion2.DataBind() + + + DdlActivoFijo.DataSource = GlobalDTActivoFijos(UsuarioActual.CveEmpresa) DdlActivoFijo.DataBind() diff --git a/Compras/RepComprasAFDetalle.aspx b/Compras/RepComprasAFDetalle.aspx index b4d4f8667..23ec0098d 100644 --- a/Compras/RepComprasAFDetalle.aspx +++ b/Compras/RepComprasAFDetalle.aspx @@ -173,10 +173,7 @@ -
- - - + @@ -194,7 +191,7 @@
Clasificación 2:
- +
@@ -293,6 +290,17 @@ + + + Clasificación 2 + + + + + + + + diff --git a/Compras/RepComprasAFDetalle.aspx.vb b/Compras/RepComprasAFDetalle.aspx.vb index ea9336f1b..fd65f6a70 100644 --- a/Compras/RepComprasAFDetalle.aspx.vb +++ b/Compras/RepComprasAFDetalle.aspx.vb @@ -186,9 +186,24 @@ Partial Class Compras_RepComprasAFDetalle DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") DdlClasificacion.DataBind() - DdlClasificacion2.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") + 'DdlClasificacion2.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") + 'DdlClasificacion2.DataBind() + + Dim ObjClasificacion As New ClsClasificaciones + + If ObjClasificacion.GetClasificacion2ProductoServicio(UsuarioActual.CveEmpresa) Then + DdlClasificacion2.DataSource = ObjClasificacion.DtResultados + Else + DdlClasificacion2.DataSource = Nothing + End If + + + ObjClasificacion.Dispose() DdlClasificacion2.DataBind() - DdlClasificacion2.Items.Insert(0, New ListItem("Sin Clasificación", "-2")) + DdlClasificacion2.Items.Insert(0, New ListItem("Totas", "-1")) + DdlClasificacion2.Items.Insert(1, New ListItem("Sin Clasificación", "-2")) + DdlClasificacion2.SelectedValueExist(-1) + DdlActivoFijo.DataSource = GlobalDTActivoFijos(UsuarioActual.CveEmpresa) DdlActivoFijo.DataBind() diff --git a/Compras/RepCxP.aspx b/Compras/RepCxP.aspx index 07bd70a8c..666f8cd15 100644 --- a/Compras/RepCxP.aspx +++ b/Compras/RepCxP.aspx @@ -269,7 +269,17 @@ - +
+ Moneda: +
+ +
+ + + + + +
diff --git a/Compras/RepCxP.aspx.vb b/Compras/RepCxP.aspx.vb index f22fe1d7f..8ebbfe1d9 100644 --- a/Compras/RepCxP.aspx.vb +++ b/Compras/RepCxP.aspx.vb @@ -180,7 +180,7 @@ Partial Class Compras_RepCxP If txtFechaVF.Text = "" Then FechaVF = "-1" Dim TipoAgrupacion As Integer = IIf(chkAgruparMes.Checked, 1, -1) Dim TipoDocto As String = If(DdlTipoDocto.GetSelectedValuesM = "", "-1", DdlTipoDocto.GetSelectedValuesM) - If Mov.GetCxP(FechaI, FechaF, DdlProveedor.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlProveedoresClasificaciones.SelectedValue.ToEntero, -1, DdlUsuarioResponsable.SelectedValue.ToEntero, DdlUsuarioRegistro.SelectedValue.ToEntero, DdlEstatusCompra.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero, + If Mov.GetCxP(FechaI, FechaF, DdlProveedor.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlProveedoresClasificaciones.SelectedValue.ToEntero, DdlMoneda.SelectedValue.ToEntero(), DdlUsuarioResponsable.SelectedValue.ToEntero, DdlUsuarioRegistro.SelectedValue.ToEntero, DdlEstatusCompra.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, RblTipoCambio.SelectedValue.ToEntero, TCEspecifico, FechaVI, FechaVF, FechaCorte:=txtCorteA.Text.ToDate, CveUsuarioConsulta:=UsuarioActual.CveUsuario, CveTipoProveedor:=IIf(DdlTipoProveedor.SelectedValue.ToEntero = 3, -1, DdlTipoProveedor.SelectedValue.ToEntero), Comprobaciones:=DdlComprobacion.SelectedValue.ToEntero, TipoDocto:=TipoDocto, TipoAgrupacion:=TipoAgrupacion) Then GvCxP.DataSource = Mov.DtResultados diff --git a/Contratos/Contrato.aspx b/Contratos/Contrato.aspx index 7fb92b014..52992ef0a 100644 --- a/Contratos/Contrato.aspx +++ b/Contratos/Contrato.aspx @@ -130,7 +130,9 @@
  • Presupuesto PDF
  • - +
  • + Presupuesto Excel +
  • Activos Fijos PDF
  • @@ -170,6 +172,7 @@ + diff --git a/Contratos/Contrato.aspx.vb b/Contratos/Contrato.aspx.vb index 5c84bf091..50bb6f76a 100644 --- a/Contratos/Contrato.aspx.vb +++ b/Contratos/Contrato.aspx.vb @@ -2754,7 +2754,7 @@ Partial Class Contratos_Default Private Sub CargaGVGastos() Dim objContrato As New ClsContratos - If objContrato.GetContratoGastos(CveContrato, UsuarioActual.cveempresa) Then + If objContrato.GetContratoGastos(CveContrato, UsuarioActual.CveEmpresa) Then DtGastos = objContrato.DtResultados GvContratosGastos.DataSource = DtGastos SumaGasto = objContrato.DtResultados.SUM("Importe", "CveContratoGasto IS NULL") @@ -3835,6 +3835,9 @@ Partial Class Contratos_Default #Region "I M P R E S I O N D E P R E S U P U E S T O " Private Sub lLbImprimirPresupuesto_Click(sender As Object, e As EventArgs) Handles LbImprimirPresupuesto.Click GenerarPDFPPresupuesto() + End Sub + Private Sub lLbImprimirPresupuestoEXCEL_Click(sender As Object, e As EventArgs) Handles LbImprimirPresupuestoExcel.Click + GenerarPDFPPresupuesto(Formato:="EXCEL") End Sub Private Sub GenerarPDFPPresupuesto(Optional Formato As String = "PDF") Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) diff --git a/CxC/RepCxC.aspx b/CxC/RepCxC.aspx index 374b50382..5baadfd42 100644 --- a/CxC/RepCxC.aspx +++ b/CxC/RepCxC.aspx @@ -335,9 +335,20 @@ +
    + Moneda: +
    + +
    + + + + + +
    -
    + diff --git a/CxC/RepCxC.aspx.vb b/CxC/RepCxC.aspx.vb index e625f98bc..d7bda4f73 100644 --- a/CxC/RepCxC.aspx.vb +++ b/CxC/RepCxC.aspx.vb @@ -203,7 +203,7 @@ Partial Class RepCxC "-1", UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero, DdlResponsable.SelectedValue.ToEntero, RblTipoCambio.SelectedValue.ToEntero, TCEspecifico, If(DdlTipoDocto.GetSelectedValuesM = "", "-1", DdlTipoDocto.GetSelectedValuesM), FechaVI, FechaVF, FechaCorte:=txtCorteA.Text.ToDate, EstatusCliente:=DdlEstatusCliente.SelectedValue.ToEntero, CveUsuarioConsulta:=UsuarioActual.CveUsuario, CveCobranzaEstatus:=CveCobranzaEstatus, CveClienteClasificacion:=DdlClienteClasificacion.SelectedValue.ToEntero, - TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, AplicaAnticiposPagados:=AplicaAnticipos) Then + TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, AplicaAnticiposPagados:=AplicaAnticipos, CveMoneda:=DdlMoneda.SelectedValue.ToEntero()) Then GvDatos.DataSource = ObjMovtos.DtResultados DtDatos = ObjMovtos.DtResultados diff --git a/Empresas/Grales/Formatos/CartaPorteTimbrado.rdlc b/Empresas/Grales/Formatos/CartaPorteTimbrado.rdlc index 54b24800a..3de89a586 100644 --- a/Empresas/Grales/Formatos/CartaPorteTimbrado.rdlc +++ b/Empresas/Grales/Formatos/CartaPorteTimbrado.rdlc @@ -52,7 +52,13 @@ 3.00921cm - 10.82134cm + 6.3532cm + + + 2.5cm + + + 1.90464cm 2.35479cm @@ -150,6 +156,86 @@ + + + + true + true + + + + + =Fields!CodigoMaterialPeligroso.Value + + + + + + + CodigoMaterialPeligroso + + 5pt + + + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Embalaje.Value + + + + + + + Embalaje + + 5pt + + + + 1pt + + 2pt + 2pt + 2pt + 2pt + + + + @@ -280,6 +366,86 @@ + + + 0.52062cm + + + true + true + + + + + Cod. Material Peligroso + + + + + + + Textbox37 + + + #4f81bd + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.52062cm + + + true + true + + + + + Embalaje + + + + + + + Textbox40 + + + #4f81bd + 2pt + 2pt + 2pt + 2pt + + + + + 0.52062cm @@ -385,7 +551,7 @@ 6.39415cm 0.38395cm 1.12062cm - 19.11271cm + 19.04921cm + + + + Placa: + + + + =Parameters!PlacaVM.Value + + + + + + + + + Año: + + + + =Parameters!AnioVM.Value + + + + + + + + + Textbox2 1.13111in @@ -1925,52 +2145,13 @@ - Placa: + - - =Parameters!PlacaVM.Value - - - - - - - - - Año: - - - - =Parameters!AnioVM.Value - - - - - - +
    + + + + Carta Porte Manual + + + + + +
  • + +
  • +
    +
    + + + + +
    + + + + + + + + +
    + <%--
    + + + + +
    +
    +
    + + TRASPASO ENTRE ALMACENES +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + + +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
    + +
    +
    + + +
    + +
    + + +
    + +
    +
    +
    + + + +
    +
    +
    --%> + + + + +
    +
    +
    +
    + + EMISIÓN DE TRASLADO +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + + + + + +
    + +
    + + +
    +
    +
    + +
    +
    + + + + + + + + + + + + + + +
    +
    + +
    + +
    + +
    + + + + + +
    + + +
    +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    + <%-- +
    +
    + + + + + + + + +
    +
    --%> +
    +
    + + + + +
    +
    +
    +
    + +
    +
    +
    +
    + + + + + +
    +
    +
    + + Direcciones +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + + + + + + + + + + + Tipo + + +
    + +
    +
    +
    + + + + + Dirección + + +
    + +
    +
    +
    + + + + Estado + + +
    + +
    +
    +
    + + + + Municipio + + +
    + +
    +
    +
    + + + + Localidad + + +
    + +
    +
    +
    + + + + + Colonia + + +
    + +
    +
    +
    + + + + C.P. + + +
    + +
    +
    +
    + + + + + + + +
    +
    +
    +
    + +
    +
    +
    +
    + + +
    +
    + +
    + + + +
    + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    #CantidadUnidadProducto + Sección AlmacenSerieLoteFecha CaducidadComandos
    + + + + + + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    + <%-- --%> + + + + + Destino: + + + + + + + + + + + + + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    +
    + +
    +
    + +
    +
    + + +
    +
    + + <%----%> +
    +
    +
    +
    + +
    +
    + + + + +
    +
    + + + +
    + +
    + + +
    + + <%-- --%> + + + + + + + + + + + + + + + +
    + + + + + diff --git a/Inventarios/CartaPorteManual.aspx.vb b/Inventarios/CartaPorteManual.aspx.vb new file mode 100644 index 000000000..c8b85b178 --- /dev/null +++ b/Inventarios/CartaPorteManual.aspx.vb @@ -0,0 +1,1341 @@ +Option Explicit On +Option Strict On + +Imports System.Data +Imports System.IO +Imports Extensiones +Imports GemBox.Spreadsheet + +Partial Class Inventarios_CartaPorteManual + Inherits ClsPaginas + +#Region "PROPIEDADES" + Public Property DtMovimientos() As DataTable + Get + Return CType(ViewState("DtMovimientos"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtMovimientos") = value + End Set + End Property + + 'Private Property DtTraslado As DataTable + ' Get + ' Return CType(ViewState("DtTraslado"), DataTable) + ' End Get + ' Set(value As DataTable) + ' ViewState("DtTraslado") = value + ' End Set + 'End Property + + + 'Private Property CveAlmacenTransitorio As Integer + ' Get + ' Return CType(ViewState("CveAlmacenTransitorio"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CveAlmacenTransitorio") = value + ' End Set + 'End Property + 'Private Property CveAlmacenDestino As Integer + ' Get + ' Return CType(ViewState("CveAlmacenDestino"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CveAlmacenDestino") = value + ' End Set + 'End Property + 'Private Property CveUsuarioResponsable As Integer + ' Get + ' Return CType(ViewState("CveUsuarioResponsable"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CveUsuarioResponsable") = value + ' End Set + 'End Property + 'Private Property CvePSSerie As Integer + ' Get + ' Return CType(ViewState("CvePSSerie"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CvePSSerie") = value + ' End Set + 'End Property + 'Private Property CveUMSerie As Integer + ' Get + ' Return CType(ViewState("CveUMSerie"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CveUMSerie") = value + ' End Set + 'End Property + 'Private Property CargadoDeMov As Boolean + ' Get + ' Return CType(ViewState("CargadoDeMov"), Boolean) + ' End Get + ' Set(value As Boolean) + ' ViewState("CargadoDeMov") = value + ' End Set + 'End Property + 'Private Property CveMovimientoSalida As Integer + ' Get + ' Return CType(ViewState("CveMovimientoSalida"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CveMovimientoSalida") = value + ' End Set + 'End Property + 'Private Property CveMov As Integer + ' Get + ' Return CType(ViewState("CveMov"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CveMov") = value + ' End Set + 'End Property + Private Property ObjFactura As Modelos.Factura + Get + Return CType(ViewState("ObjFactura"), Modelos.Factura) + End Get + Set(value As Modelos.Factura) + ViewState("ObjFactura") = value + End Set + End Property + Private Property Folio As Integer + Get + Return CType(ViewState("Folio"), Integer) + End Get + Set(value As Integer) + ViewState("Folio") = value + End Set + End Property + Private Property MensajeAlert As StringBuilder + Get + Return CType(ViewState("MensajeAlert"), StringBuilder) + End Get + Set(value As StringBuilder) + ViewState("MensajeAlert") = value + End Set + End Property + + 'Private Property CveMovimientoTimbrado As Integer + ' Get + ' Return CType(ViewState("CveMovimientoTimbrado"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CveMovimientoTimbrado") = value + ' End Set + 'End Property + + 'Private Property CantidadTotal As Decimal + ' Get + ' Return CType(ViewState("CantidadTotal"), Decimal) + ' End Get + ' Set(value As Decimal) + ' ViewState("CantidadTotal") = value + ' End Set + 'End Property + 'Private Property CvePS As Integer + ' Get + ' Return CType(ViewState("CvePS"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CvePS") = value + ' End Set + 'End Property + 'Private Property TipoSeccionAlmacen As Integer + ' Get + ' Return CType(ViewState("TipoSeccionAlmacen"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("TipoSeccionAlmacen") = value + ' End Set + 'End Property + + 'Private Property FolioBusqueda As Integer + ' Get + ' Return CType(ViewState("FolioBusqueda"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("FolioBusqueda") = value + ' End Set + 'End Property + + + Private Property FechaSalida As Date + Get + If ViewState("FechaEntrega") Is Nothing Then + ViewState("FechaEntrega") = Now + End If + Return ViewState("FechaEntrega").ToString.ToDate + End Get + Set(value As Date) + ViewState("FechaEntrega") = value + End Set + End Property + + Private Property FechaLlegada As Date + Get + If ViewState("FechaLlegada") Is Nothing Then + ViewState("FechaLlegada") = Now + End If + Return ViewState("FechaLlegada").ToString.ToDate + End Get + Set(value As Date) + ViewState("FechaLlegada") = value + End Set + End Property + + +#End Region + + Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load + If Not Page.IsPostBack Then + + TxtFecha.Text = Now.ToShortDateString + CEFecha.EndDate = Now.AddDays(-1) + RVFecha.MaximumValue = Now.ToShortDateString + + Folio = 0 + + CargaCombos() + CreaDT() + + 'If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then + ' DivCodigoSeriePS.Visible = True + 'Else + ' DivCodigoSeriePS.Visible = False + 'End If + + 'If UsuarioActual.CveEmpresa.Contiene(141, 152, 158, 159, 160, 161, 162, 163) Then + ' ChkEmitirTimbrado.Visible = False + ' divEmitir.Visible = False + 'End If + + If UsuarioActual.CveEmpresa.Contiene(1, 119, 140, 2) Then + + If UsuarioActual.Empresa.Funcionalidad(161) = "1" Then + ChkEmitirTimbrado.Checked = True + End If + + ChkEmitirCartaPorte.Visible = True + + End If + + + 'If UsuarioActual.Empresa.Funcionalidad(281).ToEntero = 1 Then + + ' TxtFecha.Enabled = False + ' ImgFecha.Visible = False + 'End If + + End If + End Sub + +#Region "CARGA DATOS" + + Protected Sub CreaDT() + Dim dt As New DataTable + + Dim column As DataColumn = New DataColumn("No") + column.DataType = Type.GetType("System.Int32") + With column + .AutoIncrement = True + .AutoIncrementSeed = 1 + .AutoIncrementStep = 1 + End With + + dt.Columns.Add(column) + + + + dt.Columns.Add("Cantidad", Type.GetType("System.Double")) + dt.Columns.Add("CveUM", Type.GetType("System.Int32")) + dt.Columns.Add("UnidadMedida") + dt.Columns.Add("UM") + dt.Columns.Add("CvePS", Type.GetType("System.Int32")) + dt.Columns.Add("CveAF", Type.GetType("System.Int32")) + dt.Columns.Add("PS") + dt.Columns.Add("Observaciones") + dt.Columns.Add("CveSeccionAlmacen", Type.GetType("System.Int32")) + dt.Columns.Add("SeccionAlmacen") + dt.Columns.Add("CveSeccionAlmacenDestino", Type.GetType("System.Int32")) + dt.Columns.Add("SeccionAlmacenDestino") + dt.Columns.Add("Serie") + dt.Columns.Add("Lote") + dt.Columns.Add("FechaCaducidad", Type.GetType("System.DateTime")) + + + + dt.Columns.Add("CveClasificacion", Type.GetType("System.Int32")) + dt.Columns.Add("EstatusExistencia") + + dt.Columns.Add("TotalImporte", Type.GetType("System.Double")) + dt.Columns.Add("PU", Type.GetType("System.Double")) + dt.Columns.Add("Descuento", Type.GetType("System.Double")) + dt.Columns.Add("SATClaveUM") + dt.Columns.Add("SATClaveProdServ") + dt.Columns.Add("Noidentificacion") + dt.Columns.Add("CuentaPredial") + dt.Columns.Add("Obs") + dt.Columns.Add("ImporteIVA", Type.GetType("System.Double")) + dt.Columns.Add("PorcentajeIVA", Type.GetType("System.Double")) + dt.Columns.Add("ClaveMaterialPeligroso") + dt.Columns.Add("ClaveEmbalaje") + dt.Columns.Add("Embalaje") + dt.Columns.Add("PesoKg", Type.GetType("System.Decimal")) + + + DtMovimientos = dt + + CargaGvDatos() + + End Sub + + + Private Sub CargaCombos() + CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto, AplicaTodos:="") + + DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione Uno", "-1")) + + DdlChofer.DataSource = GlobalDTChoferes(UsuarioActual.CveEmpresa) + DdlChofer.DataBind() + + DdlChofer.Items.Insert(0, New ListItem("Seleccione Uno", "-1")) + ' TxtFechaEntrega.Text = Now.ToShortDateString + TxtFechaLlegada.Text = Now.ToShortDateString + + + + CargaPS() + + + CargarCamiones() + End Sub + + Private Sub CargaPS() + + + Dim EsWS = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) + DdlProducto2.setEsWebService(EsWS) + + If DdlProducto2.UsaWebService Then + + If UsuarioActual.Empresa.Funcionalidad(141) = "1" Then + DdlProducto2.ddlWS.Attributes.Add("data-pagina", "inv/traspaso") + DdlProducto2.ddlWS.Attributes.Add("Data-onresult", "CargaExistenciaAlmacenes") + + End If + + End If + + End Sub + + +#End Region + +#Region " AGREGAR " + Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click + BtnAgregarPS(txtCantidad.Text.ToDecimal) + End Sub + Protected Sub BtnSerieAddNew_Click(sender As Object, e As EventArgs) + BtnAgregarPS(1) + End Sub + Private Sub BtnAgregarPS(Cantidad As Decimal) + Dim CveProducto As Integer = DdlProducto2.SelectedValue.ToEntero + Dim FuncionalidadSinSerie = True + + If CveProducto > 0 Then + + If TxtnSerie.Visible Then + Cantidad = 1 + If TxtnSerie.Text = "" Then + Alert("Serie es necesario", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") + Exit Sub + End If + If txtCantidad.Text.ToDouble > 1 Then + FuncionalidadSinSerie = False + End If + End If + Dim DrPS As DataRow = Nothing + + DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CveProducto).FiltroPrimero("") ' Estado = -1 + + If DrPS IsNot Nothing Then + + 'codigo temporal + Dim tLote As String + Dim tCaducidad As Date + + tLote = If(TxtnLote.Visible, TxtnLote.Text, "-1") + tCaducidad = If(TxtnFechaCaducidad.Visible, TxtnFechaCaducidad.Text.ToDate, MinFecha) + + + AgregarPS(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, "", CveSeccionAlmacen:=DdlSeccionAlmacen.SelectedValue.ToEntero, SeccionAlmacen:=DdlSeccionAlmacen.SelectedItem.Text, Serie:=If(TxtnSerie.Visible, TxtnSerie.Text, ""), Lote:=If(tLote = "-1", "", tLote), FechaCaducidad:=tCaducidad, CveSeccionAlmacenDestino:=DdlSeccionAlmacenDestino.SelectedValue.ToEntero, Limpia:=FuncionalidadSinSerie) + + + End If + + End If + End Sub + + + + Private Sub AgregarPS(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, Optional Observaciones As String = "", Optional CveSeccionAlmacen As Integer = -1, Optional SeccionAlmacen As String = "", Optional Serie As String = "", Optional Lote As String = "", Optional FechaCaducidad As Date = MinFecha, Optional Limpia As Boolean = True, Optional CveSeccionAlmacenDestino As Integer = -1) + If Cantidad <= 0 Then + Alert("La cantidad debe ser mayor a cero (0). Por favor verifique y vuelva a intentar", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") + End If + + Dim CveClasificacion As Integer + + Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") + If DrPS IsNot Nothing Then + CveClasificacion = DrPS("CveClasificacion").ToString.ToEntero + Dim DrUM = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).FiltroPrimero($"CveUnidadMedida = {CveUnidadMedida}") + + Dim registro As DataRow = DtMovimientos.NewRow + registro.Item("Cantidad") = Cantidad + registro.Item("CveUM") = CveUnidadMedida + registro.Item("UM") = DrUM("UnidadMedida") + registro.Item("UnidadMedida") = DrUM("UnidadMedida") + registro.Item("CvePS") = CvePS + registro.Item("PS") = DrPS("PSCodigo") + registro.Item("Observaciones") = Observaciones + registro.Item("Serie") = Serie + registro.Item("Lote") = Lote + If FechaCaducidad > MinFecha Then registro.Item("FechaCaducidad") = FechaCaducidad + registro.Item("CveClasificacion") = CveClasificacion + registro.Item("CveAF") = -1 + registro.Item("EstatusExistencia") = "1" + registro.Item("CveSeccionAlmacen") = CveSeccionAlmacen + registro.Item("SeccionAlmacen") = SeccionAlmacen + registro.Item("CveSeccionAlmacenDestino") = CveSeccionAlmacenDestino + + registro.Item("TotalImporte") = 0 + registro.Item("PU") = 0 + registro.Item("Descuento") = 0 + registro.Item("SATClaveUM") = DrPS("SATClaveUnidadMedida") + registro.Item("SATClaveProdServ") = DrPS("SATClavePS") + registro.Item("Noidentificacion") = DrPS("Codigo") + registro.Item("CuentaPredial") = "" + registro.Item("Obs") = "" + + registro.Item("ImporteIVA") = 0 + registro.Item("PorcentajeIVA") = 0 + registro("ClaveMaterialPeligroso") = DrPS("ClaveMaterialPeligroso") + registro("ClaveEmbalaje") = DrPS("ClaveEmbalaje") + registro("PesoKg") = DrPS("PesoKg") + + DtMovimientos.Rows.Add(registro) + RegistraScript("playsonidito('beep-07.wav')") + + End If + + + CargaGvDatos() + + If Limpia Then + LimpiaAgregar() + Else + txtCantidad.Text = (txtCantidad.Text.ToDouble - 1.0).ToString + TxtnSerie.Text = "" + TxtnSerie.Focus() + End If + End Sub + + Private Sub LimpiaAgregar() + 'DdlClasificacion.SelectedValue = "-1" + 'DdlClasificacion_SelectedIndexChanged(DdlClasificacion, EventArgs.Empty) + txtCantidad.Text = "" + 'TxtnObservaciones.Text = "" + TxtnSerie.Text = "" + TxtnSerie.Visible = False + TxtnLote.Text = "" + TxtnFechaCaducidad.Text = "" + + txtCantidad.Focus() + 'If TxtCodigoPS.Visible Then + ' TxtCodigoPS.Focus() + 'End If + End Sub + + +#End Region + +#Region " GUARDAR " + Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click + + + Dim CountPs As Integer = 0 + Dim CounDirecciones As Integer = 0 + + + + MensajeAlert = New StringBuilder + + For Each GvRowPS As GridViewRow In GvDatos.Rows + CountPs = CountPs + 1 + Next + + If CountPs = 0 Then + Alert("No hay productos agregados", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + For Each GvRow As GridViewRow In GvDireccionesEnvio.Rows + CounDirecciones = CounDirecciones + 1 + Next + + + If CounDirecciones <> 2 Then + Alert("Debe de agregar dos direcciones", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + + If DdlChofer.SelectedValue.ToEntero <= 0 Then + Alert("Debe de seleccionar un chofer", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If DdlUnidadCamion.SelectedValue.ToEntero <= 0 Then + Alert("Debe de seleccionar una unidad", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If DdlChofer.SelectedValue.ToEntero <= 0 Then + Alert("Debe seleccionar un Chofer", TipoMensaje.MsgAdvertencia) + RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") + + Exit Sub + End If + + + + Dim CveTimbre As Integer = -1 + Dim ErrorProceso As Boolean = False + + Dim CveDireccionOrigen As Integer = -1 + Dim CveDireccionDestino As Integer = -1 + + + Dim ObjGral As New ClsGenerales() + Dim ObjClientes As New ClsClientes(ObjGral.IniciaTransacSQL()) + + + + For Each GvRow As GridViewRow In GvDireccionesEnvio.Rows + Dim Tipo As Integer = GvRow.DataKey("Tipo").ToEntero + + Dim EnvioDireccion As String = GvRow.DataKey("EnvioDireccion") + Dim EnvioNoExt As String = GvRow.DataKey("EnvioNoExt") + Dim EnvioNoInt As String = GvRow.DataKey("EnvioNoInt") + Dim EnvioCP As Integer = GvRow.DataKey("EnvioCP").ToEntero + + Dim CvePais As Integer = GvRow.DataKey("CvePais").ToEntero + Dim CveEstado As Integer = GvRow.DataKey("CveEstado").ToEntero + Dim CveMunicipio As Integer = GvRow.DataKey("CveMunicipio").ToEntero + Dim CveLocalidad As Integer = GvRow.DataKey("CveLocalidad").ToEntero + Dim CveColonia As Integer = GvRow.DataKey("CveColonia").ToEntero + + + If Tipo = 1 Then + + CveDireccionOrigen = ObjClientes.DireccionEnvioAdd(-1, EnvioDireccion, EnvioNoExt, EnvioNoInt, "", "", "", EnvioCP, "", UsuarioActual.CveUsuario, 1, -1, "", + CvePais:=CvePais, CveEstado:=CveEstado, CveMunicipio:=CveMunicipio, CveLocalidad:=CveLocalidad, CveColonia:=CveColonia) + + Else + CveDireccionDestino = ObjClientes.DireccionEnvioAdd(-1, EnvioDireccion, EnvioNoExt, EnvioNoInt, "", "", "", EnvioCP, "", UsuarioActual.CveUsuario, 1, -1, "", + CvePais:=CvePais, CveEstado:=CveEstado, CveMunicipio:=CveMunicipio, CveLocalidad:=CveLocalidad, CveColonia:=CveColonia) + End If + + Next + + + If Not (CveDireccionOrigen > 0 And CveDireccionDestino > 0) Then + ErrorProceso = True + End If + + + Dim FechallegadaMM As DateTime = (FechaLlegada.ToString("dd/MM/yyyy") & " 23:59:59").ToDateTime + + Dim CveEntregaAlmacen As Integer = ObjGral.AddInvEntregaAlmacenRuta(DdlSubProyecto.SelectedValue.ToEntero, CveDireccionOrigen, CveDireccionDestino, -1, DdlChofer.SelectedValue.ToEntero, DdlUnidadCamion.SelectedValue.ToEntero, FechaSalida, FechallegadaMM, "T", "-1", "-1", FechaLlegada, 1, 1, TxtDistancia.Text.ToEntero) + + If CveEntregaAlmacen > 0 Then + + For Each GvRowPS As GridViewRow In GvDatos.Rows + If Not ObjGral.AddEntregaAlmacenRutaDetalle(CveEntregaAlmacen, GvRowPS.DataKey("CvePS").ToEntero, GvRowPS.DataKey("Cantidad").ToEntero, GvRowPS.DataKey("CveUM").ToEntero, UsuarioActual.CveUsuario) Then + ErrorProceso = True + Exit For + End If + Next + + CveTimbre = ObjGral.AddGralTimbre("Man", DdlSubProyecto.SelectedValue.ToEntero, TxtFecha.Text.ToDate, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEntregaAlmacen:=CveEntregaAlmacen, AplicaCP:=ChkEmitirCartaPorte.Checked) + + If Not CveTimbre > 0 Then + + ErrorProceso = True + End If + Else + ErrorProceso = True + End If + + 'End If + + + + + If Not ErrorProceso Then + ObjGral.Commit() + Else + ObjGral.RollBack() + End If + + + ObjGral.Dispose() + + + If ChkEmitirTimbrado.Checked And Not ErrorProceso Then + 'CveMovimientoTimbrado = CveMovimientoSalida + EmitirTimbrado(CveTimbre) + End If + + Alert(MensajeAlert.ToString, TipoMensaje.MsgInformacion, "") + + + End Sub + + + +#End Region + +#Region " NUEVO - LIMPIA " + +#End Region + +#Region "DDL CLASIFICACION" + + Protected Sub DdlProducto_ValueChanged(sender As Object, e As EventArgs) Handles DdlProducto2.selectedindexchange + ElProductoChange() + End Sub + Private Sub ElProductoChange() + TxtnSerie.Visible = False + TxtnLote.Visible = False + TxtnFechaCaducidad.Visible = False + + If DdlProducto2.SelectedValue.ToEntero > 0 Then + Dim drP As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProducto2.SelectedValue.ToEntero).FiltroPrimero("", "PS") + If drP IsNot Nothing Then + + ThSeccionAlmacen.Visible = CBool(drP("AplicaSeccion")) + TdSeccionAlmacen.Visible = CBool(drP("AplicaSeccion")) + DdlSeccionAlmacen.Visible = CBool(drP("AplicaSeccion")) + 'GvDatos.Columns(5).Visible = CBool(drP("AplicaSeccion")) + + + ThSerie.Visible = CBool(drP("AplicaSerie")) + TdSerie.Visible = CBool(drP("AplicaSerie")) + TxtnSerie.Visible = CBool(drP("AplicaSerie")) + 'GvDatos.Columns(6).Visible = CBool(drP("AplicaSerie")) + + + TxtnLote.Visible = CBool(drP("AplicaLote")) + ThLote.Visible = CBool(drP("AplicaLote")) + TdLote.Visible = CBool(drP("AplicaLote")) + 'GvDatos.Columns(7).Visible = CBool(drP("AplicaLote")) + + + TxtnFechaCaducidad.Visible = CBool(drP("AplicaCaducidad")) + ThFechaCaducidad.Visible = CBool(drP("AplicaCaducidad")) + If Not String.IsNullOrWhiteSpace(UsuarioActual.Empresa.Funcionalidad(147)) Then ThFechaCaducidad.InnerText = UsuarioActual.Empresa.Funcionalidad(147) + 'ThFechaCaducidad.InnerText = If(UsuarioActual.Empresa.Funcionalidad(147) = "Fecha Elaboración", "Fecha Elaboración", "Fecha Caducidad") + TdFechaCaducidad.Visible = CBool(drP("AplicaCaducidad")) + 'GvDatos.Columns(8).Visible = CBool(drP("AplicaCaducidad")) + + End If + + End If + + DdlUnidad.Items.Clear() + DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) + DdlUnidad.DataBind() + UpDatos.Update() + End Sub + Private Function isWhitFamily() As Boolean + Return (UsuarioActual.CveEmpresa = 66) + End Function + Protected Sub DdlClasificacion_GV(sender As Object, e As System.EventArgs) + Dim pDdlClasificacion As DropDownList = CType(sender, DropDownList) + Dim pDdlProducto As DropDownList = CType(pDdlClasificacion.NamingContainer.FindControl("DdlProducto"), DropDownList) + + If pDdlClasificacion.SelectedValue = "-1" Then + pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) + pDdlProducto.DataBind() + Else + pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=pDdlClasificacion.SelectedValue.ToEntero) + pDdlProducto.DataBind() + End If + + + pDdlProducto.DataBind() + pDdlProducto.Items.Insert(0, New ListItem("----", "-1")) + + End Sub +#End Region + +#Region "GV DATOS" + Private Sub CargaGvDatos() + EscondeColumnasGVM(DtMovimientos) + + GvDatos.DataSource = DtMovimientos + GvDatos.DataBind() + UpDatos.Update() + End Sub + + Private Sub EscondeColumnasGVM(DtTemp As DataTable) + + GvDatos.Columns(5).Visible = DtTemp.MAX("Serie").ToString <> "" + GvDatos.Columns(6).Visible = DtTemp.MAX("Lote").ToString <> "" + GvDatos.Columns(7).HeaderText = If(UsuarioActual.Empresa.Funcionalidad(147) = "Fecha Elaboración", "Fecha Elaboración", "Fecha Caducidad") + GvDatos.Columns(7).Visible = DtTemp.MAX("FechaCaducidad").ToString.ToDate > MinFecha + GvDatos.Columns(8).Visible = DtTemp.MAX("CveSeccionAlmacen").ToString.ToEntero > 0 + + + End Sub + + Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.DBCampo("EstatusExistencia").ToEntero < 0 Then + e.Row.Cells(0).BackColor = Drawing.Color.Red + End If + + End If + End Sub + Protected Sub GvPS_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting + Dim DbRow As DataRow = Nothing + DbRow = DtMovimientos.Rows(e.RowIndex) + + DtMovimientos.Rows.Remove(DbRow) + CargaGvDatos() + End Sub + + + + Protected Sub ChkSugiereFechaCaducidad_CheckedChanged(sender As Object, e As EventArgs) + + TxtnFechaCaducidad.Visible = Not ChkSugiereFechaCaducidad.Checked + TxtnLote.Visible = Not ChkSugiereFechaCaducidad.Checked + + End Sub + + +#End Region + +#Region " TRANSITORIO - RECEPCION " + + + Private Sub CargarUM(CvePS As Integer) + Dim ObjUM As New ClsProductosServicios() + If ObjUM.GetPSEquivalencias(CvePS, UsuarioActual.CveEmpresa) Then + DdlUnidad.Items.Clear() + DdlUnidad.DataSource = ObjUM.DtResultados + End If + ObjUM.Dispose() + DdlUnidad.DataBind() + End Sub + + + +#End Region + + + +#Region "TIMBRADO" + + + Private Sub EmitirTimbrado(CveTimbre As Integer) + + Dim ObjTimbres As New Timbres("Man", CveTimbre, UsuarioActual) + + If MensajeAlert Is Nothing Then + MensajeAlert = New StringBuilder + End If + + + MensajeAlert.Append("

    ") + + + If ObjTimbres.ObjFactura.Timbre Is Nothing Then + Alert(ObjTimbres.MsgError.ToString, TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If ObjTimbres.Timbrar() Then + + Try + PdfFactura(ObjTimbres.ObjFactura) + Catch ex As Exception + + End Try + + MensajeAlert.Append($"{ObjTimbres.ObjFactura.SerieFolio} Emitido con éxito.") + 'XML + Dim ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, ObjTimbres.ObjFactura.TipoDocto, ObjTimbres.ObjFactura.SerieFolio) + If File.Exists(ArchivoXML) Then + MensajeAlert.AppendFormat("", Encripta(String.Format("OP=DesXmlTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", -1, "XML", ObjTimbres.ObjFactura.SerieFolio, ObjTimbres.ObjFactura.TipoDocto))) + End If + 'PDF + 'Dim ArchivoPDF = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, ObjTimbres.ObjFactura.TipoDocto, ObjTimbres.ObjFactura.SerieFolio) + 'If File.Exists(ArchivoPDF) Then + ' MensajeAlert.AppendFormat("", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimientoTimbrado, "PDF", ObjTimbres.ObjFactura.SerieFolio, ObjTimbres.ObjFactura.TipoDocto))) + 'End If + + ' If ChkEmitirCartaPorte.Checked Then + MensajeAlert.AppendFormat("", Encripta(String.Format("OP=CARPOTIMBRE&CVETIMBRE={0}", CveTimbre))) + 'Else + ' MensajeAlert.AppendFormat("", Encripta(String.Format("OP=CARPO&CVEMOV={0}", CveMovimientoTimbrado))) + ' End If + + LimpiarDatos() + + Else + MensajeAlert.AppendFormat("
    • {0}
    ", ObjTimbres.MsgError.ToString) + End If + + + + + + + + End Sub + + Public Sub LimpiarDatos() + + + DT_Direcciones.Clear() + DtMovimientos.Clear() + + GvDatos.DataSource = Nothing + GvDireccionesEnvio.DataSource = Nothing + + GvDatos.DataBind() + GvDireccionesEnvio.DataBind() + + txtCantidad.Text = "" + DdlSubProyecto.SelectedValueExist(-1) + DdlChofer.SelectedValueExist(-1) + DdlUnidadCamion.SelectedValueExist(-1) + + LnkAgregarDireccion.Visible = True + + UpDatos.Update() + UpGvDireccionesEnvio.Update() + + + + + + + + End Sub + + + 'Private Sub Timbrar() + + ' CreaObjetosVenta() + ' Dim ObjTimbrado As New Timbrado + ' Dim FM As New Modelos.FemsaFactura + ' Dim TmpDT7Eleven As New DataTable + ' Dim TmpDTComplementosTimbrado As New DataTable + ' PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado) + ' MensajeAlert.Append("

    ") + + + ' If ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura) Then + ' MensajeAlert.Append("Emitido con exito.") + ' 'XML + ' Dim ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio) + ' If File.Exists(ArchivoXML) Then + ' MensajeAlert.AppendFormat("", Encripta(String.Format("OP=DesXmlTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimientoTimbrado, "XML", ObjFactura.SerieFolio, ObjFactura.TipoDocto))) + ' End If + ' 'PDF + ' 'GeneraPDFFactura() + ' Dim ArchivoPDF = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio) + ' If File.Exists(ArchivoPDF) Then + ' MensajeAlert.AppendFormat("", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimientoTimbrado, "PDF", ObjFactura.SerieFolio, ObjFactura.TipoDocto))) + ' End If + + ' If UsuarioActual.Empresa.Funcionalidad(161) = "1" Then + ' MensajeAlert.AppendFormat("", Encripta(String.Format("OP=CARPOTIMBRE&CVEMOV={0}", CveMovimientoTimbrado))) + ' Else + ' MensajeAlert.AppendFormat("", Encripta(String.Format("OP=CARPO&CVEMOV={0}", CveMovimientoTimbrado))) + ' End If + + ' Else + ' MensajeAlert.AppendFormat("
    • {0}
    ", ObjTimbrado.MensajeErrorCFDI) + ' End If + + 'End Sub + + Private Sub GeneraPDFFactura() + Try + PdfFactura(ObjFactura) + Catch ex As Exception + Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgError) + End Try + End Sub + +#End Region + + Protected Sub DldChofer_SelectedIndexChanged(sender As Object, e As EventArgs) + ' Dim ObjAcar As New ClsAcarreos() + + ' If ObjAcar.GetChofer(DdlChofer.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, 1, -1) Then + ' Dim dr As DataRow = ObjAcar.DtResultados.Rows(0) + ' If dr IsNot Nothing Then + ' TxtResponsableRecibio.Text = dr("Chofer").ToString + ' TxtIdentificacion.Text = dr("Identificacion").ToString + ' TxtDomicilio.Text = dr("Domicilio").ToString + ' TxtTelefono.Text = dr("Telefono").ToString + ' TxtCiudad.Text = dr("Ciudad").ToString + ' TxtLicencia.Text = dr("Licencia").ToString + ' End If + ' End If + ' ObjAcar.Dispose() + End Sub + + Protected Sub BtnDescargarFormatoExcelConceptos_Click(sender As Object, e As EventArgs) + Dim DtExcel As New DataTable + DtExcel.Columns.Add(New DataColumn("Cantidad", GetType(Decimal))) + DtExcel.Columns.Add(New DataColumn("Codigo", GetType(String))) + DtExcel.Columns.Add(New DataColumn("Producto", GetType(String))) + DtExcel.Columns.Add(New DataColumn("Serie", GetType(String))) + DtExcel.Columns.Add(New DataColumn("Lote", GetType(String))) + DtExcel.Columns.Add(New DataColumn("FechaCaducidad", GetType(Date))) + DtExcel.Columns.Add(New DataColumn("Observaciones", GetType(String))) + + DtExcel.TableName = "Traspaso" + + SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) + + Dim FileExcel As New ExcelFile() + + Dim worksheet = FileExcel.Worksheets.Add(DtExcel.TableName) + worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With + { + .ColumnHeaders = True, + .StartRow = 0, + .StartColumn = 0 + }) + worksheet.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(75, 119, 190), SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(0).Style.Font.Color = SpreadsheetColor.FromArgb(255, 255, 255) + + Dim columnCount = worksheet.CalculateMaxUsedColumns() + For i = 0 To columnCount + worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1)) + Next + + FileExcel.Save(Response, "Traspaso.xlsx", SaveOptions.XlsxDefault) + + End Sub + + + + Public Sub CargarCamiones() + DdlUnidadCamion.Items.Clear() + + DdlUnidadCamion.DataSource = GlobalDTInvCamiones(UsuarioActual.CveEmpresa) + DdlUnidadCamion.DataBind() + + + DdlUnidadCamion.Items.Insert(0, New ListItem("Seleccione Uno", "-1")) + + + End Sub + + + + + Protected Sub ChkEmitirTimbrado_CheckedChanged(sender As Object, e As EventArgs) + + If ChkEmitirTimbrado.Checked Then + ChkEmitirCartaPorte.Checked = False + ChkEmitirCartaPorte.Visible = True + Else + ChkEmitirCartaPorte.Visible = False + ChkEmitirCartaPorte.Checked = False + End If + + + + End Sub + + + + Private Sub ResetModalDirecciones() + + End Sub + + +#Region "D I R E C C I O N E N V I O " + + Private Sub CargaCombosDirecionesClientesSAT() + CargaDirClientePais() + CargaDirClienteEstado() + CargaDirClienteMunicipio() + CargaDirClienteLocalidad() + CargaDirClienteColonia() + End Sub + + + + Private Sub CargaDirClientePais() + + DdlDirClientePais.DataSource = GlobalDTGralPaises() + DdlDirClientePais.DataBind() + DdlDirClientePais.SelectedValueExist("151") + End Sub + + Private Sub CargaDirClienteEstado() + DdlDirClienteEstado.Items.Clear() + If DdlDirClientePais.SelectedValue.ToEntero > 0 Then + DdlDirClienteEstado.DataSource = GlobalDTGralEstados("-1", DdlDirClientePais.SelectedValue.ToEntero) + End If + DdlDirClienteEstado.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlDirClienteEstado.DataBind() + End Sub + + Private Sub CargaDirClienteMunicipio() + DdlDirClienteMunicipio.Items.Clear() + If DdlDirClienteEstado.SelectedValue.ToEntero > 0 Then + DdlDirClienteMunicipio.DataSource = GlobalDTGralMunicipios("-1", DdlDirClienteEstado.SelectedValue.ToEntero) + End If + DdlDirClienteMunicipio.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlDirClienteMunicipio.DataBind() + End Sub + + Private Sub CargaDirClienteColonia() + DdlDirClienteColonia.Items.Clear() + If DdlDirClienteMunicipio.SelectedValue.ToEntero > 0 Then + DdlDirClienteColonia.DataSource = GlobalDTGralColonias("-1", "-1", "-1", DdlDirClienteMunicipio.SelectedValue.ToEntero, CodigoPostal:=If(TxtEnvioCP.Text.Trim.Length > 0, TxtEnvioCP.Text.ToEntero, -1)) + End If + DdlDirClienteColonia.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlDirClienteColonia.DataBind() + End Sub + + + Protected Sub CargaDirClienteLocalidad() + + DdlDirClienteLocalidad.Items.Clear() + If DdlDirClienteEstado.SelectedValue.ToEntero > 0 Then + DdlDirClienteLocalidad.DataSource = GlobalDTLocalidad(DdlDirClienteEstado.SelectedValue.ToEntero, DdlDirClienteMunicipio.SelectedValue.ToEntero) + DdlDirClienteLocalidad.DataBind() + End If + + DdlDirClienteLocalidad.Items.Insert(0, New ListItem("Seleccione una", "-1")) + + End Sub + + + Protected Sub DdlDirClientePais_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaDirClienteEstado() + CargaDirClienteMunicipio() + CargaDirClienteColonia() + CargaDirClienteLocalidad() + End Sub + Protected Sub DdlDirClienteEstado_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaDirClienteMunicipio() + CargaDirClienteColonia() + CargaDirClienteLocalidad() + End Sub + + Protected Sub DdlDirClienteMunicipio_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaDirClienteColonia() + CargaDirClienteLocalidad() + End Sub + + + Protected Sub BtnDirClienteValidar_Click(sender As Object, e As EventArgs) + DirClientevalidaCodigoPostal() + End Sub + + + Protected Sub DdlDirClienteColonia_SelectedIndexChanged(sender As Object, e As EventArgs) + DirClientevalidaCodigoPostal() + End Sub + + Private Sub DirClientevalidaCodigoPostal() + + Dim CPTxt As Integer = TxtEnvioCP.Text.ToEntero() + + Dim CveColonia As Integer = DdlDirClienteColonia.SelectedValue.ToEntero + + If CPTxt > 0 And CveColonia > 0 Then + Dim CP As Integer = GlobalDTGralColonias("-1", "-1", "-1", CveColonia:=CveColonia).FiltroPrimeroValor("CP", "").ToEntero + If CPTxt <> CP Then + Alert("El código postal selecionado es diferente del codigo postal de la Colonia.", TipoMensaje.MsgAdvertencia) + End If + End If + + End Sub + + + Public Sub Edit_Click(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + + + 'CveDireccionEnvio = GvRow.DataKey("CveDireccionEnvio").ToEntero() + TxtEnvioDireccion.Text = GvRow.DataKey("EnvioDireccion") + TxtEnvioNoExt.Text = GvRow.DataKey("EnvioNoExt") + TxtEnvioNoInt.Text = GvRow.DataKey("EnvioNoInt") + 'TxtEnvioColonia.Text = GvRow.DataKey("EnvioColonia") + 'TxtEnvioCiudad.Text = GvRow.DataKey("EnvioCiudad") + 'TxtEnvioEstado.Text = GvRow.DataKey("EnvioEstado") + 'TxtEnvioContacto.Text = GvRow.DataKey("EnvioContacto") + 'TxtDepartamento.Text = GvRow.DataKey("EnvioDepartamento") + TxtEnvioCP.Text = GvRow.DataKey("EnvioCP") + ' TxtEnvioTel.Text = GvRow.DataKey("EnvioTel") + + DdlDirClientePais.SelectedValueExist(GvRow.DataKey("CvePais")) + CargaDirClienteEstado() + DdlDirClienteEstado.SelectedValueExist(GvRow.DataKey("CveEstado")) + CargaDirClienteMunicipio() + DdlDirClienteMunicipio.SelectedValueExist(GvRow.DataKey("CveMunicipio")) + CargaDirClienteColonia() + DdlDirClienteLocalidad.SelectedValueExist(GvRow.DataKey("CveLocalidad")) + CargaDirClienteLocalidad() + + DdlDirClienteColonia.SelectedValueExist(GvRow.DataKey("CveColonia")) + + 'ChkEstatus.Checked = If(GvRow.DataKey("Estatus").ToString() = "True", True, False) + 'If GvRow.DataKey("CveClienteSucursal").ToEntero() > 0 Then DdlClienteSucursalEnvio.SelectedValueExist(GvRow.DataKey("CveClienteSucursal")) Else DdlClienteSucursalEnvio.SelectedValueExist("-1") + + + CargaTiposDirecciones() + + + UpModalDVDireccionEnvio.Update() + RegistraScript("$('#divAddDireccionEnvio').modal('show');") + End Sub + + Private Sub CargaTiposDirecciones() + + DdlTipoDireccion.Items.Clear() + + + If DT_Direcciones.FiltraParametros(" Tipo = 1 ").Rows.Count = 0 Then + DdlTipoDireccion.Items.Add(New ListItem("Origen", "1")) + End If + + + If DT_Direcciones.FiltraParametros(" Tipo = 2 ").Rows.Count = 0 Then + DdlTipoDireccion.Items.Add(New ListItem("Destino", "2")) + End If + + DdlTipoDireccion.Items.Insert(0, New ListItem("Seleccione", "-1")) + End Sub + + + Private Sub BtnAgregarDireccion_Click(sender As Object, e As EventArgs) Handles BtnAgregarDireccion.Click + + + If DdlTipoDireccion.SelectedValue.ToEntero > 0 Then + + If DdlTipoDireccion.SelectedValue.ToEntero = 1 Then + FechaSalida = TxtFechaLlegada.Text.ToDate + Else + FechaLlegada = TxtFechaLlegada.Text.ToDate + End If + + Else + Alert("Debe seleccionar un tipo de dirección.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + + + DT_DireccionesAddRow(-1, TxtEnvioDireccion.Text, TxtEnvioCP.Text.ToEntero, UsuarioActual.CveUsuario, TxtEnvioNoExt.Text, TxtEnvioNoInt.Text, DdlDirClienteEstado.SelectedItem.Text, DdlDirClienteMunicipio.SelectedItem.Text, DdlDirClienteLocalidad.SelectedItem.Text, + DdlDirClienteColonia.SelectedItem.Text, DdlDirClientePais.SelectedValue.ToEntero, DdlDirClienteEstado.SelectedValue.ToEntero, DdlDirClienteMunicipio.SelectedValue.ToEntero, DdlDirClienteLocalidad.SelectedValue.ToEntero, DdlDirClienteColonia.SelectedValue.ToEntero, DdlTipoDireccion.SelectedValue.ToEntero, DdlTipoDireccion.SelectedItem.Text) + + + RegistraScript("$('#divAddDireccionEnvio').modal('hide');") + + + CargaDireccionesEnvio() + + End Sub + + Private Sub LnkAgregarDireccion_Click(sender As Object, e As EventArgs) Handles LnkAgregarDireccion.Click + + TxtEnvioDireccion.Text = "" + TxtEnvioNoExt.Text = "" + TxtEnvioNoInt.Text = "" + TxtEnvioCP.Text = "" + + CargaCombosDirecionesClientesSAT() + TxtFechaLlegada.Text = "" + + CargaTiposDirecciones() + + UpModalDVDireccionEnvio.Update() + RegistraScript("$('#divAddDireccionEnvio').modal('show');") + End Sub + Private Sub GvDireccionesEnvio_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvDireccionesEnvio.RowDeleting + Dim ObjClientes As New ClsClientes + Dim TieneError = False + + Dim CveDireccionEnvio As Integer = GvDireccionesEnvio.Rows(e.RowIndex).DataKey("CveDireccionEnvio").ToEntero() + + If Not ObjClientes.DireccionEnvioRemove(CveDireccionEnvio) Then + TieneError = True + End If + + If Not TieneError Then + 'GvDireccionesEnvio.EditIndex = -1 + DT_Direcciones_Remove(e.RowIndex) + Alert("Se eliminó correctamente la dirección de envío.", TipoMensaje.MsgInformacion) + Else + Alert("Ocurrió un error al eliminar la dirección de envío.", TipoMensaje.MsgAdvertencia) + End If + + CargaDireccionesEnvio() + End Sub + + + Public Sub CargaDireccionesEnvio() + + GvDireccionesEnvio.DataSource = DT_Direcciones + GvDireccionesEnvio.DataBind() + UpGvDireccionesEnvio.Update() + + + If DT_Direcciones.Rows.Count = 2 Then + LnkAgregarDireccion.Visible = False + Else + LnkAgregarDireccion.Visible = True + End If + + End Sub + + + + Property DT_Direcciones As DataTable + Get + + If ViewState("DT_Direcciones") Is Nothing Then + ViewState("DT_Direcciones") = Inicializa_DT_Direcciones() + End If + + Return DirectCast(ViewState("DT_Direcciones"), DataTable) + + End Get + Set(value As DataTable) + + End Set + End Property + + + Private Function Inicializa_DT_Direcciones() As DataTable + + Dim DT_Resultado As New DataTable + + DT_Resultado.Columns.Add("CveDireccionEnvio", GetType(Integer)) + DT_Resultado.Columns.Add("EnvioDireccion", GetType(String)) + + + DT_Resultado.Columns.Add("EnvioCP", GetType(Integer)) + DT_Resultado.Columns.Add("CveUsuario", GetType(Integer)) + DT_Resultado.Columns.Add("Estatus", GetType(Integer)) + DT_Resultado.Columns.Add("EnvioNoExt", GetType(String)) + DT_Resultado.Columns.Add("EnvioNoInt", GetType(String)) + + + DT_Resultado.Columns.Add("EnvioEstado", GetType(String)) + DT_Resultado.Columns.Add("EnvioMunicipio", GetType(String)) + DT_Resultado.Columns.Add("EnvioLocalidad", GetType(String)) + DT_Resultado.Columns.Add("EnvioColonia", GetType(String)) + + + DT_Resultado.Columns.Add("CvePais", GetType(Integer)) + DT_Resultado.Columns.Add("CveEstado", GetType(Integer)) + DT_Resultado.Columns.Add("CveMunicipio", GetType(Integer)) + DT_Resultado.Columns.Add("CveLocalidad", GetType(Integer)) + DT_Resultado.Columns.Add("CveColonia", GetType(Integer)) + DT_Resultado.Columns.Add("Tipo", GetType(Integer)) + DT_Resultado.Columns.Add("EnvioTipo", GetType(String)) + + + + Return DT_Resultado + + End Function + + + + Private Function DT_DireccionesAddRow(CveDireccionEnvio As Integer, EnvioDireccion As String, EnvioCP As Integer, CveUsuario As Integer, EnvioNoExt As String, EnvioNoInt As String, EnvioEstado As String, EnvioMunicipio As String, + EnvioLocalidad As String, EnvioColonia As String, CvePais As Integer, CveEstado As Integer, CveMunicipio As Integer, CveLocalidad As Integer, CveColonia As Integer, Tipo As Integer, EnvioTipo As String) As Boolean + + + + Dim Nrow As DataRow = DT_Direcciones.NewRow + + Nrow("CveDireccionEnvio") = CveDireccionEnvio + Nrow("EnvioDireccion") = EnvioDireccion + Nrow("EnvioCP") = EnvioCP + Nrow("CveUsuario") = CveUsuario + Nrow("EnvioNoExt") = EnvioNoExt + Nrow("EnvioNoInt") = EnvioNoInt + Nrow("EnvioEstado") = EnvioEstado + Nrow("EnvioMunicipio") = EnvioMunicipio + Nrow("EnvioLocalidad") = EnvioLocalidad + Nrow("EnvioColonia") = EnvioColonia + Nrow("CvePais") = CvePais + Nrow("CveEstado") = CveEstado + Nrow("CveMunicipio") = CveMunicipio + Nrow("CveLocalidad") = CveLocalidad + Nrow("CveColonia") = CveColonia + Nrow("Tipo") = Tipo + Nrow("EnvioTipo") = EnvioTipo + + DT_Direcciones.Rows.Add(Nrow) + + DT_Direcciones.AcceptChanges() + + Return True + + End Function + + + Private Sub DT_Direcciones_Remove(Index_Remove As Integer) + + DT_Direcciones.Rows(Index_Remove).Delete() + DT_Direcciones.AcceptChanges() + + End Sub + + +#End Region + + Protected Sub DdlTipoDireccion_SelectedIndexChanged(sender As Object, e As EventArgs) + + + If DdlTipoDireccion.SelectedValue.ToEntero = 2 Then + DvDistancia.Visible = True + Else + DvDistancia.Visible = False + End If + + UpBodyDireccion.Update() + UpModalDVDireccionEnvio.Update() + + End Sub +End Class + + + + diff --git a/Inventarios/EntradasSalidas.aspx.vb b/Inventarios/EntradasSalidas.aspx.vb index 3dff39843..d6556f4de 100644 --- a/Inventarios/EntradasSalidas.aspx.vb +++ b/Inventarios/EntradasSalidas.aspx.vb @@ -666,6 +666,7 @@ Partial Class Inventarios_EntradasSalidas TxtHoraInicio.SelectedTime = Mov.Fecha EstatusAlmacenCompra = Mov.EstatusAlmacenCompra Folio = Mov.Folio + Dim drM As DataRow = DtMov.Rows(0) If DtMov.Rows(0)("CveConcepto").ToString.ToEntero = 2 Then @@ -773,13 +774,13 @@ Partial Class Inventarios_EntradasSalidas CveCompra = Mov.CveCompra CveConcepto = Mov.CveConcepto - If DtMov.Rows(0)("CveEstatusTimbrado").ToString.ToEntero > 0 Then + If drM("CveEstatusTimbrado").ToString.ToEntero > 0 Then HplDescargaXml.Visible = True - HplDescargaXml.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=DesXmlTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimiento, "XML", $"Tra-{Folio}", "Tra"))) + HplDescargaXml.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=DesXmlTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimiento, "XML", drM("TimbreSerieFolio"), "Tra"))) HplDescargaPdf.Visible = True - HplDescargaPdf.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimiento, "PDF", $"Tra-{Folio}", "Tra"))) + HplDescargaPdf.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimiento, "PDF", drM("TimbreSerieFolio"), "Tra"))) - If UsuarioActual.Empresa.Funcionalidad(161) = "1" Then + If drM("AplicaCP").ToString = "True" Then HplCartaPorteTimbre.Visible = True HplCartaPorteTimbre.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CARPOTIMBRE&CVEMOV={0}", CveMovimiento))) Else diff --git a/Inventarios/EntregaAlmacen.aspx.vb b/Inventarios/EntregaAlmacen.aspx.vb index 605de65fd..a71cb65b7 100644 --- a/Inventarios/EntregaAlmacen.aspx.vb +++ b/Inventarios/EntregaAlmacen.aspx.vb @@ -2536,7 +2536,7 @@ Partial Class Inventarios_EntregaAlmacen ErrorMovInv = True Else If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then - ImporteAlmacen = ObjInventario.DtResultados.SUMD("Total") + ImporteAlmacen = ObjInventario.DtResultados.SUMD("Total").RoundSQL For Each Dr As DataRow In ObjInventario.DtResultados.Rows If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString().ToDouble, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), Dr("PU").ToString().ToDecimal, CveAF:=Dr("CveAF").ToString().ToEntero(), CveSeccionAlmacen:=-3, Serie:=Dr("Serie").ToString(), Lote:=Dr("Lote").ToString(), FechaCaducidad:=Dr("FechaCaducidad").ToString().ToDate, CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero(), EsInterno:=EsInterno, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString().ToEntero()) Then @@ -2954,7 +2954,7 @@ Partial Class Inventarios_EntregaAlmacen Dim TotalCostoAcumulado As Decimal = 0 Dim cont As Integer = 1 - Dim ValorMultiplicador = 1 + Dim ValorMultiplicador As Decimal = 1 If TipoMovimiento = 1 Then ValorMultiplicador = 1 diff --git a/Inventarios/EntregaAlmacenRuta.aspx b/Inventarios/EntregaAlmacenRuta.aspx index e356f8e91..85f2ffb50 100644 --- a/Inventarios/EntregaAlmacenRuta.aspx +++ b/Inventarios/EntregaAlmacenRuta.aspx @@ -170,7 +170,7 @@ - - Recoleccion + +
    + +
    + + + + + + +
    + +
    + + + + + +
    + +
    +
    + + + + + + + + + + +
    +
    +
    + + + +
    +
    +
    + Recoleccion + + +
    @@ -314,7 +357,12 @@ <%----%> -   +   + + + + +   @@ -441,6 +489,44 @@
    +
    +
    + + +
    +
    + + + + +
    + + + + + + + +
    +
    +
    + + +
    +
    +
    + + + +
    +
    +
    +
    + + + +
    +
    diff --git a/Inventarios/EntregaAlmacenRuta.aspx.cs b/Inventarios/EntregaAlmacenRuta.aspx.cs index f1f8567ac..8cb0d13db 100644 --- a/Inventarios/EntregaAlmacenRuta.aspx.cs +++ b/Inventarios/EntregaAlmacenRuta.aspx.cs @@ -155,7 +155,7 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas break; } DateTime fechallegada = (TxtFechaEntrega.Text + " 23:59").ToDate(); - int CveEntregaAlmacen = ObjGeneral.AddInvEntregaAlmacenRuta(row.DataKey("CveSubProyectoOrigen").ToEntero(), CveDireccionOrigen, CveDireccionDestino, row.DataKey("CveMovimiento").ToEntero(), DdlChofer.SelectedValue.ToEntero(), DdlUnidadCamion.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), fechallegada, "E",Orden,0,1); + int CveEntregaAlmacen = ObjGeneral.AddInvEntregaAlmacenRuta(row.DataKey("CveSubProyectoOrigen").ToEntero(), CveDireccionOrigen, CveDireccionDestino, row.DataKey("CveMovimiento").ToEntero(), DdlChofer.SelectedValue.ToEntero(), DdlUnidadCamion.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), fechallegada, "E", "","", "1900-01-01".ToDate(), Orden,0, 1); CveDireccionOrigen = row.DataKey("CveDireccionEnvio").ToEntero(); if (CveEntregaAlmacen > 0) @@ -249,13 +249,13 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas { - if (DdlChofer.SelectedValue.ToEntero() <= 0) + if (DdlChoferRec.SelectedValue.ToEntero() <= 0) { Alert("Debe seleccionar un chofer.", ModExtensiones.TipoMensaje.MsgAdvertencia); return; } - if (DdlUnidadCamion.SelectedValue.ToEntero() <= 0) + if (DdlUnidadRec.SelectedValue.ToEntero() <= 0) { Alert("Debe seleccionar una unidad", ModExtensiones.TipoMensaje.MsgAdvertencia); return; @@ -284,22 +284,32 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas if (CveEntregaAlmacen > 0) { - int CveTimbre = ObjGeneral.AddGralTimbre("Rec", row.DataKey("CveSubProyecto").ToEntero(), TxtFechaEntrega.Text.ToDate(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEntregaAlmacen:CveEntregaAlmacen , AplicaCP: ChkEmitirCartaPorte.Checked); - - if (CveTimbre <= 0) + // se actualizan los datos de unidad, chofer, fechas y Carta porte + if (ObjGeneral.AsignaEntregaAlmacenRuta(DdlUnidadRec.SelectedValue.ToEntero(), DdlChoferRec.SelectedValue.ToEntero(), TxtFechaRec.Text.ToDate(), CveEntregaAlmacen, UsuarioActual.CveEmpresa)) { - SBError.AppendLine($"Factura {row.DataKey("SerieFolio")} error al agregar timbre. "); - TieneError = true; - break; + int CveTimbre = ObjGeneral.AddGralTimbre("Rec", row.DataKey("CveSubProyecto").ToEntero(), TxtFechaEntrega.Text.ToDate(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEntregaAlmacen: CveEntregaAlmacen, AplicaCP: ChkEmitirPorteRec.Checked); + + if (CveTimbre <= 0) + { + SBError.AppendLine($"Factura {row.DataKey("SerieFolio")} error al agregar timbre. "); + TieneError = true; + break; + } + else + { + ListaTimbres.Add(CveTimbre); + } } else { - ListaTimbres.Add(CveTimbre); + SBError.AppendLine($"Factura {row.DataKey("SerieFolio")} error al aplicar condiciones de entrega. "); + TieneError = true; + break; } } else { - SBError.AppendLine($"Factura {row.DataKey("SerieFolio")} error al agregar entrega alamcen. "); + SBError.AppendLine($"Factura {row.DataKey("SerieFolio")} error al agregar entrega almacen. "); TieneError = true; break; } @@ -405,10 +415,12 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas private void CargaCombos() { - DdlUnidadCamion.DataSource = get_GlobalDTInvCamiones(UsuarioActual.CveEmpresa); - + DdlUnidadCamion.DataSource = get_GlobalDTInvCamiones(UsuarioActual.CveEmpresa); DdlUnidadCamion.Items.Insert(0, new ListItem("Seleccione", "-1")); DdlUnidadCamion.DataBind(); + DdlUnidadRec.DataSource = get_GlobalDTInvCamiones(UsuarioActual.CveEmpresa); + DdlUnidadRec.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlUnidadRec.DataBind(); TxtFechaI.Text = DateTime.Now.AddDays(-1).ToShortDateString(); TxtFechaF.Text = DateTime.Now.ToShortDateString(); @@ -416,6 +428,9 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas DdlChofer.DataSource = get_GlobalDTChoferes(UsuarioActual.CveEmpresa); DdlChofer.DataBind(); DdlChofer.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlChoferRec.DataSource = get_GlobalDTChoferes(UsuarioActual.CveEmpresa); + DdlChoferRec.DataBind(); + DdlChoferRec.Items.Insert(0, new ListItem("Seleccione", "-1")); TxtFechaEntrega.Text = DateTime.Now.ToShortDateString(); @@ -799,7 +814,7 @@ public partial class Inventarios_EntregaAlmacenRuta : ClsPaginas if( CveEntregaAlmacen == -1) { DateTime fechallegada = (TxtFechaEntrega.Text + " 23:59").ToDate(); - CveEntregaAlmacen = ObjGenerales.AddInvEntregaAlmacenRuta(DdlSubProyectoRecoleccion.SelectedValue.ToEntero(), DdlmodalRecoleccionDireccion.SelectedValue.ToEntero(), -1,-1, DdlChofer.SelectedValue.ToEntero(), DdlUnidadCamion.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), fechallegada , "R", 1,0,1); + CveEntregaAlmacen = ObjGenerales.AddInvEntregaAlmacenRuta(DdlSubProyectoRecoleccion.SelectedValue.ToEntero(), DdlmodalRecoleccionDireccion.SelectedValue.ToEntero(), -1,-1, DdlChofer.SelectedValue.ToEntero(), DdlUnidadCamion.SelectedValue.ToEntero(), TxtFechaEntrega.Text.ToDate(), fechallegada, "R",TxtFolioReferencia.Text, TxtReferencia.Text, TxtFechaLimite.Text.ToDate(), 1,0,1) ; if (CveEntregaAlmacen > 0) { //CveTimbrenuevo = ObjGenerales.AddGralTimbre("Rec", "-1", -1, "-1", TxtFechaEntrega.Text.ToDate(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, -1, ChkEmitirCartaPorte.Checked, CveEntregaAlmacen, -1); diff --git a/Inventarios/RepEntregaAlmacenRuta.aspx.cs b/Inventarios/RepEntregaAlmacenRuta.aspx.cs index 9815daaf8..d36145e06 100644 --- a/Inventarios/RepEntregaAlmacenRuta.aspx.cs +++ b/Inventarios/RepEntregaAlmacenRuta.aspx.cs @@ -339,7 +339,7 @@ public partial class General_RepEntregaAlmacenRuta : ClsPaginas Timbres ObjTimbres = new Timbres("Tra", cvetimbre, UsuarioActual); StringBuilder MensajeAlert = new StringBuilder(); MensajeAlert.AppendFormat("Folio: {0}  ", ObjTimbres.ObjFactura.SerieFolio); - if (ObjTimbres.Timbrar()) + if (ObjTimbres.MsgError =="" && ObjTimbres.Timbrar()) { MensajeAlert.AppendFormat("XML    ", ModExtensiones.Encripta(String.Format("OP=DesXmlTra&CveTimbre={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", cvetimbre, "XML", ObjTimbres.ObjFactura.SerieFolio, ObjTimbres.ObjFactura.TipoDocto))); Alert(MensajeAlert.ToString(), ModExtensiones.TipoMensaje.MsgInformacion); diff --git a/Inventarios/TraspasoAlmacen.aspx.vb b/Inventarios/TraspasoAlmacen.aspx.vb index eba6867e5..c4fab3d5a 100644 --- a/Inventarios/TraspasoAlmacen.aspx.vb +++ b/Inventarios/TraspasoAlmacen.aspx.vb @@ -204,29 +204,25 @@ Partial Class Inventarios_TraspasoAlmacen divEmitir.Visible = False End If - If UsuarioActual.CveEmpresa.Contiene(1, 119, 140, 2) Then - - If UsuarioActual.Empresa.Funcionalidad(161) = "1" Then - ChkEmitirTimbrado.Checked = True - End If + If UsuarioActual.CveEmpresa.Contiene(1, 2, 119, 140) Then ChkEmitirCartaPorte.Visible = True End If CantidadTotal = 0 - CvePS = 0 - TipoSeccionAlmacen = 0 + CvePS = 0 + TipoSeccionAlmacen = 0 - If UsuarioActual.Empresa.Funcionalidad(281).ToEntero = 1 Then + If UsuarioActual.Empresa.Funcionalidad(281).ToEntero = 1 Then - TxtFecha.Enabled = False - ImgFecha.Visible = False + TxtFecha.Enabled = False + ImgFecha.Visible = False - TxtFechaRecepcion.Enabled = False - ImgFechaRecepcion.Visible = False + TxtFechaRecepcion.Enabled = False + ImgFechaRecepcion.Visible = False - End If + End If Else If ChkTransitorio.Checked Then @@ -731,19 +727,19 @@ Partial Class Inventarios_TraspasoAlmacen #Region " GUARDAR " Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click - If ChkEmitirTimbrado.Checked Then + 'If ChkEmitirTimbrado.Checked Then - If DdlChofer.SelectedValue.ToEntero <= 0 Then - Alert("Debe de seleccionar un chofer") - Exit Sub - End If - If DdlUnidadCamion.SelectedValue.ToEntero <= 0 Then - Alert("Debe de seleccionar una unidad") - Exit Sub - End If + ' If DdlChofer.SelectedValue.ToEntero <= 0 Then + ' Alert("Debe de seleccionar un chofer") + ' Exit Sub + ' End If + ' If DdlUnidadCamion.SelectedValue.ToEntero <= 0 Then + ' Alert("Debe de seleccionar una unidad") + ' Exit Sub + ' End If - End If + 'End If 'VALIDA ALMACEN ORIGEN Y DESTINO If DdlAlmacenOrigen.SelectedValue = DdlAlmacenDestino.SelectedValue Then @@ -1154,8 +1150,9 @@ Partial Class Inventarios_TraspasoAlmacen Dim ObjGral As New ClsGenerales(ObjInventario.IniciaTransacSQL) Dim CveSubProyectoTimbre As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros($"CveAlmacen = {DdlAlmacenOrigen.SelectedValue}").Rows(0)("CveSubProyecto").ToString.ToEntero + Dim Fechallegada As DateTime = (TxtFechaLlegada.Text & " 23:59:59").ToDateTime - Dim CveEntregaAlmacen As Integer = ObjGral.AddInvEntregaAlmacenRuta(CveSubProyectoTimbre, -1, -1, CveMovimientoSalida, DdlChofer.SelectedValue.ToEntero, DdlUnidadCamion.SelectedValue.ToEntero, TxtFechaEntrega.Text.ToDate, TxtFechaLlegada.Text.ToDatetime, "T", 1, 1, 1) + Dim CveEntregaAlmacen As Integer = ObjGral.AddInvEntregaAlmacenRuta(CveSubProyectoTimbre, -1, -1, CveMovimientoSalida, DdlChofer.SelectedValue.ToEntero, DdlUnidadCamion.SelectedValue.ToEntero, TxtFechaEntrega.Text.ToDate, Fechallegada, "T", "", "", MinFecha, 1, 1, 1) If CveEntregaAlmacen > 0 Then CveTimbre = ObjGral.AddGralTimbre("Tra", CveSubProyectoTimbre, TxtFechaEntrega.Text.ToDate, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEntregaAlmacen:=CveEntregaAlmacen, AplicaCP:=ChkEmitirCartaPorte.Checked) diff --git a/RH/CatPersonal.aspx.vb b/RH/CatPersonal.aspx.vb index cfce5c5d2..952096265 100644 --- a/RH/CatPersonal.aspx.vb +++ b/RH/CatPersonal.aspx.vb @@ -904,7 +904,7 @@ Partial Class RH_CatPersonal Catalogos.Cell(crow, ccol).Value = "Estado" For Each row As DataRow In GlobalDTGralEstados("MEX").Rows crow = crow + 1 - Catalogos.Cell(crow, ccol).Value = String.Format("{0}: {1}", row("CveEstado"), row("Estado")) + Catalogos.Cell(crow, ccol).Value = String.Format("{0}: {1}", row("CveEstado"), row("NombreEstado")) Next colEstado = ccol rowEstado = crow diff --git a/Sistemas/UsuarioDetalle.aspx.vb b/Sistemas/UsuarioDetalle.aspx.vb index b17cec2e5..a70806496 100644 --- a/Sistemas/UsuarioDetalle.aspx.vb +++ b/Sistemas/UsuarioDetalle.aspx.vb @@ -6,8 +6,8 @@ Imports System.Data Imports System.Threading Partial Class Sistemas_UsuarioDetalle - Inherits ClsPaginas - + Inherits ClsPaginas + #Region "P R O P I E D A D E S" Private Property DTEstatusSubProyectos As DataTable Get @@ -84,7 +84,7 @@ Partial Class Sistemas_UsuarioDetalle Get Return ViewState("Password").ToString End Get - End Property + End Property Private ReadOnly Property CodigoAcceso As String Get Return ViewState("CodigoAcceso").ToString @@ -395,10 +395,10 @@ Partial Class Sistemas_UsuarioDetalle Set(value As Integer) ViewState("CveEmpresaAnterior") = value End Set - End Property + End Property #End Region - - + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then @@ -450,30 +450,30 @@ Partial Class Sistemas_UsuarioDetalle TrLimiteAutorizacion.Visible = True End If - If UsuarioActual.Empresa.Funcionalidad(599) = "1" Then - TrCodigoAcceso.Visible = True + If UsuarioActual.Empresa.Funcionalidad(599) = "1" Then + TrCodigoAcceso.Visible = True End If - CargaDatos() - InicializaClonarUsuario() - InicializaRestricciones() - CargaGvBitacora() - CargaEmpresasAsignaciones() - CreaDtAsignacionesMultiEmpresa() - CveEmpresaAnterior = DdlEmpresaAsignaciones.SelectedValue.ToEntero - + CargaDatos() + InicializaClonarUsuario() + InicializaRestricciones() + CargaGvBitacora() + CargaEmpresasAsignaciones() + CreaDtAsignacionesMultiEmpresa() + CveEmpresaAnterior = DdlEmpresaAsignaciones.SelectedValue.ToEntero + End If - End Sub - - 'DOCUMENTACION - 'LOS CAMPOS DE DATATABLE "ACCION" SE REFIERE AL ESTATUS DE LOS CAMBIOS QUE OCURRIERON ANTES DE DARLE GUARDAR - ' 0/NULL/VACIO = ORIGINAL (SIN CAMBIO) - ' 1 = AGREGADO - ' 2 = ELIMINADO - ' 3 = NADA (AGREGADO Y ELIMINADO): CUANDO AGREGA UN REGISTRO Y LO ELIMINA, ES DECIR, NO SE GUARDA NADA - ' 4 = UPDATE - - + End Sub + + 'DOCUMENTACION + 'LOS CAMPOS DE DATATABLE "ACCION" SE REFIERE AL ESTATUS DE LOS CAMBIOS QUE OCURRIERON ANTES DE DARLE GUARDAR + ' 0/NULL/VACIO = ORIGINAL (SIN CAMBIO) + ' 1 = AGREGADO + ' 2 = ELIMINADO + ' 3 = NADA (AGREGADO Y ELIMINADO): CUANDO AGREGA UN REGISTRO Y LO ELIMINA, ES DECIR, NO SE GUARDA NADA + ' 4 = UPDATE + + #Region " C A R G A R - D A T O S " Private Sub CargaDatos() @@ -527,10 +527,10 @@ Partial Class Sistemas_UsuarioDetalle CargarRol() CargaAsignaciones() - CargaUsuarioResponsable() - - ' ValidaAccesoEstatusOC() - + CargaUsuarioResponsable() + + ' ValidaAccesoEstatusOC() + End Sub Public Sub CargaUsuarioResponsable() @@ -587,7 +587,7 @@ Partial Class Sistemas_UsuarioDetalle LblFechaCaptura.Text = ObjUsuario.Fecha.ToShortDateString LblUsuarioCapturo.Text = ObjUsuario.UsuarioCreo - TxtDescuentoAutorizado.Text = ObjUsuario.DescuentoAutorizado.FormatoNumero + TxtDescuentoAutorizado.Text = ObjUsuario.DescuentoAutorizado.FormatoNumero TxtLimiteAutorizado.Text = ObjUsuario.DtResultados.Rows(0)("LimiteCreditoAutorizado").ToString() Else Alert("El Usuario Solicitado no existe, Revise su búsqueda.", TipoMensaje.MsgAdvertencia) @@ -759,23 +759,23 @@ Partial Class Sistemas_UsuarioDetalle If CveTipoDocumentoAsignado <> "-1" Then DdlTipoDocumento.SelectedValueExist(CveTipoDocumentoAsignado) UpFiltrosAsignarPermiso.Update() - End Sub + End Sub #End Region - - 'Private Sub CargaSucursal() - ' DtSubProyectos2 = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("CveSubProyecto =" & DdlSubProyectos.SelectedValue.ToEntero) - ' If DtSubProyectos2.Rows.Count > 0 Then - ' Dim dr As DataRow - ' dr = DtSubProyectos2(0) - ' CveSucursal = dr("CveSucursal").ToString.ToEntero - ' Else - ' CveSucursal = -1 - ' End If - - 'End Sub - + + 'Private Sub CargaSucursal() + ' DtSubProyectos2 = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("CveSubProyecto =" & DdlSubProyectos.SelectedValue.ToEntero) + ' If DtSubProyectos2.Rows.Count > 0 Then + ' Dim dr As DataRow + ' dr = DtSubProyectos2(0) + ' CveSucursal = dr("CveSucursal").ToString.ToEntero + ' Else + ' CveSucursal = -1 + ' End If + + 'End Sub + #Region " G U A R D A R - U P D A T E " - + Private Function ValidaUsername(Username As String, Correo As String) As Boolean Dim Retorno As Boolean = True 'If CveUsuario = -1 Then @@ -804,491 +804,490 @@ Partial Class Sistemas_UsuarioDetalle Dim TieneError = False Dim EsNuevoUsuario As Boolean = False - Try - 'Cargo la ultima empresa consultada en asignaciones - Dim DtValida = DtAsignacionesMultiEmpresa.FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresaAnterior)) - If DtValida.Rows.Count > 0 Then - Dim dr = DtAsignacionesMultiEmpresa.Select(String.Format("CveEmpresa = {0}", CveEmpresaAnterior)) - dr(0)("CveEmpresa") = CveEmpresaAnterior - dr(0)("CvePersonal") = DdlPersonal.SelectedValue.ToEntero - dr(0)("CveVendedor") = DdlVendedor.SelectedValue.ToEntero - dr(0)("CveSucursal") = DdlSubProyectos.SelectedValue.ToEntero - dr(0)("CveAlmacen") = DdlAlmacenGeneral.SelectedValue.ToEntero - dr(0)("CveTipoDocumento") = DdlTipoDocumento.SelectedValue - dr(0).AcceptChanges() - Else - Dim Row As DataRow = Nothing - Row = DtAsignacionesMultiEmpresa.NewRow() - Row("CveEmpresa") = CveEmpresaAnterior - Row("CvePersonal") = DdlPersonal.SelectedValue.ToEntero - Row("CveVendedor") = DdlVendedor.SelectedValue.ToEntero - Row("CveSucursal") = DdlSubProyectos.SelectedValue.ToEntero - Row("CveAlmacen") = DdlAlmacenGeneral.SelectedValue.ToEntero - Row("CveTipoDocumento") = DdlTipoDocumento.SelectedValue - DtAsignacionesMultiEmpresa.Rows.Add(Row) - End If - - Dim CodigoAcceso As String = If(String.IsNullOrEmpty(TxtCodigoAcceso.Text.Trim), "-1", TxtCodigoAcceso.Text.Trim) - - 'REGISTRA O ACTUALIZA LOS DATOS GENERALES DEL USUARIO - If CveUsuario = -1 Then - CveUsuario = ObjUsuarios.AddUsuario(TxtUsuario.Text.Trim, Encripta(ContraseñaPredeterminada), TxtNombre.Text.Trim, DdlRol.SelectedValue.ToEntero, TxtCorreo.Text.Trim, DdlPersonal.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, ChkCambiarContraseña.Checked, UsuarioActual.CveUsuario, DdlEmpresa.SelectedValue.ToEntero, DdlSubProyectos.SelectedValue.ToEntero, CveAlmacenAsignado:=DdlAlmacenGeneral.SelectedValue.ToEntero, AsignarSubProyecto:=ChkAsignarSubProyecto.Checked, AsignarOC:=ChkAsignarOC.Checked, DescuentoAutorizado:=TxtDescuentoAutorizado.Text.ToDouble, CodigoAcceso:=CodigoAcceso, LimiteCreditoAutorizado:=TxtLimiteAutorizado.Text.ToDecimal()) - EsNuevoUsuario = True - If CveUsuario = -1 Then - TieneError = True - End If - - For Each Row As DataRow In DtAsignacionesMultiEmpresa.FiltraParametros("CveEmpresa > 0").Rows - If Not ObjUsuarios.AddUsuarioAsignar(Row("CvePersonal").ToString.ToEntero, Row("CveVendedor").ToString.ToEntero, Row("CveAlmacen").ToString.ToEntero, Row("CveSucursal").ToString.ToEntero, Row("CveTipoDocumento").ToString, Row("CveEmpresa").ToString.ToEntero, CveUsuario) Then - TieneError = True - End If - Next - Else - If Not ObjUsuarios.UpdateUsuario(TxtUsuario.Text.Trim, TxtNombre.Text.Trim, DdlRol.SelectedValue.ToEntero, TxtCorreo.Text.Trim, DdlPersonal.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, ChkCambiarContraseña.Checked, ChkEstatus.Checked, DdlEmpresa.SelectedValue.ToEntero, CveUsuario, DdlAlmacenGeneral.SelectedValue.ToEntero, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveUsuario, AsignarSubProyecto:=ChkAsignarSubProyecto.Checked, AsignarOC:=ChkAsignarOC.Checked, DescuentoAutorizado:=TxtDescuentoAutorizado.Text.ToDouble, CodigoAcceso:=CodigoAcceso, LimiteCreditoAutorizado:=TxtLimiteAutorizado.Text.ToDecimal()) Then - TieneError = True - End If - - For Each Row As DataRow In DtAsignacionesMultiEmpresa.FiltraParametros("CveEmpresa > 0").Rows - If Not ObjUsuarios.UpdateUsuarioAsignar(Row("CvePersonal").ToString.ToEntero, Row("CveVendedor").ToString.ToEntero, Row("CveAlmacen").ToString.ToEntero, Row("CveSucursal").ToString.ToEntero, Row("CveEmpresa").ToString.ToEntero, Row("CveTipoDocumento").ToString, CveUsuario, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then - TieneError = True - End If - Next - End If - - 'GUARDA ACCESO MODULOS - If Not TieneError Then - For Each Row As GridViewRow In GvModulosAcceso.Rows - 'Nota, permitir, tiene 3 valores, ''(Vacio), no se ha estipulado, '0' que se denego, '1' permitido(aplicado solo cuando no viene del rol - If Row.DataKey("CveModuloAcceso") <> "" Then - If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkDenegar").Checked OrElse Row.DataKey("Permitir") = "0" AndAlso Row.FCCheckBox("ChkDenegar").Checked = False Then - If Not ObjUsuarios.UpdateUsuariosModulos(CveUsuario, Row.DataKey("CveModulo").ToEntero, Not Row.FCCheckBox("ChkDenegar").Checked, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - Else - If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkPermitir").Checked OrElse Row.DataKey("Permitir") = "1" AndAlso Row.FCCheckBox("ChkPermitir").Checked = False Then - If Not ObjUsuarios.UpdateUsuariosModulos(CveUsuario, Row.DataKey("CveModulo").ToEntero, Row.FCCheckBox("ChkPermitir").Checked, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - End If - - Next - End If - - 'GUARDA PERMISO MODULOS - If Not TieneError Then - For Each Row As GridViewRow In GvModulosPermiso.Rows - - If Row.DataKey("CveProcesoAcceso") <> "" Then - 'checo si el permiso que tiene es del rol, de ser así, nada más actualizo los denegados - If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkD").Checked OrElse Row.DataKey("Permitir") = "0" AndAlso Row.FCCheckBox("ChkD").Checked = False Then - If Not ObjUsuarios.UpdateUsuariosProcesos(CveUsuario, Row.DataKey("CveProceso").ToEntero, Not Row.FCCheckBox("ChkD").Checked, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - Else - 'permisos que el rol, no le está otorgando, y serán únicos para el usuario - If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkP").Checked OrElse Row.DataKey("Permitir") = "1" AndAlso Row.FCCheckBox("ChkP").Checked = False Then - If Not ObjUsuarios.UpdateUsuariosProcesos(CveUsuario, Row.DataKey("CveProceso").ToEntero, Row.FCCheckBox("ChkP").Checked, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - End If - - ''checo si el permiso que tiene es del rol, de ser así, nada más actualizo los denegados - 'If Row.DataKey("CveProcesoAcceso") <> "" Then - ' If Not ClsUsuarios.UpdateUsuariosProcesos(Row.DataKey("CveUsuario").ToEntero, Row.DataKey("CveProceso").ToEntero, Not Row.FCCheckBox("ChkD").Checked) Then - ' TieneError = True - ' Exit For - ' End If - 'Else - ' 'permisos que el rol, no le está otorgando, y serán únicos para el usuario - ' If Not ClsUsuarios.UpdateUsuariosProcesos(Row.DataKey("CveUsuario").ToEntero, Row.DataKey("CveProceso").ToEntero, Row.FCCheckBox("ChkP").Checked) Then - ' TieneError = True - ' Exit For - ' End If - 'End If - - Next - End If - - - 'Agregar Indicadores - If Not TieneError Then - For Each Row As GridViewRow In GvIndicadores.Rows - - If Row.DataKey("CveIndicador") <> "" AndAlso Row.DataKey("CveUsuario") <> "" And Row.FCCheckBox("chkIndicador").Checked = False Then - If Not Indicador.RemoveIndicadoresUsuarios(Row.DataKey("CveIndicador").ToEntero, CveUsuario, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - - If Row.DataKey("CveIndicador") <> "" AndAlso Row.DataKey("CveUsuario") = "" Then - If Row.FCCheckBox("chkIndicador").Checked Then - If Not Indicador.AddIndicadoresUsuarios(Row.DataKey("CveIndicador").ToEntero, CveUsuario, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - - - - 'GUARDA ACCESO EMPRESAS - If Not TieneError Then - For Each dr As DataRow In DtEmpresasUsuario.FiltraParametros("Accion IN (1,2)").Rows - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddUsuariosEmpresas(CveUsuario, dr("CveEmpresa").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveEmpresasAcceso(CveUsuario, dr("CveEmpresa").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - Next - End If - - 'GUARDA SUBPROYECTOS - If Not TieneError Then - For Each dr As DataRow In DtSubProyectos.FiltraParametros("Accion IN (1,2,4)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddSubProyectos(CveUsuario, dr("CveSubProyecto").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveSubProyectos(CveUsuario, dr("CveSubProyecto").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "4" Then - If Not ObjUsuarios.UpdateSubProyectos(CveUsuario, dr("CveSubProyecto").ToString.ToEntero, dr("ViejoCveSubProyecto").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - - 'GUARDA ESTATUS DE OC - If Not TieneError Then - If DTEstatusOC IsNot Nothing AndAlso DTEstatusOC.Rows.Count > 0 Then - For Each dr As DataRow In DTEstatusOC.FiltraParametros("Accion IN (1,2,4)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddEstatusOC(CveUsuario, dr("CveEstatus").ToString.ToEntero) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveEstatusOC(CveUsuario, dr("CveEstatus").ToString.ToEntero) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "4" Then - If Not ObjUsuarios.UpdateEstatusOC(CveUsuario, dr("CveEstatus").ToString.ToEntero, dr("ViejoCveEstatus").ToString.ToEntero) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - - End If - 'GUARDA CLASIFICACIONES - If Not TieneError Then - If DtClasificaciones IsNot Nothing AndAlso DtClasificaciones.Rows.Count > 0 Then - For Each dr As DataRow In DtClasificaciones.FiltraParametros("Accion IN (1,2,4)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddUsuariosClasificaciones(CveUsuario, dr("CveClasificacion").ToString.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveUsuariosClasificaciones(CveUsuario, dr("CveClasificacion").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - End If - - - - - 'GUARDA ALMACENES - If Not TieneError Then - For Each dr As DataRow In DtAlmacenes.FiltraParametros("Accion IN (1,2,4)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddAlmacen(CveUsuario, dr("CveAlmacen").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveAlmacen(CveUsuario, dr("CveAlmacen").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "4" Then - If Not ObjUsuarios.UpdateAlmacen(CveUsuario, dr("CveAlmacen").ToString.ToEntero, dr("ViejoCveAlmacen").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - End If - Next - - End If - - - 'Guarda Estatus de Ordenes de Compra - If Not TieneError Then - GuardaEstatusProyectosREQ(ObjOC, TieneError) - GuardaEstatusProyectoOC(ObjOC, TieneError) - End If - - ''Guarda Estatus de Ordenes de Servicio - 'If Not TieneError Then - ' GuardaEstatusOS(ObjOS, TieneError) - 'End If - - - 'GUARDA CUENTAS BANCARIAS - If Not TieneError Then - For Each dr As DataRow In DtCuentasBancarias.FiltraParametros("Accion IN (1,2)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjBancos.AddBancosCuentasUsuarios(dr("CveCuenta").ToString.ToEntero, CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjBancos.RemoveBancosCuentasUsuarios(dr("CveCuenta").ToString.ToEntero, CveUsuario) Then - TieneError = True - Exit For - End If - End If - End If - Next - - End If - - - 'GUARDAMOS RESTRICCIONES DE ACCESO - If Not TieneError Then - For Each dr As DataRow In DtRestricciones.FiltraParametros("Accion IN (1,2,4)").Rows - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.UsuariosRestriccionesAccesoAdd(CveUsuario, dr("IP").ToString, dr("MAC").ToString, dr("HI1").ToString, dr("HF1").ToString, dr("HI2").ToString, dr("HF2").ToString, dr("HI3").ToString, dr("HF3").ToString, dr("HI4").ToString, dr("HF4").ToString, dr("HI5").ToString, dr("HF5").ToString, dr("HI6").ToString, dr("HF6").ToString, dr("HI7").ToString, dr("HF7").ToString, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.UsuariosRestriccionesAccesoRemove(dr("CveUsuarioRestriccionAcceso").ToString.ToEntero, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "4" Then - If Not ObjUsuarios.UsuariosRestriccionesAccesoUpdate(dr("CveUsuarioRestriccionAcceso").ToString.ToEntero, dr("IP").ToString, dr("MAC").ToString, dr("HI1").ToString, dr("HF1").ToString, dr("HI2").ToString, dr("HF2").ToString, dr("HI3").ToString, dr("HF3").ToString, dr("HI4").ToString, dr("HF4").ToString, dr("HI5").ToString, dr("HF5").ToString, dr("HI6").ToString, dr("HF6").ToString, dr("HI7").ToString, dr("HF7").ToString, UsuarioActual.CveUsuario) Then - TieneError = True - Exit For - End If - End If - Next - End If - ObjUsuarios.UsuariosRestriccioneXMacUpdate(CveUsuario) - 'CLONAR USUARIO - If Not TieneError Then - If EsNuevoUsuario Then - If Not ClonarUsuario(DdlUsuarioClonar.SelectedValue.ToEntero, ObjUsuarios) Then - TieneError = True - End If - End If - End If - - - - ''''''''''''''''''''''''GUARDA ASIGNAR'''''''''''''''''''''''' - - 'GUARDA ROLES - If Not TieneError Then - For Each dr As DataRow In DTRolesAsignar.FiltraParametros("Accion IN (1,2)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddRolesAsignar(CveUsuario, dr("CveRol").ToString.ToEntero) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveRolesAsignar(CveUsuario, dr("CveRol").ToString.ToEntero) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - - 'GUARDA ALMACENES - If Not TieneError Then - For Each dr As DataRow In DtAlmacenesAsignar.FiltraParametros("Accion IN (1,2)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddAlmacenAsignar(CveUsuario, dr("CveAlmacen").ToString.ToEntero) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveAlmacenAsignar(CveUsuario, dr("CveAlmacen").ToString.ToEntero) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - - 'GUARDA SUBPROYECTOS - If Not TieneError Then - For Each dr As DataRow In DtSubProyectosAsignar.FiltraParametros("Accion IN (1,2,4)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddSubProyectosAsignar(CveUsuario, dr("CveSubProyecto").ToString.ToEntero) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveSubProyectosAsignar(CveUsuario, dr("CveSubProyecto").ToString.ToEntero) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - - 'GUARDA CUENTAS BANCARIAS - If Not TieneError Then - For Each dr As DataRow In DtCuentasBancariasAsignar.FiltraParametros("Accion IN (1,2)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If dr("Accion").ToString = "1" Then - If Not ObjUsuarios.AddCuentasBancariasAsignar(CveUsuario, dr("CveCuenta").ToString.ToEntero) Then - TieneError = True - Exit For - End If - ElseIf dr("Accion").ToString = "2" Then - If Not ObjUsuarios.RemoveCuentasBancariasAsignar(CveUsuario, dr("CveCuenta").ToString.ToEntero) Then - TieneError = True - Exit For - End If - End If - End If - Next - End If - - 'GUARDA MODULOS - If Not TieneError Then - For Each Row As GridViewRow In GvModulosAsignar.Rows - If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then - If Not ObjUsuarios.RemoveModulosAsignar(CveUsuario, Row.DataKey("CveModulo").ToEntero) Then - TieneError = True - Exit For - End If - ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then - If Not ObjUsuarios.AddModulosAsignar(CveUsuario, Row.DataKey("CveModulo").ToEntero) Then - TieneError = True - Exit For - End If - End If - Next - End If - - 'GUARDA PERMISOS - If Not TieneError Then - For Each Row As GridViewRow In GvPermisosAsignar.Rows - If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then - If Not ObjUsuarios.RemovePermisosAsignar(CveUsuario, Row.DataKey("CvePermiso").ToEntero) Then - TieneError = True - Exit For - End If - ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then - If Not ObjUsuarios.AddPermisosAsignar(CveUsuario, Row.DataKey("CvePermiso").ToEntero) Then - TieneError = True - Exit For - End If - End If - Next - End If - - 'GUARDA INDICADORES - If Not TieneError Then - For Each Row As GridViewRow In GvIndicadoresAsignar.Rows - If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then - If Not ObjUsuarios.RemoveIndicadoresAsignar(CveUsuario, Row.DataKey("CveIndicador").ToEntero) Then - TieneError = True - Exit For - End If - ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then - If Not ObjUsuarios.AddIndicadoresAsignar(CveUsuario, Row.DataKey("CveIndicador").ToEntero) Then - TieneError = True - Exit For - End If - End If - Next - End If - - 'GUARDA EMPRESAS - If Not TieneError Then - For Each Row As GridViewRow In GvEmpresasAsignar.Rows - If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then - If Not ObjUsuarios.RemoveEmpresasAsignar(CveUsuario, Row.DataKey("CveEmpresa").ToEntero) Then - TieneError = True - Exit For - End If - ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then - If Not ObjUsuarios.AddEmpresasAsignar(CveUsuario, Row.DataKey("CveEmpresa").ToEntero) Then - TieneError = True - Exit For - End If - End If - Next - End If - - 'ELIMINA YA AGREGADOS EMPRESAS - If Not TieneError Then - For Each dr As DataRow In DTEmpresasAsignar.FiltraParametros("TienePermiso IN (-2)").Rows - If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then - If Not ObjUsuarios.RemoveEmpresasAsignar(CveUsuario, dr("CveEmpresa").ToString.ToEntero) Then - TieneError = True - Exit For - End If - End If - Next - End If - - Catch ex As Exception - TieneError = True - OnError("Ocurrió un error al guardar el usuario", ex) - End Try - - + Try + 'Cargo la ultima empresa consultada en asignaciones + Dim DtValida = DtAsignacionesMultiEmpresa.FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresaAnterior)) + If DtValida.Rows.Count > 0 Then + Dim dr = DtAsignacionesMultiEmpresa.Select(String.Format("CveEmpresa = {0}", CveEmpresaAnterior)) + dr(0)("CveEmpresa") = CveEmpresaAnterior + dr(0)("CvePersonal") = DdlPersonal.SelectedValue.ToEntero + dr(0)("CveVendedor") = DdlVendedor.SelectedValue.ToEntero + dr(0)("CveSucursal") = DdlSubProyectos.SelectedValue.ToEntero + dr(0)("CveAlmacen") = DdlAlmacenGeneral.SelectedValue.ToEntero + dr(0)("CveTipoDocumento") = DdlTipoDocumento.SelectedValue + dr(0).AcceptChanges() + Else + Dim Row As DataRow = Nothing + Row = DtAsignacionesMultiEmpresa.NewRow() + Row("CveEmpresa") = CveEmpresaAnterior + Row("CvePersonal") = DdlPersonal.SelectedValue.ToEntero + Row("CveVendedor") = DdlVendedor.SelectedValue.ToEntero + Row("CveSucursal") = DdlSubProyectos.SelectedValue.ToEntero + Row("CveAlmacen") = DdlAlmacenGeneral.SelectedValue.ToEntero + Row("CveTipoDocumento") = DdlTipoDocumento.SelectedValue + DtAsignacionesMultiEmpresa.Rows.Add(Row) + End If + + Dim CodigoAcceso As String = If(String.IsNullOrEmpty(TxtCodigoAcceso.Text.Trim), "-1", TxtCodigoAcceso.Text.Trim) + + 'REGISTRA O ACTUALIZA LOS DATOS GENERALES DEL USUARIO + If CveUsuario = -1 Then + CveUsuario = ObjUsuarios.AddUsuario(TxtUsuario.Text.Trim, Encripta(ContraseñaPredeterminada), TxtNombre.Text.Trim, DdlRol.SelectedValue.ToEntero, TxtCorreo.Text.Trim, DdlPersonal.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, ChkCambiarContraseña.Checked, UsuarioActual.CveUsuario, DdlEmpresa.SelectedValue.ToEntero, DdlSubProyectos.SelectedValue.ToEntero, CveAlmacenAsignado:=DdlAlmacenGeneral.SelectedValue.ToEntero, AsignarSubProyecto:=ChkAsignarSubProyecto.Checked, AsignarOC:=ChkAsignarOC.Checked, DescuentoAutorizado:=TxtDescuentoAutorizado.Text.ToDouble, CodigoAcceso:=CodigoAcceso, LimiteCreditoAutorizado:=TxtLimiteAutorizado.Text.ToDecimal()) + EsNuevoUsuario = True + If CveUsuario = -1 Then + TieneError = True + End If + + For Each Row As DataRow In DtAsignacionesMultiEmpresa.FiltraParametros("CveEmpresa > 0").Rows + If Not ObjUsuarios.AddUsuarioAsignar(Row("CvePersonal").ToString.ToEntero, Row("CveVendedor").ToString.ToEntero, Row("CveAlmacen").ToString.ToEntero, Row("CveSucursal").ToString.ToEntero, Row("CveTipoDocumento").ToString, Row("CveEmpresa").ToString.ToEntero, CveUsuario) Then + TieneError = True + End If + Next + Else + If Not ObjUsuarios.UpdateUsuario(TxtUsuario.Text.Trim, TxtNombre.Text.Trim, DdlRol.SelectedValue.ToEntero, TxtCorreo.Text.Trim, DdlPersonal.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, ChkCambiarContraseña.Checked, ChkEstatus.Checked, DdlEmpresa.SelectedValue.ToEntero, CveUsuario, DdlAlmacenGeneral.SelectedValue.ToEntero, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveUsuario, AsignarSubProyecto:=ChkAsignarSubProyecto.Checked, AsignarOC:=ChkAsignarOC.Checked, DescuentoAutorizado:=TxtDescuentoAutorizado.Text.ToDouble, CodigoAcceso:=CodigoAcceso, LimiteCreditoAutorizado:=TxtLimiteAutorizado.Text.ToDecimal()) Then + TieneError = True + End If + + For Each Row As DataRow In DtAsignacionesMultiEmpresa.FiltraParametros("CveEmpresa > 0").Rows + If Not ObjUsuarios.UpdateUsuarioAsignar(Row("CvePersonal").ToString.ToEntero, Row("CveVendedor").ToString.ToEntero, Row("CveAlmacen").ToString.ToEntero, Row("CveSucursal").ToString.ToEntero, Row("CveEmpresa").ToString.ToEntero, Row("CveTipoDocumento").ToString, CveUsuario, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + TieneError = True + End If + Next + End If + + 'GUARDA ACCESO MODULOS + If Not TieneError Then + For Each Row As GridViewRow In GvModulosAcceso.Rows + 'Nota, permitir, tiene 3 valores, ''(Vacio), no se ha estipulado, '0' que se denego, '1' permitido(aplicado solo cuando no viene del rol + If Row.DataKey("CveModuloAcceso") <> "" Then + If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkDenegar").Checked OrElse Row.DataKey("Permitir") = "0" AndAlso Row.FCCheckBox("ChkDenegar").Checked = False Then + If Not ObjUsuarios.UpdateUsuariosModulos(CveUsuario, Row.DataKey("CveModulo").ToEntero, Not Row.FCCheckBox("ChkDenegar").Checked, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + Else + If Row.DataKey("Permitir").Contiene("", "0") AndAlso Row.FCCheckBox("ChkPermitir").Checked OrElse Row.DataKey("Permitir") = "1" AndAlso Row.FCCheckBox("ChkPermitir").Checked = False Then + If Not ObjUsuarios.UpdateUsuariosModulos(CveUsuario, Row.DataKey("CveModulo").ToEntero, Row.FCCheckBox("ChkPermitir").Checked, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + 'GUARDA PERMISO MODULOS + If Not TieneError Then + For Each Row As GridViewRow In GvModulosPermiso.Rows + + If Row.DataKey("CveProcesoAcceso") <> "" Then + 'checo si el permiso que tiene es del rol, de ser así, nada más actualizo los denegados + If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkD").Checked OrElse Row.DataKey("Permitir") = "0" AndAlso Row.FCCheckBox("ChkD").Checked = False Then + If Not ObjUsuarios.UpdateUsuariosProcesos(CveUsuario, Row.DataKey("CveProceso").ToEntero, Not Row.FCCheckBox("ChkD").Checked, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + Else + 'permisos que el rol, no le está otorgando, y serán únicos para el usuario + If Row.DataKey("Permitir") = "" AndAlso Row.FCCheckBox("ChkP").Checked OrElse Row.DataKey("Permitir") = "1" AndAlso Row.FCCheckBox("ChkP").Checked = False Then + If Not ObjUsuarios.UpdateUsuariosProcesos(CveUsuario, Row.DataKey("CveProceso").ToEntero, Row.FCCheckBox("ChkP").Checked, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + End If + + ''checo si el permiso que tiene es del rol, de ser así, nada más actualizo los denegados + 'If Row.DataKey("CveProcesoAcceso") <> "" Then + ' If Not ClsUsuarios.UpdateUsuariosProcesos(Row.DataKey("CveUsuario").ToEntero, Row.DataKey("CveProceso").ToEntero, Not Row.FCCheckBox("ChkD").Checked) Then + ' TieneError = True + ' Exit For + ' End If + 'Else + ' 'permisos que el rol, no le está otorgando, y serán únicos para el usuario + ' If Not ClsUsuarios.UpdateUsuariosProcesos(Row.DataKey("CveUsuario").ToEntero, Row.DataKey("CveProceso").ToEntero, Row.FCCheckBox("ChkP").Checked) Then + ' TieneError = True + ' Exit For + ' End If + 'End If + + Next + End If + + + 'Agregar Indicadores + If Not TieneError Then + For Each Row As GridViewRow In GvIndicadores.Rows + + If Row.DataKey("CveIndicador") <> "" AndAlso Row.DataKey("CveUsuario") <> "" And Row.FCCheckBox("chkIndicador").Checked = False Then + If Not Indicador.RemoveIndicadoresUsuarios(Row.DataKey("CveIndicador").ToEntero, CveUsuario, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + + If Row.DataKey("CveIndicador") <> "" AndAlso Row.DataKey("CveUsuario") = "" Then + If Row.FCCheckBox("chkIndicador").Checked Then + If Not Indicador.AddIndicadoresUsuarios(Row.DataKey("CveIndicador").ToEntero, CveUsuario, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + + + 'GUARDA ACCESO EMPRESAS + If Not TieneError Then + For Each dr As DataRow In DtEmpresasUsuario.FiltraParametros("Accion IN (1,2)").Rows + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddUsuariosEmpresas(CveUsuario, dr("CveEmpresa").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveEmpresasAcceso(CveUsuario, dr("CveEmpresa").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + Next + End If + + 'GUARDA SUBPROYECTOS + If Not TieneError Then + For Each dr As DataRow In DtSubProyectos.FiltraParametros("Accion IN (1,2,4)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddSubProyectos(CveUsuario, dr("CveSubProyecto").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveSubProyectos(CveUsuario, dr("CveSubProyecto").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "4" Then + If Not ObjUsuarios.UpdateSubProyectos(CveUsuario, dr("CveSubProyecto").ToString.ToEntero, dr("ViejoCveSubProyecto").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + 'GUARDA ESTATUS DE OC + If Not TieneError Then + If DTEstatusOC IsNot Nothing AndAlso DTEstatusOC.Rows.Count > 0 Then + For Each dr As DataRow In DTEstatusOC.FiltraParametros("Accion IN (1,2,4)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddEstatusOC(CveUsuario, dr("CveEstatus").ToString.ToEntero) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveEstatusOC(CveUsuario, dr("CveEstatus").ToString.ToEntero) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "4" Then + If Not ObjUsuarios.UpdateEstatusOC(CveUsuario, dr("CveEstatus").ToString.ToEntero, dr("ViejoCveEstatus").ToString.ToEntero) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + End If + 'GUARDA CLASIFICACIONES + If Not TieneError Then + If DtClasificaciones IsNot Nothing AndAlso DtClasificaciones.Rows.Count > 0 Then + For Each dr As DataRow In DtClasificaciones.FiltraParametros("Accion IN (1,2,4)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddUsuariosClasificaciones(CveUsuario, dr("CveClasificacion").ToString.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveUsuariosClasificaciones(CveUsuario, dr("CveClasificacion").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + End If + + + + + 'GUARDA ALMACENES + If Not TieneError Then + For Each dr As DataRow In DtAlmacenes.FiltraParametros("Accion IN (1,2,4)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddAlmacen(CveUsuario, dr("CveAlmacen").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveAlmacen(CveUsuario, dr("CveAlmacen").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "4" Then + If Not ObjUsuarios.UpdateAlmacen(CveUsuario, dr("CveAlmacen").ToString.ToEntero, dr("ViejoCveAlmacen").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + End If + Next + + End If + + + 'Guarda Estatus de Ordenes de Compra + If Not TieneError Then + GuardaEstatusProyectosREQ(ObjOC, TieneError) + GuardaEstatusProyectoOC(ObjOC, TieneError) + End If + + ''Guarda Estatus de Ordenes de Servicio + 'If Not TieneError Then + ' GuardaEstatusOS(ObjOS, TieneError) + 'End If + + + 'GUARDA CUENTAS BANCARIAS + If Not TieneError Then + For Each dr As DataRow In DtCuentasBancarias.FiltraParametros("Accion IN (1,2)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjBancos.AddBancosCuentasUsuarios(dr("CveCuenta").ToString.ToEntero, CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjBancos.RemoveBancosCuentasUsuarios(dr("CveCuenta").ToString.ToEntero, CveUsuario) Then + TieneError = True + Exit For + End If + End If + End If + Next + + End If + + + 'GUARDAMOS RESTRICCIONES DE ACCESO + If Not TieneError Then + For Each dr As DataRow In DtRestricciones.FiltraParametros("Accion IN (1,2,4)").Rows + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.UsuariosRestriccionesAccesoAdd(CveUsuario, dr("IP").ToString, dr("MAC").ToString, dr("HI1").ToString, dr("HF1").ToString, dr("HI2").ToString, dr("HF2").ToString, dr("HI3").ToString, dr("HF3").ToString, dr("HI4").ToString, dr("HF4").ToString, dr("HI5").ToString, dr("HF5").ToString, dr("HI6").ToString, dr("HF6").ToString, dr("HI7").ToString, dr("HF7").ToString, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.UsuariosRestriccionesAccesoRemove(dr("CveUsuarioRestriccionAcceso").ToString.ToEntero, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "4" Then + If Not ObjUsuarios.UsuariosRestriccionesAccesoUpdate(dr("CveUsuarioRestriccionAcceso").ToString.ToEntero, dr("IP").ToString, dr("MAC").ToString, dr("HI1").ToString, dr("HF1").ToString, dr("HI2").ToString, dr("HF2").ToString, dr("HI3").ToString, dr("HF3").ToString, dr("HI4").ToString, dr("HF4").ToString, dr("HI5").ToString, dr("HF5").ToString, dr("HI6").ToString, dr("HF6").ToString, dr("HI7").ToString, dr("HF7").ToString, UsuarioActual.CveUsuario) Then + TieneError = True + Exit For + End If + End If + Next + End If + ObjUsuarios.UsuariosRestriccioneXMacUpdate(CveUsuario) + 'CLONAR USUARIO + If Not TieneError Then + If EsNuevoUsuario Then + If Not ClonarUsuario(DdlUsuarioClonar.SelectedValue.ToEntero, ObjUsuarios) Then + TieneError = True + End If + End If + End If + + + + ''''''''''''''''''''''''GUARDA ASIGNAR'''''''''''''''''''''''' + + 'GUARDA ROLES + If Not TieneError Then + For Each dr As DataRow In DTRolesAsignar.FiltraParametros("Accion IN (1,2)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddRolesAsignar(CveUsuario, dr("CveRol").ToString.ToEntero) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveRolesAsignar(CveUsuario, dr("CveRol").ToString.ToEntero) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + 'GUARDA ALMACENES + If Not TieneError Then + For Each dr As DataRow In DtAlmacenesAsignar.FiltraParametros("Accion IN (1,2)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddAlmacenAsignar(CveUsuario, dr("CveAlmacen").ToString.ToEntero) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveAlmacenAsignar(CveUsuario, dr("CveAlmacen").ToString.ToEntero) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + 'GUARDA SUBPROYECTOS + If Not TieneError Then + For Each dr As DataRow In DtSubProyectosAsignar.FiltraParametros("Accion IN (1,2,4)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddSubProyectosAsignar(CveUsuario, dr("CveSubProyecto").ToString.ToEntero) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveSubProyectosAsignar(CveUsuario, dr("CveSubProyecto").ToString.ToEntero) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + 'GUARDA CUENTAS BANCARIAS + If Not TieneError Then + For Each dr As DataRow In DtCuentasBancariasAsignar.FiltraParametros("Accion IN (1,2)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If dr("Accion").ToString = "1" Then + If Not ObjUsuarios.AddCuentasBancariasAsignar(CveUsuario, dr("CveCuenta").ToString.ToEntero) Then + TieneError = True + Exit For + End If + ElseIf dr("Accion").ToString = "2" Then + If Not ObjUsuarios.RemoveCuentasBancariasAsignar(CveUsuario, dr("CveCuenta").ToString.ToEntero) Then + TieneError = True + Exit For + End If + End If + End If + Next + End If + + 'GUARDA MODULOS + If Not TieneError Then + For Each Row As GridViewRow In GvModulosAsignar.Rows + If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then + If Not ObjUsuarios.RemoveModulosAsignar(CveUsuario, Row.DataKey("CveModulo").ToEntero) Then + TieneError = True + Exit For + End If + ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then + If Not ObjUsuarios.AddModulosAsignar(CveUsuario, Row.DataKey("CveModulo").ToEntero) Then + TieneError = True + Exit For + End If + End If + Next + End If + + 'GUARDA PERMISOS + If Not TieneError Then + For Each Row As GridViewRow In GvPermisosAsignar.Rows + If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then + If Not ObjUsuarios.RemovePermisosAsignar(CveUsuario, Row.DataKey("CvePermiso").ToEntero) Then + TieneError = True + Exit For + End If + ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then + If Not ObjUsuarios.AddPermisosAsignar(CveUsuario, Row.DataKey("CvePermiso").ToEntero) Then + TieneError = True + Exit For + End If + End If + Next + End If + + 'GUARDA INDICADORES + If Not TieneError Then + For Each Row As GridViewRow In GvIndicadoresAsignar.Rows + If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then + If Not ObjUsuarios.RemoveIndicadoresAsignar(CveUsuario, Row.DataKey("CveIndicador").ToEntero) Then + TieneError = True + Exit For + End If + ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then + If Not ObjUsuarios.AddIndicadoresAsignar(CveUsuario, Row.DataKey("CveIndicador").ToEntero) Then + TieneError = True + Exit For + End If + End If + Next + End If + + 'GUARDA EMPRESAS + If Not TieneError Then + For Each Row As GridViewRow In GvEmpresasAsignar.Rows + If Row.DataKey("TienePermiso").ToEntero > 0 AndAlso Not Row.FCCheckBox("ChkP").Checked Then + If Not ObjUsuarios.RemoveEmpresasAsignar(CveUsuario, Row.DataKey("CveEmpresa").ToEntero) Then + TieneError = True + Exit For + End If + ElseIf Row.FCCheckBox("ChkP").Checked AndAlso Not Row.DataKey("TienePermiso").ToEntero > 0 Then + If Not ObjUsuarios.AddEmpresasAsignar(CveUsuario, Row.DataKey("CveEmpresa").ToEntero) Then + TieneError = True + Exit For + End If + End If + Next + End If + + 'ELIMINA YA AGREGADOS EMPRESAS + If Not TieneError Then + For Each dr As DataRow In DTEmpresasAsignar.FiltraParametros("TienePermiso IN (-2)").Rows + If DtEmpresasUsuario.FiltraParametros(String.Format("CveEmpresa = {0}", dr("CveEmpresa").ToString.ToEntero)).Rows.Count > 0 Then + If Not ObjUsuarios.RemoveEmpresasAsignar(CveUsuario, dr("CveEmpresa").ToString.ToEntero) Then + TieneError = True + Exit For + End If + End If + Next + End If + + Catch ex As Exception + TieneError = True + OnError("Ocurrió un error al guardar el usuario", ex) + End Try + + If Not TieneError Then If EsNuevoUsuario Then EnviaCorreo() @@ -1302,11 +1301,11 @@ Partial Class Sistemas_UsuarioDetalle End If - ObjUsuarios.Dispose() - ObjSubProyectos.Dispose() - ObjOC.Dispose() - ObjOS.Dispose() - Indicador.Dispose() + ObjUsuarios.Dispose() + ObjSubProyectos.Dispose() + ObjOC.Dispose() + ObjOS.Dispose() + Indicador.Dispose() ObjBancos.Dispose() End Sub @@ -1331,26 +1330,26 @@ Partial Class Sistemas_UsuarioDetalle ' Application("GlobalDTProyectosUsuarios") = Nothing ' TieneError = True 'End If - End If - - 'RECARGA GLOBAL BANCOS - 'If ObjBancos.GetBancosCuentasUsuarios(-1) Then - GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa) = Nothing 'ObjBancos.DtResultados - ' End If - - 'RECARGA GLOBAL ESTATUS + End If + + 'RECARGA GLOBAL BANCOS + 'If ObjBancos.GetBancosCuentasUsuarios(-1) Then + GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa) = Nothing 'ObjBancos.DtResultados + ' End If + + 'RECARGA GLOBAL ESTATUS If ObjOC.GetEstatus() Then Application("GlobalDTOCEstatus") = ObjOC.DtResultados Else Application("GlobalDTOCEstatus") = Nothing - GlobalDTOCEstatusUsuarios(UsuarioActual.CveEmpresa) = Nothing - - 'If ObjOC.GetEstatusUsuarios(-1, -1, -1, -1, -1) Then Application("GlobalDTOCEstatusUsuarios") = ObjOC.DtResultados Else Application("GlobalDTOCEstatusUsuarios") = Nothing - - - 'RECARGA GLOBAL ALMACEN - 'If ObjUsuarios.GetAlmacen(-1, UsuarioActual.CveEmpresa) Then Application("GlobalDTAlmacenUsuarios") = ObjUsuarios.DtResultados Else Application("GlobalDTAlmacenUsuarios") = Nothing - GlobalDTAlmacenUsuarios(-1, UsuarioActual.CveEmpresa) = Nothing - - 'RECARGA GLOBAL EMPRESAS USUARIOS + GlobalDTOCEstatusUsuarios(UsuarioActual.CveEmpresa) = Nothing + + 'If ObjOC.GetEstatusUsuarios(-1, -1, -1, -1, -1) Then Application("GlobalDTOCEstatusUsuarios") = ObjOC.DtResultados Else Application("GlobalDTOCEstatusUsuarios") = Nothing + + + 'RECARGA GLOBAL ALMACEN + 'If ObjUsuarios.GetAlmacen(-1, UsuarioActual.CveEmpresa) Then Application("GlobalDTAlmacenUsuarios") = ObjUsuarios.DtResultados Else Application("GlobalDTAlmacenUsuarios") = Nothing + GlobalDTAlmacenUsuarios(-1, UsuarioActual.CveEmpresa) = Nothing + + 'RECARGA GLOBAL EMPRESAS USUARIOS If ObjUsuarios.GetUsuariosEmpresas(-1) Then Application("GlobalDTUsuarios") = ObjUsuarios.DtResultados Application("GlobalDTUsuarioResponsable") = ObjUsuarios.DtResultados.FiltraParametros("ProveedoresResponsables > 0") @@ -1409,10 +1408,10 @@ Partial Class Sistemas_UsuarioDetalle Catch ex As Exception OnError("Ocurrió error al mandar MAIL", ex) End Try - End Sub + End Sub #End Region - - + + #Region " E L I M I N A R - U S U A R I O " Protected Sub BtnEliminar_Click(sender As Object, e As System.EventArgs) Handles BtnEliminar.Click ''DENTRO DEL PROCEDIMIENTO ELIMINA TODO LO RELACIONADO CON EL USUARIO (ALMACENES, SUBPROYECTOS, ACCESO A EMPRESAS...) @@ -1424,10 +1423,10 @@ Partial Class Sistemas_UsuarioDetalle Alert("Ocurrió un error al eliminar el usuario. Por favor vuelva a intentar", TipoMensaje.MsgError) End If ObjUsuario.Dispose() - End Sub + End Sub #End Region - - + + #Region " CONTRASEÑA " Protected Sub LnkRestablecer_Click(sender As Object, e As EventArgs) Handles LnkRestablecer.Click Dim Usuario As New ClsSisUsuarios @@ -1441,15 +1440,15 @@ Partial Class Sistemas_UsuarioDetalle Protected Sub LnkVerPass_Click(sender As Object, e As EventArgs) Handles LnkVerPass.Click Alert(Extensiones.Decripta(Password)) - End Sub + End Sub Protected Sub LnkVerCodigoAcceso_Click(sender As Object, e As EventArgs) Handles LnkVerCodigoAcceso.Click Alert(CodigoAcceso) - End Sub - - + End Sub + + #End Region - - + + #Region "TAB - ASIGNACIONES" Protected Sub DdlEmpresaAsignaciones_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlEmpresaAsignaciones.SelectedIndexChanged @@ -1511,8 +1510,8 @@ Partial Class Sistemas_UsuarioDetalle DtAsignacionesMultiEmpresa.Columns.Add("CveSucursal", GetType(Integer)) DtAsignacionesMultiEmpresa.Columns.Add("CveAlmacen", GetType(Integer)) DtAsignacionesMultiEmpresa.Columns.Add("CveTipoDocumento", GetType(String)) - End Sub - + End Sub + #Region " PROYECTOS-SUBPROYECTOS " Private Sub CargaProyectos() DdlProyecto.Items.Clear() @@ -1585,11 +1584,11 @@ Partial Class Sistemas_UsuarioDetalle Protected Sub CboProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProyecto.SelectedIndexChanged CargaSubProyectos(DdlProyecto.SelectedValue.ToEntero, DdlEmpresaAsignaciones.SelectedValue.ToEntero()) End Sub - Private Sub CargaSubProyectos(Optional CveProyectoFiltrado As Integer = -1, Optional CveEmpresaFiltro As Integer = -1) - + Private Sub CargaSubProyectos(Optional CveProyectoFiltrado As Integer = -1, Optional CveEmpresaFiltro As Integer = -1) + Dim CveEmpresaRef As Integer = UsuarioActual.CveEmpresa - If CveEmpresaFiltro > 0 Then - CveEmpresaRef = CveEmpresaFiltro + If CveEmpresaFiltro > 0 Then + CveEmpresaRef = CveEmpresaFiltro End If DdlSubProyecto.Items.Clear() @@ -1900,8 +1899,8 @@ Partial Class Sistemas_UsuarioDetalle End If End If ChkAsignarAllProyectos.Checked = False - End Sub - + End Sub + #Region "GV SUBPROYECTOS" Protected Sub GvSubProyectos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvSubProyectos.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then @@ -2003,14 +2002,14 @@ Partial Class Sistemas_UsuarioDetalle GvSubProyectos.EditIndex = -1 CargaGvSubProyectos() - End Sub - + End Sub + #End Region - + #End Region - + #Region " ALMACENES " - + Private Function GetAlmacenesSinGV() As String Dim SB As New StringBuilder Dim prefix As String = "" @@ -2119,8 +2118,8 @@ Partial Class Sistemas_UsuarioDetalle Private Sub CargaGVAlmacen() GvAlmacenes.DataSource = DtAlmacenes.FiltraParametros(String.Format("CveEmpresa = {0} And (isnull(Accion,0) < 2 Or Accion = 4)", DdlEmpresaAsignaciones.SelectedValue.ToEntero)) GvAlmacenes.DataBind() - End Sub - + End Sub + #Region "GV ALMACENES" Protected Sub GvAlmacenes_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvAlmacenes.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then @@ -2207,11 +2206,11 @@ Partial Class Sistemas_UsuarioDetalle GvAlmacenes.EditIndex = -1 CargaGVAlmacen() - End Sub + End Sub #End Region - + #End Region - + #Region " CUENTAS BANCARIAS " Private Sub CargaCuentasBancarias() DdlCuentasBancarias.Items.Clear() @@ -2274,9 +2273,9 @@ Partial Class Sistemas_UsuarioDetalle DtCuentasBancarias.AcceptChanges() CargaGvCuentasBancarias() - End Sub + End Sub #End Region - + #Region " ESTATUS DE ÓRDENES DE COMPRA" Private Sub CargaEstatusOrdenesCompra() ' Exit Sub @@ -2470,20 +2469,20 @@ Partial Class Sistemas_UsuarioDetalle Else CargaGridEstatusUsuarioOC("OC") End If - End Sub + End Sub #Region "GRIDVIEW" - - Protected Sub GvEstatusUsuariosREQ_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEstatusUsuariosREQ.RowDataBound - If e.Row.RowType = DataControlRowType.Header Then - For i As Integer = 2 To GvEstatusUsuariosREQ.Columns.Count - 1 + + Protected Sub GvEstatusUsuariosREQ_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEstatusUsuariosREQ.RowDataBound + If e.Row.RowType = DataControlRowType.Header Then + For i As Integer = 2 To GvEstatusUsuariosREQ.Columns.Count - 1 Dim CveEstatus As Integer = GvEstatusUsuariosREQ.Columns(i).FooterText.ToEntero Dim idIndex As Integer = i - 1 - If CveEstatus > -1 Then - e.Row.FCLabel($"LblTituloEstatusREQ{idIndex}").Text = GvEstatusUsuariosREQ.Columns(i).HeaderText - End If - Next - End If - + If CveEstatus > -1 Then + e.Row.FCLabel($"LblTituloEstatusREQ{idIndex}").Text = GvEstatusUsuariosREQ.Columns(i).HeaderText + End If + Next + End If + If e.Row.RowType = DataControlRowType.DataRow Then Dim tmpT As DataTable = DTEstatusSubProyectos.FiltraParametros(String.Format("CveSubProyecto = {0}", e.Row.DBCampo("CveSubProyecto").ToString)) @@ -2610,18 +2609,18 @@ Partial Class Sistemas_UsuarioDetalle Next End If End Sub - Protected Sub GvEstatusUsuariosOC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEstatusUsuariosOC.RowDataBound - - If e.Row.RowType = DataControlRowType.Header Then - For i As Integer = 2 To GvEstatusUsuariosOC.Columns.Count - 1 + Protected Sub GvEstatusUsuariosOC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEstatusUsuariosOC.RowDataBound + + If e.Row.RowType = DataControlRowType.Header Then + For i As Integer = 2 To GvEstatusUsuariosOC.Columns.Count - 1 Dim CveEstatus As Integer = GvEstatusUsuariosOC.Columns(i).FooterText.ToEntero Dim idIndex As Integer = i - 1 - If CveEstatus > -1 Then - e.Row.FCLabel($"LblTituloEstatus{idIndex}").Text = GvEstatusUsuariosOC.Columns(i).HeaderText - End If - Next - End If - + If CveEstatus > -1 Then + e.Row.FCLabel($"LblTituloEstatus{idIndex}").Text = GvEstatusUsuariosOC.Columns(i).HeaderText + End If + Next + End If + If e.Row.RowType = DataControlRowType.DataRow Then Dim tmpT As DataTable = DTEstatusSubProyectos.FiltraParametros(String.Format("CveSubProyecto = {0}", e.Row.DBCampo("CveSubProyecto").ToString)) @@ -2634,7 +2633,7 @@ Partial Class Sistemas_UsuarioDetalle Dim ImgClasificaciones As LinkButton = e.Row.FCLinkButton($"ImgClasificaciones{idIndex}") Dim hdnCveEstatusUsuarios As HiddenField = e.Row.FCHiddenField($"hdnCveEstatusUsuarios{idIndex}") Dim lblSuperior As Label = e.Row.FCLabel($"lblSuperior{idIndex}") - Dim lblLimites As Label = e.Row.FCLabel($"lblLimites{idIndex}") + Dim lblLimites As Label = e.Row.FCLabel($"lblLimites{idIndex}") chkEstatus.CssClass = $"chkEstatus{idIndex}" Dim dtTemp As New DataTable @@ -2749,13 +2748,13 @@ Partial Class Sistemas_UsuarioDetalle End If Next End If - End Sub - - + End Sub + + #End Region - + #End Region - + #Region "ESTATUS DE ORDENES DE SERVICIO" Private Sub CargaEstatusOS() CreaGridEstatusOS() @@ -2908,9 +2907,9 @@ Partial Class Sistemas_UsuarioDetalle End If Next Next - End Sub + End Sub #End Region - + #Region " ESTATUS ORDENES DE COMPRA - CLASIFICACIONES USUARIO OC " Private Sub InicializaEstasClasificacionesOC() @@ -2972,15 +2971,15 @@ Partial Class Sistemas_UsuarioDetalle ObjOC.Dispose() CargaGVOCClasificaciones() - End Sub - - - + End Sub + + + #End Region - + #End Region - - + + #Region "TAB - ACCESO MODULOS" Public Sub CargaModulosAcceso() Dim ObjPermisos As New ClsSisUsuarios @@ -3066,10 +3065,10 @@ Partial Class Sistemas_UsuarioDetalle Alert("Los Permisos se eliminaron correctamente.", TipoMensaje.MsgInformacion, "window.location.href=""/Sistemas/Usuarios.aspx""") End If ObjUsuario.Dispose() - End Sub + End Sub #End Region - - + + #Region "TAB - PERMISO MODULOS" Public Sub CargaModulosPermisos() Dim ObjProcesos As New ClsSisUsuarios @@ -3169,10 +3168,10 @@ Partial Class Sistemas_UsuarioDetalle Alert("Los Procesos se eliminaron correctamente.", TipoMensaje.MsgInformacion, "window.location.href=""/Sistemas/Usuarios.aspx""") End If ObjUsuario.Dispose() - End Sub + End Sub #End Region - - + + #Region "TAB - ACCESO EMPRESAS" Private Sub CargaEmpresas() Dim ClsUsuarios As New ClsSisUsuarios @@ -3362,10 +3361,10 @@ Partial Class Sistemas_UsuarioDetalle Private Sub LnkRenviaCorreo_Click(sender As Object, e As EventArgs) Handles LnkRenviaCorreo.Click EnviaCorreo() Alert("Correo enviado con exito.", TipoMensaje.MsgInformacion) - End Sub + End Sub #End Region - - + + #Region "TAB - RESTRICCIONES ACCESO " Private Sub InicializaRestricciones() CargaDtRestricciones() @@ -3578,8 +3577,8 @@ Partial Class Sistemas_UsuarioDetalle CargaGvRestricciones() RegistraScript("$('#DivAgregarRestricción').modal('hide')") - End Sub - + End Sub + #Region " GV " Private Sub GvRestricciones_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvRestricciones.RowCommand @@ -3669,13 +3668,13 @@ Partial Class Sistemas_UsuarioDetalle End If CargaGvRestricciones() - End Sub + End Sub #End Region - - + + #End Region - - + + #Region "TAB - INDICADORES" Public Sub CargaGridIndicadores() Dim Objeto As New ClsIndicadores @@ -3692,11 +3691,11 @@ Partial Class Sistemas_UsuarioDetalle e.Row.FCCheckBox("chkIndicador").Checked = True End If End If - End Sub - + End Sub + #End Region - - + + #Region " CLONAR USUARIO " Private Sub InicializaClonarUsuario() DdlUsuarioClonar.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa) @@ -3744,16 +3743,16 @@ Partial Class Sistemas_UsuarioDetalle End If - ObjUsuarios.Dispose() - - LblClonarMensaje.Text = $"En el usuario {TxtUsuario.Text} se reemplazará la información del usuario {DdlUsuarioClonar.SelectedItem.Text} con las siguientes secciones que seleccione." + ObjUsuarios.Dispose() + + LblClonarMensaje.Text = $"En el usuario {TxtUsuario.Text} se reemplazará la información del usuario {DdlUsuarioClonar.SelectedItem.Text} con las siguientes secciones que seleccione." Else LblClonarMensaje.Text = "" - End If - - - - + End If + + + + UpClonarUsuario.Update() End Sub Protected Sub BtnClonar_Click(sender As Object, e As EventArgs) @@ -3782,12 +3781,12 @@ Partial Class Sistemas_UsuarioDetalle 'CargaDatos() Return Retorno - End Function - - + End Function + + #End Region - - + + #Region " MANDA CORREO " Private Sub MandaCorreo(Asunto As String, Para As String, Body As String) Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para) @@ -3795,13 +3794,13 @@ Partial Class Sistemas_UsuarioDetalle Dim Mail As New ClsSisMail() 'Mail.MandaCorreo(ClsPaginas.EmpresaNotificaciones, Para, Asunto, "", "", Nothing, Body) Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body) - End Sub - - - + End Sub + + + #End Region - - + + #Region " ASIGNACIONES DE PERMISOS " Protected Sub DdlEmpresaAsignarPermiso_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlEmpresaAsignarPermiso.SelectedIndexChanged CargaAsignaciones() @@ -3825,8 +3824,8 @@ Partial Class Sistemas_UsuarioDetalle CargaDtEstatusOC() CargaGvEstatusOC() - End Sub - + End Sub + #Region " EMPRESAS " Public Sub CargaDTEmpresasAsignar() Dim ObjPermisos As New ClsSisUsuarios @@ -3885,10 +3884,10 @@ Partial Class Sistemas_UsuarioDetalle CargaAsignaciones() - End Sub - + End Sub + #End Region - + #Region " ROLES " Private Sub CargaDtRolesAsignar() Dim ClsUsuarios As New ClsSisUsuarios @@ -3977,9 +3976,9 @@ Partial Class Sistemas_UsuarioDetalle DTRolesAsignar.AcceptChanges() CargaGVRolesAsignar() - End Sub + End Sub #End Region - + #Region " ALMACENES " Private Sub CargaDtAlmacenAsignar() Dim ClsUsuarios As New ClsSisUsuarios @@ -4070,11 +4069,11 @@ Partial Class Sistemas_UsuarioDetalle DtAlmacenesAsignar.AcceptChanges() CargaGVAlmacenAsignar() - End Sub - - + End Sub + + #End Region - + #Region " PROYECTOS-SUBPROYECTOS " Private Sub CargaDtSubProyectosAsignar() Dim ClsUsuarios As New ClsSisUsuarios @@ -4185,10 +4184,10 @@ Partial Class Sistemas_UsuarioDetalle DtSubProyectosAsignar.AcceptChanges() CargarGvSubProyectosAsignar() - End Sub - + End Sub + #End Region - + #Region " CUENTAS BANCARIAS " Private Sub CargaCuentasBancariasAsignar() DdlCuentasBancariasAsignar.Items.Clear() @@ -4273,9 +4272,9 @@ Partial Class Sistemas_UsuarioDetalle DtCuentasBancariasAsignar.AcceptChanges() CargaGvCuentasBancariasAsignar() - End Sub + End Sub #End Region - + #Region " MODULOS " Public Sub CargaDTModulosAsignar() Dim ObjPermisos As New ClsSisUsuarios @@ -4310,10 +4309,10 @@ Partial Class Sistemas_UsuarioDetalle End If End If - End Sub - + End Sub + #End Region - + #Region " PERMISOS " Public Sub CargaDTPermisosAsignar() Dim ObjPermisos As New ClsSisUsuarios @@ -4348,9 +4347,9 @@ Partial Class Sistemas_UsuarioDetalle End If End If - End Sub + End Sub #End Region - + #Region " INDICADORES " Public Sub CargaDTIndicadoresAsignar() Dim ObjIndicadores As New ClsSisUsuarios @@ -4378,13 +4377,13 @@ Partial Class Sistemas_UsuarioDetalle End If End If - End Sub + End Sub #End Region - - + + #End Region - - + + #Region " USUARIO CONTROLADO " Private Sub InicializaUsuarioControlado() Dim ClsUsuarios As New ClsSisUsuarios @@ -4434,12 +4433,12 @@ Partial Class Sistemas_UsuarioDetalle End If ClsUsuarios.Dispose() - End Sub + End Sub #End Region - - + + #Region "C O N T O L E S DE U S U A R I O S" - + #Region "ESTATUS DE ÓRDENES DE COMPRA" Private Sub CargaDtEstatusOCPermisos() Dim ClsUsuarios As New ClsSisUsuarios @@ -4560,10 +4559,10 @@ Partial Class Sistemas_UsuarioDetalle DTEstatusOC = dt DTEstatusOCAsignar = dt - End Sub + End Sub #End Region - - + + #Region "GV ESTATUS DE OC" Protected Sub GvEstatusOC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEstatusOC.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then @@ -4674,11 +4673,11 @@ Partial Class Sistemas_UsuarioDetalle GvEstatusUsuariosOC.Columns(i).Visible = (dtValida IsNot Nothing AndAlso dtValida.Rows.Count = 1) End If Next - End Sub - + End Sub + #End Region #End Region - + Protected Sub LnkAgregarClasificacion_Click(sender As Object, e As EventArgs) If DtClasificaciones IsNot Nothing Then Dim CveClasificacion As Integer = DdlClasificacion.SelectedValue.ToEntero @@ -4805,10 +4804,10 @@ Partial Class Sistemas_UsuarioDetalle - End Sub - + End Sub + #Region "USUARIO RESPONSABLE" - + Protected Sub BtnUpdateUsuarioResponsable_Click(sender As Object, e As EventArgs) Dim ObjUsuarios As New ClsSisUsuarios If ObjUsuarios.UpdateUsuarioResponsableMasivo(CveUsuario, DdlUsuarioResponsable.SelectedValue.ToEntero) Then @@ -4816,10 +4815,10 @@ Partial Class Sistemas_UsuarioDetalle RegistraScript("$('#DivUpdateUsuarioResponsable').modal('hide')") End If ObjUsuarios.Dispose() - End Sub - + End Sub + #End Region - + Protected Sub LnkAutorizarEquipo_Click(sender As Object, e As EventArgs) 'CveUsuario Dim AdsCodex As String = Encripta(String.Format("{0}_{1}_{2}", CveUsuario, DateTime.Now.Ticks, UsuarioActual.CveUsuario)) @@ -4833,63 +4832,63 @@ Partial Class Sistemas_UsuarioDetalle Protected Sub BtnCerrarSession_Click(sender As Object, e As EventArgs) 'ADSSession.ADSSessionConfig.SessionManager(ADSSession.OpcionSession.CerrarSession, CveUsuario:=CveUsuario) - Dim objlist As List(Of ADSSession.ADSSessionObj) = DirectCast(ADSSession.ADSSessionConfig.SessionManager(ADSSession.OpcionSession.getListasession, CveUsuario:=CveUsuario), List(Of ADSSession.ADSSessionObj)) - - For Each user As ADSSession.ADSSessionObj In objlist - If CveUsuario = user.CveUsuario Then 'AndAlso (CveEmpresa = -1 OrElse CveEmpresa = user.CveEmpresa) Then - Dim taspsig As String = user.ASPSIG '"94C6AC57E8599390A4B7B8AB41FEABEF466D9B31120BE06D78110E66265F1ACC5616297BF3B88EDCEE71EBCFE35484308F62C8017EAC29FB3F0FB45CEC09E8F03DFBB4A4DD890D45755B7A30185C6D01F20AEFA74BE3A25FD12D536B20DCB8D9940A3D95" - Dim tsessionID As String = user.SessionID - Dim url = System.Configuration.ConfigurationManager.AppSettings("urlcerrarSession").ToString() - Dim cookie As String = String.Format("ASP.NET_SessionId={0};.ASPXSIG={1}", tsessionID, taspsig) - sendURL(url, cookie) - End If + Dim objlist As List(Of ADSSession.ADSSessionObj) = DirectCast(ADSSession.ADSSessionConfig.SessionManager(ADSSession.OpcionSession.getListasession, CveUsuario:=CveUsuario), List(Of ADSSession.ADSSessionObj)) + + For Each user As ADSSession.ADSSessionObj In objlist + If CveUsuario = user.CveUsuario Then 'AndAlso (CveEmpresa = -1 OrElse CveEmpresa = user.CveEmpresa) Then + Dim taspsig As String = user.ASPSIG '"94C6AC57E8599390A4B7B8AB41FEABEF466D9B31120BE06D78110E66265F1ACC5616297BF3B88EDCEE71EBCFE35484308F62C8017EAC29FB3F0FB45CEC09E8F03DFBB4A4DD890D45755B7A30185C6D01F20AEFA74BE3A25FD12D536B20DCB8D9940A3D95" + Dim tsessionID As String = user.SessionID + Dim url = System.Configuration.ConfigurationManager.AppSettings("urlcerrarSession").ToString() + Dim cookie As String = String.Format("ASP.NET_SessionId={0};.ASPXSIG={1}", tsessionID, taspsig) + sendURL(url, cookie) + End If Next Alert("Sessión Cerrada") - End Sub - - Private Shared Function sendURL(ByVal URL As String, ByVal Optional Cookie As String = "", ByVal Optional maxTimeMilliseconds As Integer = 120000) As String - Dim resultado As String = "" - - Try - - Dim request As Net.HttpWebRequest = CType(Net.HttpWebRequest.Create(URL), Net.HttpWebRequest) - request.Timeout = maxTimeMilliseconds - request.Method = "POST" - request.ContentType = "text/xml; charset=utf-8" - - If Not String.IsNullOrEmpty(Cookie) Then - request.Headers.Add("Cookie", Cookie) - End If - - Using stream As IO.Stream = request.GetRequestStream() - - Using stmw As IO.StreamWriter = New IO.StreamWriter(stream) - stmw.Write("") - End Using - End Using - - Using response As Net.WebResponse = CType(request.GetResponse(), Net.WebResponse) - Using sr As IO.StreamReader = New IO.StreamReader(response.GetResponseStream()) - - resultado = sr.ReadToEnd() - sr.Close() - End Using - - End Using - request = Nothing - Catch ex As Exception - 'Extenciones.ApplicationParameter.GuardaLogEx(ex, $"SOAPAction : {SOAPAction} XML : {xml}") - End Try - - Return resultado - End Function - - Protected Sub LnkClonarUsuario_Click(sender As Object, e As EventArgs) - - RegistraScript("$('#DivClonar').modal('show');") - LblClonarMensaje.Text = "" - UpClonarUsuario.Update() - - End Sub - + End Sub + + Private Shared Function sendURL(ByVal URL As String, ByVal Optional Cookie As String = "", ByVal Optional maxTimeMilliseconds As Integer = 120000) As String + Dim resultado As String = "" + + Try + + Dim request As Net.HttpWebRequest = CType(Net.HttpWebRequest.Create(URL), Net.HttpWebRequest) + request.Timeout = maxTimeMilliseconds + request.Method = "POST" + request.ContentType = "text/xml; charset=utf-8" + + If Not String.IsNullOrEmpty(Cookie) Then + request.Headers.Add("Cookie", Cookie) + End If + + Using stream As IO.Stream = request.GetRequestStream() + + Using stmw As IO.StreamWriter = New IO.StreamWriter(stream) + stmw.Write("") + End Using + End Using + + Using response As Net.WebResponse = CType(request.GetResponse(), Net.WebResponse) + Using sr As IO.StreamReader = New IO.StreamReader(response.GetResponseStream()) + + resultado = sr.ReadToEnd() + sr.Close() + End Using + + End Using + request = Nothing + Catch ex As Exception + 'Extenciones.ApplicationParameter.GuardaLogEx(ex, $"SOAPAction : {SOAPAction} XML : {xml}") + End Try + + Return resultado + End Function + + Protected Sub LnkClonarUsuario_Click(sender As Object, e As EventArgs) + + RegistraScript("$('#DivClonar').modal('show');") + LblClonarMensaje.Text = "" + UpClonarUsuario.Update() + + End Sub + End Class diff --git a/Ventas/ClientesAbonar.aspx.vb b/Ventas/ClientesAbonar.aspx.vb index 95fe80359..6c53d676e 100644 --- a/Ventas/ClientesAbonar.aspx.vb +++ b/Ventas/ClientesAbonar.aspx.vb @@ -800,20 +800,31 @@ Partial Class Ventas_ClientesAbonar Dim FuncionalidadFluctuacionImpuestos As Boolean = If(UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False) Dim TipoCambioFluctuacion As Decimal = 1 Dim FechaUltimaFluctuacion As Date = MinFecha - If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then - If ObjIE.DtResultados.Rows.Count > 0 Then - Dim tFecha As Date = TxtFechaDocumento.Text.ToDate - Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) - Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & Fecha & "#", "Fecha DESC") - If drr IsNot Nothing Then - FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate - TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal - End If + Dim tFecha As Date = TxtFechaDocumento.Text.ToDate + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha) + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion < tFecha Then + FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion + TipoCambioFluctuacion = UltimaFluctuacion.TCFluctuacion End If End If + 'If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + ' If ObjIE.DtResultados.Rows.Count > 0 Then + ' Dim tFecha As Date = TxtFechaDocumento.Text.ToDate + ' Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) + ' Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & Fecha & "#", "Fecha DESC") + + ' If drr IsNot Nothing Then + ' FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate + ' TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal + ' End If + + ' End If + 'End If + If ObjMov.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPoliza) Then dtConceptos = ObjMov.DtResultados End If @@ -2554,24 +2565,35 @@ Partial Class Ventas_ClientesAbonar Dim CvePrePoliza As Integer = 0 Dim MsgError As String = "" - Dim ObjIE As New ClsBancos + 'Dim ObjIE As New ClsBancos Dim FechaUltimaFluctuacion As Date = MinFecha Dim TipoCambioFluctuacion As Decimal = 1 - If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then - If ObjIE.DtResultados.Rows.Count > 0 Then - Dim tFecha As Date = TxtFechaIncobrable.Text.ToDate - Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) - Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & Fecha & "#", "Fecha DESC") - If drr IsNot Nothing Then - FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate - TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal - End If + Dim tFecha As Date = TxtFechaIncobrable.Text.ToDate + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha) + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion < tFecha Then + FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion + TipoCambioFluctuacion = UltimaFluctuacion.TCFluctuacion End If End If - ObjIE.Dispose() + 'If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + ' If ObjIE.DtResultados.Rows.Count > 0 Then + ' Dim tFecha As Date = TxtFechaIncobrable.Text.ToDate + ' Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) + ' Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & Fecha & "#", "Fecha DESC") + + ' If drr IsNot Nothing Then + ' FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate + ' TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal + ' End If + + ' End If + 'End If + + 'ObjIE.Dispose() CvePrePoliza = ObjConta.AddPrePolizas("Bancos/ClientesAbonar/SaldarI", 47, 0, 0, 1, TxtFechaIncobrable.Text.ToDate, TxtObsSaldarIncobrable.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 40ec22a04..72d066785 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -4388,7 +4388,7 @@ Partial Class Ventas DdlTipoComprobante.Items.Insert(0, New ListItem("Devolucion", "Dev")) HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() - ViewState("CveDevolucion") = DbRowVenta("CveVentaPadre").ToString().ToEntero() + 'ViewState("CveDevolucion") = DbRowVenta("CveVentaPadre").ToString().ToEntero() Trsaldo.Visible = True HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) @@ -6286,7 +6286,7 @@ Partial Class Ventas Dim ValorAutorizacion As String = UsuarioActual.Empresa.Funcionalidad(595) 'OBLIGAR PAGO DE CONTADO SI EL CLIENTE NO PERMITE CREDITO - If UsuarioActual.Empresa.Funcionalidad(570) = "1" AndAlso Me.PermiteCredito = False AndAlso ((DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") AndAlso CveVenta < 1) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot") AndAlso EsCreaApartirDe) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso CveVenta > 0)) Then + If UsuarioActual.Empresa.Funcionalidad(570) = "1" AndAlso Me.PermiteCredito = False AndAlso ((DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") AndAlso CveVenta < 1) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso EsCreaApartirDe) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso CveVenta > 0)) Then RBLPago.SelectedValue = "2" RBLPago.Items(0).Enabled = False RBLPago_SelectedIndexChanged(Nothing, Nothing) @@ -14615,20 +14615,31 @@ Partial Class Ventas Dim FechaUltimaFluctuacion As Date = MinFecha Dim TipoCambioFluctuacion As Decimal = 1 - If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then - If ObjIE.DtResultados.Rows.Count > 0 Then - Dim tFecha As Date = Now 'gvr.DataKey("Fecha").ToDate - Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) - Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & Fecha & "#", "Fecha DESC") + Dim tFecha As Date = Now - If drr IsNot Nothing Then - FechaUltimaFluctuacion = drr("Fecha").ToString().ToDate - TipoCambioFluctuacion = drr("TipoCambio").ToString().ToDecimal - End If + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha) + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion < tFecha Then + FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion + TipoCambioFluctuacion = UltimaFluctuacion.TCFluctuacion End If End If + 'If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + ' If ObjIE.DtResultados.Rows.Count > 0 Then + ' Dim tFecha As Date = Now 'gvr.DataKey("Fecha").ToDate + ' Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) + ' Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & Fecha & "#", "Fecha DESC") + + ' If drr IsNot Nothing Then + ' FechaUltimaFluctuacion = drr("Fecha").ToString().ToDate + ' TipoCambioFluctuacion = drr("TipoCambio").ToString().ToDecimal + ' End If + + ' End If + 'End If + If DdlMoneda.SelectedValue.ToEntero() = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero() = 1 Then 'SI LA VENTA VIENE EN PESOS Y SE VA A PAGAR EN PESOS tipoCambioPago = 1 tipoCambioVenta = 1 @@ -23944,6 +23955,7 @@ Partial Class Ventas For Each Dr2 As DataRow In DtContratosSerieDetalle.FiltraParametros($"ConsecId = {Dr("CveContratoDetalle")}").Rows Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, factura.CveEmpresa, CveAlmacenExistenciasContrato, Serie:=Dr2("Serie").ToString(), FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1) If Existencia < 1 Then + GuardaLogAD($"El producto no tiene existencia: CvePS:{CveProducto},CveUnidad:{CveUnidad},Cantidad: {Cantidad},Existencia: {Existencia},CveAlmacen:{CveAlmacenExistenciasContrato},Serie:{Dr2("Serie").ToString()}") Return False End If @@ -23956,6 +23968,7 @@ Partial Class Ventas Else Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, factura.CveEmpresa, CveAlmacenExistenciasContrato, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1) If Existencia < Cantidad Then + GuardaLogAD($"El producto no tiene existencia: CvePS:{CveProducto},CveUnidad:{CveUnidad},Cantidad: {Cantidad},Existencia: {Existencia},CveAlmacen:{CveAlmacenExistenciasContrato}") Return False End If @@ -24728,24 +24741,34 @@ Partial Class Ventas Dim CvePrePoliza As Integer = 0 Dim MsgError As String = "" - Dim ObjIE As New ClsBancos + 'Dim ObjIE As New ClsBancos Dim FechaUltimaFluctuacion As Date = MinFecha Dim TipoCambioFluctuacion As Decimal = 1 - If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then - If ObjIE.DtResultados.Rows.Count > 0 Then - Dim tFecha As Date = TxtFechaSaldarVenta.Text.ToDate - Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) - Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & Fecha & "#", "Fecha DESC") - If drr IsNot Nothing Then - FechaUltimaFluctuacion = drr("Fecha").ToString().ToDate - TipoCambioFluctuacion = drr("TipoCambio").ToString().ToDecimal - End If + Dim tFecha As Date = TxtFechaSaldarVenta.Text.ToDate + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha) + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion < tFecha Then + FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion + TipoCambioFluctuacion = UltimaFluctuacion.TCFluctuacion End If End If + 'If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + ' If ObjIE.DtResultados.Rows.Count > 0 Then + ' Dim tFecha As Date = TxtFechaSaldarVenta.Text.ToDate + ' Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) + ' Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & Fecha & "#", "Fecha DESC") - ObjIE.Dispose() + ' If drr IsNot Nothing Then + ' FechaUltimaFluctuacion = drr("Fecha").ToString().ToDate + ' TipoCambioFluctuacion = drr("TipoCambio").ToString().ToDecimal + ' End If + + ' End If + 'End If + + ' ObjIE.Dispose() Dim IdCtaContable As Integer = IdCtaContClientes @@ -27728,20 +27751,29 @@ Partial Class Ventas TipoCambioFactura = TxtTipoCambio.Text.ToDecimal If DdlMoneda.SelectedValue.ToEntero() > 1 Then - Dim ObjIE As New ClsBancos - If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then - If ObjIE.DtResultados.Rows.Count > 0 Then - Dim tFecha As Date = TxtFecha.Text.ToDate - Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) - Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha > #" & Fecha & "#", "Fecha DESC") - - If drr IsNot Nothing Then - TipoCambioFactura = drr("TipoCambio").ToString().ToDecimal - End If + Dim tFecha As Date = TxtFecha.Text.ToDate + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha) + If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then + If UltimaFluctuacion.FechaFluctuacion > tFecha Then + TipoCambioFactura = UltimaFluctuacion.TCFluctuacion End If End If - ObjIE.Dispose() + + 'Dim ObjIE As New ClsBancos + 'If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then + ' If ObjIE.DtResultados.Rows.Count > 0 Then + ' Dim tFecha As Date = TxtFecha.Text.ToDate + ' Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) + ' Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha > #" & Fecha & "#", "Fecha DESC") + + ' If drr IsNot Nothing Then + ' TipoCambioFactura = drr("TipoCambio").ToString().ToDecimal + ' End If + + ' End If + 'End If + 'ObjIE.Dispose() Else TipoCambioFactura = 1 End If