Se trabajo en los listados de Viajes y Contratos de V&A con su CRUD y PA. Se eliminó Crear Viajes y ContratoTransporte, ya que lo termina absorbiendo los listados
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports ADSNetLibrary.SIGAPI.Helpers
|
||||
Imports Extensiones.ModExtensiones
|
||||
|
||||
Partial Class ListadoViajes
|
||||
Inherits ClsPaginas
|
||||
@@ -15,42 +16,148 @@ Partial Class ListadoViajes
|
||||
Private Sub CargaDatos()
|
||||
Dim ObjViajes As New ClsViajes
|
||||
|
||||
ObjViajes.IniciaTransacSQL()
|
||||
|
||||
If ObjViajes.GetViajes() Then
|
||||
GvViajes.DataSource = ObjViajes.DtResultados
|
||||
ObjViajes.Dispose()
|
||||
GvViajes.DataBind()
|
||||
Else
|
||||
Me.GvViajes.DataSource = Nothing
|
||||
End If
|
||||
'Lista Activos Fijos'
|
||||
Dim ObjAF As New ClsAF()
|
||||
If ObjAF.GetActivosFijos(-1, 13, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, 1, "-1", -1, -1, -1) Then
|
||||
If ObjAF.DtResultados.Rows.Count > 0 Then
|
||||
DdlTransporte.DataSource = ObjAF.DtResultados
|
||||
DdlTransporte.DataBind()
|
||||
|
||||
DdlTransporte.Items.Insert(0, New ListItem("Seleccione Transporte", ""))
|
||||
End If
|
||||
End If
|
||||
ObjAF.Dispose()
|
||||
|
||||
'Lista Rutas'
|
||||
Dim ObjRutas As New ClsRutas()
|
||||
If ObjRutas.GetRutas(-1, -1, -1, "", True, DateTime.Now) Then
|
||||
|
||||
If ObjRutas.DtResultados.Rows.Count > 0 Then
|
||||
DdlRutas.DataSource = ObjRutas.DtResultados
|
||||
DdlRutas.DataBind()
|
||||
DdlRutas.Items.Insert(0, New ListItem("Seleccione Ruta", ""))
|
||||
End If
|
||||
End If
|
||||
ObjRutas.Dispose()
|
||||
|
||||
'Lista Destinos'
|
||||
Dim ObjDestinos As New ClsDestinos()
|
||||
If ObjDestinos.GetDestinos(-1, -1, -1, "", True, True, DateTime.Now) Then
|
||||
|
||||
If ObjDestinos.DtResultados.Rows.Count > 0 Then
|
||||
|
||||
DdlPartida.DataSource = ObjDestinos.DtResultados
|
||||
DdlPartida.DataBind()
|
||||
DdlPartida.Items.Insert(0, New ListItem("Seleccione Partida", ""))
|
||||
|
||||
DdlDestino.DataSource = ObjDestinos.DtResultados
|
||||
DdlDestino.DataBind()
|
||||
DdlDestino.Items.Insert(0, New ListItem("Seleccione Destino", ""))
|
||||
End If
|
||||
End If
|
||||
ObjRutas.Dispose()
|
||||
'Lista Chofer'
|
||||
DdlChofer.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa)
|
||||
DdlChofer.DataBind()
|
||||
DdlChofer.Items.Insert(0, New ListItem("Seleccione Chofer", ""))
|
||||
|
||||
ObjViajes.Dispose()
|
||||
GvViajes.DataBind()
|
||||
Page.Response.Write("<script>console.log('El resultado de tu variable" + GvViajes.ToString + "')</script>")
|
||||
End Sub
|
||||
|
||||
Protected Sub GvViajes_Comandos(sender As Object, e As GridViewCommandEventArgs)
|
||||
Dim id As Integer = Convert.ToInt32(e.CommandArgument)
|
||||
Dim url As String = $"CrearViaje.aspx?CveViaje={id}"
|
||||
Protected Sub MostrarModal(sender As Object, e As System.EventArgs)
|
||||
DdlRutas.Text = ""
|
||||
DdlTransporte.Text = ""
|
||||
DdlChofer.Text = ""
|
||||
TxtFechaViaje.Text = ""
|
||||
DdlPartida.Text = ""
|
||||
DdlDestino.SelectedValue = ""
|
||||
BtnGuardar.Text = "Guardar"
|
||||
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalAgregar"))
|
||||
End Sub
|
||||
|
||||
If e.CommandName = "Editar" Then
|
||||
Dim script As String = $"window.open('{url}', '_blank');"
|
||||
Page.ClientScript.RegisterStartupScript(Me.GetType(), "OpenWindow", script, True)
|
||||
Protected Sub AddViaje(sender As Object, e As EventArgs)
|
||||
Dim ObjViajes As New ClsViajes
|
||||
|
||||
ObjViajes.IniciaTransacSQL()
|
||||
|
||||
Try
|
||||
|
||||
If BtnGuardar.Text = "Guardar" Then
|
||||
Dim CveContratoHijo As Integer = -1
|
||||
CveContratoHijo = ObjViajes.AddViajes(DdlRutas.Text.ToEntero, DdlTransporte.Text.ToEntero, DdlChofer.Text.ToEntero, UsuarioActual.CveEmpresa, TxtFechaViaje.Text.ToDate, DdlPartida.Text.ToEntero, DdlDestino.Text.ToEntero)
|
||||
|
||||
If CveContratoHijo > 0 Then
|
||||
ObjViajes.Commit()
|
||||
Alert("El Viaje se registró Correctamente.", TipoMensaje.MsgInformacion)
|
||||
DdlRutas.Text = ""
|
||||
DdlTransporte.Text = ""
|
||||
DdlChofer.Text = ""
|
||||
TxtFechaViaje.Text = ""
|
||||
DdlPartida.Text = ""
|
||||
DdlDestino.SelectedValue = ""
|
||||
|
||||
End If
|
||||
|
||||
Else
|
||||
Dim id As Integer = Convert.ToInt32(Request.QueryString("CveViaje"))
|
||||
|
||||
If ObjViajes.UpdateViajes(id, DdlRutas.Text.ToEntero, DdlTransporte.Text.ToEntero, DdlChofer.Text.ToEntero, UsuarioActual.CveEmpresa, TxtFechaViaje.Text.ToDate, DdlPartida.Text.ToEntero, DdlDestino.Text.ToEntero) = True Then
|
||||
Alert("El viaje se modificó correctamente.", TipoMensaje.MsgInformacion)
|
||||
ObjViajes.Commit()
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
ObjViajes.RollBack()
|
||||
Finally
|
||||
ObjViajes.Dispose()
|
||||
Response.Redirect("ListadoViajes.aspx")
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Protected Sub UpdateViaje(sender As Object, e As EventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
|
||||
DdlTransporte.SelectedValue = GvRow.DataKey("CveAF")
|
||||
DdlRutas.SelectedValue = GvRow.DataKey("CveRuta")
|
||||
DdlDestino.SelectedValue = GvRow.DataKey("CveDestino")
|
||||
DdlPartida.SelectedValue = GvRow.DataKey("CvePartida")
|
||||
DdlChofer.SelectedValue = GvRow.DataKey("CvePersonal")
|
||||
Dim fecha As DateTime
|
||||
|
||||
If DateTime.TryParse(GvRow.DataKey("Fecha").ToString, fecha) Then
|
||||
TxtFechaViaje.Text = fecha.ToString("yyyy-MM-dd").Replace(" ", "T")
|
||||
End If
|
||||
|
||||
If e.CommandName = "Eliminar" Then
|
||||
Dim ObjViajes As New ClsViajes
|
||||
ObjViajes.IniciaTransacSQL()
|
||||
|
||||
Try
|
||||
ObjViajes.RemoveViaje(id)
|
||||
ObjViajes.Commit()
|
||||
Catch ex As Exception
|
||||
ObjViajes.RollBack()
|
||||
Finally
|
||||
ObjViajes.Dispose()
|
||||
Response.Redirect("ListadoViajes.aspx")
|
||||
End Try
|
||||
BtnGuardar.Text = "Editar"
|
||||
|
||||
End If
|
||||
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalAgregar"))
|
||||
End Sub
|
||||
|
||||
Protected Sub RemoveViaje(sender As Object, e As EventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
Dim ObjViajes As New ClsViajes
|
||||
|
||||
ObjViajes.IniciaTransacSQL()
|
||||
Try
|
||||
ObjViajes.RemoveViaje(GvRow.DataKey("CveViaje").ToEntero)
|
||||
ObjViajes.Commit()
|
||||
Response.Redirect(Request.RawUrl)
|
||||
Catch ex As Exception
|
||||
Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError)
|
||||
Finally
|
||||
ObjViajes.Dispose()
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user