diff --git a/App_Code/ClsOC.vb b/App_Code/ClsOC.vb index a492db067..28f1d50fd 100644 --- a/App_Code/ClsOC.vb +++ b/App_Code/ClsOC.vb @@ -581,7 +581,7 @@ Public Class ClsOC Return Retorno End Function - Public Function GetOC(CveOrdenCompra As Integer, CveEmpresa As Integer, Optional Folio As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional Tipo As String = "-1", Optional CveVendedor As Integer = -1, Optional CveCliente As Integer = -1, Optional Guia As String = "-1", Optional CveUsuario As Integer = -1) As Boolean + Public Function GetOC(CveOrdenCompra As Integer, CveEmpresa As Integer, Optional Folio As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional Tipo As String = "-1", Optional CveVendedor As Integer = -1, Optional CveCliente As Integer = -1, Optional Guia As String = "-1", Optional CveUsuario As Integer = -1, Optional ConsultaInventarioOC As Boolean = False) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_OC_OrdenesCompraGet") @@ -596,6 +596,7 @@ Public Class ClsOC .Add("@Guia", SqlDbType.Int).Value = Guia .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@ConsultaInventarioOC", SqlDbType.Bit).Value = ConsultaInventarioOC End With Try @@ -707,7 +708,7 @@ Public Class ClsOC Optional PorcentajeIVA As Decimal = 0.16D, Optional IVA As Decimal = 0, Optional RetIVA As Decimal = 0, Optional RetISR As Decimal = 0, Optional FechaExpiracion As Date = Nothing, Optional CveCotizacion As Integer = -1, Optional FolioAdicional As String = "", Optional EntregaDirecta As Integer = -1, Optional CveDireccionEnvio As Integer = -1, Optional Guia As String = "-1", Optional IEPS As Decimal = -1, Optional CveIEAnticipo As Integer = -1, Optional ImporteAnticipo As Decimal = 0, Optional UsoCFDI As Integer = -1, Optional Promocion As String = "-1", Optional CveProveedorContacto As Integer = -1, Optional NumRemision As String = "-1", - Optional CveColectiva As Integer = -1) As Boolean + Optional CveColectiva As Integer = -1, Optional MetodoPago As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_OC_OrdenesCompraAdd") @@ -752,6 +753,7 @@ Public Class ClsOC .Add("@CveProveedorContacto", SqlDbType.Int).Value = CveProveedorContacto .Add("@NumRemision", SqlDbType.VarChar).Value = NumRemision .Add("@CveColectiva", SqlDbType.Int).Value = CveColectiva + .Add("@MetodoPago", SqlDbType.Int).Value = MetodoPago ' 0 Contado, 1 Credito .Add("@vCveOrdenCompra", SqlDbType.Int).Direction = ParameterDirection.Output .Add("@vFolio", SqlDbType.Int).Direction = ParameterDirection.Output @@ -915,7 +917,7 @@ Public Class ClsOC pCveProveedor As Integer, pCveOrdenCompra As Integer, pCveUsuarioModifico As Integer, Optional CveCliente As Integer = -1, Optional CveVendedor As Integer = -1, Optional PrioridadObservacion As String = "", Optional IVA As Decimal = 0, Optional RetIVA As Decimal = 0, Optional RetISR As Decimal = 0, Optional IDPoliza As Integer = -1, Optional FechaExpiracion As Date = Nothing, Optional FolioAdicional As String = "", Optional EntregaDirecta As Integer = -1, Optional CveDireccionEnvio As Integer = -1, Optional Guia As String = "-1", Optional IEPS As Decimal = -1, Optional UsoCFDI As Integer = -1, Optional Promocion As String = "-1", - Optional pCveProveedorSucursal As Integer = -1, Optional CveProveedorContacto As Integer = -1, Optional PorcentajeIVA As Decimal = 0.16D, Optional NumRemision As String = "-1") As Boolean + Optional pCveProveedorSucursal As Integer = -1, Optional CveProveedorContacto As Integer = -1, Optional PorcentajeIVA As Decimal = 0.16D, Optional NumRemision As String = "-1", Optional MetodoPago As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_OC_OrdenesCompraUpdate") @@ -950,6 +952,7 @@ Public Class ClsOC .Add("@CveProveedorContacto", SqlDbType.Int).Value = CveProveedorContacto .Add("@PorcentajeIVA", SqlDbType.SmallMoney).Value = PorcentajeIVA .Add("@NumRemision", SqlDbType.VarChar).Value = NumRemision + .Add("@MetodoPago", SqlDbType.Int).Value = MetodoPago ' 0 Contado, 1 Credito End With Try diff --git a/OC/OC.aspx b/OC/OC.aspx index 863375582..0434e51f2 100644 --- a/OC/OC.aspx +++ b/OC/OC.aspx @@ -452,6 +452,16 @@ + + Método de pago: + + + + + + + + diff --git a/OC/OC.aspx.vb b/OC/OC.aspx.vb index 8c5e80bbb..7048bdf41 100644 --- a/OC/OC.aspx.vb +++ b/OC/OC.aspx.vb @@ -623,6 +623,10 @@ Partial Class OC_OC ChkCotizacion.Enabled = False End If + If UsuarioActual.CveRol = 1 Then + TrMetodoPago.Visible = True + End If + 'CARGA YA REGISTRADO If Request("OC") IsNot Nothing AndAlso IsNumeric(Request("OC")) AndAlso Request("OC").ToEntero > 0 Then @@ -1326,9 +1330,11 @@ Partial Class OC_OC 'REINICIALIZA TrPendientes.Visible = False + Dim TieneInventario As Boolean = False + Dim objOC As New ClsOC - If objOC.GetOC(pCveOrdenCompra, CveEmpresaActual, CveUsuario:=UsuarioActual.CveUsuario) AndAlso objOC.DtResultados.Rows.Count > 0 Then + If objOC.GetOC(pCveOrdenCompra, CveEmpresaActual, CveUsuario:=UsuarioActual.CveUsuario, ConsultaInventarioOC:=True) AndAlso objOC.DtResultados.Rows.Count > 0 Then CveEmpresaActual = objOC.CveEmpresa If CveEmpresaActual > 0 Then EmpresaActualOC = CreaObjetoEmpresa(CveEmpresaActual) @@ -1343,6 +1349,9 @@ Partial Class OC_OC ViewState("CveUsuario") = objOC.CveUsuario ViewState("CvePresupuestoEgreso") = objOC.CvePresupuestoEgreso + TieneInventario = CBool(objOC.DtResultados.Rows(0)("TieneInvOC")) + DdlMetodoPago.SelectedValueExist(objOC.DtResultados.Rows(0)("MetodoPago")) + 'PROMOCIONES TxtPromocion.Text = objOC.Promocion ChkPromocion.Checked = TxtPromocion.Text.Trim.Length > 0 @@ -1817,8 +1826,10 @@ Partial Class OC_OC objOC.Dispose() GvVentaRelacionadas.DataBind() - 'CARGA MOVTOS DE ALMACEN - InicializaMovtosAlmacen() + If TieneInventario Then + 'CARGA MOVTOS DE ALMACEN + InicializaMovtosAlmacen() + End If If UsuarioActual.Empresa.Funcionalidad(565) = "1" And pCveOrdenCompra > 0 And TipoOC.ToUpper() = "REQ" Then 'LAS COTIZACIONES RAPIDAS SOLO DEBE APARECER SI EL PROVEEDOR ES DEDICADO @@ -2685,7 +2696,7 @@ Partial Class OC_OC LugarEntrega, UsuarioActual.CveUsuario, CveEmpresaActual, GvD.Rows(0).FCHiddenField("HdnCvePresupuestoEgreso").Value.ToString.ToEntero, pCveProveedor:=CveProveedor, pCveProveedorSucursal:=CveProveedorSucursal, RequiereCotizacion:=ChkCotizacion.Checked, CveCliente:=Ddlcliente.txtValue.Value.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero, PrioridadObservacion:=txtobsprioridad.Text, PorcentajeIVA:=Math.Round(DdlIVA.SelectedValue.ToDecimal - 1, 2), IVA:=IVA, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal, CveCotizacion:=CveCotizacion, FolioAdicional:=TxtFolioAdicional.Text, EntregaDirecta:=If(ChkEntregaDirecta.Checked, 1, -1), CveDireccionEnvio:=If(DdlDireccionEnvio.Visible, DdlDireccionEnvio.SelectedValue.ToEntero, -1), Guia:=TxtGuia.Text.Trim, - IEPS:=TxtIEPS.Text.ToDecimal, UsoCFDI:=DdlUsoCFDI.SelectedValue.ToEntero, Promocion:=Promocion, CveProveedorContacto:=CveProveedorContacto, NumRemision:=TxtNumRemision.Text.Trim()) Then + IEPS:=TxtIEPS.Text.ToDecimal, UsoCFDI:=DdlUsoCFDI.SelectedValue.ToEntero, Promocion:=Promocion, CveProveedorContacto:=CveProveedorContacto, NumRemision:=TxtNumRemision.Text.Trim(), MetodoPago:=DdlMetodoPago.SelectedValue.ToEntero()) Then CveOrdenCompraPadre = OC.CveOrdenCompra If CveOrdenCompraPadre > 0 Then @@ -2726,7 +2737,7 @@ Partial Class OC_OC RequiereCotizacion:=ChkCotizacion.Checked, CveUsuarioAsignado:=DdlUsuariosAsignado.SelectedValue.ToEntero, CveCliente:=Ddlcliente.txtValue.Value.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero, PrioridadObservacion:=txtobsprioridad.Text, PorcentajeIVA:=Math.Round(DdlIVA.SelectedValue.ToDecimal - 1, 2), IVA:=IVA, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal, CveCotizacion:=CveCotizacion, FolioAdicional:=TxtFolioAdicional.Text, EntregaDirecta:=If(ChkEntregaDirecta.Checked, 1, -1), CveDireccionEnvio:=If(DdlDireccionEnvio.Visible, DdlDireccionEnvio.SelectedValue.ToEntero, -1), Guia:=TxtGuia.Text.Trim, IEPS:=TxtIEPS.Text.ToDecimal, CveIEAnticipo:=CveIEAnticipo, ImporteAnticipo:=ImporteAnticipos, UsoCFDI:=DdlUsoCFDI.SelectedValue.ToEntero, - Promocion:=Promocion, CveProveedorContacto:=CveProveedorContacto, NumRemision:=TxtNumRemision.Text) Then + Promocion:=Promocion, CveProveedorContacto:=CveProveedorContacto, NumRemision:=TxtNumRemision.Text, MetodoPago:=DdlMetodoPago.SelectedValue.ToEntero()) Then CveOrdenCompra = OC.CveOrdenCompra CveEstatus = CboE.SelectedValue.ToEntero @@ -2896,7 +2907,7 @@ Partial Class OC_OC LugarEntrega, DdlMoneda.SelectedValue.ToEntero, CveProveedor, CveOrdenCompra, UsuarioActual.CveUsuario, Ddlcliente.txtValue.Value.ToEntero, DdlVendedor.SelectedValue.ToEntero, txtobsprioridad.Text, IVA:=IVA, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal, FolioAdicional:=TxtFolioAdicional.Text, EntregaDirecta:=If(ChkEntregaDirecta.Checked, 1, -1), CveDireccionEnvio:=If(DdlDireccionEnvio.Visible, DdlDireccionEnvio.SelectedValue.ToEntero, -1), Guia:=TxtGuia.Text.Trim, IEPS:=TxtIEPS.Text.ToDecimal, UsoCFDI:=DdlUsoCFDI.SelectedValue.ToEntero, Promocion:=Promocion, pCveProveedorSucursal:=DdlProveedorSucursal.SelectedValue.ToEntero, CveProveedorContacto:=CveProveedorContacto, - PorcentajeIVA:=Math.Round(DdlIVA.SelectedValue.ToDecimal - 1, 2), NumRemision:=TxtNumRemision.Text) Then + PorcentajeIVA:=Math.Round(DdlIVA.SelectedValue.ToDecimal - 1, 2), NumRemision:=TxtNumRemision.Text, MetodoPago:=DdlMetodoPago.SelectedValue.ToEntero()) Then If CveProveedorOriginal <> CveProveedor Then If Not ObjConta.UpdateProveedorPoliza(CveOrdenCompra, CveProveedor, Proveedor) Then TieneError = True @@ -3330,7 +3341,7 @@ Partial Class OC_OC CveUsuario, CveEmpresaActual, 0, pCveProveedor:=CveProveedor, CveCliente:=Ddlcliente.txtValue.Value.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero, PrioridadObservacion:=txtobsprioridad.Text, PorcentajeIVA:=PorIVA, IVA:=IVACot, RetIVA:=RetIVA.ToString.ToDecimal, RetISR:=RetISR.ToString.ToDecimal, IDPoliza:=IdPoliza, CveCotizacion:=CveCotizacion, FolioAdicional:=TxtFolioAdicional.Text, EntregaDirecta:=If(ChkEntregaDirecta.Checked, 1, -1), CveDireccionEnvio:=If(DdlDireccionEnvio.Visible, DdlDireccionEnvio.SelectedValue.ToEntero, -1), IEPS:=TxtIEPS.Text.ToDecimal, - CveIEAnticipo:=CveIEAnticipo, ImporteAnticipo:=ImporteAnticipos, Promocion:=Promocion, UsoCFDI:=DdlUsoCFDI.SelectedValue.ToEntero, NumRemision:=TxtNumRemision.Text.Trim) Then + CveIEAnticipo:=CveIEAnticipo, ImporteAnticipo:=ImporteAnticipos, Promocion:=Promocion, UsoCFDI:=DdlUsoCFDI.SelectedValue.ToEntero, NumRemision:=TxtNumRemision.Text.Trim, MetodoPago:=DdlMetodoPago.SelectedValue.ToEntero()) Then 'CREA POLIZA POR CADA PROVEEDOR @@ -3406,7 +3417,7 @@ Partial Class OC_OC CveUsuario, CveEmpresaActual, 0, pCveProveedor:=DdlProveedores.SelectedValue.ToEntero, pCveProveedorSucursal:=DdlProveedorSucursal.SelectedValue.ToEntero, CveUsuarioAsignado:=DdlUsuariosAsignado.SelectedValue.ToEntero(), CveCliente:=Ddlcliente.txtValue.Value.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero, PrioridadObservacion:=txtobsprioridad.Text, PorcentajeIVA:=Math.Round(DdlIVA.SelectedValue.ToDecimal - 1, 2), IVA:=IVA, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal, IDPoliza:=IDPolizaPresupuestal, CveCotizacion:=CveCotizacion, FolioAdicional:=TxtFolioAdicional.Text, EntregaDirecta:=If(ChkEntregaDirecta.Checked, 1, -1), CveDireccionEnvio:=If(DdlDireccionEnvio.Visible, DdlDireccionEnvio.SelectedValue.ToEntero, -1), IEPS:=TxtIEPS.Text.ToDecimal, CveIEAnticipo:=CveIEAnticipo, ImporteAnticipo:=ImporteAnticipos, UsoCFDI:=DdlUsoCFDI.SelectedValue.ToEntero, - Promocion:=Promocion, NumRemision:=TxtNumRemision.Text.Trim) Then + Promocion:=Promocion, NumRemision:=TxtNumRemision.Text.Trim, MetodoPago:=DdlMetodoPago.SelectedValue.ToEntero()) Then 'USA AC @@ -4209,6 +4220,7 @@ Partial Class OC_OC gvCotizaciones.Enabled = False DdlProveedorSucursal.Enabled = False DdlProveedorContacto.Enabled = False + DdlMetodoPago.Enabled = False GvD.Columns(12).Visible = False GvD.Columns(13).Visible = True diff --git a/Transportes/Boletos.aspx b/Transportes/Boletos.aspx index 740a84677..cf1b168df 100644 --- a/Transportes/Boletos.aspx +++ b/Transportes/Boletos.aspx @@ -1,12 +1,12 @@ -<%@ Page Language="VB" Title="Transportes V&A - Comprar Boleto" AutoEventWireup="false" - MasterPageFile="~/Site.master" CodeFile="Boletos.aspx.vb" - Inherits="Boletos" EnableEventValidation="true" %> - - - Comprar Boleto - - - +<%@ Page Language="VB" Title="Transportes V&A - Comprar Boleto" AutoEventWireup="false" + MasterPageFile="~/Site.master" CodeFile="Boletos.aspx.vb" + Inherits="Boletos" EnableEventValidation="false" %> + + + Comprar Boleto + + + - - - - - - <%-- Datos de cliente y su viaje --%> -
- -
-
-
- - Datos del Viaje -
-
- -
- -
-
-
- - -
-
- -
-
- - - - - -
-
-
- -
-
-
- - -
-
- -
-
- - - - -
-
-
- -
- -
-
- -
-
- -
-
-
-
-
-
- - Datos del Pasajero -
-
-
-
-
-
-
-
- - - - -
- -
-
-
- - -
-
- -
-
-
-
- - - - - - -
-
-
-
- - - -
-
-
- -
- - - -
-
- - -
-
-
-
- -
- - - - - - - - - - -
-
- -
- -
- <%-- Asientos --%> -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -      - - - -
- - - -      - - - -
- - - -      - - - -
- - - -      - - - -
- - - -      - - - -
- - - -      - - - -
- - - -      - - - -
- - - -      - - - -
- - - -      - - - -
- - - -      - - - -
- - - -      - - - -
- - - -      - - - -
- - - -
-
- - - - - - - - + + + + + + + <%-- Datos de cliente y su viaje --%> +
+
+
+
+
+
+ + Datos del Viaje +
+
+
+ +
+
+
+ + +
+
+ +
+
+ + + + + +
+
+
+ +
+
+
+ + +
+
+ +
+
+ + + + +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+ + Datos del Pasajero + + +
+
+
+
+
+
+
+
+ + + + +
+ +
+
+
+ + +
+
+ +
+
+
+
+ + + + + + +
+
+
+
+ + + +
+
+
+ +
+ + + +
+
+ + +
+
+
+
+
+
+
+ + + + + + + + +
+
+
+
+
+ +
+
+
+
+ <%-- Asientos --%> +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +      + + + +
+ + + +      + + + +
+ + + +      + + + +
+ + + +      + + + +
+ + + +      + + + +
+ + + +      + + + +
+ + + +      + + + +
+ + + +      + + + +
+ + + +      + + + +
+ + + +      + + + +
+ + + +      + + + +
+ + + +      + + + +
+ + + +
+
+
+
+
+
+ + + + + diff --git a/Transportes/Boletos.aspx.vb b/Transportes/Boletos.aspx.vb index 9054a5b9e..74451e011 100644 --- a/Transportes/Boletos.aspx.vb +++ b/Transportes/Boletos.aspx.vb @@ -6,7 +6,7 @@ Imports Extensiones.ModExtensiones Imports Microsoft.Ajax.Utilities Partial Class Boletos - Inherits ClsPaginas + Inherits ClsPaginas #Region "Propiedades" Private Property AsientoSeleccionado As String Get @@ -18,7 +18,7 @@ Partial Class Boletos End Property Private Property Importe As Decimal Get - Return ViewState("Importe").ToString().ToDecimal + Return If(IsNothing(ViewState("Importe")), 0, ViewState("Importe")).ToString().ToDecimal() End Get Set(value As Decimal) ViewState("Importe") = value @@ -48,9 +48,11 @@ Partial Class Boletos Set(value As DataTable) ViewState("DtPasajeros") = value End Set - End Property + End Property + + #End Region - + Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then If Request.QueryString("CveViaje") Is Nothing Then @@ -60,7 +62,6 @@ Partial Class Boletos CveViaje = Request.QueryString("CveViaje").ToEntero If CveViaje > 0 Then CargaDatos() - End If End If @@ -69,6 +70,7 @@ 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 @@ -78,8 +80,10 @@ Partial Class Boletos 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("Asiento", GetType(String)) + DtPasajeros.Columns.Add("Celular", GetType(String)) DtPasajeros.Columns.Add("Importe", GetType(Decimal)) + DtPasajeros.Columns.Add("Observaciones", GetType(String)) InicializaCombos() @@ -99,30 +103,18 @@ Partial Class Boletos End If End If - Else ObjContratos.Dispose() + ObjViaje.Dispose() + Response.Redirect($"~/Transportes/RepContratos.aspx") - End If + End If + ObjContratos.Dispose() ObjViaje.Dispose() - Dim ObjViaje As New ClsTransportes - '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 Sub Protected Sub InicializaCombos() @@ -130,48 +122,42 @@ Partial Class Boletos 'Lista Destinos''carga específicos Dim ObjDestinos As New ClsTransportes() - If Not ObjDestinos.GetDestinos(CveRuta:=CveRuta) Then - Else + If ObjDestinos.GetDestinos(CveRuta:=CveRuta) Then If ObjDestinos.DtResultados.Rows.Count > 0 Then DdlPartida.DataSource = ObjDestinos.DtResultados DdlPartida.DataBind() - DdlPartida.Items.Insert(0, New ListItem("Seleccione Partida", "")) + DdlPartida.Items.Insert(0, New ListItem("Seleccione Partida", "-1")) DdlDestino.DataSource = ObjDestinos.DtResultados DdlDestino.DataBind() - DdlDestino.Items.Insert(0, New ListItem("Seleccione Destino", "")) + DdlDestino.Items.Insert(0, New ListItem("Seleccione Destino", "-1")) End If End If ObjDestinos.Dispose() End Sub - Protected Sub CargaDestinos() - - End Sub - Protected Sub CotizarTarifa(sender As Object, e As EventArgs) + Protected Sub CotizarTarifa() If DdlDestino.SelectedValue <> "" And DdlPartida.SelectedValue <> "" Then - + Dim ImporteR As Decimal = 0 Dim ObjDestinos As New ClsTransportes() - Dim retorno As Boolean = ObjDestinos.GetDestinosTarifas(DdlPartida.SelectedValue.ToEntero, DdlDestino.SelectedValue.ToEntero) - Dim ImporteR As Decimal = ObjDestinos.DtResultados.FiltroPrimeroValor("Importe").ToDecimal.RoundSQL + If ObjDestinos.GetDestinosTarifas(DdlPartida.SelectedValue.ToEntero, DdlDestino.SelectedValue.ToEntero) Then + ImporteR = ObjDestinos.DtResultados.FiltroPrimeroValor("Importe").ToDecimal.RoundSQL + End If ObjDestinos.Dispose() - If retorno Then - If ImporteR > 0 Then - ViewState("Importe") = ImporteR - TxtCosto.Text = $"El precio de su boleto es ${ImporteR.FormatoNumero}" - BtnGuardar.Visible = True - UpPanel.Visible = True - Else - TxtCosto.Text = "" - BtnGuardar.Visible = False - UpPanel.Visible = False - ViewState("Importe") = 0 - End If + If ImporteR > 0 Then + ViewState("Importe") = ImporteR + TxtCosto.Text = $"El precio de su boleto es ${ImporteR.FormatoNumero}" + BtnGuardar.Visible = True + Else + Alert("No se encontro una tarifa para esta ruta", TipoMensaje.MsgAdvertencia) + + TxtCosto.Text = "" + BtnGuardar.Visible = False + ViewState("Importe") = 0 End If End If - End Sub Protected Sub OnLinkButtonClick(sender As Object, e As EventArgs) @@ -186,19 +172,20 @@ Partial Class Boletos Dim buttonID As String = linkButton.ID linkButton.CssClass += " activo" AsientoSeleccionado = buttonID + + UpPanel.Update() End Sub Protected Sub FinalizarVenta(sender As Object, e As EventArgs) - If AsientoSeleccionado = "" Then - Alert("Se requiere seleccionar su asiento", TipoMensaje.MsgAdvertencia) - Exit Sub - End If + + Dim SbAlert As New StringBuilder() + Dim Retorno As New Modelos.Factura.MMensajeFactura() Dim ObjTransporte As New ClsTransportes() ObjTransporte.IniciaTransacSQL() - Try - AsientoSeleccionado = AsientoSeleccionado.Replace("A", "") + Dim TieneError As Boolean = False + Try 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 @@ -210,34 +197,81 @@ Partial Class Boletos 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 + '.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 + TieneError = True + SbAlert.Append("Ocurrió un error al generar el viaje") + End If + Next + + If Not TieneError Then + Retorno = CrearRemision(ObjTransporte) + End If + + If Retorno IsNot Nothing Then + TieneError = Retorno.TieneError + + If Not TieneError Then + If Retorno.CveVenta > 0 AndAlso Not Retorno.TieneError Then + SbAlert.AppendFormat("{0}", Retorno.Mensajes(Retorno.Mensajes.Count - 1)) + Else + TieneError = True + SbAlert.Append("Ocurrió un error al generar la factura") + End If + + If Retorno.Mensajes IsNot Nothing AndAlso Retorno.Mensajes.Count > 0 Then + For Each Mensaje As String In Retorno.Mensajes + SbAlert.AppendFormat("{0}
", Mensaje) + Next + Else + TieneError = True + End If + End If + Else + TieneError = True + SbAlert.Append("Ocurrió un error al generar la factura") + End If + + If SbAlert.Length = 0 Then + SbAlert.Append("Ocurrió un error al generar la factura") + End If Catch ex As Exception - ObjTransporte.RollBack() - Alert($"No se pudo generar el boleto {ex}", TipoMensaje.MsgError) - Finally - ObjTransporte.Dispose() - CargaDatos() + TieneError = True + SbAlert.Append("Ocurrió un error al generar la factura." + ex.ToString()) + GuardaLog(ex.ToString()) + Finally + If TieneError Then + ObjTransporte.RollBack() + ObjTransporte.Dispose() + Else + SbAlert.Append("El boleto se genero correctamente") + ObjTransporte.Commit() + ObjTransporte.Dispose() + + DdlPartida.SelectedValueExist("-1") + DdlDestino.SelectedValueExist("-1") + AsientoSeleccionado = "" + CargaDatos() + End If + + Alert(SbAlert.ToString(), If(TieneError, TipoMensaje.MsgError, TipoMensaje.MsgInformacion), ShowCloseButton:=False) + UpPanel.Update() - End Try + End Try + End Sub - Protected Sub DdlPartida_SelectedIndexChanged(sender As Object, e As EventArgs) - CotizarTarifa(sender, e) + Protected Sub DdlPartida_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPartida.SelectedIndexChanged + CotizarTarifa() + UpPanel.Update() End Sub - Protected Sub DdlDestino_SelectedIndexChanged(sender As Object, e As EventArgs) - CotizarTarifa(sender, e) + Protected Sub DdlDestino_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlDestino.SelectedIndexChanged + CotizarTarifa() + UpPanel.Update() End Sub Protected Sub BtnNumPasajeros_Click(sender As Object, e As EventArgs) @@ -263,10 +297,16 @@ Partial Class Boletos Exit Sub End If + If Me.Importe <= 0 Then + Alert("No hay un importe asignado.") + 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 + Dr1("Importe") = Me.Importe 'asiento DtPasajeros.Rows.Add(Dr1) AsientoSeleccionado = "" @@ -284,5 +324,55 @@ Partial Class Boletos lnk.ToolTip = dr("Nombre").ToString End If Next + + UpPanel.Update() End Sub + + Private Function CrearRemision(ByRef objTrans As ClsTransportes) As Modelos.Factura.MMensajeFactura + Dim Retorno As Modelos.Factura.MMensajeFactura = Nothing + + Dim CveCliente As Integer = 1154164 + Dim CveMoneda As Integer = 2 + Dim CveSubProyecto As Integer = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto").ToEntero() + + If CveCliente <= 0 Then + Retorno.Mensajes.Add("No se pudo cargar el cliente") + Return Retorno + End If + + If CveSubProyecto <= 0 Then + Retorno.Mensajes.Add("No se pudo cargar el subproyecto") + 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 + + 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 + + If ObjFactura IsNot Nothing Then + ObjFactura.Dispose() + End If + + Return Retorno + End Function End Class