diff --git a/App_Code/ClsViajes.vb b/App_Code/ClsViajes.vb index 7ee08071c..3e11be332 100644 --- a/App_Code/ClsViajes.vb +++ b/App_Code/ClsViajes.vb @@ -34,6 +34,7 @@ Public Class ClsViajes Public Property CveEmpresa As Integer Public Property CvePartida As Integer Public Property CveDestino As Integer + Public Property CveMasivo As Integer Public Property Fecha As DateTime #End Region @@ -135,7 +136,7 @@ Public Class ClsViajes #End Region #Region "Métodos" - Public Function AddViajes(CveRuta As Integer, CveAF As Integer, CvePersonal As Integer, CveEmpresa As Integer, Fecha As DateTime, CvePartida As Integer, CveDestino As Integer) As Integer + Public Function AddViajes(CveRuta As Integer, CveAF As Integer, CvePersonal As Integer, CveEmpresa As Integer, Fecha As DateTime, CvePartida As Integer, CveDestino As Integer, Optional IsMasivo As Boolean = False, Optional CveMasivo As Integer = -1) As Integer Dim Retorno As Integer = -1 DataAdapter("PA_Trans_ViajesAdd") @@ -149,6 +150,8 @@ Public Class ClsViajes .Add("@Fecha", SqlDbType.DateTime).Value = Fecha .Add("@CvePartida", SqlDbType.Int).Value = CvePartida .Add("@CveDestino", SqlDbType.Int).Value = CveDestino + .Add("@IsMasivo", SqlDbType.Bit).Value = IsMasivo + .Add("@CveMasivo", SqlDbType.Int).Value = CveMasivo End With Try @@ -164,6 +167,7 @@ Public Class ClsViajes Public Function GetViajes(Optional CveViaje As Integer = 0) As Boolean Dim Retorno As Boolean = False + DataAdapter("PA_Trans_ViajesGet") If CveViaje > 0 Then With SqlAdapter.SelectCommand.Parameters @@ -179,6 +183,7 @@ Public Class ClsViajes CveEmpresa = Data.Rows(0)("CveEmpresa").ToString.ToEntero CvePartida = Data.Rows(0)("CvePartida").ToString.ToEntero CveDestino = Data.Rows(0)("CveDestino").ToString.ToEntero + CveMasivo = Data.Rows(0)("CveMasivo").ToString.ToEntero Fecha = Data.Rows(0)("Fecha").ToString.ToDate End If Retorno = True @@ -189,12 +194,14 @@ Public Class ClsViajes Return Retorno End Function - Public Function RemoveViaje(CveViaje As Integer) As Boolean + Public Function RemoveViaje(CveViaje As Integer, Optional CveMasivo As Integer = 0) As Boolean Dim Retorno As Boolean = False + DataAdapter("PA_Trans_ViajesRemove") With SqlAdapter.SelectCommand.Parameters .Add("@CveViaje", SqlDbType.Int).Value = CveViaje + .Add("@CveMasivo", SqlDbType.Int).Value = CveMasivo End With Try diff --git a/Transportes/ListadoContratos.aspx b/Transportes/ListadoContratos.aspx index 917465acc..f8b159f6a 100644 --- a/Transportes/ListadoContratos.aspx +++ b/Transportes/ListadoContratos.aspx @@ -36,7 +36,7 @@
  • Contratos + Target="_blank">Contratos
  • @@ -42,7 +45,7 @@ + data-sort="true" DataKeyNames="CveViaje, CveRuta, Fecha, CveAF, CvePersonal, CveEmpresa, CvePartida, CveDestino, CveMasivo"> @@ -81,13 +84,19 @@ + + + > + + + @@ -207,7 +216,7 @@
    + MaxLength="10"> "" 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 ObjViajes As New ClsViajes ObjViajes.IniciaTransacSQL() @@ -86,8 +97,8 @@ Partial Class ListadoViajes Dim ObjViajes As New ClsViajes + ObjViajes.IniciaTransacSQL() - Page.Response.Write("") If IsMasivo.Checked = True Then If TxtFechaInicial.Text = "" Or TxtFrecuencia.Text = "" Then @@ -95,6 +106,8 @@ Partial Class ListadoViajes Exit Sub End If + Dim CveMasivo = 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)() @@ -106,7 +119,7 @@ Partial Class ListadoViajes 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) + CveContratoHijo = ObjViajes.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 ObjViajes.Commit() @@ -187,18 +200,35 @@ Partial Class ListadoViajes Protected Sub RemoveViaje(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim IsMasivo = GvRow.DataKey("CveMasivo") + Dim ObjViajes As New ClsViajes ObjViajes.IniciaTransacSQL() - Try - ObjViajes.RemoveViaje(GvRow.DataKey("CveViaje").ToEntero) - ObjViajes.Commit() - Response.Redirect(Request.RawUrl) - Catch ex As Exception - Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError) - Finally - ObjViajes.Dispose() - End Try + If IsMasivo <> "" Then + Try + ObjViajes.RemoveViaje(-1, CveMasivo:=IsMasivo.ToEntero) + ObjViajes.Commit() + Response.Redirect(Request.RawUrl) + Catch ex As Exception + Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError) + Finally + ObjViajes.Dispose() + End Try + + Else + Try + ObjViajes.RemoveViaje(GvRow.DataKey("CveViaje").ToEntero) + ObjViajes.Commit() + Response.Redirect(Request.RawUrl) + Catch ex As Exception + Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError) + Finally + ObjViajes.Dispose() + End Try + End If + + End Sub Protected Sub ToggleMasivo(sender As Object, e As EventArgs)