-- Se pasó fecha inicial abajo, se cambió CveRuta por Ruta descriptiva, se cambio "activo" por sí en la columna de viajes masivos, se quitó generar viajes masivos cuando es update, se implementó buscadores en Listado de viajes y contratos y se usó función cargarDatos() en vez de refrescar la página
This commit is contained in:
@@ -10,31 +10,11 @@ Partial Class ListadoViajes
|
||||
|
||||
If Not IsPostBack Then
|
||||
CargaDatos()
|
||||
InicializaCombos()
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub GvViajes_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvViajes.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
If e.Row.DBCampo("CveMasivo") <> "" Then
|
||||
e.Row.FCLabel("LtlMasivo").Text = "Sí"
|
||||
e.Row.FCLabel("LtlMasivo").ForeColor = Drawing.Color.Green
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
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
|
||||
Private Sub InicializaCombos()
|
||||
'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
|
||||
@@ -81,8 +61,31 @@ Partial Class ListadoViajes
|
||||
DdlChofer.Items.Insert(0, New ListItem("Seleccione Chofer", ""))
|
||||
|
||||
End Sub
|
||||
Private Sub GvViajes_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvViajes.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
If e.Row.DBCampo("CveMasivo") <> "" Then
|
||||
e.Row.FCLabel("LtlMasivo").Text = "Sí"
|
||||
e.Row.FCLabel("LtlMasivo").ForeColor = Drawing.Color.Green
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
Private Sub CargaDatos()
|
||||
Dim ObjTransportes As New ClsTransportes
|
||||
|
||||
Protected Sub MostrarModal(sender As Object, e As System.EventArgs)
|
||||
If ObjTransportes.GetViajes() Then
|
||||
GvViajes.DataSource = ObjTransportes.DtResultados
|
||||
ObjTransportes.Dispose()
|
||||
GvViajes.DataBind()
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub LBAgregarViaje_Click(sender As Object, e As EventArgs) Handles LBAgregarViaje.Click
|
||||
MostrarModal()
|
||||
End Sub
|
||||
|
||||
Public Sub MostrarModal()
|
||||
IsMasivo.Visible = True
|
||||
DdlRutas.Text = ""
|
||||
DdlTransporte.Text = ""
|
||||
DdlChofer.Text = ""
|
||||
@@ -95,10 +98,10 @@ Partial Class ListadoViajes
|
||||
|
||||
Protected Sub AddViaje(sender As Object, e As EventArgs)
|
||||
|
||||
Dim ObjViajes As New ClsViajes
|
||||
Dim ObjTransportes As New ClsTransportes
|
||||
|
||||
|
||||
ObjViajes.IniciaTransacSQL()
|
||||
ObjTransportes.IniciaTransacSQL()
|
||||
|
||||
If IsMasivo.Checked = True Then
|
||||
If TxtFechaInicial.Text = "" Or TxtFrecuencia.Text = "" Then
|
||||
@@ -119,10 +122,10 @@ Partial Class ListadoViajes
|
||||
For Each fecha As DateTime In fechasGeneradas
|
||||
Try
|
||||
Dim CveContratoHijo As Integer = -1
|
||||
CveContratoHijo = ObjViajes.AddViajes(DdlRutas.Text.ToEntero, DdlTransporte.Text.ToEntero, DdlChofer.Text.ToEntero, UsuarioActual.CveEmpresa, fecha, DdlPartida.Text.ToEntero, DdlDestino.Text.ToEntero, IsMasivo:=True, CveMasivo:=CveMasivo)
|
||||
CveContratoHijo = ObjTransportes.AddViajes(DdlRutas.Text.ToEntero, DdlTransporte.Text.ToEntero, DdlChofer.Text.ToEntero, UsuarioActual.CveEmpresa, fecha, DdlPartida.Text.ToEntero, DdlDestino.Text.ToEntero, IsMasivo:=True, CveMasivo:=CveMasivo)
|
||||
|
||||
If CveContratoHijo > 0 Then
|
||||
ObjViajes.Commit()
|
||||
ObjTransportes.Commit()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError)
|
||||
@@ -135,18 +138,18 @@ Partial Class ListadoViajes
|
||||
TxtFechaViaje.Text = ""
|
||||
DdlPartida.Text = ""
|
||||
DdlDestino.SelectedValue = ""
|
||||
ObjViajes.Dispose()
|
||||
Response.Redirect("ListadoViajes.aspx")
|
||||
ObjTransportes.Dispose()
|
||||
CargaDatos()
|
||||
Alert("El viaje masivo se registró correctamente.", TipoMensaje.MsgInformacion)
|
||||
|
||||
Else
|
||||
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)
|
||||
CveContratoHijo = ObjTransportes.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()
|
||||
ObjTransportes.Commit()
|
||||
Alert("El Viaje se registró Correctamente.", TipoMensaje.MsgInformacion)
|
||||
DdlRutas.Text = ""
|
||||
DdlTransporte.Text = ""
|
||||
@@ -160,25 +163,25 @@ Partial Class ListadoViajes
|
||||
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
|
||||
If ObjTransportes.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()
|
||||
ObjTransportes.Commit()
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
Catch ex As Exception
|
||||
ObjViajes.RollBack()
|
||||
ObjTransportes.RollBack()
|
||||
Finally
|
||||
ObjViajes.Dispose()
|
||||
Response.Redirect("ListadoViajes.aspx")
|
||||
CargaDatos()
|
||||
ObjTransportes.Dispose()
|
||||
End Try
|
||||
End If
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub UpdateViaje(sender As Object, e As EventArgs)
|
||||
IsMasivo.Visible = False
|
||||
DivFechaMasivo.Visible = False
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
|
||||
DdlTransporte.SelectedValue = GvRow.DataKey("CveAF")
|
||||
@@ -192,42 +195,38 @@ Partial Class ListadoViajes
|
||||
TxtFechaViaje.Text = fecha.ToString("yyyy-MM-dd").Replace(" ", "T")
|
||||
End If
|
||||
|
||||
|
||||
BtnGuardar.Text = "Editar"
|
||||
|
||||
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 IsMasivo = GvRow.DataKey("CveMasivo")
|
||||
Dim CveMasivo = GvRow.DataKey("CveMasivo")
|
||||
|
||||
Dim ObjViajes As New ClsViajes
|
||||
Dim ObjTransportes As New ClsTransportes
|
||||
|
||||
ObjViajes.IniciaTransacSQL()
|
||||
If IsMasivo <> "" Then
|
||||
ObjTransportes.IniciaTransacSQL()
|
||||
If CveMasivo = "" Then
|
||||
Try
|
||||
ObjViajes.RemoveViaje(-1, CveMasivo:=IsMasivo.ToEntero)
|
||||
ObjViajes.Commit()
|
||||
Response.Redirect(Request.RawUrl)
|
||||
ObjTransportes.RemoveViaje(CveViaje:=GvRow.DataKey("CveViaje").ToEntero)
|
||||
ObjTransportes.Commit()
|
||||
Catch ex As Exception
|
||||
Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError)
|
||||
Finally
|
||||
ObjViajes.Dispose()
|
||||
End Try
|
||||
|
||||
Else
|
||||
Try
|
||||
ObjViajes.RemoveViaje(GvRow.DataKey("CveViaje").ToEntero)
|
||||
ObjViajes.Commit()
|
||||
Response.Redirect(Request.RawUrl)
|
||||
ObjTransportes.RemoveViaje(CveMasivo:=CveMasivo.ToEntero)
|
||||
ObjTransportes.Commit()
|
||||
Catch ex As Exception
|
||||
Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError)
|
||||
Finally
|
||||
ObjViajes.Dispose()
|
||||
|
||||
End Try
|
||||
End If
|
||||
|
||||
Alert("Viaje eliminado correctamente")
|
||||
CargaDatos()
|
||||
ObjTransportes.Dispose()
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Reference in New Issue
Block a user