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"> <asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
<style> <style>
.my-1 { .my-1 {
margin-block: 1rem; margin-block: .5rem;
} }
.fecha {
padding: 3px;
}
</style> </style>
</asp:Content> </asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="HB" runat="Server"> <asp:Content ID="Content1" ContentPlaceHolderID="HB" runat="Server">
<ContentTemplate> <contenttemplate>
<li> <li>
<asp:HyperLink ID="LBListadoContratos" runat="server" NavigateUrl="ListadoContratos.aspx" <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>
<li> <li>
<asp:HyperLink ID="LBListadoViajes" runat="server" NavigateUrl="ListadoViajes.aspx" <asp:HyperLink ID="LBListadoViajes" runat="server" NavigateUrl="ListadoViajes.aspx"
Target="_blank"><i class='fa fa-road'></i>Viajes</asp:HyperLink> Target="_blank"><i class='fa fa-road'></i>Viajes</asp:HyperLink>
</li> </li>
</ContentTemplate> </contenttemplate>
</asp:Content> </asp:Content>
@@ -66,7 +71,7 @@
<asp:TemplateField HeaderText="Unidad"> <asp:TemplateField HeaderText="Unidad">
<ItemTemplate> <ItemTemplate>
<asp:Literal ID="LtlFecha" runat="server" Text='<%# Eval("Fecha") %>'></asp:Literal> <asp:Literal ID="LltAF" runat="server" Text='<%# Eval("Unidad") %>'></asp:Literal>
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
@@ -195,14 +200,15 @@
</div> </div>
</div> </div>
<div class="row my-1"> <div class="row my-1 truncate">
<label class="col-md-4 bold">Fecha Viaje:</label> <label class="col-md-4 boldinput-group date date-picker bold" data-date-format="dd/mm/yyyy">
<div class="col-md-8"> Fecha Viaje:</label>
<div class="col-md-8 fecha">
<div class="input-group input-sm input-small date date-picker"> <div class="input-group input-sm input-small date date-picker">
<asp:TextBox ID="TxtFechaViaje" runat="server" CssClass="form-control text-center" <asp:TextBox ID="TxtFechaViaje" runat="server" CssClass="form-control" CausesValidation="True"
Width="200px" type="date"
CausesValidation="True" MaxLength="10"> <i class="fa fa-calendar"></i>
type="date"></asp:TextBox> </asp:TextBox>
<asp:RequiredFieldValidator ID="RFVTxtFechaViaje" runat="server" ControlToValidate="TxtFechaViaje" <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." 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> </div>
<div class="form-group form-md-line-input input-iconright" id="divEstatus" runat="server"> <div class="row">
<asp:CheckBox ID="ChkEstatus" runat="server" CssClass="form-control bold" /> <asp:CheckBox CssClass="col-md-4" ID="IsMasivo" runat="server" Text="Generar Viajes Masivo"
<label>Generar Viaje Masivo</label> 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>
<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>
<div class="modal-footer"> <div class="modal-footer">
<asp:Button ID="BtnGuardar" OnClick="AddViaje" runat="server" CssClass="btn btn-primary" <asp:Button ID="BtnGuardar" OnClick="AddViaje" runat="server" CssClass="btn btn-primary"
Text="Guardar" ValidationGroup="GrpGuardar"
ValidationGroup="GrpGuardar"></asp:Button> Text="Guardar"></asp:Button>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
</div> </div>

View File

@@ -10,7 +10,6 @@ Partial Class ListadoViajes
If Not IsPostBack Then If Not IsPostBack Then
CargaDatos() CargaDatos()
End If End If
End Sub End Sub
Private Sub CargaDatos() Private Sub CargaDatos()
@@ -84,12 +83,51 @@ Partial Class ListadoViajes
End Sub End Sub
Protected Sub AddViaje(sender As Object, e As EventArgs) Protected Sub AddViaje(sender As Object, e As EventArgs)
Dim ObjViajes As New ClsViajes Dim ObjViajes As New ClsViajes
ObjViajes.IniciaTransacSQL() 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 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 If BtnGuardar.Text = "Guardar" Then
Dim CveContratoHijo As Integer = -1 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 = 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() ObjViajes.Commit()
End If End If
End If
End If
Catch ex As Exception Catch ex As Exception
ObjViajes.RollBack() ObjViajes.RollBack()
Finally Finally
ObjViajes.Dispose() ObjViajes.Dispose()
Response.Redirect("ListadoViajes.aspx") Response.Redirect("ListadoViajes.aspx")
End Try End Try
End If
End Sub End Sub
Protected Sub UpdateViaje(sender As Object, e As EventArgs) Protected Sub UpdateViaje(sender As Object, e As EventArgs)
@@ -160,4 +200,10 @@ Partial Class ListadoViajes
ObjViajes.Dispose() ObjViajes.Dispose()
End Try End Try
End Sub 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 End Class