--Cambios para adaptar a la nueva BD RMF. Tanto métodos, PA y contenidos de las tablas
This commit is contained in:
262
Transportes/RepViajes.aspx.vb
Normal file
262
Transportes/RepViajes.aspx.vb
Normal file
@@ -0,0 +1,262 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
Imports Extensiones.ModExtensiones
|
||||
|
||||
Partial Class ListadoViajes
|
||||
Inherits ClsPaginas
|
||||
|
||||
#Region "Propiedades"
|
||||
Private Property CveViaje As String
|
||||
Get
|
||||
Return ViewState("CveViaje").ToString()
|
||||
End Get
|
||||
Set(value As String)
|
||||
ViewState("CveViaje") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property Ruta As String
|
||||
Get
|
||||
Return ViewState("Ruta").ToString()
|
||||
End Get
|
||||
Set(value As String)
|
||||
ViewState("Ruta") = value
|
||||
End Set
|
||||
End Property
|
||||
#End Region
|
||||
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
||||
|
||||
If Not IsPostBack Then
|
||||
CargaDatos()
|
||||
InicializaCombos()
|
||||
End If
|
||||
|
||||
End Sub
|
||||
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
|
||||
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 ClsTransportes()
|
||||
If ObjDestinos.GetDestinos() 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(185)
|
||||
DdlChofer.DataBind()
|
||||
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
|
||||
|
||||
If ObjTransportes.GetViajes(-1, UsuarioActual.CveEmpresa) 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 = ""
|
||||
TxtFechaViaje.Text = ""
|
||||
DdlPartida.Text = ""
|
||||
DdlDestino.SelectedValue = ""
|
||||
BtnGuardar.Text = "Guardar"
|
||||
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalAgregar"))
|
||||
End Sub
|
||||
|
||||
Protected Sub AddViaje(sender As Object, e As EventArgs)
|
||||
Dim ObjTransportes As New ClsTransportes
|
||||
|
||||
ObjTransportes.IniciaTransacSQL()
|
||||
|
||||
If IsMasivo.Checked = True Then
|
||||
If TxtFechaInicial.Text = "" Or TxtFrecuencia.Text = "" Then
|
||||
Alert("Es necesario agregar la fecha inicial y la frecuencia", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim CveMasivo As Integer = DateTimeOffset.Now.ToUnixTimeSeconds().ToEntero
|
||||
|
||||
Dim fechaInicial As DateTime = DateTime.Parse(TxtFechaInicial.Text)
|
||||
Dim frecuencia As Integer = Integer.Parse(TxtFrecuencia.Text)
|
||||
Dim fechasGeneradas As New List(Of DateTime)()
|
||||
While fechaInicial.Year = DateTime.Now.Year
|
||||
fechasGeneradas.Add(fechaInicial)
|
||||
fechaInicial = fechaInicial.AddDays(frecuencia)
|
||||
End While
|
||||
|
||||
For Each fecha As DateTime In fechasGeneradas
|
||||
Try
|
||||
Dim CveContratoHijo As Integer = -1
|
||||
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
|
||||
ObjTransportes.Commit()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError)
|
||||
End Try
|
||||
Next
|
||||
|
||||
DdlRutas.Text = ""
|
||||
DdlTransporte.Text = ""
|
||||
DdlChofer.Text = ""
|
||||
TxtFechaViaje.Text = ""
|
||||
DdlPartida.Text = ""
|
||||
DdlDestino.SelectedValue = ""
|
||||
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 = 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
|
||||
ObjTransportes.Commit()
|
||||
Alert("El Viaje se registró Correctamente.", TipoMensaje.MsgInformacion)
|
||||
DdlRutas.Text = ""
|
||||
DdlTransporte.Text = ""
|
||||
DdlChofer.Text = ""
|
||||
TxtFechaViaje.Text = ""
|
||||
DdlPartida.Text = ""
|
||||
DdlDestino.SelectedValue = ""
|
||||
End If
|
||||
Else
|
||||
|
||||
If ObjTransportes.UpdateViajes(CveViaje.ToEntero, 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)
|
||||
ObjTransportes.Commit()
|
||||
CargaDatos()
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
ObjTransportes.RollBack()
|
||||
Finally
|
||||
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")
|
||||
DdlRutas.SelectedValue = GvRow.DataKey("CveRuta")
|
||||
DdlDestino.SelectedValue = GvRow.DataKey("CveDestino")
|
||||
DdlPartida.SelectedValue = GvRow.DataKey("CvePartida")
|
||||
DdlChofer.SelectedValue = GvRow.DataKey("CvePersonal")
|
||||
ViewState("CveViaje") = GvRow.DataKey("CveViaje")
|
||||
ViewState("Ruta") = GvRow.DataKey("Ruta")
|
||||
Dim fecha As DateTime
|
||||
|
||||
If DateTime.TryParse(GvRow.DataKey("Fecha").ToString, fecha) Then
|
||||
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 CveMasivo As String = GvRow.DataKey("CveMasivo")
|
||||
|
||||
Dim ObjTransportes As New ClsTransportes
|
||||
|
||||
ObjTransportes.IniciaTransacSQL()
|
||||
If CveMasivo = "" Then
|
||||
Try
|
||||
ObjTransportes.RemoveViaje(CveViaje:=GvRow.DataKey("CveViaje").ToEntero)
|
||||
ObjTransportes.Commit()
|
||||
Catch ex As Exception
|
||||
Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError)
|
||||
End Try
|
||||
Else
|
||||
Try
|
||||
ObjTransportes.RemoveViaje(CveMasivo:=CveMasivo.ToEntero)
|
||||
ObjTransportes.Commit()
|
||||
Catch ex As Exception
|
||||
Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError)
|
||||
|
||||
End Try
|
||||
End If
|
||||
Alert("Viaje eliminado correctamente")
|
||||
CargaDatos()
|
||||
ObjTransportes.Dispose()
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub ToggleMasivo(sender As Object, e As EventArgs)
|
||||
DivFechaMasivo.Visible = IsMasivo.Checked
|
||||
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalAgregar"))
|
||||
End Sub
|
||||
|
||||
Protected Sub GoViaje(sender As Object, e As EventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
Dim CveViaje As String = GvRow.DataKey("CveViaje")
|
||||
Response.Redirect(String.Format("~/Transportes/Boletos.aspx?CveViaje={0}", CveViaje))
|
||||
End Sub
|
||||
Protected Sub GoBoletos(sender As Object, e As EventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
Dim CveViaje As String = GvRow.DataKey("CveViaje")
|
||||
Dim Ruta As String = GvRow.DataKey("Ruta")
|
||||
Response.Redirect(String.Format("~/Transportes/RepBoletos.aspx?CveViaje={0}&Ruta={1}", CveViaje, Ruta))
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user