VYA Viajes

This commit is contained in:
rakcsle
2024-11-27 16:13:41 -07:00
parent 69ef75f22b
commit 816622b06b
16 changed files with 2855 additions and 356 deletions

View File

@@ -1,11 +1,12 @@
Option Explicit On
Option Strict On
Imports System.Activities.Statements
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Imports Modelos
Partial Class RepContratoDetalle
@@ -231,6 +232,18 @@ Partial Class RepContratoDetalle
End Property
Private Property DTViajesPasajeros As DataTable
Get
If ViewState("DTViajesPasajeros") Is Nothing Then
ViewState("DTViajesPasajeros") = New DataTable
End If
Return CType(ViewState("DTViajesPasajeros"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTViajesPasajeros") = value
End Set
End Property
#End Region
@@ -297,9 +310,34 @@ Partial Class RepContratoDetalle
DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
DdlVendedor.DataBind()
DdlVendedor.Items.Insert(0, New ListItem("Todos", "-1"))
For i As Integer = DdlVendedor.Items.Count - 1 To 0 Step -1
If DdlVendedor.Items(i).Text = "Sin Asignar" Then
DdlVendedor.Items.RemoveAt(i)
End If
Next
If EsAgencia Then
DdlVendedor.SelectedValueExist(UsuarioActual.CveVendedor)
DdlVendedor.Enabled = False
End If
End Sub
Private Sub CargaDatos()
CargaDatosContrato()
CargaDatosViajes()
'Información General
End Sub
Private Sub CargaDatosContrato()
Dim ObjContratos As New ClsContratos
If ObjContratos.GetContratos(CveContrato, UsuarioActual.CveEmpresa) Then
Contrato = ObjContratos.DtResultados
@@ -322,7 +360,7 @@ Partial Class RepContratoDetalle
TxtFechaSalida.Text = Contrato.Rows(0)("FechaInicial").ToString.ToDate.ToString("dd/MM/yyyy HH:mm:ss")
TxtFechaRegreso.Text = Contrato.Rows(0)("FechaFinal").ToString.ToDate.ToString("dd/MM/yyyy HH:mm:ss")
TxtCantidadPasajeros.Text = Contrato.Rows(0)("CantidadPasajeros").ToString
DdlTipoAF.SelectedValue = If(Contrato.Rows(0)("CveTipoAF") Is Nothing, "", Contrato.Rows(0)("CveTipoAF").ToString)
DdlTipoAF.SelectedValueExist(If(Contrato.Rows(0)("CveTipoAF") Is Nothing, "", Contrato.Rows(0)("CveTipoAF").ToString))
TxtImporte.Text = Math.Round(Importe, 2).ToString
TxtAnticipo.Text = Math.Round(Anticipo, 2).ToString
CveContratoEstatus = Contrato.Rows(0)("CveContratosEstatus").ToString.ToEntero
@@ -367,17 +405,7 @@ Partial Class RepContratoDetalle
A1.Visible = True
End If
'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
BusquedaSeleccionada(ObjTransportes.DtResultados)
End If
ObjTransportes.Dispose()
GvViajesPasajeros.DataBind()
End If
''Bitácora
'Dim ObjEventoBitacora As New ClsOIEventos
'If ObjEventoBitacora.GetEventos(-1, -1, -1, "-1", "-1", -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveContrato:=CveContrato) Then
@@ -393,10 +421,38 @@ Partial Class RepContratoDetalle
End If
ObjContratos.Dispose()
UpTabContainer.Update()
End Sub
#End Region
Private Sub CargaDatosViajes()
'Boletos Vendidos
DTViajesPasajeros = New DataTable
If CveContratoTipo = 35 Then
TabBoletos.Visible = True
Dim ObjTransportes As New ClsTransportes
If ObjTransportes.GetViajesPasajeros(CveContrato) Then
If DdlVendedor.SelectedValue.ToEntero > 0 Then
DTViajesPasajeros = ObjTransportes.DtResultados.FiltraParametros($" CveVendedor = {DdlVendedor.SelectedValue.ToEntero} ")
Else
DTViajesPasajeros = ObjTransportes.DtResultados
End If
GvViajesPasajeros.DataSource = DTViajesPasajeros
BusquedaSeleccionada(DTViajesPasajeros)
End If
ObjTransportes.Dispose()
GvViajesPasajeros.DataBind()
End If
UpPasajeros.Update()
UpTabContainer.Update()
End Sub
#End Region
Protected Sub DdlUsuarioFiltroBoletos_SelectedIndexChanged(sender As Object, e As EventArgs)
CargaDatosViajes()
End Sub
#Region "Bitacora"
Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEB.RowDataBound
@@ -715,7 +771,7 @@ Partial Class RepContratoDetalle
For Each dRow As DataRow In DTPrePoliza.Rows
If Not ObjConta.UpdatePrePolizasDetalle(dRow("CvePrePolizaDetalle").ToString.ToEntero, dRow("Concepto").ToString, dRow("CveSubProyecto").ToString.ToEntero, -1, Boolean.Parse(dRow("TipoMovto").ToString), ImporteMN:=(TotalNew * TC), Importe:=TotalNew, TipoCambio:=TC) Then
If Not ObjConta.UpdatePrePolizasDetalle(dRow("CvePrePolizaDetalle").ToString.ToEntero, dRow("Concepto").ToString, dRow("CveSubProyecto").ToString.ToEntero, -1, Boolean.Parse(dRow("TipoMovto").ToString), ImporteMN:=TotalNew, Importe:=TotalNew, TipoCambio:=TC) Then
OcurrioError = True
Exit For
End If
@@ -848,7 +904,7 @@ Partial Class RepContratoDetalle
Try
ObjTransportes.IniciaTransacSQL()
If ObjTransportes.UpdateViajesPasajeros(CveViajePasajero, DdlRuta.SelectedValue.ToEntero, UsuarioActual.CveVendedor, LbImporte.Text.ToDecimal, TxtAsiento.Text.ToEntero, TxtNombre.Text, TxtVisa.Text, TxtCelular.Text, TxtObservacion.Text, CBool(TxtEstatus.Text), UsuarioActual.CveUsuario, CBool(RblSexo.SelectedValue)) Then
If ObjTransportes.UpdateViajesPasajeros(CveViajePasajero, DdlRuta.SelectedValue.ToEntero, UsuarioActual.CveVendedor, LbImporte.Text.ToDecimal, TxtAsiento.Text.ToEntero, TxtNombre.Text, TxtVisa.Text, TxtCelular.Text, TxtObservacion.Text, CBool(TxtEstatus.Text), UsuarioActual.CveUsuario, CBool(RblSexo.SelectedValue), FechaNacimiento:=TxtFechaNacimiento.Text.ToDate) Then
ObjTransportes.Commit()
End If
Catch ex As ArgumentException
@@ -863,6 +919,7 @@ Partial Class RepContratoDetalle
End Try
CargaDatos()
RegistraScript(String.Format("$('#{0}').modal('hide');", "ModalEditar"))
End Sub
Protected Sub OnChangeRuta(sender As Object, e As EventArgs)
@@ -901,53 +958,39 @@ Partial Class RepContratoDetalle
ViajeActual = dt
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, 2).ToString),
New ReportParameter("TipoBoleto", "Tipo Boleto"),
New ReportParameter("Agencia", "Agencia"),
New ReportParameter("TelefonoAgencia", "TelefonoAgencia"),
New ReportParameter("Asiento", GvRow.DataKey("Asiento"))
}
ImprimirPDFStimul($"{UsuarioActual.Empresa.Ruta}Formatos\Boleto.mrt", dtResult, params, NombreArchivo:="Boleto")
End Sub
Protected Sub GvViajesPasajeros_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
If EsAgencia Then
e.Row.FCLinkButton("BtnCancelar").Visible = False
e.Row.FCLinkButton("BtnReAgendar").Visible = False
End If
Dim Liga As String = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=BOLETO&CVEVIAJEPASAJERO={0}", e.Row.DataKey("CveViajePasajero"))))
e.Row.FCLiteral("LtlImprimir").Text = $"<a class='btn btn-circle btn-sm blue' target='_blank' href='{Liga}'><i class='fa fa-print'></i></a>"
ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("BtnImprimir"))
'ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("BtnImprimir"))
End If
If e.Row.RowType = DataControlRowType.Footer Then
e.Row.FCLiteral("LtlImportePie").Text = DTViajesPasajeros.SUM("Importe").ToString("###,###,###.00")
End If
End Sub
Protected Sub EditarBoleto(sender As Object, e As EventArgs)
PnEditarUsuario.Visible = True
PnEditarViaje.Visible = False
PnAsientos.Visible = False
TxtFechaNacimiento.Enabled = True
TxtNombre.Enabled = True
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
CveViajePasajero = GvRow.DataKey("CveViajePasajero").ToEntero
DdlRuta.SelectedValue = GvRow.DataKey("CveViaje")
DdlRuta.SelectedValueExist(GvRow.DataKey("CveViaje"))
LbPartida.Text = GvRow.DataKey("Partida").ToString()
LbDestino.Text = GvRow.DataKey("Destino").ToString()
LbImporte.Text = Convert.ToDecimal(GvRow.DataKey("Importe")).ToString("C")
@@ -960,6 +1003,12 @@ Partial Class RepContratoDetalle
TxtEstatus.Text = GvRow.DataKey("Estatus").ToString
LbEstatus.CssClass = If(CBool(GvRow.DataKey("Estatus").ToString), "text-success bold", "text-danger bold")
TxtAsiento.Text = GvRow.DataKey("Asiento").ToString()
TxtFechaNacimiento.Text = GvRow.DataKey("FechaNacimiento").ToString().ToDate.ToString("yyyy-MM-dd") 'Este es el formato que admite el control
If EsAgencia Then
TxtFechaNacimiento.Enabled = False
TxtNombre.Enabled = False
End If
UpTabContainer.Update()
UpModal.Update()
@@ -985,6 +1034,7 @@ Partial Class RepContratoDetalle
LbEstatus.Text = GvRow.DataKey("Estatus").ToString()
LbCreado.Text = GvRow.DataKey("FechaIng").ToString()
TxtAsiento.Text = GvRow.DataKey("Asiento").ToString()
TxtFechaNacimiento.Text = GvRow.DataKey("FechaNacimiento").ToString().ToDate.ToString("dd/MM/yyyy")
'Seleccionamos la ruta que tiene el usuario actual
DdlRuta.ClearSelection()
@@ -998,7 +1048,7 @@ Partial Class RepContratoDetalle
DdlRuta.Items.Add(listItem)
Next
End If
DdlRuta.SelectedValue = GvRow.DataKey("CveViaje")
DdlRuta.SelectedValueExist(GvRow.DataKey("CveViaje"))
ObjContratos.Dispose()
UpTabContainer.Update()
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalEditar"))
@@ -1185,6 +1235,83 @@ Partial Class RepContratoDetalle
End Class
#End Region
Protected Sub DdlVendedor_SelectedIndexChanged(sender As Object, e As EventArgs)
CargaDatosViajes()
End Sub
#Region "IMPRESION MANIFIESTO"
'Private Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
' GeneraPDF("Excel")
' 'GvDatos.ExportToExcel("ReporteProductosServicios" & NowADS().ToShortDateString)
'End Sub
Private Sub PreparaManifiesto()
End Sub
Protected Sub GeneraPDF(Optional Formato As String = "PDF")
Dim DTManifiestoViajes As DataTable = DTViajesPasajeros.Copy
DTManifiestoViajes.Rows.Clear()
DTManifiestoViajes.Columns.Add("SexoStr")
For x = 1 To 50
Dim dRow As DataRow = DTManifiestoViajes.NewRow
Dim Encontrado As Boolean = False
For Each faRow As DataRow In DTViajesPasajeros.Rows
If faRow("Asiento").ToString.ToEntero = x Then
Encontrado = True
dRow("Asiento") = x
dRow("Nombre") = faRow("Nombre").ToString
dRow("Visa") = faRow("Visa").ToString
dRow("Celular") = faRow("Celular").ToString
dRow("SexoStr") = If(Boolean.Parse(faRow("Sexo").ToString), "Masculino", "Femenino")
dRow("Partida") = faRow("Partida").ToString
dRow("Destino") = faRow("Destino").ToString
dRow("Importe") = faRow("Importe").ToString.ToDecimal
Exit For
End If
Next
If Not Encontrado Then
dRow("Asiento") = x
End If
DTManifiestoViajes.Rows.Add(dRow)
Next
DTManifiestoViajes.TableName = "DTManifiestoViajes"
DTManifiestoViajes.AcceptChanges()
Dim DTManifiesto As DataTable = DTManifiestoViajes.FiltraParametros("", "Asiento")
DTManifiesto.TableName = "DTManifiestoViajes"
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
Dim params As New List(Of ReportParameter)()
params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
params.Add(New ReportParameter("Contrato", TxtFolio.Text))
params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
params.Add(New ReportParameter("FechaSalida", TxtFechaSalida.Text))
ImprimirPDF("Empresas/Grales/Formatos/ManifiestoViajes.rdlc", DTManifiesto, params, "Reporte de Productos Servicios", Formato)
End Sub
Protected Sub ImgPDF_Click(sender As Object, e As EventArgs)
GeneraPDF()
End Sub
#End Region
End Class