--Remove Masivo

This commit is contained in:
AbrahamCastilloV
2023-12-16 11:38:12 -07:00
parent 37899f4826
commit ce0e5707b6
4 changed files with 63 additions and 17 deletions

View File

@@ -7,12 +7,23 @@ Partial Class ListadoViajes
Inherits ClsPaginas
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
CargaDatos()
End If
End Sub
Private Sub GvViajes_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvViajes.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("CveMasivo") <> "" 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("<script>console.log('El resultado de tu variable" + IsMasivo.Checked.ToString + "')</script>")
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)