-- multiples pasajeros en una venta

This commit is contained in:
2024-02-16 18:41:19 -07:00
parent d78eb630e0
commit 0a02981ea4
2 changed files with 214 additions and 86 deletions

View File

@@ -1,10 +1,9 @@
Option Explicit On
Option Strict On
Imports System.Data
Imports ADSNetLibrary.Helpers
Imports ADSNetLibrary.SIGAPI.Helpers
Imports Extensiones
Imports Extensiones.ModExtensiones
Imports Microsoft.Ajax.Utilities
Partial Class Boletos
Inherits ClsPaginas
@@ -42,6 +41,14 @@ Partial Class Boletos
ViewState("Contrato") = value
End Set
End Property
Private Property DtPasajeros As DataTable
Get
Return CType(ViewState("DtPasajeros"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtPasajeros") = value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
@@ -53,7 +60,7 @@ Partial Class Boletos
CveViaje = Request.QueryString("CveViaje").ToEntero
If CveViaje > 0 Then
CargaDatos()
InicializaCombos()
End If
End If
@@ -61,14 +68,44 @@ Partial Class Boletos
Private Sub CargaDatos()
Dim ObjContratos As New ClsContratos
Dim ObjViaje As New ClsTransportes
If ObjContratos.GetContratos(CveViaje, UsuarioActual.CveEmpresa) Then
Contrato = ObjContratos.DtResultados
If ObjContratos.DtResultados IsNot Nothing AndAlso ObjContratos.DtResultados.Rows.Count > 0 Then
TxtRuta.Text = Contrato.Rows(0)("Ruta").ToString
TxtFecha.Text = Contrato.Rows(0)("FechaInicial").ToString.ToDate.ToShortDateString
DtPasajeros = New DataTable
DtPasajeros.Columns.Add("Numero", GetType(Integer))
DtPasajeros.Columns.Add("Nombre", GetType(String))
DtPasajeros.Columns.Add("Visa", GetType(String))
DtPasajeros.Columns.Add("Asiento", GetType(String))
DtPasajeros.Columns.Add("Importe", GetType(Decimal))
InicializaCombos()
'Boletos Vendidos
Dim dt As DataTable
If ObjViaje.GetViajesPasajeros(CveViaje, Estatus:=1) Then 'Poner párametro para estatus y cancelado de viajes
dt = ObjViaje.DtResultados
Dim cph As ContentPlaceHolder = CType(Me.Master.FindControl("C"), ContentPlaceHolder)
For Each dr As DataRow In dt.Rows
Dim lnk As LinkButton = CType(cph.FindControl($"A{dr("Asiento")}"), LinkButton)
If lnk IsNot Nothing Then
lnk.Enabled = False
lnk.CssClass = "nodisponible"
lnk.ToolTip = dr("Nombre").ToString
End If
Next
End If
End If
Else
ObjContratos.Dispose()
Response.Redirect($"~/Transportes/RepContratos.aspx")
End If
TxtRuta.Text = Contrato.Rows(0)("Ruta").ToString
TxtFecha.Text = Contrato.Rows(0)("FechaInicial").ToString
ObjContratos.Dispose()
ObjViaje.Dispose()
End Sub
@@ -80,7 +117,6 @@ Partial Class Boletos
Dim ObjDestinos As New ClsTransportes()
If Not ObjDestinos.GetDestinos(CveRuta:=CveRuta) Then
Else
If ObjDestinos.DtResultados.Rows.Count > 0 Then
DdlPartida.DataSource = ObjDestinos.DtResultados
@@ -136,7 +172,7 @@ Partial Class Boletos
linkButton.CssClass += " activo"
AsientoSeleccionado = buttonID
End Sub
Protected Sub AddBoleto(sender As Object, e As EventArgs)
Protected Sub FinalizarVenta(sender As Object, e As EventArgs)
If AsientoSeleccionado = "" Then
Alert("Se requiere seleccionar su asiento", TipoMensaje.MsgAdvertencia)
Exit Sub
@@ -147,17 +183,29 @@ Partial Class Boletos
Try
AsientoSeleccionado = AsientoSeleccionado.Replace("A", "")
If ObjTransporte.AddViajesPasajeros(CveViaje, DdlPartida.SelectedValue.ToEntero, DdlDestino.SelectedValue.ToEntero, Importe, AsientoSeleccionado.ToEntero, TxtNombre.Text, TxtVisa.Text, TxtCelular.Text, CBool(RblSexo.SelectedValue), TxtObservaciones.Text, UsuarioActual.CveUsuario, UsuarioActual.CveVendedor) > 1 Then
Alert("Boleto generado correctamente")
ObjTransporte.Commit()
DdlPartida.SelectedValue = ""
DdlDestino.SelectedValue = ""
TxtNombre.Text = ""
TxtVisa.Text = ""
TxtCelular.Text = ""
TxtObservaciones.Text = ""
AsientoSeleccionado = ""
End If
For Each dr As DataRow In DtPasajeros.Rows 'gvr As GridViewRow In GvB.Rows
Dim Nombre, Visa, Celular, Obs, Asiento As String
Dim Sexo As Boolean = False
Dim Importe As Decimal = 0
Nombre = dr("Nombre").ToString
Visa = dr("Visa").ToString
Celular = dr("Celular").ToString
Obs = dr("Observaciones").ToString
Asiento = dr("Asiento").ToString
Importe = dr("Importe").ToString.ToDecimal
'.Text, TxtVisa.Text, TxtCelular.Text, CBool(RblSexo.SelectedValue), TxtObservaciones.Text
If ObjTransporte.AddViajesPasajeros(CveViaje, DdlPartida.SelectedValue.ToEntero, DdlDestino.SelectedValue.ToEntero, Importe, Asiento.ToEntero, Nombre, Visa, Celular, Sexo, Obs, UsuarioActual.CveUsuario, UsuarioActual.CveVendedor) > 1 Then
Alert("Boleto generado correctamente")
ObjTransporte.Commit()
DdlPartida.SelectedValue = ""
DdlDestino.SelectedValue = ""
AsientoSeleccionado = ""
End If
Next
Catch ex As Exception
ObjTransporte.RollBack()
Alert($"No se pudo generar el boleto {ex}", TipoMensaje.MsgError)
@@ -176,4 +224,50 @@ Partial Class Boletos
Protected Sub DdlDestino_SelectedIndexChanged(sender As Object, e As EventArgs)
CotizarTarifa(sender, e)
End Sub
Protected Sub BtnNumPasajeros_Click(sender As Object, e As EventArgs)
' GeneraPasajeros(TxtNumPasajeros.Text.ToEntero)
End Sub
Private Sub GeneraPasajeros(Cantidad As Integer)
DtPasajeros.Clear()
For i As Integer = 1 To Cantidad
Dim Dr1 As DataRow = DtPasajeros.NewRow
Dr1("Numero") = i
'asiento
DtPasajeros.Rows.Add(Dr1)
Next
GvB.DataSource = DtPasajeros
GvB.DataBind()
End Sub
Protected Sub BtnAgregar_Click(sender As Object, e As EventArgs)
If AsientoSeleccionado = "" Then
Alert("No se ha seleccionado el asiento.")
Exit Sub
End If
Dim Dr1 As DataRow = DtPasajeros.NewRow
Dr1("Asiento") = AsientoSeleccionado.Replace("A", "")
Dr1("Nombre") = TxtNombre.Text.Trim
Dr1("Visa") = TxtVisa.Text.Trim
'asiento
DtPasajeros.Rows.Add(Dr1)
AsientoSeleccionado = ""
GvB.DataSource = DtPasajeros
GvB.DataBind()
'identifico los asientos seleccionados para la venta
Dim cph As ContentPlaceHolder = CType(Me.Master.FindControl("C"), ContentPlaceHolder)
For Each dr As DataRow In DtPasajeros.Rows
Dim lnk As LinkButton = CType(cph.FindControl($"A{dr("Asiento")}"), LinkButton)
If lnk IsNot Nothing Then
lnk.Enabled = False
lnk.CssClass = "seleccionado"
lnk.ToolTip = dr("Nombre").ToString
End If
Next
End Sub
End Class