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,230 +8,248 @@
<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>
<li>
<asp:HyperLink ID="LBListadoContratos" runat="server" NavigateUrl="ListadoContratos.aspx"
Target="_blank"><i class='fa fa-list'></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>
<li>
<asp:HyperLink ID="LBListadoContratos" runat="server" NavigateUrl="ListadoContratos.aspx"
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>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="C" runat="Server">
<div class="row" style="margin-block: 10px; margin-right: 10px;" align="right">
<asp:LinkButton OnClick="MostrarModal" runat="server" AlternateText="Agregar"
CssClass="btn btn-sm blue" align="right" Text="Agregar<i class='fa fa-plus'></i>" />
</div>
<asp:GridView ID="GvViajes" runat="server" AutoGenerateColumns="false" EmptyDataText="No se encontró ningún viaje registrado"
CssClass="table table-striped table-hover Widthall ScrollAD text-center" GridLines="None"
data-sort="true" DataKeyNames="CveViaje, CveRuta, Fecha, CveAF, CvePersonal, CveEmpresa, CvePartida, CveDestino">
<Columns>
<div class="row" style="margin-block: 10px; margin-right: 10px;" align="right">
<asp:LinkButton OnClick="MostrarModal" runat="server" AlternateText="Agregar"
CssClass="btn btn-sm blue" align="right" Text="Agregar<i class='fa fa-plus'></i>" />
</div>
<asp:TemplateField HeaderText="Ruta">
<ItemTemplate>
<asp:Literal ID="LtlRuta" runat="server" Text='<%# Eval("CveRuta") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:GridView ID="GvViajes" runat="server" AutoGenerateColumns="false" EmptyDataText="No se encontró ningún viaje registrado"
CssClass="table table-striped table-hover Widthall ScrollAD text-center" GridLines="None"
data-sort="true" DataKeyNames="CveViaje, CveRuta, Fecha, CveAF, CvePersonal, CveEmpresa, CvePartida, CveDestino">
<Columns>
<asp:TemplateField HeaderText="Partida">
<ItemTemplate>
<asp:Literal ID="LtlPartida" runat="server" Text='<%# Eval("Partida") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Ruta">
<ItemTemplate>
<asp:Literal ID="LtlRuta" runat="server" Text='<%# Eval("CveRuta") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Destino">
<ItemTemplate>
<asp:Literal ID="LtlDestino" runat="server" Text='<%# Eval("Destino") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Partida">
<ItemTemplate>
<asp:Literal ID="LtlPartida" runat="server" Text='<%# Eval("Partida") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fecha">
<ItemTemplate>
<asp:Literal ID="LtlFecha" runat="server" Text='<%# Eval("Fecha") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Destino">
<ItemTemplate>
<asp:Literal ID="LtlDestino" runat="server" Text='<%# Eval("Destino") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Unidad">
<ItemTemplate>
<asp:Literal ID="LtlFecha" runat="server" Text='<%# Eval("Fecha") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fecha">
<ItemTemplate>
<asp:Literal ID="LtlFecha" runat="server" Text='<%# Eval("Fecha") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Chofer">
<ItemTemplate>
<asp:Literal ID="LtlChofer" runat="server" Text='<%# Eval("NombreCompleto") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Unidad">
<ItemTemplate>
<asp:Literal ID="LltAF" runat="server" Text='<%# Eval("Unidad") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Acciones">
<ItemTemplate>
<asp:LinkButton ID="BtnEditar" runat="server" AlternateText="Editar"
CssClass="btn btn-circle btn-sm green" OnClick="UpdateViaje" Text="<i class='fa fa-pencil'></i>" />
<asp:LinkButton ID="BtnEliminar" runat="server" AlternateText="Eliminar"
CssClass="btn btn-circle btn-sm red" OnClick="RemoveViaje" Text="<i class='fa fa-trash'></i>"
data-toggle="confirmation" data-popout="true" data-original-title="Confirmar"
data-btn-ok-label="si" />
<asp:TemplateField HeaderText="Chofer">
<ItemTemplate>
<asp:Literal ID="LtlChofer" runat="server" Text='<%# Eval("NombreCompleto") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Acciones">
<ItemTemplate>
<asp:LinkButton ID="BtnEditar" runat="server" AlternateText="Editar"
CssClass="btn btn-circle btn-sm green" OnClick="UpdateViaje" Text="<i class='fa fa-pencil'></i>" />
<asp:LinkButton ID="BtnEliminar" runat="server" AlternateText="Eliminar"
CssClass="btn btn-circle btn-sm red" OnClick="RemoveViaje" Text="<i class='fa fa-trash'></i>"
data-toggle="confirmation" data-popout="true" data-original-title="Confirmar"
data-btn-ok-label="si" />
<div id="ModalAgregar" class="modal ADS fade" role="dialog">
<div class="modal-dialog">
<div id="UpAddChofer" class="modal-content rowpadding" tabindex="-1"
runat="server">
<contenttemplate>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="ModalLabel" runat="server">Agregar Viaje</h4>
</div>
<div class="modal-body">
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<div class="portlet-body">
<div class="row margin-bottom-5" id="TrAF" runat="server">
<label class="col-md-4 bold">
<asp:Label runat="server" Text="Transporte:"></asp:Label></label><div
class="col-md-8">
<asp:DropDownList ID="DdlTransporte" AppendDataBoundItems="true" DataTextField="Descripcion"
DataValueField="CveActivoFijo" Class="table-group-action-input form-control input-inline text-center"
Width="200px" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVTransporte" runat="server" ControlToValidate="DdlTransporte"
Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Transporte''</b> es necesario, por favor ingréselo."
ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCETransporte" runat="server" HighlightCssClass="vco"
TargetControlID="RFVTransporte" Width="400px" BehaviorID="_content_VCETransporte">
</ajax:ValidatorCalloutExtender>
</div>
</div>
<div class="row margin-bottom-5" id="TrRutas" runat="server">
<label class="col-md-4 bold">
<asp:Label runat="server" Text="Seleccione Ruta:"></asp:Label></label><div
class="col-md-8">
<asp:DropDownList ID="DdlRutas" AppendDataBoundItems="true" DataTextField="Ruta"
DataValueField="CveRuta" Class="table-group-action-input form-control input-inline text-center"
Width="200px" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVRutas" runat="server" ControlToValidate="DdlRutas"
Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Rutas''</b> es necesario, por favor ingréselo."
ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCERutas" runat="server" HighlightCssClass="vco"
TargetControlID="RFVRutas" Width="400px" BehaviorID="_content_VCERutas">
</ajax:ValidatorCalloutExtender>
</div>
</div>
<div class="row margin-bottom-5" id="TrDestino" runat="server">
<label class="col-md-4 bold">
<asp:Label runat="server" Text="Destino:"></asp:Label></label><div
class="col-md-8">
<asp:DropDownList ID="DdlDestino" AppendDataBoundItems="true" DataTextField="Destino"
DataValueField="CveDestino" Class="table-group-action-input form-control input-inline text-center"
Width="200px" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVDestino" runat="server" ControlToValidate="DdlDestino"
Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Destino''</b> es necesario, por favor ingréselo."
ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCEDestino" runat="server" HighlightCssClass="vco"
TargetControlID="RFVDestino" Width="400px" BehaviorID="_content_VCEDestino">
</ajax:ValidatorCalloutExtender>
</div>
</div>
<div class="row margin-bottom-5" id="TrPartida" runat="server">
<label class="col-md-4 bold">
<asp:Label runat="server" Text="Partida:"></asp:Label></label><div
class="col-md-8">
<asp:DropDownList ID="DdlPartida" AppendDataBoundItems="true" DataTextField="Destino"
DataValueField="CveDestino" Class="table-group-action-input form-control input-inline text-center"
Width="200px" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVPartida" runat="server" ControlToValidate="DdlPartida"
Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Partida''</b> es necesario, por favor ingréselo."
ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCEPartida" runat="server" HighlightCssClass="vco"
TargetControlID="RFVPartida" Width="400px" BehaviorID="_content_VCEPartida">
</ajax:ValidatorCalloutExtender>
</div>
</div>
<div class="row margin-bottom-5" id="TrChofer" runat="server">
<label class="col-md-4 bold">
<asp:Label runat="server" Text="Chofer:"></asp:Label></label><div
class="col-md-8">
<asp:DropDownList ID="DdlChofer" AppendDataBoundItems="true" DataValueField="CvePersonal"
DataTextField="NombreCompleto" Class="table-group-action-input form-control input-inline text-center"
Width="200px" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVChofer" runat="server" ControlToValidate="DdlChofer"
Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Chofer''</b> es necesario, por favor ingréselo."
ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCEChofer" runat="server" HighlightCssClass="vco"
TargetControlID="RFVChofer" Width="400px" BehaviorID="_content_VCEChofer">
</ajax:ValidatorCalloutExtender>
</div>
</div>
<div class="row my-1">
<label class="col-md-4 bold">Fecha Viaje:</label>
<div class="col-md-8">
<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: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."
ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCETxtFechaViaje" runat="server" HighlightCssClass="vco"
TargetControlID="RFVTxtFechaViaje" Width="400px" BehaviorID="_content_VCETxtFechaViaje">
</ajax:ValidatorCalloutExtender>
</div>
</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>
</div>
<div class="modal-footer">
<asp:Button ID="BtnGuardar" OnClick="AddViaje" runat="server" CssClass="btn btn-primary"
Text="Guardar"
ValidationGroup="GrpGuardar"></asp:Button>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
</div>
</div>
</contenttemplate>
<div id="ModalAgregar" class="modal ADS fade" role="dialog">
<div class="modal-dialog">
<div id="UpAddChofer" class="modal-content rowpadding" tabindex="-1"
runat="server">
<contenttemplate>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="ModalLabel" runat="server">Agregar Viaje</h4>
</div>
</div>
<div class="modal-body">
<div class="portlet-body">
<div class="row margin-bottom-5" id="TrAF" runat="server">
<label class="col-md-4 bold">
<asp:Label runat="server" Text="Transporte:"></asp:Label></label><div
class="col-md-8">
<asp:DropDownList ID="DdlTransporte" AppendDataBoundItems="true" DataTextField="Descripcion"
DataValueField="CveActivoFijo" Class="table-group-action-input form-control input-inline text-center"
Width="200px" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVTransporte" runat="server" ControlToValidate="DdlTransporte"
Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Transporte''</b> es necesario, por favor ingréselo."
ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCETransporte" runat="server" HighlightCssClass="vco"
TargetControlID="RFVTransporte" Width="400px" BehaviorID="_content_VCETransporte">
</ajax:ValidatorCalloutExtender>
</div>
</div>
<div class="row margin-bottom-5" id="TrRutas" runat="server">
<label class="col-md-4 bold">
<asp:Label runat="server" Text="Seleccione Ruta:"></asp:Label></label><div
class="col-md-8">
<asp:DropDownList ID="DdlRutas" AppendDataBoundItems="true" DataTextField="Ruta"
DataValueField="CveRuta" Class="table-group-action-input form-control input-inline text-center"
Width="200px" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVRutas" runat="server" ControlToValidate="DdlRutas"
Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Rutas''</b> es necesario, por favor ingréselo."
ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCERutas" runat="server" HighlightCssClass="vco"
TargetControlID="RFVRutas" Width="400px" BehaviorID="_content_VCERutas">
</ajax:ValidatorCalloutExtender>
</div>
</div>
<div class="row margin-bottom-5" id="TrDestino" runat="server">
<label class="col-md-4 bold">
<asp:Label runat="server" Text="Destino:"></asp:Label></label><div
class="col-md-8">
<asp:DropDownList ID="DdlDestino" AppendDataBoundItems="true" DataTextField="Destino"
DataValueField="CveDestino" Class="table-group-action-input form-control input-inline text-center"
Width="200px" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVDestino" runat="server" ControlToValidate="DdlDestino"
Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Destino''</b> es necesario, por favor ingréselo."
ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCEDestino" runat="server" HighlightCssClass="vco"
TargetControlID="RFVDestino" Width="400px" BehaviorID="_content_VCEDestino">
</ajax:ValidatorCalloutExtender>
</div>
</div>
<div class="row margin-bottom-5" id="TrPartida" runat="server">
<label class="col-md-4 bold">
<asp:Label runat="server" Text="Partida:"></asp:Label></label><div
class="col-md-8">
<asp:DropDownList ID="DdlPartida" AppendDataBoundItems="true" DataTextField="Destino"
DataValueField="CveDestino" Class="table-group-action-input form-control input-inline text-center"
Width="200px" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVPartida" runat="server" ControlToValidate="DdlPartida"
Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Partida''</b> es necesario, por favor ingréselo."
ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCEPartida" runat="server" HighlightCssClass="vco"
TargetControlID="RFVPartida" Width="400px" BehaviorID="_content_VCEPartida">
</ajax:ValidatorCalloutExtender>
</div>
</div>
<div class="row margin-bottom-5" id="TrChofer" runat="server">
<label class="col-md-4 bold">
<asp:Label runat="server" Text="Chofer:"></asp:Label></label><div
class="col-md-8">
<asp:DropDownList ID="DdlChofer" AppendDataBoundItems="true" DataValueField="CvePersonal"
DataTextField="NombreCompleto" Class="table-group-action-input form-control input-inline text-center"
Width="200px" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVChofer" runat="server" ControlToValidate="DdlChofer"
Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Chofer''</b> es necesario, por favor ingréselo."
ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCEChofer" runat="server" HighlightCssClass="vco"
TargetControlID="RFVChofer" Width="400px" BehaviorID="_content_VCEChofer">
</ajax:ValidatorCalloutExtender>
</div>
</div>
<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" 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."
ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCETxtFechaViaje" runat="server" HighlightCssClass="vco"
TargetControlID="RFVTxtFechaViaje" Width="400px" BehaviorID="_content_VCETxtFechaViaje">
</ajax:ValidatorCalloutExtender>
</div>
</div>
</div>
<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"
ValidationGroup="GrpGuardar"
Text="Guardar"></asp:Button>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
</div>
</div>
</contenttemplate>
</div>
</div>
</div>
</asp:Content>

View File

@@ -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