diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 8c8c7823d..2732e461b 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -7405,6 +7405,26 @@ Public Class ClsVentas End Function + Public Function UpdateVentaAdjunto(CveVenta As Integer, Adjunto As String, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentaAdjuntoUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@Adjunto", SqlDbType.VarChar).Value = Adjunto + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el adjunto de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + #Region "IDisposable Support" diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index a29f07cc5..34c0b0272 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -4299,7 +4299,8 @@
- +    + diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index ced6650d3..abcd3658b 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -5023,7 +5023,7 @@ Partial Class Ventas If Adjunto <> "" Then BtnArchivoAdjunto.Text = Adjunto BtnArchivoAdjunto.Visible = True - BtnEliminarAdjunto.Visible = False + BtnEliminarAdjunto.Visible = True BtnAdjuntar.Visible = False BtnReemplazarAdjunto.Visible = True End If @@ -5956,10 +5956,7 @@ Partial Class Ventas 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR If (TmpDT.SUM("CantidadFacturadaRem") < TmpDT.SUM("Cantidad")) AndAlso TieneBloqueoPorCreditoVencimiento = 0 Then - BtnsFacturar.Visible = True - If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then - BtnsFacturar.Visible = UsuarioActual.TienePermisoProceso(60) - End If + BtnsFacturar.Visible = UsuarioActual.TienePermisoProceso(60) 'E119, bloquear la facturación de remisiones que no estén surtidas If UsuarioActual.CveEmpresa = 119 Then @@ -6010,7 +6007,7 @@ Partial Class Ventas ObjUsados.Dispose() - BtnsFacturar.Visible = True + BtnsFacturar.Visible = UsuarioActual.TienePermisoProceso(60) 'VERIFICA SI YA SE FACTURO COMPLETAMENTE If TmpDT.SUM("CantidadFacturadaRem") = TmpDT.SUM("Cantidad") Then @@ -6078,7 +6075,7 @@ Partial Class Ventas If DbRowVenta("TipoDocto").ToString().Contiene("Ped") Then 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR If TmpDT.SUM("CantidadFacturadaPed2") < TmpDT.SUM("Cantidad") Then - BtnsFacturar.Visible = True + BtnsFacturar.Visible = UsuarioActual.TienePermisoProceso(60) 'bloquear la facturación de remisiones que no estén surtidas If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then @@ -6142,7 +6139,7 @@ Partial Class Ventas 'Verifico si es su supervisor asignado If DTVendedores.Rows.Count > 0 Then If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 2 Then - BtnsFacturar.Visible = True + BtnsFacturar.Visible = UsuarioActual.TienePermisoProceso(60) BtnGenerarRemision.Visible = True Else BtnsFacturar.Visible = False @@ -6263,7 +6260,7 @@ Partial Class Ventas 'Verifico si es su supervisor asignado If DTVendedores.Rows.Count > 0 Then If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 2 Then - BtnsFacturar.Visible = True + BtnsFacturar.Visible = UsuarioActual.TienePermisoProceso(60) If UsuarioActual.TienePermisoProceso(199) Then BtnGenerarRemision.Visible = If(CveEstatus = 10, False, True) @@ -7785,7 +7782,7 @@ Partial Class Ventas 'SI NO TIENE AUTORIZACION, MANTIENE EL BLOQUEO POR CONDICIONES DE CREDITO If Autorizacion > 0 Then - BtnsFacturar.Visible = True + BtnsFacturar.Visible = UsuarioActual.TienePermisoProceso(60) TieneBloqueoPorCreditoVencimiento = 0 End If End If @@ -15633,7 +15630,7 @@ Partial Class Ventas If DT.Rows.Count > 0 Then 'Se agrega movimiento separado por la cuenta de ventas (ER) For Each Row2 As DataRow In DT.Rows - importeMovimiento = (TmpDTDetalle.SUM("Descuento", String.Format("CveClasificacion = {0} And CveSubProyecto = {1}", Row2("CveClasificacion"), Row2("CveSubProyecto"))).ToString().ToDecimal) * ValorMultiplicador + importeMovimiento = (TmpDTDetalle.SUM("Descuento", String.Format("CveClasificacion = {0} And CveSubProyecto = {1} AND PorcentajeIVA = {2}", Row2("CveClasificacion"), Row2("CveSubProyecto"), Row2("PorcentajeIVA"))).ToString().ToDecimal) * ValorMultiplicador importeMX = importeMovimiento * tipoCambio * Multiplicador FechaMovimiento = ObjFactura.FechaPago Concepto = $"{ObjFactura.SerieFolio} {If(Row2("CveClasificacion").ToString().ToEntero() > 0, GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = {Row2("CveClasificacion").ToString()}"), "")} - {If(Row2("CveSubProyecto").ToString().ToEntero() > 0, GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa).FiltroPrimeroValor("SubProyecto", $"CveSubProyecto = {Row2("CveSubProyecto").ToString()}"), "Sin SubProyecto Asignado")}" @@ -36309,12 +36306,16 @@ Partial Class Ventas End If My.Computer.FileSystem.MoveFile(fileItem.FileUrl, Path) - If File.Exists(Path) AndAlso Me.CveVenta > 0 Then - Using ObjVta As New ClsVentasTemp - If ObjVta.UpdateVentaAdjunto(Me.CveVenta, Adjunto, UsuarioActual.CveEmpresa) Then - Alert("Documento cargado", TipoMensaje.MsgInformacion) - End If - End Using + If File.Exists(Path) Then + If Me.CveVenta > 0 Then + Using ObjVta As New ClsVentas + If ObjVta.UpdateVentaAdjunto(Me.CveVenta, Adjunto, UsuarioActual.CveEmpresa) Then + Alert("Documento cargado", TipoMensaje.MsgInformacion) + End If + End Using + Else + Alert("Documento cargado", TipoMensaje.MsgInformacion) + End If End If BtnAdjuntar.Visible = False @@ -36363,9 +36364,20 @@ Partial Class Ventas Dim objVentas As New ClsVentas Dim Path As String Path = String.Format("{0}Ventas/{1}", UsuarioActual.Empresa.Ruta, Adjunto) + If File.Exists(Path) Then File.Delete(Path) + + If Me.CveVenta > 0 Then + Using ObjVta As New ClsVentasTemp + If ObjVta.UpdateVentaAdjunto(Me.CveVenta, "", UsuarioActual.CveEmpresa) Then + Alert("Documento eliminado", TipoMensaje.MsgInformacion) + End If + End Using + End If + End If + BtnAdjuntar.Visible = True BtnArchivoAdjunto.Text = "" BtnArchivoAdjunto.Visible = False @@ -38930,181 +38942,161 @@ Partial Class Ventas End Sub - Public Class ClsVentasTemp - Implements IDisposable + 'Public Class ClsVentasTemp + ' Implements IDisposable -#Region "Campos" + ' 'SQL + ' Private SqlConexion As SqlClient.SqlConnection + ' Private SqlAdapter As SqlClient.SqlDataAdapter + ' Private SqlCommand As SqlClient.SqlCommand + ' Private SqlTransacc As SqlClient.SqlTransaction + ' Private Data As DataTable + ' Private Dataset As DataSet - 'SQL - Private SqlConexion As SqlClient.SqlConnection - Private SqlAdapter As SqlClient.SqlDataAdapter - Private SqlCommand As SqlClient.SqlCommand - Private SqlTransacc As SqlClient.SqlTransaction - Private Data As DataTable - Private Dataset As DataSet + ' 'Atributos de la clase + ' Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + ' Private CveConexion As Integer = 0 + ' Private EsTransaccionCompartida As Boolean = False - 'Atributos de la clase - Private disposedValue As Boolean = False ' Para detectar llamadas redundantes - Private CveConexion As Integer = 0 - Private EsTransaccionCompartida As Boolean = False - -#End Region - -#Region "Propiedades" - Public ReadOnly Property DtResultados() As DataTable - Get - DtResultados = Data - End Get - End Property - -#End Region - - Public Function IniciaTransacSQL() As SqlClient.SqlTransaction - If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() - Return SqlTransacc - End Function - - Public Sub Commit() - SqlTransacc.Commit() - End Sub - Public Sub RollBack() - SqlTransacc.Rollback() - End Sub - - Sub New(Optional TransaccionCompartida As SqlClient.SqlTransaction = Nothing, Optional UsuarioActual As Usuario = Nothing) - - If TransaccionCompartida Is Nothing Then - SqlConexion = New SqlClient.SqlConnection - SqlConexion.ConnectionString = If(UsuarioActual IsNot Nothing, UsuarioActual.RutaDB, ClsPaginas.UsuarioActualRutaDB) - - Try - SqlConexion.Open() - Catch ex As Exception - OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) - End Try - Else - SqlConexion = TransaccionCompartida.Connection - SqlTransacc = TransaccionCompartida - EsTransaccionCompartida = True - End If - SqlAdapter = New SqlClient.SqlDataAdapter("", SqlConexion) - ConexionAdd() - - End Sub - Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) - With SqlAdapter.SelectCommand - .Parameters.Clear() - .CommandText = pStrSQL - .CommandType = TipoComando - End With - If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc - Data = New DataTable - End Sub - -#Region "Conexiones" - - Private Sub ConexionAdd() - If Not EsTransaccionCompartida AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then - Try - DataAdapter("PA_Sis_RegistrarConexion") - With SqlAdapter.SelectCommand.Parameters - .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name - .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}?{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) - .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output - End With - SqlAdapter.Fill(Data) - CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero - Catch ex As Exception - OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - - End If - End Sub - - Private Sub ConexionClose() - If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then - - DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) - - Try - SqlAdapter.Fill(Data) - - Catch ex As Exception - OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try - CveConexion = 0 - End If - - End Sub -#End Region + ' Public ReadOnly Property DtResultados() As DataTable + ' Get + ' DtResultados = Data + ' End Get + ' End Property - Public Function UpdateVentaAdjunto(CveVenta As Integer, Adjunto As String, CveEmpresa As Integer) As Boolean - Dim Retorno As Boolean = False - DataAdapter("PA_Vta_VentaAdjuntoUpdate") + ' Public Function IniciaTransacSQL() As SqlClient.SqlTransaction + ' If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() + ' Return SqlTransacc + ' End Function - With SqlAdapter.SelectCommand.Parameters - .Add("@CveVenta", SqlDbType.Int).Value = CveVenta - .Add("@Adjunto", SqlDbType.VarChar).Value = Adjunto - .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - End With + ' Public Sub Commit() + ' SqlTransacc.Commit() + ' End Sub + ' Public Sub RollBack() + ' SqlTransacc.Rollback() + ' End Sub - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - OnError("Ocurrió un error al actualizar el adjunto de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) - End Try + ' Sub New(Optional TransaccionCompartida As SqlClient.SqlTransaction = Nothing, Optional UsuarioActual As Usuario = Nothing) - Return Retorno - End Function + ' If TransaccionCompartida Is Nothing Then + ' SqlConexion = New SqlClient.SqlConnection + ' SqlConexion.ConnectionString = If(UsuarioActual IsNot Nothing, UsuarioActual.RutaDB, ClsPaginas.UsuarioActualRutaDB) + + ' Try + ' SqlConexion.Open() + ' Catch ex As Exception + ' OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) + ' End Try + ' Else + ' SqlConexion = TransaccionCompartida.Connection + ' SqlTransacc = TransaccionCompartida + ' EsTransaccionCompartida = True + ' End If + ' SqlAdapter = New SqlClient.SqlDataAdapter("", SqlConexion) + ' ConexionAdd() + + ' End Sub + ' Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) + ' With SqlAdapter.SelectCommand + ' .Parameters.Clear() + ' .CommandText = pStrSQL + ' .CommandType = TipoComando + ' End With + ' If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc + ' Data = New DataTable + ' End Sub + + ' Private Sub ConexionAdd() + ' If Not EsTransaccionCompartida AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + ' Try + ' DataAdapter("PA_Sis_RegistrarConexion") + ' With SqlAdapter.SelectCommand.Parameters + ' .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + ' .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}?{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + ' .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + ' End With + ' SqlAdapter.Fill(Data) + ' CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + ' Catch ex As Exception + ' OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + ' End Try + + ' End If + ' End Sub + + ' Private Sub ConexionClose() + ' If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + ' DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + + ' Try + ' SqlAdapter.Fill(Data) + + ' Catch ex As Exception + ' OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + ' End Try + ' CveConexion = 0 + ' End If + + ' End Sub -#Region "IDisposable Support" + ' Public Function UpdateVentaAdjunto(CveVenta As Integer, Adjunto As String, CveEmpresa As Integer) As Boolean + ' Dim Retorno As Boolean = False + ' DataAdapter("PA_Vta_VentaAdjuntoUpdate") + + ' With SqlAdapter.SelectCommand.Parameters + ' .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + ' .Add("@Adjunto", SqlDbType.VarChar).Value = Adjunto + ' .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + ' End With + + ' Try + ' SqlAdapter.Fill(Data) + ' Retorno = True + ' Catch ex As Exception + ' OnError("Ocurrió un error al actualizar el adjunto de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + ' End Try + + ' Return Retorno + ' End Function - ' IDisposable - Protected Overridable Sub Dispose(disposing As Boolean) - If Not Me.disposedValue Then - If disposing Then - ' TODO: dispose managed state (managed objects). + ' ' IDisposable + ' Protected Overridable Sub Dispose(disposing As Boolean) + ' If Not Me.disposedValue Then + ' If disposing Then + ' ' TODO: dispose managed state (managed objects). - If Not Data Is Nothing Then Data.Dispose() : Data = Nothing - If Not Dataset Is Nothing Then Dataset.Dispose() : Dataset = Nothing - If Not SqlAdapter Is Nothing Then SqlAdapter.Dispose() : SqlAdapter = Nothing - If Not SqlCommand Is Nothing Then SqlCommand.Dispose() : SqlCommand = Nothing - If Not SqlTransacc Is Nothing Then SqlTransacc.Dispose() : SqlTransacc = Nothing - If SqlConexion.State <> ConnectionState.Closed Then SqlConexion.Close() - If Not SqlConexion Is Nothing Then SqlConexion.Dispose() : SqlConexion = Nothing + ' If Not Data Is Nothing Then Data.Dispose() : Data = Nothing + ' If Not Dataset Is Nothing Then Dataset.Dispose() : Dataset = Nothing + ' If Not SqlAdapter Is Nothing Then SqlAdapter.Dispose() : SqlAdapter = Nothing + ' If Not SqlCommand Is Nothing Then SqlCommand.Dispose() : SqlCommand = Nothing + ' If Not SqlTransacc Is Nothing Then SqlTransacc.Dispose() : SqlTransacc = Nothing + ' If SqlConexion.State <> ConnectionState.Closed Then SqlConexion.Close() + ' If Not SqlConexion Is Nothing Then SqlConexion.Dispose() : SqlConexion = Nothing - End If + ' End If - ' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below. - ' TODO: set large fields to null. - End If - Me.disposedValue = True - End Sub + ' ' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below. + ' ' TODO: set large fields to null. + ' End If + ' Me.disposedValue = True + ' End Sub - ' TODO: override Finalize() only if Dispose(disposing As Boolean) above has code to free unmanaged resources. - 'Protected Overrides Sub Finalize() - ' ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. - ' Dispose(False) - ' MyBase.Finalize() - 'End Sub - - ' This code added by Visual Basic to correctly implement the disposable pattern. - Public Sub Dispose() Implements IDisposable.Dispose - ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. - ConexionClose() - Dispose(True) - GC.SuppressFinalize(Me) - End Sub -#End Region - End Class + ' ' This code added by Visual Basic to correctly implement the disposable pattern. + ' Public Sub Dispose() Implements IDisposable.Dispose + ' ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. + ' ConexionClose() + ' Dispose(True) + ' GC.SuppressFinalize(Me) + ' End Sub + 'End Class End Class