diff --git a/App_Code/ClsExportaciones.vb b/App_Code/ClsExportaciones.vb new file mode 100644 index 000000000..492523b4b --- /dev/null +++ b/App_Code/ClsExportaciones.vb @@ -0,0 +1,446 @@ +Option Explicit On +Option Strict On + +Imports System.Data +Imports System.Data.SqlClient +Imports Extensiones +Imports Modelos +Imports Profact.TimbraCFDI.Complementos.ComercioExterior10 + +Public Class ClsExportaciones + Implements IDisposable + +#Region "Campos" + + Private SqlConexion As SqlConnection + Private SqlAdapter As SqlDataAdapter + Private SqlTransacc As SqlTransaction + Private SqlCommand As SqlCommand + Private StrSQL As StringBuilder + Private Data As DataTable + Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIÓN + 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 + + Public Property CveExportacion As Integer + Public Property CveExportacionDetalle As Integer + +#End Region + + Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing) + + If TransaccionCompartida Is Nothing Then + SqlConexion = New SqlConnection + SqlConexion.ConnectionString = 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 + + SqlCommand = New SqlCommand("", SqlConexion) + SqlAdapter = New SqlDataAdapter("", SqlConexion) + StrSQL = New StringBuilder + ConexionAdd() + End Sub + + Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) + With SqlAdapter.SelectCommand + .Parameters.Clear() + .CommandText = StrSQL + .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 Function IniciaTransacSQL() As SqlTransaction + If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() + Return SqlTransacc + End Function + Public Sub RollBack() + If SqlTransacc IsNot Nothing Then SqlTransacc.Rollback() + SqlTransacc = Nothing + End Sub + Public Sub Commit() + If SqlTransacc IsNot Nothing Then SqlTransacc.Commit() + SqlTransacc = Nothing + End Sub + +#Region "EXPORTACIONES" + Public Function GetExportacion(Optional CveExportacion As Integer = -1, Optional CveEmpresa As Integer = -1, Optional FechaInicio As Date = MinFecha, Optional FechaFin As Date = MaxFecha) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Exp_ExportacionesRep") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveExportacion", SqlDbType.Int).Value = CveExportacion + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las Exportaciones.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function AddExportacion(NumeroPedimento As String, FechaPedimento As Date, CveVenta As Integer, TipoCambio As Decimal, TipoExportacion As Integer, CveExportacionEstatus As Integer, + CveClienteExportador As Integer, CveClienteImportador As Integer, CveClienteConsignatario As Integer, CveAgente As Integer, ClaveAduana As Integer, + CveProveedor As Integer, MedioTransporte As Integer, TipoContenedor As Integer, Sello1 As String, Sello2 As String, Sello3 As String, SCAC As String, + CAAT As String, ContenedorPlaca As String, CveEmpresa As Integer, CveUsuario As Integer, CveDirExportador As Integer, CveDirConsignatario As Integer, + CveIncoterm As Integer, Notas As String, CvePedimento As Integer, CveAgenteExtranjero As Integer) As Integer + Dim Retorno As Integer = -1 + DataAdapter("PA_Exp_ExportacionesAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@NumeroPedimento", SqlDbType.VarChar).Value = NumeroPedimento + .Add("@FechaPedimento", SqlDbType.Date).Value = FechaPedimento + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@TipoCambio", SqlDbType.Decimal).Value = TipoCambio + .Add("@TipoExportacion", SqlDbType.Int).Value = TipoExportacion + .Add("@CveExportacionEstatus", SqlDbType.Int).Value = CveExportacionEstatus + .Add("@CveClienteExportador", SqlDbType.Int).Value = CveClienteExportador + .Add("@CveClienteImportador", SqlDbType.Int).Value = CveClienteImportador + .Add("@CveClienteConsignatario", SqlDbType.Int).Value = CveClienteConsignatario + .Add("@CveAgente", SqlDbType.Int).Value = CveAgente + .Add("@ClaveAduana", SqlDbType.Int).Value = ClaveAduana + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@MedioTransporte", SqlDbType.Int).Value = MedioTransporte + .Add("@TipoContenedor", SqlDbType.Int).Value = TipoContenedor + .Add("@Sello1", SqlDbType.VarChar).Value = Sello1 + .Add("@Sello2", SqlDbType.VarChar).Value = Sello2 + .Add("@Sello3", SqlDbType.VarChar).Value = Sello3 + .Add("@SCAC", SqlDbType.VarChar).Value = SCAC + .Add("@CAAT", SqlDbType.VarChar).Value = CAAT + .Add("@ContenedorPlaca", SqlDbType.VarChar).Value = ContenedorPlaca + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveDirExportador", SqlDbType.Int).Value = CveDirExportador + .Add("@CveDirConsignatario", SqlDbType.Int).Value = CveDirConsignatario + .Add("@CveIncoterm", SqlDbType.Int).Value = CveIncoterm + .Add("@Notas", SqlDbType.VarChar).Value = Notas + .Add("@CvePedimento", SqlDbType.Int).Value = CvePedimento + .Add("@CveAgenteExtranjero", SqlDbType.Int).Value = CveAgenteExtranjero + + .Add("@CveExportacion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + Try + SqlAdapter.Fill(Data) + CveExportacion = SqlAdapter.SelectCommand.Parameters("@CveExportacion").Value.ToString.ToEntero + Retorno = CveExportacion + Catch ex As Exception + OnError("Ocurrió un error al guardar la Exportación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function UpdateExportacion(CveExportacion As Integer, NumeroPedimento As String, FechaPedimento As Date, CveVenta As Integer, TipoCambio As Decimal, TipoExportacion As Integer, CveExportacionEstatus As Integer, + CveClienteExportador As Integer, CveClienteImportador As Integer, CveClienteConsignatario As Integer, CveAgente As Integer, ClaveAduana As Integer, + CveProveedor As Integer, MedioTransporte As Integer, TipoContenedor As Integer, Sello1 As String, Sello2 As String, Sello3 As String, SCAC As String, + CAAT As String, ContenedorPlaca As String, CveEmpresa As Integer, CveUsuario As Integer, CveDirExportador As Integer, CveDirConsignatario As Integer, + CveIncoterm As Integer, Notas As String, CvePedimento As Integer, CveAgenteExtranjero As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Exp_ExportacionesUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveExportacion", SqlDbType.Int).Value = CveExportacion + .Add("@NumeroPedimento", SqlDbType.VarChar).Value = NumeroPedimento + .Add("@FechaPedimento", SqlDbType.Date).Value = FechaPedimento + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@TipoCambio", SqlDbType.Decimal).Value = TipoCambio + .Add("@TipoExportacion", SqlDbType.Int).Value = TipoExportacion + .Add("@CveExportacionEstatus", SqlDbType.Int).Value = CveExportacionEstatus + .Add("@CveClienteExportador", SqlDbType.Int).Value = CveClienteExportador + .Add("@CveClienteImportador", SqlDbType.Int).Value = CveClienteImportador + .Add("@CveClienteConsignatario", SqlDbType.Int).Value = CveClienteConsignatario + .Add("@CveAgente", SqlDbType.Int).Value = CveAgente + .Add("@ClaveAduana", SqlDbType.Int).Value = ClaveAduana + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@MedioTransporte", SqlDbType.Int).Value = MedioTransporte + .Add("@TipoContenedor", SqlDbType.Int).Value = TipoContenedor + .Add("@Sello1", SqlDbType.VarChar).Value = Sello1 + .Add("@Sello2", SqlDbType.VarChar).Value = Sello2 + .Add("@Sello3", SqlDbType.VarChar).Value = Sello3 + .Add("@SCAC", SqlDbType.VarChar).Value = SCAC + .Add("@CAAT", SqlDbType.VarChar).Value = CAAT + .Add("@ContenedorPlaca", SqlDbType.VarChar).Value = ContenedorPlaca + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveDirExportador", SqlDbType.Int).Value = CveDirExportador + .Add("@CveDirConsignatario", SqlDbType.Int).Value = CveDirConsignatario + .Add("@CveIncoterm", SqlDbType.Int).Value = CveIncoterm + .Add("@Notas", SqlDbType.VarChar).Value = Notas + .Add("@CvePedimento", SqlDbType.Int).Value = CvePedimento + .Add("@CveAgenteExtranjero", SqlDbType.Int).Value = CveAgenteExtranjero + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la Exportación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + Public Function RemoveExportacion(CveExportacion As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Exp_ExportacionesRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveExportacion", SqlDbType.Int).Value = CveExportacion + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la Exportación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function GetGastos(CveExportacion As Integer, Optional CveTG As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Exp_Exportaciones_TranspGastosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveExportacion", SqlDbType.Int).Value = CveExportacion + .Add("@CveTG", SqlDbType.Int).Value = CveTG + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los Gastos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + Public Function AddGastos(IncFletes As Decimal, IncSeguro As Decimal, IncEmbalajes As Decimal, IncEmbalaje As Decimal, IncConexos As Decimal, + DecFlete As Decimal, DecSeguro As Decimal, DecCarga As Decimal, DecDescarga As Decimal, DecOtros As Decimal, CveExportacion As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Exp_Exportaciones_TranspGastosAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@IncFletes", SqlDbType.Decimal).Value = IncFletes + .Add("@IncSeguro", SqlDbType.Decimal).Value = IncSeguro + .Add("@IncEmbalajes", SqlDbType.Decimal).Value = IncEmbalajes + .Add("@IncEmbalaje", SqlDbType.Decimal).Value = IncEmbalaje + .Add("@IncConexos", SqlDbType.Decimal).Value = IncConexos + .Add("@DecFlete", SqlDbType.Decimal).Value = DecFlete + .Add("@DecSeguro", SqlDbType.Decimal).Value = DecSeguro + .Add("@DecCarga", SqlDbType.Decimal).Value = DecCarga + .Add("@DecDescarga", SqlDbType.Decimal).Value = DecDescarga + .Add("@DecOtros", SqlDbType.Decimal).Value = DecOtros + .Add("@CveExportacion", SqlDbType.Int).Value = CveExportacion + + .Add("@CveTG", SqlDbType.Int).Direction = ParameterDirection.Output + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al guardar los Gastos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + Public Function UpdateGastos(IncFletes As Decimal, IncSeguro As Decimal, IncEmbalajes As Decimal, IncEmbalaje As Decimal, IncConexos As Decimal, + DecFlete As Decimal, DecSeguro As Decimal, DecCarga As Decimal, DecDescarga As Decimal, DecOtros As Decimal, CveExportacion As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Exp_Exportaciones_TranspGastosUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@IncFletes", SqlDbType.Decimal).Value = IncFletes + .Add("@IncSeguro", SqlDbType.Decimal).Value = IncSeguro + .Add("@IncEmbalajes", SqlDbType.Decimal).Value = IncEmbalajes + .Add("@IncEmbalaje", SqlDbType.Decimal).Value = IncEmbalaje + .Add("@IncConexos", SqlDbType.Decimal).Value = IncConexos + .Add("@DecFlete", SqlDbType.Decimal).Value = DecFlete + .Add("@DecSeguro", SqlDbType.Decimal).Value = DecSeguro + .Add("@DecCarga", SqlDbType.Decimal).Value = DecCarga + .Add("@DecDescarga", SqlDbType.Decimal).Value = DecDescarga + .Add("@DecOtros", SqlDbType.Decimal).Value = DecOtros + .Add("@CveExportacion", SqlDbType.Int).Value = CveExportacion + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar los Gastos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function +#End Region + +#Region "PARTIDAS" + Public Function GetPartidas(Optional CveEmpresa As Integer = -1, Optional CveExportacion As Integer = -1, Optional CveExportacionDetalle As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Exp_ExportacionesDetalleGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveExportacion", SqlDbType.Int).Value = CveExportacion + .Add("@CveExportacionDetalle", SqlDbType.Int).Value = CveExportacionDetalle + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las Partidas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function AddPartida(CvePS As Integer, CveUnidadMedida As Integer, Precio As Decimal, CveEmpresa As Integer, CveUsuario As Integer, CveExportacion As Integer, Cantidad As Decimal, + PesoUnitario As Decimal, CvePais As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Exp_ExportacionesDetalleAdd") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida + .Add("@Precio", SqlDbType.Decimal).Value = Precio + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveExportacion", SqlDbType.Int).Value = CveExportacion + .Add("@Cantidad", SqlDbType.Decimal).Value = Cantidad + .Add("@PesoUnitario", SqlDbType.Decimal).Value = PesoUnitario + .Add("@CvePais", SqlDbType.Int).Value = CvePais + + .Add("@CveExportacionDetalle", SqlDbType.Int).Direction = ParameterDirection.Output + End With + Try + SqlAdapter.Fill(Data) + CveExportacionDetalle = SqlAdapter.SelectCommand.Parameters("@CveExportacionDetalle").Value.ToString.ToEntero + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al guardar la Partida.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function UpdatePartida(CveExportacionDetalle As Integer, CvePS As Integer, CveUnidadMedida As Integer, Precio As Decimal, CveUsuario As Integer, Cantidad As Decimal, + PesoUnitario As Decimal, CvePais As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Exp_ExportacionesDetalleUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveExportacionDetalle", SqlDbType.Int).Value = CveExportacionDetalle + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@CveUnidadMedida", SqlDbType.Int).Value = CveUnidadMedida + .Add("@Precio", SqlDbType.Decimal).Value = Precio + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@Cantidad", SqlDbType.Decimal).Value = Cantidad + .Add("@PesoUnitario", SqlDbType.Decimal).Value = PesoUnitario + .Add("@CvePais", SqlDbType.Int).Value = CvePais + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar la Partida.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function + + Public Function RemovePartida(CveExportacionDetalle As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Exp_ExportacionesDetalleRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveExportacionDetalle", SqlDbType.Int).Value = CveExportacionDetalle + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar la Partida.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function +#End Region + +#Region "AGENTES" + Public Function GetAgentes(Optional CveAgente As Integer = -1, Optional CveEmpresa As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Exp_AgentesGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveAgente", SqlDbType.Int).Value = CveAgente + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los Agentes.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + End Function +#End Region + +#Region "IDisposable Support" + ' IDisposable + Protected Overridable Sub Dispose(disposing As Boolean) + If Not Me.disposedValue Then + If disposing Then + + If Not Data Is Nothing Then Data.Dispose() : Data = 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 + Me.disposedValue = True + End Sub + Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() + Dispose(True) + GC.SuppressFinalize(Me) + End Sub +#End Region + +End Class diff --git a/App_Code/ClsGenerales.vb b/App_Code/ClsGenerales.vb index 37a62c152..9df264da9 100644 --- a/App_Code/ClsGenerales.vb +++ b/App_Code/ClsGenerales.vb @@ -3017,6 +3017,45 @@ Public Class ClsGenerales OnError("Ocurrió un error al obtener los motivos de traslado del SAT", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) End Try Return Retorno + End Function + Public Function GetSATContenedores() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_SAT_ContenedoresGet") + With SqlAdapter.SelectCommand.Parameters + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los contenedores del SAT", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function GetSATMediosTransporte() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_SAT_MediosTransporteGet") + With SqlAdapter.SelectCommand.Parameters + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los medios de transporte del SAT", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function GetSATAduanasSeccion() As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Gral_SAT_AduanasSeccionGet") + With SqlAdapter.SelectCommand.Parameters + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener las secciones de aduanas del SAT", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno End Function Public Function GetSATTipoOperacion() As Boolean diff --git a/App_Code/ClsNominas.vb b/App_Code/ClsNominas.vb index 81615630c..e315a33e6 100644 --- a/App_Code/ClsNominas.vb +++ b/App_Code/ClsNominas.vb @@ -3391,7 +3391,7 @@ Public Class ClsNominas End Function #Region "MovtosPermanentes" - Public Function GetMovtoPermanenteRepFechas(cvePersonal As Int32, cveEmpresa As Int32, cveTipo As Int32, cveSaldo As Int32, cveEstatus As Int32, cveConcepto As Int32, STRFechaInicio As String, STRFechaFin As String) As Boolean + Public Function GetMovtoPermanenteRepFechas(cvePersonal As Int32, cveEmpresa As Int32, cveTipo As Int32, cveSaldo As Int32, cveEstatus As Int32, cveConcepto As Int32, STRFechaInicio As String, STRFechaFin As String, Optional CvePeriodo As Integer = -1) As Boolean Dim retorno As Boolean = False DataAdapter("PA_GetMovtoPermanenteRepFechas", CommandType.StoredProcedure) With SqlAdapter.SelectCommand.Parameters @@ -3401,6 +3401,7 @@ Public Class ClsNominas .Add("@CveSaldo", SqlDbType.Int).Value = cveSaldo .Add("@CveEstatus", SqlDbType.Int).Value = cveEstatus .Add("@CveConcepto", SqlDbType.Int).Value = cveConcepto + .Add("@CvePeriodo", SqlDbType.Int).Value = CvePeriodo .Add("@STRFechaInicio", SqlDbType.VarChar).Value = STRFechaInicio .Add("@STRFechaFin", SqlDbType.VarChar).Value = STRFechaFin End With diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 5753a6ec5..4e6967359 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -545,6 +545,51 @@ Public Class ClsPaginas Application(AppNombre) = value End Set End Property + Property GlobalDTSATContenedores() As DataTable + Get + Dim AppNombre As String = "GlobalDTSATContenedores" + If Application(AppNombre) Is Nothing Then + Dim ObjGrales As New ClsGenerales + If ObjGrales.GetSATContenedores() Then Application(AppNombre) = ObjGrales.DtResultados + ObjGrales.Dispose() + End If + GlobalDTSATContenedores = DirectCast(Application(AppNombre), DataTable) + End Get + Set(value As DataTable) + Dim AppNombre As String = "GlobalDTSATContenedores" + Application(AppNombre) = value + End Set + End Property + Property GlobalDTSATMediosTransporte() As DataTable + Get + Dim AppNombre As String = "GlobalDTSATMediosTransporte" + If Application(AppNombre) Is Nothing Then + Dim ObjGrales As New ClsGenerales + If ObjGrales.GetSATMediosTransporte() Then Application(AppNombre) = ObjGrales.DtResultados + ObjGrales.Dispose() + End If + GlobalDTSATMediosTransporte = DirectCast(Application(AppNombre), DataTable) + End Get + Set(value As DataTable) + Dim AppNombre As String = "GlobalDTSATMediosTransporte" + Application(AppNombre) = value + End Set + End Property + Property GlobalDTSATAduanasSeccion() As DataTable + Get + Dim AppNombre As String = "GlobalDTSATAduanasSeccion" + If Application(AppNombre) Is Nothing Then + Dim ObjGrales As New ClsGenerales + If ObjGrales.GetSATAduanasSeccion() Then Application(AppNombre) = ObjGrales.DtResultados + ObjGrales.Dispose() + End If + GlobalDTSATAduanasSeccion = DirectCast(Application(AppNombre), DataTable) + End Get + Set(value As DataTable) + Dim AppNombre As String = "GlobalDTSATAduanasSeccion" + Application(AppNombre) = value + End Set + End Property Property GlobalDTUnidadAduana() As DataTable Get Dim AppNombre As String = "GlobalDTUnidadAduana" @@ -3210,6 +3255,27 @@ Public Class ClsPaginas End Property #End Region #Region "***********************************************************************DT GENERALES**************************************************************************************" + Property GlobalDTGralAgentes(CveAgente As Integer, CveEmpresa As Integer) As DataTable + Get + Dim AppNombre As String = $"GlobalDTGralAgentes-{CveEmpresa}" + If Application(AppNombre) Is Nothing Then + Dim A As New ClsExportaciones + If A.GetAgentes(-1, CveEmpresa) Then Application(AppNombre) = A.DtResultados + A.Dispose() + End If + If CveAgente <> -1 Then + Dim Dv As New DataView(DirectCast(Application(AppNombre), DataTable), String.Format("CveAgente = {0}", CveAgente), "", DataViewRowState.CurrentRows) + GlobalDTGralAgentes = Dv.ToTable + Dv.Dispose() + Else + GlobalDTGralAgentes = DirectCast(Application(AppNombre), DataTable) + End If + End Get + Set(value As DataTable) + Dim AppNombre As String = $"GlobalDTGralAgentes-{CveEmpresa}" + Application(AppNombre) = value + End Set + End Property Property GlobalDTGralCategorias(CveEmpresa As Integer) As DataTable Get Dim AppNombre As String = $"GlobalDTGralCategorias-{CveEmpresa}" @@ -8125,12 +8191,12 @@ Public Class ClsPaginas 'If Not Archivo.Exists Or (UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso UsuarioActual.CveEmpresa = 197) Then Dim ObjProveedor As New ClsCompProveedores - If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, ObjOC.CveProveedor, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, EmpresaActual.CveEmpresa) Then - If ObjProveedor.DtResultados.Rows.Count > 0 Then - params.Add(New ReportParameter("PlazoPago", ObjProveedor.PlazoPago.ToString)) - End If + If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, ObjOC.CveProveedor, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, EmpresaActual.CveEmpresa) Then + If ObjProveedor.DtResultados.Rows.Count > 0 Then + params.Add(New ReportParameter("PlazoPago", ObjProveedor.PlazoPago.ToString)) End If - ObjProveedor.Dispose() + End If + ObjProveedor.Dispose() 'End If @@ -10524,6 +10590,10 @@ Public Class ClsPaginas PaginaDict.Add("/CxC/GestionCobranza.aspx".ToUpper(), 490) PaginaDict.Add("/CxC/RepCxCPeriodo.aspx".ToUpper(), 887) #End Region +#Region "Exportaciones" + PaginaDict.Add("/Export/RepExportaciones.aspx".ToUpper(), 77) + PaginaDict.Add("/Export/ExpDetalle.aspx".ToUpper(), 77) +#End Region #Region "Finanzas" PaginaDict.Add("/Finanzas/RepRazonesFinancieras.aspx".ToUpper(), 592) PaginaDict.Add("/Finanzas/FinanMetas.aspx".ToUpper(), 361) diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb index 12b98c61b..7c63cd39d 100644 --- a/Bancos/IE.aspx.vb +++ b/Bancos/IE.aspx.vb @@ -1553,6 +1553,9 @@ Partial Class Bancos_IE If trIEDevolucion.Visible And RBL.SelectedValue <> "C" Then CargaIEDevoluciones() End If + + CargaCuentasDepositos() + End Sub #End Region @@ -4084,8 +4087,13 @@ Partial Class Bancos_IE #Region " CUENTAS DEPOSITOS " 'Si la cuenta no esta activa, no la muestra. Private Sub CargaCuentasDepositos() - DdlCuentaDeposito.Items.Clear() + '¿DdlCuentaDeposito.Items.Clear() 'If DdlTipoTransaccion.SelectedValue.Contiene("2", "9") Then ' transferencias y layout + + DdlCuentaDeposito.ClearSelection() + DdlCuentaDeposito.SelectedValue = Nothing + DdlCuentaDeposito.Items.Clear() + trCuentaDeposito.Visible = False Dim dtc As DataTable = Nothing @@ -4099,73 +4107,165 @@ Partial Class Bancos_IE End If - ' If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor, CveCliente:=CveCliente, CvePersonal:=CvePersonal) Then - If dtc IsNot Nothing Then - - If DdlTipoTransaccion.SelectedValue = "9" And CveIE <= -1 Then - - DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'") - - If dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then - trCuentaDeposito.Visible = True - DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) - Else - Alert("El Beneficiario no tiene una cuenta activa en BBVA, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia) - End If - DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) - ElseIf DdlTipoTransaccion.SelectedValue = "17" And CveIE <= -1 Then - - If dtc.Rows.Count > 0 Then - DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" Estatus = 'True' ") - trCuentaDeposito.Visible = True - BtnGuardar.ToolTip = "" - Else - BtnGuardar.Enabled = False - Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia) - BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito" - - End If - DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) - UpGuardar.Update() - - Else - DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'") - If dtc.Rows.Count > 0 Then - trCuentaDeposito.Visible = True - DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) - - End If - End If - - Else - - If DdlTipoTransaccion.SelectedValue.Contiene("9", "17") And CveIE <= -1 Then - - BtnGuardar.Enabled = False - Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia) - BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito" - Else - trCuentaDeposito.Visible = True - BtnGuardar.Enabled = True - End If - - UpGuardar.Update() + Dim OpBanco As Integer = 1 + Dim CuentaBanco As String = DdlCuenta.SelectedItem.Text.ToUpper + If CuentaBanco.Contains("BBVA") Or CuentaBanco.Contains("BANCOMER") Then + OpBanco = 1 + 'ElseIf CuentaBanco.Contains("BAJIO") Then + ' OpBanco = 2 + ElseIf CuentaBanco.Contains("SCOTIA") Then + OpBanco = 3 End If + If DdlCuenta.SelectedValue = "-1" Then + BtnGuardar.Enabled = False + trCuentaDeposito.Visible = False + DdlCuentaDeposito.Items.Clear() + 'UpnCuentasPago.Update() + UpCuentaDeposito.Update() + Return + End If + + + '' If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor, CveCliente:=CveCliente, CvePersonal:=CvePersonal) Then + 'If dtc IsNot Nothing Then + + ' If DdlTipoTransaccion.SelectedValue = "9" And CveIE <= -1 Then + + ' DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'") + + ' If dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then + ' trCuentaDeposito.Visible = True + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' Else + ' Alert("El Beneficiario no tiene una cuenta activa en BBVA, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia) + ' End If + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' ElseIf DdlTipoTransaccion.SelectedValue = "17" And CveIE <= -1 Then + + ' If dtc.Rows.Count > 0 Then + ' DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" Estatus = 'True' ") + ' trCuentaDeposito.Visible = True + ' BtnGuardar.ToolTip = "" + ' Else + ' BtnGuardar.Enabled = False + ' Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia) + ' BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito" + + ' End If + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' UpGuardar.Update() + + ' Else + ' DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'") + ' If dtc.Rows.Count > 0 Then + ' trCuentaDeposito.Visible = True + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + + ' End If + ' End If + + 'Else + + ' If DdlTipoTransaccion.SelectedValue.Contiene("9", "17") And CveIE <= -1 Then + + ' BtnGuardar.Enabled = False + ' Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia) + ' BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito" + ' Else + ' trCuentaDeposito.Visible = True + ' BtnGuardar.Enabled = True + ' End If + + ' UpGuardar.Update() + + 'End If + 'If DdlTipoTransaccion.SelectedValue = "9" AndAlso DdlCuentaDeposito.Items.Count = 0 Then ' BtnIEGuardar.Enabled = False 'End If 'GVCuentasPago.DataBind() - DdlCuentaDeposito.DataBind() + 'DdlCuentaDeposito.DataBind() 'Else ' trCuentaDeposito.Visible = False ' DdlCuentaDeposito.Items.Clear() 'End If + + If dtc IsNot Nothing Then + + If DdlTipoTransaccion.SelectedValue = "9" Then + + If OpBanco = 1 Then + If dtc.Rows.Count > 0 Then + DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'") + DdlCuentaDeposito.DataBind() + End If + + If dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then + trCuentaDeposito.Visible = True + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + Else + BtnGuardar.Enabled = False + Alert("El Beneficiario no tiene una cuenta activa en BBVA, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia) + End If + + ElseIf OpBanco = 3 Then + If dtc.Rows.Count > 0 Then + DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND Estatus ='True'") + DdlCuentaDeposito.DataBind() + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + End If + + If dtc.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND Estatus ='True'").Rows.Count > 0 Then + trCuentaDeposito.Visible = True + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + Else + BtnGuardar.Enabled = False + Alert("El Beneficiario no tiene una cuenta activa en Scotiabank, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia) + End If + End If + ElseIf DdlTipoTransaccion.SelectedValue = "17" Then + + If OpBanco = 1 Then + If dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' AND Estatus ='True'").Rows.Count > 0 Then + DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' AND Estatus ='True'") + DdlCuentaDeposito.DataBind() + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + trCuentaDeposito.Visible = True + BtnGuardar.ToolTip = "" + Else + BtnGuardar.Enabled = False + BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito" + Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia) + End If + + Else + BtnGuardar.Enabled = False + BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito para layout grupos" + Alert("El proveedor no tiene cuentas deposito para layout grupos.", TipoMensaje.MsgAdvertencia) + End If + + + + Else + 'Respuesta = True + DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'") + DdlCuentaDeposito.DataBind() + + If dtc.Rows.Count > 0 Then + trCuentaDeposito.Visible = True + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + End If + BtnGuardar.Enabled = True + End If + End If + + UpGuardar.Update() UpCuentaDeposito.Update() UpDatos.Update() End Sub diff --git a/Bancos/PagoElectronico.aspx.vb b/Bancos/PagoElectronico.aspx.vb index a9414bc09..bde6db7ea 100644 --- a/Bancos/PagoElectronico.aspx.vb +++ b/Bancos/PagoElectronico.aspx.vb @@ -1044,35 +1044,35 @@ Partial Class Bancos_PagoElectronico Dim NombreArchivo As String = $"pagos_{NowADS.ToString("ddMMyyyy")}_001.txt" '"pagos_03062025_001.txt" - 'If InsertaEnDB Then + If InsertaEnDB Then - ' Dim ObjBancos As New ClsBancos - ' ObjBancos.IniciaTransacSQL() + Dim ObjBancos As New ClsBancos + ObjBancos.IniciaTransacSQL() - ' Dim CveLayoutEnvio As Integer = ObjBancos.AddLayoutEnvios(NombreArchivo, NowADS(), CveCuenta, PorGrupos:=True) + Dim CveLayoutEnvio As Integer = ObjBancos.AddLayoutEnvios(NombreArchivo, NowADS(), CveCuenta, PorGrupos:=True) - ' If CveLayoutEnvio > 0 Then - ' For Each dr As DataRow In DTPendientes.Rows - ' If dr("CveProveedor").ToString <> "" Or dr("CvePersonal").ToString <> "" Then - ' If Not ObjBancos.AddLayoutEnviosDetalle(CveLayoutEnvio, dr("CveIE").ToString.ToEntero, dr("CveProveedor").ToString.ToEntero, dr("CvePersonal").ToString.ToEntero, 1, "Observaciones") Then - ' ErrorLayout = True - ' Exit For - ' End If - ' End If - ' Next - ' Else - ' ErrorLayout = True - ' End If + If CveLayoutEnvio > 0 Then + For Each dr As DataRow In DTPendientes.Rows + If dr("CveProveedor").ToString <> "" Or dr("CvePersonal").ToString <> "" Then + If Not ObjBancos.AddLayoutEnviosDetalle(CveLayoutEnvio, dr("CveIE").ToString.ToEntero, dr("CveProveedor").ToString.ToEntero, dr("CvePersonal").ToString.ToEntero, 1, "Observaciones") Then + ErrorLayout = True + Exit For + End If + End If + Next + Else + ErrorLayout = True + End If - ' If ErrorLayout Then - ' ObjBancos.RollBack() - ' ObjBancos.Dispose() - ' Else - ' ObjBancos.Commit() - ' ObjBancos.Dispose() - ' End If + If ErrorLayout Then + ObjBancos.RollBack() + ObjBancos.Dispose() + Else + ObjBancos.Commit() + ObjBancos.Dispose() + End If - 'End If + End If Dim path As String = String.Format("{0}Layout\{1}", UsuarioActual.Empresa.Ruta, NombreArchivo) Dim pathDirectorio As String = String.Format("{0}Layout\", UsuarioActual.Empresa.Ruta) @@ -1499,11 +1499,23 @@ Partial Class Bancos_PagoElectronico End If ObjBancos.Dispose() - If DtRegenerar IsNot Nothing Then - GeneraPago(DtRegenerar, CveBLE) - Else - Alert("Ocurrió un error al obtener los datos para generar el archivo. Por favor vuelva a intentar.", TipoMensaje.MsgError) + If OpBancos = 1 Then + If DtRegenerar IsNot Nothing Then + GeneraPago(DtRegenerar, CveBLE) + Else + Alert("Ocurrió un error al obtener los datos para generar el archivo. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If End If + + If OpBancos = 3 Then + If DtRegenerar IsNot Nothing Then + GeneraPagoScotiaBank(DtRegenerar, False) + Else + Alert("Ocurrió un error al obtener los datos para generar el archivo. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + End If + + End Sub #End Region @@ -1900,8 +1912,9 @@ Partial Class Bancos_PagoElectronico ElseIf OpBancos = 2 Then ElseIf OpBancos = 3 Then - If DTPendientes.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND EstatusCtaDeposito = 'True'") IsNot Nothing Then - GeneraPagoScotiaBank(DTPendientes.FiltraParametros("EstatusPagoElectronico > 0 AND EstatusCtaDeposito > 0"), False) + If DTPendientes.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND EstatusCtaDeposito = 'True'") IsNot Nothing AndAlso + DTPendientes.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND EstatusCtaDeposito = 'True'").Rows.Count > 0 Then + GeneraPagoScotiaBank(DTPendientes.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND EstatusCtaDeposito = 'True'"), True) Else Alert("No hay registros para generar pagos en ScotiaBank", TipoMensaje.MsgAdvertencia) End If @@ -2370,6 +2383,8 @@ Partial Class Bancos_PagoElectronico If OpBancos = 3 Then + TextoArreglo = File.ReadAllLines(path:=NombreArchivo) ' Texto.Split(CChar(vbCrLf)) + Dim SBCuentasAltas As New StringBuilder Dim SBErrores As New StringBuilder Dim ErrorArchivoScotia As Boolean = False @@ -2399,6 +2414,7 @@ Partial Class Bancos_PagoElectronico End If Dim ObjBancos As New ClsBancos + ObjBancos.IniciaTransacSQL() For i As Integer = 1 To TextoArreglo.Length - 2 Step 1 @@ -2406,12 +2422,17 @@ Partial Class Bancos_PagoElectronico If Linea.Length = 140 Then - Dim CodigoRespuesta As String = Linea.Substring(0, 3) + Dim CodigoRespuesta As String = Linea.Substring(109, 3) + Dim DTipoArchivo As String = Linea.Substring(0, 2) Dim Cuenta As String = Linea.Substring(12, 20) - 'Dim FechaEliminacion As Date = Linea.Substring(32, 8).ToDate Dim FechaEliminacion As Date = Date.ParseExact(Linea.Substring(32, 8), "yyyyMMdd", Globalization.CultureInfo.InvariantCulture) + If DTipoArchivo <> "SP" Then + SBErrores.Append($"Error Linea {i} el tipo de archivo no es un archivo de respuesta (SP), inicia con codigo {DTipoArchivo}.
") + ErrorArchivoScotia = True + End If + If CodigoRespuesta = "000" Or CodigoRespuesta = " " Then Dim CveCuentaDeposito As Integer = Linea.Substring(40, 50).Trim.ToEntero @@ -2439,11 +2460,16 @@ Partial Class Bancos_PagoElectronico Next If ErrorArchivoScotia Then - Alert($"El archivo presento errores en su procesamiento({SBErrores.Length}). Se dieron de alta {SBCuentasAltas.Length} cuentas.
Altas:
{SBCuentasAltas.ToString}.

