diff --git a/App_Code/ClsExportaciones.vb b/App_Code/ClsExportaciones.vb index 72509a08e..8670c2847 100644 --- a/App_Code/ClsExportaciones.vb +++ b/App_Code/ClsExportaciones.vb @@ -120,7 +120,7 @@ Public Class ClsExportaciones End Sub #Region "EXPORTACIONES" - Public Function GetExportacion(Optional CveExportacion As Integer = -1, Optional CveEmpresa As Integer = -1, Optional EsExportacion As Integer = 1, Optional FechaInicio As Date = MinFecha, Optional FechaFin As Date = MaxFecha) As Boolean + Public Function GetExportacion(Optional CveExportacion As Integer = -1, Optional CveEmpresa As Integer = -1, Optional EsExportacion As Boolean = True, 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 @@ -143,7 +143,7 @@ Public Class ClsExportaciones 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, ITN As String, Vinculacion As Boolean) As Integer + CveIncoterm As Integer, Notas As String, CvePedimento As Integer, CveAgenteExtranjero As Integer, ITN As String, Vinculacion As Boolean, EsExportacion As Boolean) As Integer Dim Retorno As Integer = -1 DataAdapter("PA_Exp_ExportacionesAdd") With SqlAdapter.SelectCommand.Parameters @@ -177,6 +177,7 @@ Public Class ClsExportaciones .Add("@CveAgenteExtranjero", SqlDbType.Int).Value = CveAgenteExtranjero .Add("@ITN", SqlDbType.VarChar).Value = ITN .Add("@Vinculacion", SqlDbType.Bit).Value = Vinculacion + .Add("@EsExportacion", SqlDbType.Bit).Value = EsExportacion .Add("@CveExportacion", SqlDbType.Int).Direction = ParameterDirection.Output End With diff --git a/Export/ExpDetalle.aspx.cs b/Export/ExpDetalle.aspx.cs index f9b41f66e..ba462f3db 100644 --- a/Export/ExpDetalle.aspx.cs +++ b/Export/ExpDetalle.aspx.cs @@ -35,6 +35,12 @@ public partial class Export_ExpDetalle : ClsPaginas get { return (ViewState["CveExportacionDetalle"] == null) ? -1 : Convert.ToInt32(ViewState["CveExportacionDetalle"]); } set { ViewState["CveExportacionDetalle"] = value; } } + + private bool EsImportacion + { + get { return (ViewState["EsImportacion"] == null) ? false : Boolean.Parse(ViewState["EsImportacion"].ToString()); } + set { ViewState["EsImportacion"] = value; } + } #endregion @@ -42,6 +48,12 @@ public partial class Export_ExpDetalle : ClsPaginas { if (!IsPostBack) { + EsImportacion = false; + if (!string.IsNullOrEmpty(Request["Opcion"]) && Request["Opcion"].Equals("I", StringComparison.OrdinalIgnoreCase)) + { + EsImportacion = true; + } + CveExportacion = !string.IsNullOrEmpty(Request["CveExportacion"]) ? Request["CveExportacion"].ToEntero() : -1; InicializarValores(); CargaDatos(); @@ -117,7 +129,8 @@ public partial class Export_ExpDetalle : ClsPaginas { DataTable DTExportaciones = new DataTable(); ClsExportaciones Exportaciones = new ClsExportaciones(); - if (Exportaciones.GetExportacion(CveExportacion, UsuarioActual.CveEmpresa)) + bool EsExportacion = !EsImportacion; + if (Exportaciones.GetExportacion(CveExportacion, UsuarioActual.CveEmpresa, EsExportacion)) { DTExportaciones = Exportaciones.DtResultados; if (DTExportaciones.Rows.Count > 0) @@ -371,7 +384,7 @@ public partial class Export_ExpDetalle : ClsPaginas decimal DecOtros = ModExtensiones.ToDecimal(TxtDecOtros.Text); ClsExportaciones Exportaciones = new ClsExportaciones(); - + bool EsExportacion = !EsImportacion; if (CveExportacion == -1) { int ExportacionGuardada = Exportaciones.AddExportacion( @@ -404,7 +417,8 @@ public partial class Export_ExpDetalle : ClsPaginas CvePedimento, CveAgenteExtranjero, ITN, - Vinculacion + Vinculacion, + EsExportacion ); if (ExportacionGuardada != -1) { @@ -442,8 +456,10 @@ public partial class Export_ExpDetalle : ClsPaginas } //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); + string liga = EsImportacion + ? $"document.location.href=\"/Export/ExpDetalle.aspx?CveExportacion={ExportacionGuardada}&Opcion=I\";" + : $"document.location.href=\"/Export/ExpDetalle.aspx?CveExportacion={ExportacionGuardada}\";"; + Alert("La Exportación se ha agregado correctamente.", JSBtnAceptar: liga); } Exportaciones.Dispose(); } diff --git a/Export/RepExportaciones.aspx.cs b/Export/RepExportaciones.aspx.cs index 474c146de..3ee4b2c68 100644 --- a/Export/RepExportaciones.aspx.cs +++ b/Export/RepExportaciones.aspx.cs @@ -49,7 +49,7 @@ public partial class Export_RepExportaciones : ClsPaginas protected void CargaExportaciones() { ClsExportaciones Exportaciones = new ClsExportaciones(); - int EsExportacion = EsImportacion ? 0 : 1; // 0 = importación, 1 = exportación + bool EsExportacion = !EsImportacion; if (Exportaciones.GetExportacion(-1, UsuarioActual.CveEmpresa, EsExportacion)) { GVExportaciones.DataSource = Exportaciones.DtResultados;