diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index d63910d2f..e8a08ddee 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -9441,6 +9441,9 @@ Public Class ClsPaginas #Region "Transportes" PaginaDict.Add("/Transportes/ContratoTransporte.aspx".ToUpper(), 598) + PaginaDict.Add("/Transportes/ListadoContratos.aspx".ToUpper(), 598) + PaginaDict.Add("/Transportes/CrearViaje.aspx".ToUpper(), 598) + PaginaDict.Add("/Transportes/ListadoViajes.aspx".ToUpper(), 598) #End Region 'Antes de aquí. diff --git a/App_Code/ClsViajes.vb b/App_Code/ClsViajes.vb index cc207147e..7ee08071c 100644 --- a/App_Code/ClsViajes.vb +++ b/App_Code/ClsViajes.vb @@ -28,19 +28,22 @@ Public Class ClsViajes #Region "Propiedades" Public Property CveViaje As Integer - Public Property CveRuta As String + Public Property CveRuta As Integer Public Property CveAF As Integer - Public Property CvePersonal As String + Public Property CvePersonal As Integer Public Property CveEmpresa As Integer - Public Property Fecha As String + Public Property CvePartida As Integer + Public Property CveDestino As Integer + Public Property Fecha As DateTime #End Region #Region "Funciones básicas" Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing) If TransaccionCompartida Is Nothing Then - SqlConexion = New SqlConnection - SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString + SqlConexion = New SqlConnection With { + .ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString + } Try SqlConexion.Open() Catch ex As Exception @@ -60,7 +63,7 @@ Public Class ClsViajes .CommandText = StrSQL .CommandType = TipoComando End With - If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc + If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub #Region "Conexiones" @@ -75,7 +78,7 @@ Public Class ClsViajes .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output End With SqlAdapter.Fill(Data) - CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + CveConexion = CInt(SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString) Catch ex As Exception OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) End Try @@ -131,7 +134,8 @@ Public Class ClsViajes End Sub #End Region - Public Function AddViajes(CveRuta As Integer, CveAF As Integer, CvePersonal As Integer, CveEmpresa As Integer, Fecha As DateTime) As Integer +#Region "Métodos" + Public Function AddViajes(CveRuta As Integer, CveAF As Integer, CvePersonal As Integer, CveEmpresa As Integer, Fecha As DateTime, CvePartida As Integer, CveDestino As Integer) As Integer Dim Retorno As Integer = -1 DataAdapter("PA_Trans_ViajesAdd") @@ -143,12 +147,13 @@ Public Class ClsViajes .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@Fecha", SqlDbType.DateTime).Value = Fecha - + .Add("@CvePartida", SqlDbType.Int).Value = CvePartida + .Add("@CveDestino", SqlDbType.Int).Value = CveDestino End With Try SqlAdapter.Fill(Data) - Retorno = SqlAdapter.SelectCommand.Parameters("@CveViaje").Value.ToString.ToEntero + Retorno = CInt(SqlAdapter.SelectCommand.Parameters("@CveViaje").Value.ToString) Catch ex As Exception OnError("Ocurrió un error al guardar el nuevo viaje.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) @@ -156,4 +161,76 @@ Public Class ClsViajes Return Retorno End Function + + Public Function GetViajes(Optional CveViaje As Integer = 0) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Trans_ViajesGet") + If CveViaje > 0 Then + With SqlAdapter.SelectCommand.Parameters + .Add("@CveViajeSeleccionado", SqlDbType.Int).Value = CveViaje + End With + End If + Try + SqlAdapter.Fill(Data) + If CveViaje > 0 AndAlso Data IsNot Nothing AndAlso Data.Rows.Count > 0 Then + CveRuta = Data.Rows(0)("CveRuta").ToString.ToEntero + CveAF = Data.Rows(0)("CveAF").ToString.ToEntero + CvePersonal = Data.Rows(0)("CvePersonal").ToString.ToEntero + CveEmpresa = Data.Rows(0)("CveEmpresa").ToString.ToEntero + CvePartida = Data.Rows(0)("CvePartida").ToString.ToEntero + CveDestino = Data.Rows(0)("CveDestino").ToString.ToEntero + Fecha = Data.Rows(0)("Fecha").ToString.ToDate + End If + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el catálogo de viajes.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function RemoveViaje(CveViaje As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Trans_ViajesRemove") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveViaje", SqlDbType.Int).Value = CveViaje + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar el contrato.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdateViajes(CveViaje As Integer, CveRuta As Integer, CveAF As Integer, CvePersonal As Integer, CveEmpresa As Integer, Fecha As DateTime, CvePartida As Integer, CveDestino As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Trans_ViajesUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveViaje", SqlDbType.Int).Value = CveViaje + .Add("@CveRuta", SqlDbType.Int).Value = CveRuta + .Add("@CveAF", SqlDbType.Int).Value = CveAF + .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@Fecha", SqlDbType.Date).Value = Fecha + .Add("@CvePartida", SqlDbType.Int).Value = CvePartida + .Add("@CveDestino", SqlDbType.Int).Value = CveDestino + + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el Contrato.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function +#End Region End Class diff --git a/Transportes/ContratoTransporte.aspx b/Transportes/ContratoTransporte.aspx index ba6064227..faabd6ff8 100644 --- a/Transportes/ContratoTransporte.aspx +++ b/Transportes/ContratoTransporte.aspx @@ -95,16 +95,22 @@ - -