Files
SIG/Transportes/RepContratoDetalle.aspx.vb

206 lines
8.8 KiB
VB.net

Option Explicit On
Option Strict On
Imports System.Data
Imports ADSNetLibrary.Helpers
Imports ADSNetLibrary.SIGAPI.Helpers
Imports Extensiones
Imports Extensiones.ModExtensiones
Imports Microsoft.Reporting.WebForms
Partial Class RepContratoDetalle
Inherits ClsPaginas
Private Property CveContrato As Integer
Get
Return CType(ViewState("CveContrato"), Integer)
End Get
Set(value As Integer)
ViewState("CveContrato") = value
End Set
End Property
Private Property Contrato As DataTable
Get
Return CType(ViewState("Contrato"), DataTable)
End Get
Set(value As DataTable)
ViewState("Contrato") = value
End Set
End Property
Private Property SubProyecto As String
Get
Return CType(ViewState("SubProyecto"), String)
End Get
Set(value As String)
ViewState("SubProyecto") = value
End Set
End Property
Private Property AsientoSeleccionado As String
Get
Return ViewState("AsientoSeleccionado").ToString()
End Get
Set(value As String)
ViewState("AsientoSeleccionado") = value
End Set
End Property
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Request("CveContrato") Is Nothing Then
Response.Redirect($"~/Transportes/RepContratos.aspx")
End If
CveContrato = Request("CveContrato").ToEntero
If Not IsPostBack Then
InicializaCombos()
CargaDatos()
End If
End Sub
Private Sub InicializaCombos()
'Lista Tipo AF
DdlTipoAF.DataSource = GlobalDTTipoActivoFijo(UsuarioActual.CveEmpresa)
DdlTipoAF.DataBind()
DdlTipoAF.Items.Insert(0, New ListItem("-", ""))
End Sub
Private Sub CargaDatos()
'Información General
Dim ObjContratos As New ClsContratos
If ObjContratos.GetContratos(CveContrato, UsuarioActual.CveEmpresa) Then
Contrato = ObjContratos.DtResultados
If Contrato IsNot Nothing AndAlso Contrato.Rows.Count > 0 Then
SubProyecto = Contrato.Rows(0)("SubProyecto").ToString
LbFolio.Text = Contrato.Rows(0)("NumeroContrato").ToString
DdlClientes.SelectedText = Contrato.Rows(0)("NombreComercial").ToString
DdlClientes.SelectedValue = Contrato.Rows(0)("CveCliente").ToString
TxtDescripcion.Text = Contrato.Rows(0)("DescripcionContrato").ToString
TxtObservaciones.Text = Contrato.Rows(0)("Observaciones").ToString
TxtUbicacion.Text = Contrato.Rows(0)("Ubicacion").ToString
TxtFechaSalida.Text = Contrato.Rows(0)("FechaInicial").ToString
TxtFechaRegreso.Text = Contrato.Rows(0)("FechaFinal").ToString
TxtCantidadPasajeros.Text = Contrato.Rows(0)("CantidadPasajeros").ToString
DdlTipoAF.SelectedValue = Contrato.Rows(0)("CveTipoAF").ToString
TxtDolares.Text = Contrato.Rows(0)("Importe").ToString
TxtPesos.Text = Contrato.Rows(0)("ImporteMax").ToString
TxtAnticipo.Text = Contrato.Rows(0)("ImporteMin").ToString
'Boletos Vendidos
If Contrato.Rows(0)("CveContratoTipo").ToString() = "35" Then
TabBoletos.Visible = True
Dim ObjTransportes As New ClsTransportes
If ObjTransportes.GetViajesPasajeros(CveContrato) Then
GvViajesPasajeros.DataSource = ObjTransportes.DtResultados
End If
ObjTransportes.Dispose()
GvViajesPasajeros.DataBind()
End If
End If
Else
ObjContratos.Dispose()
Response.Redirect($"~/Transportes/RepContratos.aspx")
End If
ObjContratos.Dispose()
End Sub
Protected Sub BtnCancelar_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
Dim CveViajePasajero As String = GvRow.DataKey("CveViajePasajero")
Dim Estatus As String = GvRow.DataKey("Estatus")
Dim cambiarEstatus As Boolean = Not Estatus.ToBool
Dim ObjTransportes As New ClsTransportes
ObjTransportes.IniciaTransacSQL()
Try
If ObjTransportes.UpdateViajesPasajeros(CveViajePasajero.ToEntero, Activar:=cambiarEstatus, Estatus:=cambiarEstatus) Then
If Not cambiarEstatus Then
Alert($"El boleto ha sido cancelado correctamente.")
Else
Alert($"El boleto ha sido reactivado correctamente.")
End If
End If
ObjTransportes.Commit()
Catch ex As Exception
ObjTransportes.RollBack()
Alert($"No se pudo cambiar el estatus del boleto {ex}", TipoMensaje.MsgError)
Finally
ObjTransportes.Dispose()
CargaDatos()
End Try
End Sub
Protected Sub EditarBoleto(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
LbPartida.Text = GvRow.DataKey("Partida").ToString()
LbDestino.Text = GvRow.DataKey("Destino").ToString()
LbImporte.Text = GvRow.DataKey("Importe").ToString()
LbNombre.Text = GvRow.DataKey("Nombre").ToString()
LbVisa.Text = GvRow.DataKey("Visa").ToString()
LbCelular.Text = GvRow.DataKey("Celular").ToString()
LbObservacion.Text = GvRow.DataKey("Observacion").ToString()
LbEstatus.Text = GvRow.DataKey("Estatus").ToString()
LbCreado.Text = GvRow.DataKey("FechaIng").ToString()
LbAsiento.Text = GvRow.DataKey("Asiento").ToString()
'Seleccionamos la ruta que tiene el usuario actual
DdlRuta.ClearSelection()
Dim ObjContratos As New ClsContratos
If ObjContratos.GetContratosReporte(UsuarioActual.CveEmpresa, MinFecha, MaxFecha, -1, CveEstatus:=-1, CveTipoContrato:=35) Then
For Each row As DataRow In ObjContratos.DtResultados.Rows
' Asigna los valores de la columna deseada al ListItem
Dim listItem As New ListItem(row("CveContrato").ToString(), row("CveContrato").ToString())
' Agrega el ListItem al DropDownList
DdlRuta.Items.Add(listItem)
Next
End If
ObjContratos.Dispose()
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalEditar"))
End Sub
Protected Sub UpdateBoleto(sender As Object, e As EventArgs)
End Sub
Protected Sub OnLinkButtonClick(sender As Object, e As EventArgs)
'quitamos la selección anterior, en caso de existir.
If AsientoSeleccionado <> "" Then
Dim cph As ContentPlaceHolder = CType(Me.Master.FindControl("C"), ContentPlaceHolder)
Dim lnk As LinkButton = CType(cph.FindControl(AsientoSeleccionado), LinkButton)
lnk.CssClass = "disponible"
End If
Dim linkButton As LinkButton = DirectCast(sender, LinkButton)
Dim buttonID As String = linkButton.ID
linkButton.CssClass += " activo"
AsientoSeleccionado = buttonID
UpBoletos.Update()
End Sub
Protected Sub ImprimirBoleto(sender As Object, e As EventArgs)
Dim dtResult As New DataTable()
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
Dim Fecha As Date = GvRow.DataKey("FechaIng").ToDate
Dim Importe As Decimal = GvRow.DataKey("Importe").ToDecimal
Dim params As New List(Of ReportParameter) From {
New ReportParameter("Ruta", SubProyecto),
New ReportParameter("Origen", GvRow.DataKey("Partida")),
New ReportParameter("Destino", GvRow.DataKey("Destino")),
New ReportParameter("FechaSalida", Fecha.ToShortDateString()),
New ReportParameter("HoraSalida", Fecha.ToString("HH:mm")),
New ReportParameter("Nombre", GvRow.DataKey("Nombre")),
New ReportParameter("Visa", GvRow.DataKey("Visa")),
New ReportParameter("Celular", GvRow.DataKey("Celular")),
New ReportParameter("Importe", Math.Round(Importe, 1).ToString),
New ReportParameter("TipoBoleto", "Tipo Boleto"),
New ReportParameter("Agencia", GvRow.DataKey("Agencia")),
New ReportParameter("TelefonoAgencia", GvRow.DataKey("TelefonoAgencia")),
New ReportParameter("Asiento", GvRow.DataKey("Asiento"))
}
ImprimirPDFStimul($"{UsuarioActual.Empresa.Ruta}Formatos\Boleto.mrt", dtResult, params, NombreArchivo:="Boleto")
'Empresas/Grales/Formatos/EntradaSalida.mrt
'Empresas/188/Formatos/Boleto.mrt
End Sub
End Class