--Remove Masivo
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<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"
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
.fecha {
|
||||
padding: 3px;
|
||||
}
|
||||
.masivo{
|
||||
color:green;
|
||||
}
|
||||
|
||||
</style>
|
||||
</asp:Content>
|
||||
@@ -42,7 +45,7 @@
|
||||
|
||||
<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">
|
||||
data-sort="true" DataKeyNames="CveViaje, CveRuta, Fecha, CveAF, CvePersonal, CveEmpresa, CvePartida, CveDestino, CveMasivo">
|
||||
<Columns>
|
||||
|
||||
<asp:TemplateField HeaderText="Ruta">
|
||||
@@ -81,13 +84,19 @@
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
|
||||
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Masivo">
|
||||
<ItemTemplate>
|
||||
<asp:Label ID="LtlMasivo" runat="server" Text='<%# Eval("CveMasivo") %>'>></asp:Label>
|
||||
</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-toggle="confirmation" data-popout="true" data-original-title='<%# If(Eval("CveMasivo").ToString <> "", "Eliminación masiva", "Confirmar") %>'
|
||||
data-btn-ok-label="si" />
|
||||
|
||||
</ItemTemplate>
|
||||
@@ -207,7 +216,7 @@
|
||||
<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>
|
||||
MaxLength="10">
|
||||
</asp:TextBox>
|
||||
|
||||
<asp:RequiredFieldValidator ID="RFVTxtFechaViaje" runat="server" ControlToValidate="TxtFechaViaje"
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user