Errores:
{SBErrores.ToString}", TipoMensaje.MsgAdvertencia) + ObjBancos.RollBack() + Alert($"El archivo presento errores en su procesamiento({SBErrores.Length}). Correctos {SBCuentasAltas.Length} cuentas.
Altas:
{SBCuentasAltas.ToString}.

Errores:
{SBErrores.ToString}", TipoMensaje.MsgAdvertencia) Else + ObjBancos.Commit() Alert($"El archivo se analizo correctamente y se efectuaron todos los cambios en el sistema. cuentas procesadas:
{SBCuentasAltas.ToString}", TipoMensaje.MsgInformacion) End If + + + ObjBancos.Dispose() End If @@ -2944,6 +2970,8 @@ Partial Class Bancos_PagoElectronico If OpBancos = 3 Then + TextoArreglo = File.ReadAllLines(NombreArchivo) 'Texto.Split(CChar(vbCrLf)) + Dim CveIES As List(Of Integer) = New List(Of Integer) Dim LienasCount As Integer = TextoArreglo.Length Dim SBErrores As New StringBuilder @@ -2956,8 +2984,9 @@ Partial Class Bancos_PagoElectronico End If Dim Header As String = TextoArreglo(0) - Dim HCodigo As String = TextoArreglo(0).Substring(0, 3).Trim - If HCodigo <> "SVH" Then + Dim HCodigo As String = TextoArreglo(0).Substring(35, 3).Trim + Dim HTipoArchivo As String = TextoArreglo(0).Substring(0, 3).Trim + If HTipoArchivo <> "SVH" Then Alert("El archivo no es un archivo de respuesta, debe tener un encabezado con SVH.", TipoMensaje.MsgError) Exit Sub End If @@ -3130,13 +3159,14 @@ Partial Class Bancos_PagoElectronico End If Next Catch ex As Exception - Alert("Ocurrió un error al enviar los correos de notificación.", TipoMensaje.MsgError) + Alert("Ocurrió un error al enviar los correos de notificación.", TipoMensaje.MsgAdvertencia) End Try Alert(Respuesta.ToString, TipoMensaje.MsgInformacion) Else + Alert("Ocurrió un error al procesar el archivo.", TipoMensaje.MsgAdvertencia) objIE.RollBack() End If diff --git a/Bancos/PagoElectronicoGrupos.aspx.vb b/Bancos/PagoElectronicoGrupos.aspx.vb index 94f068664..ac144efca 100644 --- a/Bancos/PagoElectronicoGrupos.aspx.vb +++ b/Bancos/PagoElectronicoGrupos.aspx.vb @@ -442,7 +442,7 @@ Partial Class Bancos_PagoElectronicoGrupos Case DdlCuenta.SelectedItem.Text.ToUpper.Contains("SCOTIA") - habilitada = (dr("EstatusPagoElectronicoGruposScotia").ToString = "True") + habilitada = (dr("EstatusPagoElectronicoScotia").ToString = "True") Case Else habilitada = False 'Otros bancos sin bandera propia @@ -689,7 +689,7 @@ Partial Class Bancos_PagoElectronicoGrupos CuentaDepositoSinAlta = True End If - If DdlCuenta.SelectedItem.Text.ToUpper.Contains("SCOTIA") AndAlso e.Row.DBCampo("EstatusPagoElectronicoGruposScotia").ToString <> "True" Then + If DdlCuenta.SelectedItem.Text.ToUpper.Contains("SCOTIA") AndAlso e.Row.DBCampo("EstatusPagoElectronicoScotia").ToString <> "True" Then CuentaDepositoSinAlta = True End If diff --git a/Bancos/PopIECompras.aspx.vb b/Bancos/PopIECompras.aspx.vb index 5d3eb3332..ee457fcd8 100644 --- a/Bancos/PopIECompras.aspx.vb +++ b/Bancos/PopIECompras.aspx.vb @@ -774,73 +774,178 @@ Partial Class Bancos_PopIECompras End Sub Private Sub CargaCuentasDepositos() - DdlCuentaDeposito.Items.Clear() - If DdlTipoTransaccion.SelectedValue.Contiene("2", "9", "17") Then ' transferencias y layout - trCuentaDeposito.Visible = False - - Dim dtc As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor) + 'DdlCuentaDeposito.Items.Clear() - If dtc IsNot Nothing Then + 'If DdlTipoTransaccion.SelectedValue.Contiene("2", "9", "17") Then ' transferencias y layout + ' trCuentaDeposito.Visible = False - If DdlTipoTransaccion.SelectedValue = "9" Then - - DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'") - - If dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then - trCuentaDeposito.Visible = True - DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) - Else - BtnGuardar.Enabled = False - Alert("El Beneficiario no tiene una cuenta activa en BBVA, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia) - End If - DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) - ElseIf DdlTipoTransaccion.SelectedValue = "17" Then + ' Dim dtc As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor) + ' If dtc IsNot Nothing Then + + ' If DdlTipoTransaccion.SelectedValue = "9" Then + + ' DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'") + + ' If dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then + ' trCuentaDeposito.Visible = True + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' Else + ' BtnGuardar.Enabled = False + ' Alert("El Beneficiario no tiene una cuenta activa en BBVA, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia) + ' End If + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' ElseIf DdlTipoTransaccion.SelectedValue = "17" Then + + ' If dtc.Rows.Count > 0 Then + ' DdlCuentaDeposito.DataSource = dtc + ' trCuentaDeposito.Visible = True + ' BtnGuardar.ToolTip = "" + ' Else + + ' BtnGuardar.Enabled = False + ' BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito" + + ' End If + + ' UpGuardar.Update() + + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' Else + ' DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'") + ' If dtc.Rows.Count > 0 Then + ' trCuentaDeposito.Visible = True + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' End If + ' End If + ' Else + + ' If DdlTipoTransaccion.SelectedValue.Contiene("9", "17") Then + + ' BtnGuardar.Enabled = False + ' BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito" + ' Else + ' trCuentaDeposito.Visible = True + ' BtnGuardar.Enabled = True + ' BtnGuardar.ToolTip = "" + ' End If + + ' UpGuardar.Update() + + ' End If + + ' DdlCuentaDeposito.DataBind() + + 'Else + ' trCuentaDeposito.Visible = False + ' DdlCuentaDeposito.Items.Clear() + ' 'TrReferenciaCIE.Visible = False + 'End If + + 'UpCuentaDeposito.Update() + + DdlCuentaDeposito.ClearSelection() + DdlCuentaDeposito.SelectedValue = Nothing + DdlCuentaDeposito.Items.Clear() + + trCuentaDeposito.Visible = False + + + Dim OpBanco As Integer = 1 + Dim CuentaBanco As String = DdlCuenta.SelectedItem.Text.ToUpper + + If CuentaBanco.Contains("BBVA") Or CuentaBanco.Contains("BANCOMER") Then + OpBanco = 1 + 'ElseIf CuentaBanco.Contains("BAJIO") Then + ' OpBanco = 2 + ElseIf CuentaBanco.Contains("SCOTIA") Then + OpBanco = 3 + End If + + If DdlCuenta.SelectedValue = "-1" Then + BtnGuardar.Enabled = False + trCuentaDeposito.Visible = False + DdlCuentaDeposito.Items.Clear() + 'UpnCuentasPago.Update() + UpCuentaDeposito.Update() + Return + End If + + + Dim dtc As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor) + + If dtc IsNot Nothing Then + + If DdlTipoTransaccion.SelectedValue = "9" Then + + If OpBanco = 1 Then If dtc.Rows.Count > 0 Then - DdlCuentaDeposito.DataSource = dtc + DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'") + DdlCuentaDeposito.DataBind() + End If + + If dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then + trCuentaDeposito.Visible = True + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + Else + BtnGuardar.Enabled = False + Alert("El Beneficiario no tiene una cuenta activa en BBVA, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia) + End If + + ElseIf OpBanco = 3 Then + If dtc.Rows.Count > 0 Then + DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND Estatus ='True'") + DdlCuentaDeposito.DataBind() + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + End If + + If dtc.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND Estatus ='True'").Rows.Count > 0 Then + trCuentaDeposito.Visible = True + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + Else + BtnGuardar.Enabled = False + Alert("El Beneficiario no tiene una cuenta activa en Scotiabank, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia) + End If + End If + ElseIf DdlTipoTransaccion.SelectedValue = "17" Then + + If OpBanco = 1 Then + If dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' AND Estatus ='True'").Rows.Count > 0 Then + DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' AND Estatus ='True'") + DdlCuentaDeposito.DataBind() + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) trCuentaDeposito.Visible = True BtnGuardar.ToolTip = "" Else - BtnGuardar.Enabled = False BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito" - + Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia) End If - UpGuardar.Update() - - DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) - Else - DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'") - If dtc.Rows.Count > 0 Then - trCuentaDeposito.Visible = True - DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) - End If - End If - Else - - If DdlTipoTransaccion.SelectedValue.Contiene("9", "17") Then - - BtnGuardar.Enabled = False - BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito" Else - trCuentaDeposito.Visible = True - BtnGuardar.Enabled = True - BtnGuardar.ToolTip = "" + BtnGuardar.Enabled = False + BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito para layout grupos" + Alert("El proveedor no tiene cuentas deposito para layout grupos.", TipoMensaje.MsgAdvertencia) End If - UpGuardar.Update() - - End If - DdlCuentaDeposito.DataBind() - - Else - trCuentaDeposito.Visible = False - DdlCuentaDeposito.Items.Clear() - 'TrReferenciaCIE.Visible = False + + Else + 'Respuesta = True + DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'") + DdlCuentaDeposito.DataBind() + + If dtc.Rows.Count > 0 Then + trCuentaDeposito.Visible = True + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + End If + + BtnGuardar.Enabled = True + End If End If + 'UpnCuentasPago.Update() + UpGuardar.Update() UpCuentaDeposito.Update() End Sub @@ -896,6 +1001,9 @@ Partial Class Bancos_PopIECompras Banco.Dispose() End If + + CargaCuentasDepositos() + End Sub 'Private Sub DdlOtrosPagos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlOtrosPagos.SelectedIndexChanged diff --git a/Bancos/ProveedoresAbonar.aspx.vb b/Bancos/ProveedoresAbonar.aspx.vb index 86cad07ec..3094fe5e3 100644 --- a/Bancos/ProveedoresAbonar.aspx.vb +++ b/Bancos/ProveedoresAbonar.aspx.vb @@ -1405,6 +1405,10 @@ Partial Class Bancos_ProveedoresAbonar TxtFolio.Text = "" End If + 'ValidaCuentasDepositoLayouts() + + CargaCuentasDepositos() + 'Dim dr2 As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveCuenta = " & DdlCuenta.SelectedValue) 'If dr2 IsNot Nothing Then @@ -1416,6 +1420,106 @@ Partial Class Bancos_ProveedoresAbonar 'End If End Sub + 'Function ValidaCuentasDepositoLayouts() As Boolean + + ' Dim Respuesta As Boolean = False + ' Dim OpBanco As Integer = 1 + + ' Dim CuentaBanco As String = DdlCuenta.SelectedItem.Text.ToUpper + + ' If CuentaBanco.Contains("BBVA") Or CuentaBanco.Contains("BANCOMER") Then + ' OpBanco = 1 + ' 'ElseIf CuentaBanco.Contains("BAJIO") Then + ' ' OpBanco = 2 + ' ElseIf CuentaBanco.Contains("SCOTIA") Then + ' OpBanco = 3 + ' End If + + + ' Dim dtc As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor) + + ' If dtc IsNot Nothing Then + + ' If DdlTipoTransaccion.SelectedValue = "9" Then + + ' If OpBanco = 1 Then + ' If dtc.Rows.Count > 0 Then + ' DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'") + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' End If + + ' If dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then + ' trCuentaDeposito.Visible = True + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' Else + ' BtnIEGuardar.Enabled = False + ' Alert("El Beneficiario no tiene una cuenta activa en BBVA, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia) + ' End If + + ' ElseIf OpBanco = 3 Then + ' If dtc.Rows.Count > 0 Then + ' DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND Estatus ='True'") + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' End If + + ' If dtc.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND Estatus ='True'").Rows.Count > 0 Then + ' trCuentaDeposito.Visible = True + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' Else + ' BtnIEGuardar.Enabled = False + ' Alert("El Beneficiario no tiene una cuenta activa en Scotiabank, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia) + ' End If + ' End If + ' ElseIf DdlTipoTransaccion.SelectedValue = "17" Then + + ' If OpBanco = 1 Then + ' If dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' Estatus ='True'").Rows.Count > 0 Then + ' DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' Estatus ='True'") + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' trCuentaDeposito.Visible = True + ' BtnIEGuardar.ToolTip = "" + ' Else + ' BtnIEGuardar.Enabled = False + ' BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito" + ' Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia) + ' End If + ' 'ElseIf OpBanco = 3 Then + ' ' If dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' Estatus ='True'").Rows.Count > 0 Then + ' ' DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' Estatus ='True'") + ' ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' ' trCuentaDeposito.Visible = True + ' ' BtnIEGuardar.ToolTip = "" + ' ' Else + ' ' BtnIEGuardar.Enabled = False + ' ' BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito" + ' ' Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia) + ' ' End If + ' Else + ' BtnIEGuardar.Enabled = False + ' BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito para layout grupos" + ' Alert("El proveedor no tiene cuentas deposito para layout grupos.", TipoMensaje.MsgAdvertencia) + ' End If + + + + ' Else + ' Respuesta = True + ' DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'") + ' If dtc.Rows.Count > 0 Then + ' trCuentaDeposito.Visible = True + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' End If + ' End If + ' End If + + + + ' UpGuardar.Update() + + ' Return Respuesta + + 'End Function + 'Private Sub CargaGridTarjetas() @@ -1432,20 +1536,120 @@ Partial Class Bancos_ProveedoresAbonar #Region " CUENTAS DEPOSITOS" Private Sub CargaCuentasDepositos() + + DdlCuentaDeposito.ClearSelection() + DdlCuentaDeposito.SelectedValue = Nothing DdlCuentaDeposito.Items.Clear() trCuentaDeposito.Visible = False + 'Dim dtc As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor) + 'If dtc IsNot Nothing Then + + ' If dtc.FiltraParametros("Estatus ='True'").Rows.Count > 0 Then + + ' If DdlTipoTransaccion.SelectedValue = "9" Then + + ' If dtc.Rows.Count > 0 Then + ' DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'") + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' End If + + ' If dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then + ' trCuentaDeposito.Visible = True + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' Else + ' 'BtnIEGuardar.Enabled = False + ' 'Alert("El Beneficiario no tiene una cuenta activa en BBVA, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia) + ' End If + + ' ElseIf DdlTipoTransaccion.SelectedValue = "17" Then + + ' If dtc.Rows.Count > 0 Then + ' DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" Estatus ='True'") + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' trCuentaDeposito.Visible = True + ' BtnIEGuardar.ToolTip = "" + ' Else + ' 'BtnIEGuardar.Enabled = False + ' 'BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito" + ' 'Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia) + ' End If + ' UpGuardar.Update() + ' Else + ' DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'") + ' If dtc.Rows.Count > 0 Then + ' trCuentaDeposito.Visible = True + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' End If + ' End If + ' DdlCuentaDeposito.DataBind() + ' Else + + ' If DdlTipoTransaccion.SelectedValue.Contiene("9", "17") Then + ' 'BtnIEGuardar.Enabled = False + ' 'BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito" + ' 'Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia) + ' Else + ' trCuentaDeposito.Visible = True + ' BtnIEGuardar.Enabled = True + ' BtnIEGuardar.ToolTip = "" + ' End If + ' UpGuardar.Update() + ' End If + 'Else + + ' If DdlTipoTransaccion.SelectedValue = "17" Then + ' BtnIEGuardar.Enabled = False + ' BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito" + ' Else + ' trCuentaDeposito.Visible = True + ' BtnIEGuardar.Enabled = True + ' BtnIEGuardar.ToolTip = "" + ' End If + + ' UpGuardar.Update() + 'End If + + 'Else + ' trCuentaDeposito.Visible = False + ' DdlCuentaDeposito.Items.Clear() + 'End If + 'RecargaGlobalCuentasBancarias() + + + Dim OpBanco As Integer = 1 + + Dim CuentaBanco As String = DdlCuenta.SelectedItem.Text.ToUpper + + If CuentaBanco.Contains("BBVA") Or CuentaBanco.Contains("BANCOMER") Then + OpBanco = 1 + 'ElseIf CuentaBanco.Contains("BAJIO") Then + ' OpBanco = 2 + ElseIf CuentaBanco.Contains("SCOTIA") Then + OpBanco = 3 + End If + + If DdlCuenta.SelectedValue = "-1" Then + BtnIEGuardar.Enabled = False + trCuentaDeposito.Visible = False + DdlCuentaDeposito.Items.Clear() + UpnCuentasPago.Update() + UpCuentaDeposito.Update() + Return + End If + + Dim dtc As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor) + If dtc IsNot Nothing Then - If dtc.FiltraParametros("Estatus ='True'").Rows.Count > 0 Then - - If DdlTipoTransaccion.SelectedValue = "9" Then + If DdlTipoTransaccion.SelectedValue = "9" Then + If OpBanco = 1 Then If dtc.Rows.Count > 0 Then DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'") - DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + DdlCuentaDeposito.DataBind() End If If dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then @@ -1456,10 +1660,27 @@ Partial Class Bancos_ProveedoresAbonar Alert("El Beneficiario no tiene una cuenta activa en BBVA, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia) End If - ElseIf DdlTipoTransaccion.SelectedValue = "17" Then - + ElseIf OpBanco = 3 Then If dtc.Rows.Count > 0 Then - DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" Estatus ='True'") + DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND Estatus ='True'") + DdlCuentaDeposito.DataBind() + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + End If + + If dtc.FiltraParametros("EstatusPagoElectronicoScotia = 'True' AND Estatus ='True'").Rows.Count > 0 Then + trCuentaDeposito.Visible = True + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + Else + BtnIEGuardar.Enabled = False + Alert("El Beneficiario no tiene una cuenta activa en Scotiabank, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia) + End If + End If + ElseIf DdlTipoTransaccion.SelectedValue = "17" Then + + If OpBanco = 1 Then + If dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' AND Estatus ='True'").Rows.Count > 0 Then + DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' AND Estatus ='True'") + DdlCuentaDeposito.DataBind() DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) trCuentaDeposito.Visible = True BtnIEGuardar.ToolTip = "" @@ -1468,47 +1689,39 @@ Partial Class Bancos_ProveedoresAbonar BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito" Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia) End If - UpGuardar.Update() + 'ElseIf OpBanco = 3 Then + ' If dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' Estatus ='True'").Rows.Count > 0 Then + ' DdlCuentaDeposito.DataSource = dtc.FiltraParametros(" EstatusPagoElectronicoGrupos = 'True' Estatus ='True'") + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' trCuentaDeposito.Visible = True + ' BtnIEGuardar.ToolTip = "" + ' Else + ' BtnIEGuardar.Enabled = False + ' BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito" + ' Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia) + ' End If Else - DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'") - If dtc.Rows.Count > 0 Then - trCuentaDeposito.Visible = True - DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) - End If - End If - DdlCuentaDeposito.DataBind() - Else - - If DdlTipoTransaccion.SelectedValue.Contiene("9", "17") Then BtnIEGuardar.Enabled = False - BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito" - Alert("El proveedor no tiene cuentas deposito.", TipoMensaje.MsgAdvertencia) - Else - trCuentaDeposito.Visible = True - BtnIEGuardar.Enabled = True - BtnIEGuardar.ToolTip = "" + BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito para layout grupos" + Alert("El proveedor no tiene cuentas deposito para layout grupos.", TipoMensaje.MsgAdvertencia) End If - UpGuardar.Update() - End If - Else - If DdlTipoTransaccion.SelectedValue = "17" Then - BtnIEGuardar.Enabled = False - BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito" + + Else - trCuentaDeposito.Visible = True - BtnIEGuardar.Enabled = True - BtnIEGuardar.ToolTip = "" - End If + 'Respuesta = True + DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'") + DdlCuentaDeposito.DataBind() - UpGuardar.Update() + If dtc.Rows.Count > 0 Then + trCuentaDeposito.Visible = True + DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + End If + BtnIEGuardar.Enabled = True + End If End If - 'Else - ' trCuentaDeposito.Visible = False - ' DdlCuentaDeposito.Items.Clear() - 'End If - 'RecargaGlobalCuentasBancarias() + UpGuardar.Update() UpnCuentasPago.Update() UpCuentaDeposito.Update() End Sub diff --git a/Export/ExpDetalle.aspx b/Export/ExpDetalle.aspx new file mode 100644 index 000000000..bb3d6d95d --- /dev/null +++ b/Export/ExpDetalle.aspx @@ -0,0 +1,810 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ExpDetalle.aspx.cs" Inherits="Export_ExpDetalle" %> + + + + + + + Exportación: + + + +
  • + Exportar PDF +
  • +
    + + + + + +
    +
    + + +
    +
    + + +
    +
    + + + +
    +
    + + + + + + + + + +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + +
    +
    + + + +
    + + + + + +
    Fecha de Pedimento: +
    + + + + + + + + + + + + + + +
    +
    +
    +
    +
    + + + + +
    + + + +
    +
    +
    + + Pedimento +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + + + +
    +
    + + +
    +
    +
    + + + + + +
    +
    +
    +
    +
    + + Cliente +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    + + Dirección +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    + + Agentes Aduanales +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    + + Patentes +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    + + + + +
    +
    +
    +
    +
    + + Vehículos +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + +
    +
    +
    + +
    + + +
    +
    +
    + +
    + + +
    +
    +
    +
    +
    +
    +
    +
    +
    + + Otros +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    + + +
    +
    +
    + +
    + + +
    +
    +
    + +
    + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + Flete +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    + + Incrementables +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + Decrementables +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + +
    Notas:  
    +
    +
    +
    +
    +
    +
    + + + + + +
    +
    + + + <%--asp:TemplateField HeaderText="Id" ItemStyle-HorizontalAlign="Left"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    +
    +
    + + + + + +
    + +
    +
    + +
    + + + diff --git a/Export/ExpDetalle.aspx.cs b/Export/ExpDetalle.aspx.cs new file mode 100644 index 000000000..af4c7a036 --- /dev/null +++ b/Export/ExpDetalle.aspx.cs @@ -0,0 +1,941 @@ +using ADSNetLibrary.Helpers; +using CrystalDecisions.ReportAppServer.DataDefModel; + +//using DocumentFormat.OpenXml.Wordprocessing; +using Extensiones; +using HigLabo.Core; +using Profact.TimbraCFDI; +using Profact.TimbraCFDI.Complementos.ComercioExterior10; +using StackExchange.Redis; +using System; +using System.Activities; +using System.Activities.Expressions; +using System.Activities.Statements; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using ModExtensiones = Extensiones.ModExtensiones; + +public partial class Export_ExpDetalle : ClsPaginas +{ + #region Propiedades + private int CveExportacion + { + get { return (ViewState["CveExportacion"] == null) ? -1 : Convert.ToInt32(ViewState["CveExportacion"]); } + set { ViewState["CveExportacion"] = value; } + } + private int CveExportacionDetalle + { + get { return (ViewState["CveExportacionDetalle"] == null) ? -1 : Convert.ToInt32(ViewState["CveExportacionDetalle"]); } + set { ViewState["CveExportacionDetalle"] = value; } + } + #endregion + + + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + CveExportacion = !string.IsNullOrEmpty(Request["CveExportacion"]) ? Request["CveExportacion"].ToEntero() : -1; + InicializarValores(); + CargaDatos(); + } + else + { + ActualizarValores(); + } + } + protected void InicializarValores() + { + int CveEmpresa = UsuarioActual.CveEmpresa; + + // Factura + ClsVentas Ventas = new ClsVentas(); + // El problema es que solo se obtienen los registros donde CveUsuarioConsulta = Sis_UsuariosSubProyectos.CveUsuario en la BD + if (Ventas.GetVentas(CveEmpresa, "-1", "-1", -1, "-1", -1, -1, -1, -1, DateTime.Today.AddMonths(-1).ToString(), ModExtensiones.MaxFecha.ToString(), "-1", CveUsuarioConsulta: UsuarioActual.CveUsuario)) + { + DdlVentas.Items.Clear(); + DdlVentas.DataSource = Ventas.DtResultados; + DdlVentas.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlVentas.DataBind(); + } + Ventas.Dispose(); + + // Fecha de Factura + //TxtFechaFact.Text = DateTime.Today.ToString(); + + // Clave Pedimento + DdlClavePedimento.Items.Clear(); + DdlClavePedimento.DataSource = GlobalDTClavePedimento; + DdlClavePedimento.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlClavePedimento.DataBind(); + + // Incoterm + DdlIncoterm.Items.Clear(); + DdlIncoterm.DataSource = GlobalDTIncoterm; + DdlIncoterm.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlIncoterm.DataBind(); + + // Agente A. Mexicano + DdlAgenteMex.Items.Clear(); + DdlAgenteMex.DataSource = get_GlobalDTGralAgentes(-1, CveEmpresa); + DdlAgenteMex.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlAgenteMex.DataBind(); + // Agente A. Extranjero + DdlAgenteExt.Items.Clear(); + DdlAgenteExt.DataSource = get_GlobalDTGralAgentes(-1, CveEmpresa); + DdlAgenteExt.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlAgenteExt.DataBind(); + + // Clave Aduana + DdlClaveAduana.Items.Clear(); + DdlClaveAduana.DataSource = GlobalDTSATAduanasSeccion; + DdlClaveAduana.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlClaveAduana.DataBind(); + + // Medio Transporte + DdlMedioTran.Items.Clear(); + DdlMedioTran.DataSource = GlobalDTSATMediosTransporte; + DdlMedioTran.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlMedioTran.DataBind(); + + // Tipo Contenedor + DdlTipoContenedor.Items.Clear(); + DdlTipoContenedor.DataSource = GlobalDTSATContenedores; + DdlTipoContenedor.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlTipoContenedor.DataBind(); + } + protected void CargaDatos() + { + if (CveExportacion != -1) + { + DataTable DTExportaciones = new DataTable(); + ClsExportaciones Exportaciones = new ClsExportaciones(); + if (Exportaciones.GetExportacion(CveExportacion, UsuarioActual.CveEmpresa)) + { + DTExportaciones = Exportaciones.DtResultados; + if (DTExportaciones.Rows.Count > 0) + { + LblExp.Text = DTExportaciones.FiltroPrimeroValor("CveExportacion"); + + string CveVenta = Exportaciones.DtResultados.FiltroPrimeroValor("CveVenta"); + if (CveVenta != "" && CveVenta != "-1") + { + if (DdlVentas.Items.FindByValue(CveVenta) == null) + { + string Folio = Exportaciones.DtResultados.FiltroPrimeroValor("SerieFolio"); + DdlVentas.Items.Insert(1, new ListItem(Folio, CveVenta)); + } + DdlVentas.SelectedValue = CveVenta; + TxtFechaFact.Text = DTExportaciones.FiltroPrimeroValor("FechaFact"); + } + + //TxtNumFact.Text = DTExportaciones.FiltroPrimeroValor("SerieFolio"); + DdlTipoExp.SelectedValue = DTExportaciones.FiltroPrimeroValor("TipoExportacion"); + DdlClavePedimento.SelectedValue = DTExportaciones.FiltroPrimeroValor("CvePedimento"); + TxtNumPed.Text = DTExportaciones.FiltroPrimeroValor("NumeroPedimento"); + TxtFechaPedim.Text = DTExportaciones.FiltroPrimeroValor("FechaPedimento"); + DdlExpEstatus.SelectedValue = DTExportaciones.FiltroPrimeroValor("CveExportacionEstatus"); + + TxtTipoCambio.Text = DTExportaciones.FiltroPrimeroValor("TipoCambio"); + DdlIncoterm.SelectedValue = DTExportaciones.FiltroPrimeroValor("CveIncoterm"); + + DdlExp.SelectedValue = DTExportaciones.FiltroPrimeroValor("CveClienteExportador"); + DdlExp.SelectedText = DTExportaciones.FiltroPrimeroValor("ClienteExportador"); + DdlImp.SelectedValue = DTExportaciones.FiltroPrimeroValor("CveClienteImportador"); + DdlImp.SelectedText = DTExportaciones.FiltroPrimeroValor("ClienteImportador"); + DdlCon.SelectedValue = DTExportaciones.FiltroPrimeroValor("CveClienteConsignatario"); + DdlCon.SelectedText = DTExportaciones.FiltroPrimeroValor("ClienteConsignatario"); + + DdlAgenteMex.SelectedValue = DTExportaciones.FiltroPrimeroValor("CveAgente"); + DdlAgenteExt.SelectedValue = DTExportaciones.FiltroPrimeroValor("CveAgenteExtranjero"); + DdlClaveAduana.SelectedValue = DTExportaciones.FiltroPrimeroValor("ClaveAduana"); + + DdlCompTransportista.SelectedValue = DTExportaciones.FiltroPrimeroValor("CveProveedor"); + DdlCompTransportista.SelectedText = DTExportaciones.FiltroPrimeroValor("Proveedor"); + TxtPlaca.Text = DTExportaciones.FiltroPrimeroValor("ContenedorPlaca"); + TxtSCAC.Text = DTExportaciones.FiltroPrimeroValor("SCAC"); + TxtCAAT.Text = DTExportaciones.FiltroPrimeroValor("CAAT"); + DdlMedioTran.SelectedValue = DTExportaciones.FiltroPrimeroValor("MedioTransporte"); + DdlTipoContenedor.SelectedValue = DTExportaciones.FiltroPrimeroValor("TipoContenedor"); + TxtSello1.Text = DTExportaciones.FiltroPrimeroValor("Sello1"); + TxtSello2.Text = DTExportaciones.FiltroPrimeroValor("Sello2"); + TxtSello3.Text = DTExportaciones.FiltroPrimeroValor("Sello3"); + + ClsExportaciones Gastos = new ClsExportaciones(); + if (Gastos.GetGastos(CveExportacion)) + { + DataTable DTGastos = Gastos.DtResultados; + if (DTGastos.Rows.Count > 0) + { + TxtIncFletes.Text = DTGastos.FiltroPrimeroValor("IncFletes"); + TxtIncSeguro.Text = DTGastos.FiltroPrimeroValor("IncSeguro"); + TxtIncEmbalajes.Text = DTGastos.FiltroPrimeroValor("IncEmbalajes"); + TxtIncEmbalaje.Text = DTGastos.FiltroPrimeroValor("IncEmbalaje"); + TxtIncConexos.Text = DTGastos.FiltroPrimeroValor("IncConexos"); + TxtDecFlete.Text = DTGastos.FiltroPrimeroValor("DecFlete"); + TxtDecSeguro.Text = DTGastos.FiltroPrimeroValor("DecSeguro"); + TxtDecCarga.Text = DTGastos.FiltroPrimeroValor("DecCarga"); + TxtDecDescarga.Text = DTGastos.FiltroPrimeroValor("DecDescarga"); + TxtDecOtros.Text = DTGastos.FiltroPrimeroValor("DecOtros"); + } + } + Gastos.Dispose(); + + TxtNotas.Text = DTExportaciones.FiltroPrimeroValor("Notas"); + + ActualizarValores(); // Se actualizan los valores que dependen de otros campos + DdlDirExp.SelectedValue = DTExportaciones.FiltroPrimeroValor("CveDirExportador"); // Seleccionar las Dir DESPUÉS de llenar el dropdown + DdlDirCon.SelectedValue = DTExportaciones.FiltroPrimeroValor("CveDirConsignatario"); + + CargarPartidas(); + } + } + Exportaciones.Dispose(); + } + else + { + liImprimir.Visible = false; + } + } + protected void ActualizarValores() + { + int CveEmpresa = UsuarioActual.CveEmpresa; + + // Factura + if (IsPostBack) + { + ClsVentas Ventas = new ClsVentas(); + string CveVenta = DdlVentas.Text; + string SerieFolio = DdlVentas.SelectedItem.Text; + string Serie = "-1"; + string Folio = "-1"; + if (CveVenta != "" && CveVenta != "-1") + { + if (SerieFolio.Contains("-")) + { + var partes = SerieFolio.Split('-'); + Serie = partes[0]; + Folio = partes[1]; + } + else + { + Folio = SerieFolio; + } + if (Ventas.GetVentas(CveEmpresa, "-1", Serie, Folio.ToEntero(), "-1", -1, -1, -1, -1, ModExtensiones.MinFecha.ToString(), ModExtensiones.MaxFecha.ToString(), "-1", CveUsuarioConsulta: UsuarioActual.CveUsuario)) + { + TxtFechaFact.Text = Ventas.DtResultados.FiltroPrimeroValor("Fecha"); ; + } + Ventas.Dispose(); + } + else + { + TxtFechaFact.Text = ""; + } + } + + // Clave Dir. Exportador + string CveExportador = DdlExp.SelectedValue; + if (CveExportador != "" && CveExportador != "-1") + { + string CveDirExp = DdlDirExp.Text; + DdlDirExp.Items.Clear(); + DdlDirExp.DataSource = get_GlobalDTProveedorSucursales(CveExportador.ToEntero(), CveEmpresa); + DdlDirExp.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlDirExp.DataBind(); + if (CveDirExp != "" && CveDirExp != "-1") + { + ListItem ItemDirExp = DdlDirExp.Items.FindByValue(CveDirExp); + if (ItemDirExp != null) + DdlDirExp.SelectedValue = CveDirExp; + } + } + + // Clave Dir. Consignatario + string CveConsignatario = DdlCon.SelectedValue; + if (CveConsignatario != "" && CveConsignatario != "-1") + { + string CveDirCon = DdlDirCon.Text; + DdlDirCon.Items.Clear(); + DdlDirCon.DataSource = get_GlobalDTProveedorSucursales(CveConsignatario.ToEntero(), CveEmpresa); + DdlDirCon.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlDirCon.DataBind(); + if (CveDirCon != "" && CveDirCon != "-1") + { + ListItem ItemDirCon = DdlDirCon.Items.FindByValue(CveDirCon); + if (ItemDirCon != null) + DdlDirCon.SelectedValue = CveDirCon; + } + } + + // Agentes Aduanales + ClsExportaciones Exportaciones = new ClsExportaciones(); + string CveAgenteMx = DdlAgenteMex.Text; + string CveAgenteExt = DdlAgenteExt.Text; + if (CveAgenteMx != "" && CveAgenteMx != "-1") + { + if (Exportaciones.GetAgentes(CveAgenteMx.ToEntero(), CveEmpresa)) + { + TxtPatente.Text = Exportaciones.DtResultados.FiltroPrimeroValor("Cedula"); + } + Exportaciones.Dispose(); + } + else + { + TxtPatente.Text = ""; + } + if (CveAgenteExt != "" && CveAgenteExt != "-1") + { + if (Exportaciones.GetAgentes(CveAgenteExt.ToEntero(), CveEmpresa)) + { + TxtTaxId.Text = Exportaciones.DtResultados.FiltroPrimeroValor("Cedula"); + } + Exportaciones.Dispose(); + } + else + { + TxtTaxId.Text = ""; + } + + // Incrementables y Decrementables + decimal TotalInc = ModExtensiones.ToDecimal(TxtIncFletes.Text.Replace(",", "").Trim()) + + ModExtensiones.ToDecimal(TxtIncSeguro.Text.Replace(",", "").Trim()) + + ModExtensiones.ToDecimal(TxtIncEmbalajes.Text.Replace(",", "").Trim()) + + ModExtensiones.ToDecimal(TxtIncEmbalaje.Text.Replace(",", "").Trim()) + + ModExtensiones.ToDecimal(TxtIncConexos.Text.Replace(",", "").Trim()); + TxtTotalInc.Text = TotalInc.ToString("#,###.####"); + decimal TotalDec = ModExtensiones.ToDecimal(TxtDecFlete.Text.Replace(",", "").Trim()) + + ModExtensiones.ToDecimal(TxtDecSeguro.Text.Replace(",", "").Trim()) + + ModExtensiones.ToDecimal(TxtDecCarga.Text.Replace(",", "").Trim()) + + ModExtensiones.ToDecimal(TxtDecDescarga.Text.Replace(",", "").Trim()) + + ModExtensiones.ToDecimal(TxtDecOtros.Text.Replace(",", "").Trim()); + TxtTotalDec.Text = TotalDec.ToString("#,###.####"); + } + protected void BtnExpGuardar_Click(object sender, EventArgs e) + { + string CveClienteExportador = DdlExp.SelectedValue; + string CveClienteImportador = DdlImp.SelectedValue; + string CveClienteConsignatario = DdlCon.SelectedValue; + if (string.IsNullOrEmpty(CveClienteExportador) || string.IsNullOrEmpty(CveClienteImportador) || string.IsNullOrEmpty(CveClienteConsignatario) || + CveClienteExportador == "-1" || CveClienteImportador == "-1" || CveClienteConsignatario == "-1") + { + Alert("Debe seleccionar un Exportador, Importador y un Consignatario.", ModExtensiones.TipoMensaje.MsgAdvertencia); + return; + } + + string NumeroPedimento = TxtNumPed.Text; + DateTime FechaPedimento = TxtFechaPedim.Text.ToDate(); + int CveVenta = DdlVentas.Text.ToEntero(); + decimal TipoCambio = ModExtensiones.ToDecimal(TxtTipoCambio.Text); + int TipoExportacion = DdlTipoExp.Text.ToEntero(); + int CveExportacionEstatus = DdlExpEstatus.Text.ToEntero(); + int CveAgente = DdlAgenteMex.Text.ToEntero(); + int ClaveAduana = DdlClaveAduana.Text.ToEntero(); + int CveProveedor = DdlCompTransportista.SelectedValue.ToEntero(); + int MedioTransporte = DdlMedioTran.Text.ToEntero(); + int TipoContenedor = DdlTipoContenedor.Text.ToEntero(); + string Sello1 = TxtSello1.Text; + string Sello2 = TxtSello2.Text; + string Sello3 = TxtSello3.Text; + string SCAC = TxtSCAC.Text; + string CAAT = TxtCAAT.Text; + string ContenedorPlaca = TxtPlaca.Text; + int CveEmpresa = UsuarioActual.CveEmpresa; + int CveUsuario = UsuarioActual.CveUsuario; + int CveDirExportador = DdlDirExp.Text.ToEntero(); + int CveDirConsignatario = DdlDirCon.Text.ToEntero(); + int CveIncoterm = DdlIncoterm.Text.ToEntero(); + string Notas = TxtNotas.Text; + int CvePedimento = DdlClavePedimento.Text.ToEntero(); + int CveAgenteExtranjero = DdlAgenteExt.Text.ToEntero(); + + decimal IncFletes = ModExtensiones.ToDecimal(TxtIncFletes.Text); + decimal IncSeguro = ModExtensiones.ToDecimal(TxtIncSeguro.Text); + decimal IncEmbalajes = ModExtensiones.ToDecimal(TxtIncEmbalajes.Text); + decimal IncEmbalaje = ModExtensiones.ToDecimal(TxtIncEmbalaje.Text); + decimal IncConexos = ModExtensiones.ToDecimal(TxtIncConexos.Text); + decimal DecFlete = ModExtensiones.ToDecimal(TxtDecFlete.Text); + decimal DecSeguro = ModExtensiones.ToDecimal(TxtDecSeguro.Text); + decimal DecCarga = ModExtensiones.ToDecimal(TxtDecCarga.Text); + decimal DecDescarga = ModExtensiones.ToDecimal(TxtDecDescarga.Text); + decimal DecOtros = ModExtensiones.ToDecimal(TxtDecOtros.Text); + + ClsExportaciones Exportaciones = new ClsExportaciones(); + + if (CveExportacion == -1) + { + int ExportacionGuardada = Exportaciones.AddExportacion( + NumeroPedimento, + FechaPedimento, + CveVenta, + TipoCambio, + TipoExportacion, + CveExportacionEstatus, + CveClienteExportador.ToEntero(), + CveClienteImportador.ToEntero(), + CveClienteConsignatario.ToEntero(), + CveAgente, + ClaveAduana, + CveProveedor, + MedioTransporte, + TipoContenedor, + Sello1, + Sello2, + Sello3, + SCAC, + CAAT, + ContenedorPlaca, + CveEmpresa, + CveUsuario, + CveDirExportador, + CveDirConsignatario, + CveIncoterm, + Notas, + CvePedimento, + CveAgenteExtranjero + ); + if (ExportacionGuardada != -1) + { + Exportaciones.AddGastos( + IncFletes, + IncSeguro, + IncEmbalajes, + IncEmbalaje, + IncConexos, + DecFlete, + DecSeguro, + DecCarga, + DecDescarga, + DecOtros, + ExportacionGuardada + ); + + // AQUÍ SE VAN A GUARDAR LAS PARTIDAS TEMPORALES + DataTable DTPartidas = ViewState["Partidas"] as DataTable; + if (DTPartidas != null) + { + foreach (DataRow row in DTPartidas.Rows) + { + int CvePS = row["CvePS"].ToEntero(); + int CveUnidadMedida = row["CveUnidadMedida"].ToEntero(); + int CvePais = row["CvePais"].ToEntero(); + decimal Precio = ModExtensiones.ToDecimal(row["Precio"].ToString()); + decimal Cantidad = ModExtensiones.ToDecimal(row["Cantidad"].ToString()); + decimal PesoUnitario = ModExtensiones.ToDecimal(row["PesoUnitario"].ToString()); + + ClsExportaciones Partidas = new ClsExportaciones(); + Partidas.AddPartida(CvePS, CveUnidadMedida, Precio, CveEmpresa, CveUsuario, ExportacionGuardada, Cantidad, PesoUnitario, CvePais); + Partidas.Dispose(); + } + } + + //string Liga = "document.location.href=\"/Export/RepExportaciones.aspx\";"; + string Liga = $"document.location.href=\"/Export/ExpDetalle.aspx?CveExportacion={ExportacionGuardada}\";"; + Alert("La Exportación se ha agregado correctamente.", JSBtnAceptar: Liga); + } + Exportaciones.Dispose(); + } + else + { + bool Continuar = Exportaciones.UpdateExportacion( + CveExportacion, + NumeroPedimento, + FechaPedimento, + CveVenta, + TipoCambio, + TipoExportacion, + CveExportacionEstatus, + CveClienteExportador.ToEntero(), + CveClienteImportador.ToEntero(), + CveClienteConsignatario.ToEntero(), + CveAgente, + ClaveAduana, + CveProveedor, + MedioTransporte, + TipoContenedor, + Sello1, + Sello2, + Sello3, + SCAC, + CAAT, + ContenedorPlaca, + CveEmpresa, + CveUsuario, + CveDirExportador, + CveDirConsignatario, + CveIncoterm, + Notas, + CvePedimento, + CveAgenteExtranjero + ); + if (Continuar) + { + Exportaciones.UpdateGastos( + IncFletes, + IncSeguro, + IncEmbalajes, + IncEmbalaje, + IncConexos, + DecFlete, + DecSeguro, + DecCarga, + DecDescarga, + DecOtros, + CveExportacion + ); + Exportaciones.Dispose(); + CargarPartidas(); + Alert("La Exportación se ha actualizado correctamente."); + } + Exportaciones.Dispose(); + } + } + + protected void CargarPartidas() + { + DataTable DTPartidas = new DataTable(); + ClsExportaciones Partidas = new ClsExportaciones(); + if (CveExportacion != -1) + { + if (Partidas.GetPartidas(UsuarioActual.CveEmpresa, CveExportacion)) + { + DTPartidas = Partidas.DtResultados; + if (DTPartidas.Rows.Count > 0) + { + GVPartidas.DataSource = DTPartidas; + GVPartidas.DataBind(); + UpPartidas.Update(); + } + } + } + else + { + DTPartidas = ViewState["Partidas"] as DataTable; + if (DTPartidas != null) + { + GVPartidas.DataSource = DTPartidas; + GVPartidas.DataBind(); + UpPartidas.Update(); + } + } + Partidas.Dispose(); + } + protected void CargarUnidadMedida(string CvePS = "-1", string CveUnidadMedida = "-1") + { + int CveEmpresa = UsuarioActual.CveEmpresa; + + DdlUM.Items.Clear(); + if (CvePS != "" && CvePS != "-1") + { + if (UsuarioActual.Empresa.UsaInventarios) + DdlUM.DataSource = get_GlobalDTProductosServiciosEquivalencias(CvePS.ToEntero(), -1, CveEmpresa); + else + DdlUM.DataSource = get_GlobalDTUnidadesMedida(CveEmpresa); + DdlUM.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlUM.DataBind(); + DdlUM.SelectedValueExist(CveUnidadMedida); + } + else + { + DdlUM.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlUM.SelectedValue = "-1"; + } + } + protected void AbrirModalPartida(int GVPartidasRowIndex = -1) + { + RegistraScript("$('#DModalPartida').modal();"); + + int CveEmpresa = UsuarioActual.CveEmpresa; + + DdlPS.Items.Clear(); + DdlPS.DataSource = get_GlobalDTPS(CveEmpresa); + DdlPS.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlPS.DataBind(); + + DdlUM.Items.Clear(); + + DdlPaisOrigen.Items.Clear(); + DdlPaisOrigen.DataSource = GlobalDTGralPaises; + DdlPaisOrigen.Items.Insert(0, new ListItem("Seleccione", "-1")); + DdlPaisOrigen.DataBind(); + + if (CveExportacionDetalle != -1) + { + ChkSeguirAgregandoPartidas.Checked = false; + DivAgregarOtraPartida.Visible = false; + BtnPartidaGuardar.Visible = false; + BtnPartidaActualizar.Visible = true; + + ClsExportaciones Partidas = new ClsExportaciones(); + if (Partidas.GetPartidas(CveEmpresa, CveExportacion, CveExportacionDetalle)) + { + DataTable DTPartidas = Partidas.DtResultados; + if (DTPartidas.Rows.Count > 0) + { + string CvePS = DTPartidas.FiltroPrimeroValor("CvePS"); + DdlPS.SelectedValue = CvePS; + DdlPaisOrigen.SelectedValue = DTPartidas.FiltroPrimeroValor("CvePais"); ; + TxtPrecio.Text = DTPartidas.FiltroPrimeroValor("Precio"); + TxtCantidad.Text = DTPartidas.FiltroPrimeroValor("Cantidad"); + TxtPesoUnitario.Text = DTPartidas.FiltroPrimeroValor("PesoUnitario"); + + CargarUnidadMedida(CvePS, DTPartidas.FiltroPrimeroValor("CveUnidadMedida")); + } + } + Partidas.Dispose(); + } + else + { + if (GVPartidasRowIndex >= 0) + { + ChkSeguirAgregandoPartidas.Checked = false; + DivAgregarOtraPartida.Visible = false; + BtnPartidaGuardar.Visible = false; + BtnPartidaActualizar.Visible = true; + + DataTable DTTemp = ViewState["Partidas"] as DataTable; + if (GVPartidasRowIndex < DTTemp.Rows.Count) + { + string CvePS = DTTemp.Rows[GVPartidasRowIndex]["CvePS"].ToString(); + DdlPS.SelectedValue = CvePS; + DdlPaisOrigen.SelectedValue = DTTemp.Rows[GVPartidasRowIndex]["CvePais"].ToString(); + TxtPrecio.Text = DTTemp.Rows[GVPartidasRowIndex]["Precio"].ToString(); + TxtCantidad.Text = DTTemp.Rows[GVPartidasRowIndex]["Cantidad"].ToString(); + TxtPesoUnitario.Text = DTTemp.Rows[GVPartidasRowIndex]["PesoUnitario"].ToString(); + + CargarUnidadMedida(CvePS, DTTemp.Rows[GVPartidasRowIndex]["CveUnidadMedida"].ToString()); + } + } + else + { + ChkSeguirAgregandoPartidas.Checked = true; + DivAgregarOtraPartida.Visible = true; + BtnPartidaGuardar.Visible = true; + BtnPartidaActualizar.Visible = false; + TxtPrecio.Text = ""; + TxtCantidad.Text = ""; + TxtPesoUnitario.Text = ""; + } + } + UpPSS.Update(); + } + protected void GVPartidas_RowCommand(object sender, GridViewCommandEventArgs e) + { + if (e.CommandName == "EditarPartida") + { + CveExportacionDetalle = -1; + int GVPartidasRowIndex = -1; + if (CveExportacion == -1) + { + Control control = (Control)e.CommandSource; + GridViewRow GVPartidasRow = (GridViewRow)control.NamingContainer; + GVPartidasRowIndex = GVPartidasRow.RowIndex; + + DataTable DTTemp = ViewState["Partidas"] as DataTable; + DTTemp.Rows[GVPartidasRowIndex]["Actualizar"] = true; + } + else + { + CveExportacionDetalle = e.CommandArgument.ToEntero(); + } + AbrirModalPartida(GVPartidasRowIndex); + } + if (e.CommandName == "EliminarPartida") + { + if (CveExportacion != -1) + { + ClsExportaciones Partidas = new ClsExportaciones(); + bool Continuar = Partidas.RemovePartida(e.CommandArgument.ToEntero()); + Partidas.Dispose(); + if (Continuar) + { + Alert("La Partida se ha eliminado correctamente.", ModExtensiones.TipoMensaje.ToastInformacion); + } + } + else + { + Control control = (Control)e.CommandSource; + GridViewRow GVPartidasRow = (GridViewRow)control.NamingContainer; + int GVPartidasRowIndex = GVPartidasRow.RowIndex; + + DataTable DTTemp = ViewState["Partidas"] as DataTable; + if (GVPartidasRowIndex >= 0 && GVPartidasRowIndex < DTTemp.Rows.Count) + { + DTTemp.Rows.RemoveAt(GVPartidasRowIndex); + ViewState["Partidas"] = DTTemp; + Alert("La Partida se ha eliminado correctamente.", ModExtensiones.TipoMensaje.ToastInformacion); + } + } + CargarPartidas(); + } + } + protected void GVPartidas_RowDataBound(object sender, GridViewRowEventArgs e) + { + if (e.Row.RowType == DataControlRowType.Footer && GVPartidas.Rows.Count > 0) + { + decimal TotalPrecio = 0; + decimal TotalMXP = 0; + decimal TotalEmpaque = 0; + decimal PesoUnitario = 0; + decimal PesoBruto = 0; + + foreach (GridViewRow row in GVPartidas.Rows) + { + if (row.RowType == DataControlRowType.DataRow) + { + Label lblPrecio = (Label)row.FindControl("lblPrecio"); + Label lblValorTotalMXP = (Label)row.FindControl("lblValorTotalMXP"); + Label lblTotalEmpaque = (Label)row.FindControl("lblTotalEmpaque"); + Label lblPesoUnitario = (Label)row.FindControl("lblPesoUnitario"); + Label lblPesoBruto = (Label)row.FindControl("lblPesoBruto"); + + if (lblPrecio != null && lblPrecio.Text != "") + TotalPrecio += Convert.ToDecimal(lblPrecio.Text.Replace(",", "").Trim()); + + if (lblValorTotalMXP != null && lblValorTotalMXP.Text != "") + TotalMXP += Convert.ToDecimal(lblValorTotalMXP.Text.Replace(",", "").Trim()); + + if (lblTotalEmpaque != null && lblTotalEmpaque.Text != "") + TotalEmpaque += Convert.ToDecimal(lblTotalEmpaque.Text.Replace(",", "").Trim()); + + if (lblPesoUnitario != null && lblPesoUnitario.Text != "") + PesoUnitario += Convert.ToDecimal(lblPesoUnitario.Text.Replace(",", "").Trim()); + + if (lblPesoBruto != null && lblPesoBruto.Text != "") + PesoBruto += Convert.ToDecimal(lblPesoBruto.Text.Replace(",", "").Trim()); + } + } + + e.Row.Cells[0].Text = "Totales:"; + e.Row.Cells[2].Text = TotalPrecio.ToString("#,###.####"); + e.Row.Cells[3].Text = TotalMXP.ToString("#,###.####"); + e.Row.Cells[4].Text = TotalEmpaque.ToString("#,###.####"); + e.Row.Cells[7].Text = TotalEmpaque.ToString("#,###.####"); + e.Row.Cells[8].Text = PesoUnitario.ToString("#,###.####"); + e.Row.Cells[9].Text = PesoBruto.ToString("#,###.####"); + + e.Row.Font.Bold = true; + e.Row.BackColor = System.Drawing.Color.LightGray; + } + } + protected void BtnAgregarPartida_Click(object sender, EventArgs e) + { + CveExportacionDetalle = -1; + AbrirModalPartida(); + } + protected void CrearPartidaTemporal(DataTable DTTemp, bool Actualizar = false) + { + int CvePS = DdlPS.Text.ToEntero(); + string PSCodigo = DdlPS.SelectedItem.Text; + int CveUnidadMedida = (DdlUM.Text == "") ? -1 : DdlUM.Text.ToEntero(); + string UnidadMedida = (CveUnidadMedida == -1) ? "" : DdlUM.SelectedItem.Text; + int CvePais = (DdlPaisOrigen.Text == "") ? -1 : DdlPaisOrigen.Text.ToEntero(); + string ClaveSATPais = (CvePais == -1) ? "" : DdlPaisOrigen.SelectedItem.Text; + decimal Precio = ModExtensiones.ToDecimal(TxtPrecio.Text); + decimal ValorTotalMXP = Precio * ModExtensiones.ToDecimal(TxtTipoCambio.Text); + decimal Cantidad = ModExtensiones.ToDecimal(TxtCantidad.Text); + decimal PesoUnitario = ModExtensiones.ToDecimal(TxtPesoUnitario.Text); + decimal PesoBruto = PesoUnitario * Cantidad; + int CveEmpresa = UsuarioActual.CveEmpresa; + int CveUsuario = UsuarioActual.CveUsuario; + string FraccionArancelaria = ""; + string UnidadAduana = ""; + + string CveFraccionArancelaria = get_GlobalDTPS(CveEmpresa, CvePS).FiltroPrimeroValor("CveFraccionArancelaria"); + if (CveFraccionArancelaria != "" && GlobalDTFraccionArancelaria.Any()) + { + DataTable DTFraccArancelaria = GlobalDTFraccionArancelaria.CopyToDataTable(); + DataRow RowFA = DTFraccArancelaria.FiltroPrimeroPK("CveFraccionArancelaria", CveFraccionArancelaria); + FraccionArancelaria = RowFA["ClaveSATFraccionArancelariaDescripcion"].ToString(); + UnidadAduana = RowFA["ClaveSATUnidadAduanaDescripcion"].ToString(); + } + + if (!Actualizar) + { + DataRow PartidaRow = DTTemp.NewRow(); + PartidaRow["CvePS"] = CvePS; + PartidaRow["PSCodigo"] = PSCodigo; + PartidaRow["CveUnidadMedida"] = CveUnidadMedida; + PartidaRow["UnidadMedida"] = UnidadMedida; + PartidaRow["CvePais"] = CvePais; + PartidaRow["ClaveSATPais"] = ClaveSATPais; + PartidaRow["Precio"] = Precio; + PartidaRow["ValorTotalMXP"] = ValorTotalMXP; + PartidaRow["Cantidad"] = Cantidad; + PartidaRow["PesoUnitario"] = PesoUnitario; + PartidaRow["PesoBruto"] = PesoBruto; + PartidaRow["CveEmpresa"] = CveEmpresa; + PartidaRow["CveUsuario"] = CveUsuario; + PartidaRow["FraccionArancelaria"] = FraccionArancelaria; + PartidaRow["UnidadAduana"] = UnidadAduana; + PartidaRow["Actualizar"] = false; + + DTTemp.Rows.Add(PartidaRow); + } + else + { + DataRow[] filas = DTTemp.Select("Actualizar = true"); + DataRow PartidaRow = filas[0]; + PartidaRow["CvePS"] = CvePS; + PartidaRow["PSCodigo"] = PSCodigo; + PartidaRow["CveUnidadMedida"] = CveUnidadMedida; + PartidaRow["UnidadMedida"] = UnidadMedida; + PartidaRow["CvePais"] = CvePais; + PartidaRow["ClaveSATPais"] = ClaveSATPais; + PartidaRow["Precio"] = Precio; + PartidaRow["ValorTotalMXP"] = ValorTotalMXP; + PartidaRow["Cantidad"] = Cantidad; + PartidaRow["PesoUnitario"] = PesoUnitario; + PartidaRow["PesoBruto"] = PesoBruto; + PartidaRow["CveEmpresa"] = CveEmpresa; + PartidaRow["CveUsuario"] = CveUsuario; + PartidaRow["FraccionArancelaria"] = FraccionArancelaria; + PartidaRow["UnidadAduana"] = UnidadAduana; + PartidaRow["Actualizar"] = false; + } + + ViewState["Partidas"] = DTTemp; + } + protected void BtnPartidaGuardar_Click(object sender, EventArgs e) + { + int CvePS = DdlPS.Text.ToEntero(); + int CveUnidadMedida = (DdlUM.Text == "") ? -1 : DdlUM.Text.ToEntero(); + int CvePais = (DdlPaisOrigen.Text == "") ? -1 : DdlPaisOrigen.Text.ToEntero(); + decimal Precio = ModExtensiones.ToDecimal(TxtPrecio.Text); + decimal ValorTotalMXP = Precio * ModExtensiones.ToDecimal(TxtTipoCambio.Text); + decimal Cantidad = ModExtensiones.ToDecimal(TxtCantidad.Text); + decimal PesoUnitario = ModExtensiones.ToDecimal(TxtPesoUnitario.Text); + decimal PesoBruto = PesoUnitario * Cantidad; + int CveUsuario = UsuarioActual.CveUsuario; + + ClsExportaciones Partidas = new ClsExportaciones(); + if (CveExportacionDetalle == -1) + { + if (CveExportacion == -1) + { + string Mensaje = "La Partida se ha agregado correctamente. Recuerde guardar la Exportación para conservar los cambios."; + if (ViewState["Partidas"] == null) + { + DataTable DTTemp = new DataTable(); + DTTemp.Columns.Add("CveExportacionDetalle", typeof(int)); + DTTemp.Columns.Add("CvePS", typeof(int)); + DTTemp.Columns.Add("PSCodigo", typeof(string)); + DTTemp.Columns.Add("CveUnidadMedida", typeof(int)); + DTTemp.Columns.Add("UnidadMedida", typeof(string)); + DTTemp.Columns.Add("CvePais", typeof(int)); + DTTemp.Columns.Add("ClaveSATPais", typeof(string)); + DTTemp.Columns.Add("Precio", typeof(decimal)); + DTTemp.Columns.Add("ValorTotalMXP", typeof(decimal)); + DTTemp.Columns.Add("Cantidad", typeof(decimal)); + DTTemp.Columns.Add("PesoUnitario", typeof(decimal)); + DTTemp.Columns.Add("PesoBruto", typeof(decimal)); + DTTemp.Columns.Add("CveEmpresa", typeof(int)); + DTTemp.Columns.Add("CveUsuario", typeof(int)); + DTTemp.Columns.Add("FraccionArancelaria", typeof(string)); + DTTemp.Columns.Add("UnidadAduana", typeof(string)); + DTTemp.Columns.Add("Actualizar", typeof(bool)); + + CrearPartidaTemporal(DTTemp); + } + else + { + Button btn = sender as Button; + DataTable DTTemp = ViewState["Partidas"] as DataTable; + bool Actualizar = false; + if (btn.ID == "BtnPartidaActualizar") + { + Actualizar = true; + Mensaje = "La Partida se ha actualizado correctamente. Recuerde guardar la Exportación para conservar los cambios."; + } + CrearPartidaTemporal(DTTemp, Actualizar); + } + //RegistraScript("$('#DModalPartida').modal('hide');"); + Alert(Mensaje, ModExtensiones.TipoMensaje.ToastInformacion); + } + else + { + bool Continuar = Partidas.AddPartida(CvePS, CveUnidadMedida, Precio, UsuarioActual.CveEmpresa, CveUsuario, CveExportacion, Cantidad, PesoUnitario, CvePais); + Partidas.Dispose(); + if (Continuar) + { + //RegistraScript("$('#DModalPartida').modal('hide');"); + Alert("La Partida se ha agregado correctamente.", ModExtensiones.TipoMensaje.ToastInformacion); + } + } + } + else + { + bool Continuar = Partidas.UpdatePartida(CveExportacionDetalle, CvePS, CveUnidadMedida, Precio, CveUsuario, Cantidad, PesoUnitario, CvePais); + Partidas.Dispose(); + if (Continuar) + { + //RegistraScript("$('#DModalPartida').modal('hide');"); + Alert("La Partida se ha actualizado correctamente.", ModExtensiones.TipoMensaje.ToastInformacion); + } + } + if (ChkSeguirAgregandoPartidas.Checked == false) + { + RegistraScript("$('#DModalPartida').modal('hide');"); + } + else + { + DdlUM.Items.Clear(); + DdlPS.SelectedValue = "-1"; + DdlPaisOrigen.SelectedValue = "-1"; + TxtPrecio.Text = ""; + TxtCantidad.Text = ""; + TxtPesoUnitario.Text = ""; + UpPSS.Update(); + } + CargarPartidas(); + } + protected void DdlPS_SelectedIndexChanged(object sender, EventArgs e) + { + CargarUnidadMedida(DdlPS.Text, DdlUM.Text); + UpPSS.Update(); + } + + protected void ImprimirReporte(string Formato = "PDF") + { + FileInfo Archivo = new FileInfo(string.Format("{0}Empresas/Grales/Formatos/FacturaImportacion.mrt", UsuarioActual.Empresa.Ruta)); + } + protected void LBImprimir_Click(object sender, EventArgs e) + { + /*if (DtDatos != null) + { + ImprimirReporte(); + } + else + { + CargaDatos(); + if (DtDatos != null) + Alert("No se encontró información para el reporte.", ModExtensiones.TipoMensaje.MsgAdvertencia); + else + ImprimirReporte(); + }*/ + ImprimirReporte(); + } + + + + protected void DdlVentas_SelectedIndexChanged(object sender, EventArgs e) + { + + } + protected void DdlAgenteMex_SelectedIndexChanged(object sender, EventArgs e) + { + // Debe existir esta definición para que se haga postback. + // El valor de TxtPatente ya se actualiza en ActualizarValores() + } + + protected void DdlAgenteExt_SelectedIndexChanged(object sender, EventArgs e) + { + // Debe existir esta definición para que se haga postback. + // El valor de TxtTaxId ya se actualiza en ActualizarValores() + } + +} \ No newline at end of file diff --git a/Export/RepExportaciones.aspx b/Export/RepExportaciones.aspx new file mode 100644 index 000000000..b8f405ae6 --- /dev/null +++ b/Export/RepExportaciones.aspx @@ -0,0 +1,144 @@ +<%@ Page Title="Exportaciones" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="RepExportaciones.aspx.cs" Inherits="Export_RepExportaciones" %> + + + + + + + + Exportaciones + + +
  • + Agregar Exportación +
  • +
    + + + + + + + + +
    +
    +
    + + Información + +
    + +
    + + <%----%> +
    +
    +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    +
    + +
    +
    + + + + + + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    + +
    + + + diff --git a/Export/RepExportaciones.aspx.cs b/Export/RepExportaciones.aspx.cs new file mode 100644 index 000000000..7a71cc001 --- /dev/null +++ b/Export/RepExportaciones.aspx.cs @@ -0,0 +1,61 @@ +using DocumentFormat.OpenXml.Wordprocessing; +using Extensiones; +using StackExchange.Redis; +using System; +using System.Activities; +using System.Activities.Expressions; +using System.Activities.Statements; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory; +using static Stimulsoft.Report.Export.DeflaterHuffman; + +public partial class Export_RepExportaciones : ClsPaginas +{ + #region Propiedades + private int CveExportacion + { + get { return (ViewState["CveExportacion"] == null) ? -1 : Convert.ToInt32(ViewState["CveExportacion"]); } + set { ViewState["CveExportacion"] = value; } + } + #endregion + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + CargaExportaciones(); + } + } + protected void CargaExportaciones() + { + ClsExportaciones Exportaciones = new ClsExportaciones(); + if (Exportaciones.GetExportacion(-1, UsuarioActual.CveEmpresa)) + { + GVExportaciones.DataSource = Exportaciones.DtResultados; + GVExportaciones.DataBind(); + } + Exportaciones.Dispose(); + upDatosExp.Update(); + } + protected void EditarExp_Click(object sender, EventArgs e) + { + GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); + Response.Redirect($"/Export/ExpDetalle.aspx?CveExportacion={gvRow.DataKey("CveExportacion")}", true); + upDatosExp.Update(); + } + protected void EliminarExp_Click(object sender, EventArgs e) + { + GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); + ClsExportaciones Exportaciones = new ClsExportaciones(); + bool Continuar = Exportaciones.RemoveExportacion(gvRow.DataKey("CveExportacion").ToEntero()); + Exportaciones.Dispose(); + if (Continuar) + { + CargaExportaciones(); + Alert("La Exportación se ha eliminado correctamente."); + } + } +} \ No newline at end of file diff --git a/Nomina/RepMovtosPermanentes.aspx b/Nomina/RepMovtosPermanentes.aspx index 020044693..7f80cac29 100644 --- a/Nomina/RepMovtosPermanentes.aspx +++ b/Nomina/RepMovtosPermanentes.aspx @@ -130,8 +130,6 @@
    - <%----%> -
    @@ -139,13 +137,10 @@ - -
    - <%----%>
    @@ -153,8 +148,6 @@ - -
    @@ -164,10 +157,31 @@
    - +
    - diff --git a/Nomina/RepMovtosPermanentes.aspx.cs b/Nomina/RepMovtosPermanentes.aspx.cs index 81e63b937..4ce3246a7 100644 --- a/Nomina/RepMovtosPermanentes.aspx.cs +++ b/Nomina/RepMovtosPermanentes.aspx.cs @@ -8,6 +8,8 @@ using System.Web.UI; using System.Web.UI.WebControls; using ClosedXML.Excel; using Extensiones; +using Profact.TimbraCFDI40; +using static Extensiones.ModExtensiones; public partial class Nomina_RepMovtosPermanentes : ClsPaginas { @@ -70,6 +72,39 @@ public partial class Nomina_RepMovtosPermanentes : ClsPaginas } } + protected void DdlEjercicios_SelectedIndexChanged(object sender, EventArgs e) + { + cargaPeriodos(); + } + + protected void DdlTipoPeriodo_SelectedIndexChanged(object sender, EventArgs e) + { + cargaPeriodos(1); + } + private void cargaPeriodos(int tipo = 0) + { + int tipoPeriodo = DdlTipoPeriodo.SelectedValue.ToEntero(); + int ejercicio = DdlEjercicios.SelectedValue.ToEntero(); + DataTable dtPeriodos = null; + if (DdlTipoPeriodo.SelectedValue.ToEntero() > 0) + { + using (ClsNominas objperiodos = new ClsNominas()) + { + if (objperiodos.GetPeriodos(tipoPeriodo, UsuarioActual.CveEmpresa, ejercicio, -1, -1)) + { + + dtPeriodos = objperiodos.DtResultados.FiltraParametros("Estatus IN (1,2,3,4,5)"); + } + } + } + DdlPeriodo.DataSource = dtPeriodos; + DdlPeriodo.DataBind(); + DdlPeriodo.Items.Insert(0, new ListItem("Seleccione", "-1")); + if (tipo == 1 && dtPeriodos != null && dtPeriodos.Rows.Count > 0) + { + DdlPeriodo.SelectedValue = dtPeriodos.Rows[0]["CvePeriodo"].ToString(); + } + } protected void CargaCombos() { DDlPersonal.DataSource = get_GlobalDTRHPersonal(UsuarioActual.CveEmpresa); @@ -88,6 +123,20 @@ public partial class Nomina_RepMovtosPermanentes : ClsPaginas DDLSaldo.SelectedValueExist(RcveSaldo.ToString()); DDLEstatus.SelectedValueExist(RcveEstatus.ToString()); DDLConcepto.SelectedValueExist(RcveConcepto.ToString()); + + + DataTable dtejercicio = null; + using (ClsNominas objnom = new ClsNominas()) + { + if (objnom.GetEjercicios(UsuarioActual.CveEmpresa)) + { + dtejercicio = objnom.DtResultados; + } + } + DdlEjercicios.DataSource = dtejercicio; + DdlEjercicios.DataBind(); + DdlTipoPeriodo.DataSource = get_GlobalDTTipoPeriodos(UsuarioActual.CveEmpresa); + DdlTipoPeriodo.DataBind(); } protected void cargardatos() { @@ -95,7 +144,8 @@ public partial class Nomina_RepMovtosPermanentes : ClsPaginas { //string fechaInicio = ""; //string fechaFin = ""; - ObjGetM.GetMovtoPermanenteRepFechas(RcvePersonal, UsuarioActual.CveEmpresa, RcveTipo, RcveSaldo, RcveEstatus, RcveConcepto, fechaInicio.ToDateTime().ToString("yyyy-MM-dd"), fechaFin.ToDateTime().ToString("yyyy-MM-dd")); + int CvePeriodo = DdlPeriodo.SelectedValue.ToEntero() > 0 ? DdlPeriodo.SelectedValue.ToEntero() : -1; + ObjGetM.GetMovtoPermanenteRepFechas(RcvePersonal, UsuarioActual.CveEmpresa, RcveTipo, RcveSaldo, RcveEstatus, RcveConcepto, fechaInicio.ToDateTime().ToString("yyyy-MM-dd"), fechaFin.ToDateTime().ToString("yyyy-MM-dd"), CvePeriodo); GVGetMovtoPermanenteRep.DataSource = ObjGetM.DtResultados; GVGetMovtoPermanenteRep.DataBind();