From 1305ad5572fc61e2b3ab59def669efbfc1ec813b Mon Sep 17 00:00:00 2001 From: SLopez Date: Thu, 26 Jun 2025 11:59:56 -0700 Subject: [PATCH] =?UTF-8?q?Implementacion=20de=20m=C3=B3dulo=20de=20Export?= =?UTF-8?q?aci=C3=B3n=20y=20Partidas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App_Code/ClsExportaciones.vb | 446 +++++++++++++++ App_Code/ClsGenerales.vb | 39 ++ App_Code/ClsPaginas.vb | 82 ++- Export/ExpDetalle.aspx | 810 +++++++++++++++++++++++++++ Export/ExpDetalle.aspx.cs | 941 ++++++++++++++++++++++++++++++++ Export/RepExportaciones.aspx | 144 +++++ Export/RepExportaciones.aspx.cs | 61 +++ 7 files changed, 2517 insertions(+), 6 deletions(-) create mode 100644 App_Code/ClsExportaciones.vb create mode 100644 Export/ExpDetalle.aspx create mode 100644 Export/ExpDetalle.aspx.cs create mode 100644 Export/RepExportaciones.aspx create mode 100644 Export/RepExportaciones.aspx.cs 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/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 072a970f2..8b9eb1449 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" @@ -1022,7 +1067,7 @@ Public Class ClsPaginas For Each file As String In files Dim fi As IO.FileInfo = New IO.FileInfo(file) - If fi.LastAccessTime -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 @@ -10506,6 +10572,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/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