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:
AbrahamCastilloV
2023-12-14 10:10:25 -07:00
parent f4eba5924f
commit fe84320c83
2 changed files with 296 additions and 232 deletions

View File

@@ -8,22 +8,27 @@
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
<style>
.my-1 {
margin-block: 1rem;
margin-block: .5rem;
}
.fecha {
padding: 3px;
}
</style>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="HB" runat="Server">
<ContentTemplate>
<contenttemplate>
<li>
<asp:HyperLink ID="LBListadoContratos" runat="server" NavigateUrl="ListadoContratos.aspx"
Target="_blank"><i class='fa fa-list'></i>Contratos</asp:HyperLink>
Target="_blank"><i class='fa fa-file'></i>Contratos</asp:HyperLink>
</li>
<li>
<asp:HyperLink ID="LBListadoViajes" runat="server" NavigateUrl="ListadoViajes.aspx"
Target="_blank"><i class='fa fa-road'></i>Viajes</asp:HyperLink>
</li>
</ContentTemplate>
</contenttemplate>
</asp:Content>
@@ -66,7 +71,7 @@
<asp:TemplateField HeaderText="Unidad">
<ItemTemplate>
<asp:Literal ID="LtlFecha" runat="server" Text='<%# Eval("Fecha") %>'></asp:Literal>
<asp:Literal ID="LltAF" runat="server" Text='<%# Eval("Unidad") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
@@ -195,14 +200,15 @@
</div>
</div>
<div class="row my-1">
<label class="col-md-4 bold">Fecha Viaje:</label>
<div class="col-md-8">
<div class="row my-1 truncate">
<label class="col-md-4 boldinput-group date date-picker bold" data-date-format="dd/mm/yyyy">
Fecha Viaje:</label>
<div class="col-md-8 fecha">
<div class="input-group input-sm input-small date date-picker">
<asp:TextBox ID="TxtFechaViaje" runat="server" CssClass="form-control text-center"
Width="200px"
CausesValidation="True"
type="date"></asp:TextBox>
<asp:TextBox ID="TxtFechaViaje" runat="server" CssClass="form-control" CausesValidation="True"
type="date"
MaxLength="10"> <i class="fa fa-calendar"></i>
</asp:TextBox>
<asp:RequiredFieldValidator ID="RFVTxtFechaViaje" runat="server" ControlToValidate="TxtFechaViaje"
Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Fecha Viaje''</b> es necesario, por favor ingréselo."
@@ -214,16 +220,28 @@
</div>
</div>
<div class="form-group form-md-line-input input-iconright" id="divEstatus" runat="server">
<asp:CheckBox ID="ChkEstatus" runat="server" CssClass="form-control bold" />
<label>Generar Viaje Masivo</label>
<div class="row">
<asp:CheckBox CssClass="col-md-4" ID="IsMasivo" runat="server" Text="Generar Viajes Masivo"
OnCheckedChanged="ToggleMasivo" AutoPostBack="true" />
<asp:Panel ID="DivFechaMasivo" runat="server" Visible="false" CssClass="col-md-8">
<div class="row col-md-8">
<label class="col-md-4 bold">Fecha Inicial:</label>
<asp:TextBox CssClass="col-md-8" ID="TxtFechaInicial" runat="server" type="date"></asp:TextBox>
</div>
<div class="row col-md-8 ">
<label class="col-md-4 bold">Lapso</label>
<asp:TextBox CssClass="col-md-8" ID="TxtFrecuencia" runat="server" type="number"></asp:TextBox>
</div>
</asp:Panel>
</div>
</div>
<div class="modal-footer">
<asp:Button ID="BtnGuardar" OnClick="AddViaje" runat="server" CssClass="btn btn-primary"
Text="Guardar"
ValidationGroup="GrpGuardar"></asp:Button>
ValidationGroup="GrpGuardar"
Text="Guardar"></asp:Button>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
</div>

View File

@@ -10,7 +10,6 @@ Partial Class ListadoViajes
If Not IsPostBack Then
CargaDatos()
End If
End Sub
Private Sub CargaDatos()
@@ -84,12 +83,51 @@ 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>")
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 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)
@@ -114,15 +152,17 @@ Partial Class ListadoViajes
ObjViajes.Commit()
End If
End If
End If
Catch ex As Exception
ObjViajes.RollBack()
Finally
ObjViajes.Dispose()
Response.Redirect("ListadoViajes.aspx")
End Try
End If
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