Se implementa checkbox para generar viajes masivos. Se completa el descriptivo de la unidad y de chofer en la lista de viajes. Se hace la función para generar viajes en el lado de cliente.
This commit is contained in:
@@ -10,7 +10,6 @@ Partial Class ListadoViajes
|
||||
If Not IsPostBack Then
|
||||
CargaDatos()
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDatos()
|
||||
@@ -84,45 +83,86 @@ Partial Class ListadoViajes
|
||||
End Sub
|
||||
|
||||
Protected Sub AddViaje(sender As Object, e As EventArgs)
|
||||
|
||||
Dim ObjViajes As New ClsViajes
|
||||
|
||||
ObjViajes.IniciaTransacSQL()
|
||||
Page.Response.Write("<script>console.log('El resultado de tu variable" + IsMasivo.Checked.ToString + "')</script>")
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
Catch ex As Exception
|
||||
ObjViajes.RollBack()
|
||||
Finally
|
||||
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 = ObjViajes.AddViajes(DdlRutas.Text.ToEntero, DdlTransporte.Text.ToEntero, DdlChofer.Text.ToEntero, UsuarioActual.CveEmpresa, fecha, DdlPartida.Text.ToEntero, DdlDestino.Text.ToEntero)
|
||||
|
||||
If CveContratoHijo > 0 Then
|
||||
ObjViajes.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 = ""
|
||||
ObjViajes.Dispose()
|
||||
Response.Redirect("ListadoViajes.aspx")
|
||||
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)
|
||||
|
||||
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 If
|
||||
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Protected Sub UpdateViaje(sender As Object, e As EventArgs)
|
||||
@@ -160,4 +200,10 @@ Partial Class ListadoViajes
|
||||
ObjViajes.Dispose()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Protected Sub ToggleMasivo(sender As Object, e As EventArgs)
|
||||
DivFechaMasivo.Visible = IsMasivo.Checked
|
||||
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalAgregar"))
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user