--cancelacion de remision con boleto. --solo si es una partida
This commit is contained in:
@@ -67,6 +67,20 @@ Partial Class Boletos
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub CreaDTPasajeros()
|
||||
DtPasajeros = New DataTable
|
||||
DtPasajeros.Columns.Add("CveViajePasajero", GetType(Integer))
|
||||
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("Celular", GetType(String))
|
||||
DtPasajeros.Columns.Add("Importe", GetType(Decimal))
|
||||
DtPasajeros.Columns.Add("Observaciones", GetType(String))
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub CargaDatos()
|
||||
Dim ObjContratos As New ClsContratos
|
||||
Dim ObjViaje As New ClsTransportes
|
||||
@@ -76,15 +90,8 @@ Partial Class Boletos
|
||||
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("Celular", GetType(String))
|
||||
DtPasajeros.Columns.Add("Importe", GetType(Decimal))
|
||||
DtPasajeros.Columns.Add("Observaciones", GetType(String))
|
||||
|
||||
CreaDTPasajeros()
|
||||
InicializaCombos()
|
||||
|
||||
'Boletos Vendidos
|
||||
@@ -199,10 +206,14 @@ Partial Class Boletos
|
||||
Importe = dr("Importe").ToString.ToDecimal
|
||||
|
||||
'.Text, TxtVisa.Text, TxtCelular.Text, CBool(RblSexo.SelectedValue), TxtObservaciones.Text
|
||||
If Not ObjTransporte.AddViajesPasajeros(CveViaje, DdlPartida.SelectedValue.ToEntero, DdlDestino.SelectedValue.ToEntero, Importe, Asiento.ToEntero, Nombre, Visa, Celular, Sexo, Obs, UsuarioActual.CveUsuario, UsuarioActual.CveVendedor) > 1 Then
|
||||
Dim CveViajePasajero = ObjTransporte.AddViajesPasajeros(CveViaje, DdlPartida.SelectedValue.ToEntero, DdlDestino.SelectedValue.ToEntero, Importe, Asiento.ToEntero, Nombre, Visa, Celular, Sexo, Obs, UsuarioActual.CveUsuario, UsuarioActual.CveVendedor)
|
||||
If CveViajePasajero < 1 Then
|
||||
TieneError = True
|
||||
SbAlert.Append("Ocurrió un error al generar el viaje")
|
||||
Exit For
|
||||
End If
|
||||
|
||||
dr("CveViajePasajero") = CveViajePasajero
|
||||
Next
|
||||
|
||||
If Not TieneError Then
|
||||
@@ -329,11 +340,11 @@ Partial Class Boletos
|
||||
End Sub
|
||||
|
||||
Private Function CrearRemision(ByRef objTrans As ClsTransportes) As Modelos.Factura.MMensajeFactura
|
||||
Dim Retorno As Modelos.Factura.MMensajeFactura = Nothing
|
||||
Dim Retorno As New Modelos.Factura.MMensajeFactura
|
||||
|
||||
Dim CveCliente As Integer = 1154164
|
||||
Dim CveMoneda As Integer = 2
|
||||
Dim CveSubProyecto As Integer = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto").ToEntero()
|
||||
Dim CveSubProyecto As Integer = -1
|
||||
|
||||
If CveCliente <= 0 Then
|
||||
Retorno.Mensajes.Add("No se pudo cargar el cliente")
|
||||
@@ -345,34 +356,46 @@ Partial Class Boletos
|
||||
Return Retorno
|
||||
End If
|
||||
|
||||
Dim ObjFactura = Modelos.Factura.CrearVentaNueva(UsuarioActual, CveSubProyecto, CveCliente, CveMoneda, "Rem")
|
||||
|
||||
Dim CvePSBoleto As Integer = 912720
|
||||
|
||||
For Each Dr As DataRow In DtPasajeros.Rows
|
||||
Dim Obs = Dr("Nombre").ToString
|
||||
Dim Importe = Dr("Importe").ToString.ToDecimal()
|
||||
If Importe <= 0 Then
|
||||
Retorno.Mensajes.Add("El importe debe ser mayor a 0")
|
||||
Return Retorno
|
||||
End If
|
||||
If EsProduccion Then
|
||||
CvePSBoleto = 986337
|
||||
CveCliente = 1172306
|
||||
End If
|
||||
|
||||
ObjFactura.AgregarPS(CvePSBoleto, 1, Importe, 0, Obs, CveSubProyecto:=CveSubProyecto, PorcentajeIVA:=0)
|
||||
Next
|
||||
|
||||
ObjFactura.CalculaTotales()
|
||||
|
||||
Try
|
||||
Retorno = ObjFactura.EmitirFactura(False, Transac:=objTrans.IniciaTransacSQL())
|
||||
Catch ex As Exception
|
||||
Retorno = Nothing
|
||||
GuardaLog(ex.ToString())
|
||||
End Try
|
||||
Dim ObjFactura = Modelos.Factura.CrearVentaNueva(UsuarioActual, CveSubProyecto, CveCliente, CveMoneda, "Rem")
|
||||
|
||||
If ObjFactura IsNot Nothing Then
|
||||
ObjFactura.Dispose()
|
||||
CveSubProyecto = ObjFactura.Cliente.CveSubProyecto
|
||||
|
||||
For Each Dr As DataRow In DtPasajeros.Rows
|
||||
Dim Obs = Dr("Nombre").ToString
|
||||
Dim Importe = Dr("Importe").ToString.ToDecimal()
|
||||
If Importe <= 0 Then
|
||||
Retorno.Mensajes.Add("El importe debe ser mayor a 0")
|
||||
Return Retorno
|
||||
End If
|
||||
|
||||
ObjFactura.AgregarPS(CvePSBoleto, 1, Importe, 0, Obs, CveSubProyecto:=CveSubProyecto, PorcentajeIVA:=0, CveViajePasajero:=Dr("CveViajePasajero").ToString().ToEntero())
|
||||
Next
|
||||
|
||||
ObjFactura.CalculaTotales()
|
||||
|
||||
Try
|
||||
Retorno = ObjFactura.EmitirFactura(False, Transac:=objTrans.IniciaTransacSQL())
|
||||
Catch ex As Exception
|
||||
Retorno = Nothing
|
||||
GuardaLog(ex.ToString())
|
||||
End Try
|
||||
|
||||
If ObjFactura IsNot Nothing Then
|
||||
ObjFactura.Dispose()
|
||||
End If
|
||||
Else
|
||||
Retorno.Mensajes.Add("No se pudo generar la factura")
|
||||
End If
|
||||
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
End Class
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports System.Data
|
||||
Imports ADSNetLibrary.Helpers
|
||||
Imports ADSNetLibrary.SIGAPI.Helpers
|
||||
@@ -32,16 +33,10 @@ Partial Class ListadoBoletos
|
||||
CveViaje = Request.QueryString("CveViaje").ToEntero
|
||||
Ruta = IfNull(Request("Ruta"), "").ToString
|
||||
LblViaje.Text = Ruta
|
||||
|
||||
InicializaCombos()
|
||||
CargaDatos()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub InicializaCombos()
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDatos()
|
||||
Dim ObjTransportes As New ClsTransportes
|
||||
If ObjTransportes.GetViajesPasajeros(CveViaje) Then
|
||||
@@ -86,22 +81,58 @@ Partial Class ListadoBoletos
|
||||
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)
|
||||
|
||||
Dim TieneError As Boolean = False
|
||||
Try
|
||||
Dim DtRem As DataTable = Nothing
|
||||
If ObjTransportes.GetRemisionBoleto(CveViajePasajero.ToEntero, UsuarioActual.CveEmpresa) Then
|
||||
DtRem = ObjTransportes.DtResultados.Copy()
|
||||
End If
|
||||
|
||||
If DtRem IsNot Nothing Then
|
||||
If DtRem.Rows.Count > 0 Then
|
||||
Dim CveVenta As Integer = DtRem.Rows(0)("CveVenta").ToString().ToEntero()
|
||||
If CveVenta > 0 Then
|
||||
Dim ObjRem As New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, VerificaAlmacen:=False)
|
||||
|
||||
If ObjRem.DtDetalle.Rows.Count > 0 Then
|
||||
'SI SOLO TIENE UNA PARTIDA CANCELAR LA REMISION
|
||||
If ObjRem.DtDetalle.Rows.Count = 1 Then
|
||||
Dim RespCancelacion = ObjRem.CancelarFactura(False, ValidarSAT:=False, CancelarBoletos:=True)
|
||||
If RespCancelacion IsNot Nothing Then
|
||||
TieneError = RespCancelacion.HuboError
|
||||
Else
|
||||
TieneError = True
|
||||
End If
|
||||
Else
|
||||
TieneError = Not ObjRem.CancelarBoleto(CveViajePasajero.ToEntero)
|
||||
End If
|
||||
Else
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
End If
|
||||
Else
|
||||
'SI NO TIENE VENTA, SOLO CANCELAR EL BOLETO
|
||||
If Not ObjTransportes.UpdateViajesPasajeros(CveViajePasajero.ToEntero, Activar:=cambiarEstatus, Estatus:=cambiarEstatus) Then
|
||||
TieneError = True
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
TieneError = True
|
||||
GuardaLog(ex.ToString())
|
||||
Finally
|
||||
If TieneError Then
|
||||
Alert($"El boleto ha sido cancelado correctamente.")
|
||||
Else
|
||||
Alert($"Ocurrió un error al cancelar el boleto.")
|
||||
End If
|
||||
ObjTransportes.Dispose()
|
||||
CargaDatos()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user