1298 lines
54 KiB
VB.net
1298 lines
54 KiB
VB.net
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
|
|
|
|
Partial Class RepContratoDetalle
|
|
Inherits ClsPaginas
|
|
#Region "Propiedades"
|
|
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 ArchivoUpdate As String
|
|
Get
|
|
Return ViewState("ArchivoUpdate").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("ArchivoUpdate") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveContratoTipo As Integer
|
|
Get
|
|
Return CType(ViewState("CveContratoTipo"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveContratoTipo") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveContratoEstatus As Integer
|
|
Get
|
|
Return CType(ViewState("CveContratoEstatus"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveContratoEstatus") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveMasivo As Integer
|
|
Get
|
|
Return CType(ViewState("CveMasivo"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMasivo") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveViajePasajero As Integer
|
|
Get
|
|
Return CType(ViewState("CveViajePasajero"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveViajePasajero") = 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 ViajeActual As DataTable
|
|
Get
|
|
Return CType(ViewState("ViajeActual"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("ViajeActual") = 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
|
|
Private Property TelefonoEmpresa As String
|
|
Get
|
|
Return ViewState("TelefonoEmpresa").ToString()
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("TelefonoEmpresa") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveVentaRemision As Integer
|
|
Get
|
|
If ViewState("CveVentaRemision") Is Nothing Then
|
|
ViewState("CveVentaRemision") = -1
|
|
End If
|
|
|
|
Return ViewState("CveVentaRemision").ToString.ToEntero
|
|
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveVentaRemision") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveSubProyectoOriginal As Integer
|
|
Get
|
|
If ViewState("CveSubProyectoOriginal") Is Nothing Then
|
|
ViewState("CveSubProyectoOriginal") = -1
|
|
End If
|
|
|
|
Return ViewState("CveSubProyectoOriginal").ToString.ToEntero
|
|
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveSubProyectoOriginal") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveMonedaOriginal As Integer
|
|
Get
|
|
If ViewState("CveMonedaOriginal") Is Nothing Then
|
|
ViewState("CveMonedaOriginal") = -1
|
|
End If
|
|
|
|
Return ViewState("CveMonedaOriginal").ToString.ToEntero
|
|
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMonedaOriginal") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveClienteOriginal As Integer
|
|
Get
|
|
If ViewState("CveClienteOriginal") Is Nothing Then
|
|
ViewState("CveClienteOriginal") = -1
|
|
End If
|
|
Return ViewState("CveClienteOriginal").ToString.ToEntero
|
|
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveClienteOriginal") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property ImporteOrigial As Decimal
|
|
Get
|
|
If ViewState("ImporteOrigial") Is Nothing Then
|
|
ViewState("ImporteOrigial") = 0D
|
|
End If
|
|
|
|
Return ViewState("ImporteOrigial").ToString.ToDecimal
|
|
|
|
End Get
|
|
Set(value As Decimal)
|
|
ViewState("ImporteOrigial") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property DescripcionOriginal As String
|
|
Get
|
|
If ViewState("DescripcionOriginal") Is Nothing Then
|
|
ViewState("DescripcionOriginal") = ""
|
|
End If
|
|
|
|
Return ViewState("DescripcionOriginal").ToString
|
|
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("DescripcionOriginal") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property TipoAFOriginal As String
|
|
Get
|
|
If ViewState("TipoAFOriginal") Is Nothing Then
|
|
ViewState("TipoAFOriginal") = ""
|
|
End If
|
|
|
|
Return ViewState("TipoAFOriginal").ToString
|
|
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("TipoAFOriginal") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property FolioOriginal As String
|
|
Get
|
|
If ViewState("FolioOriginal") Is Nothing Then
|
|
ViewState("FolioOriginal") = ""
|
|
End If
|
|
|
|
Return ViewState("FolioOriginal").ToString
|
|
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("FolioOriginal") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property TotalPagos As Decimal
|
|
Get
|
|
If ViewState("TotalPagos") Is Nothing Then
|
|
ViewState("TotalPagos") = 0
|
|
End If
|
|
|
|
Return ViewState("TotalPagos").ToString.ToDecimal
|
|
|
|
End Get
|
|
Set(value As Decimal)
|
|
ViewState("TotalPagos") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
Private Property EsAgencia As Boolean
|
|
Get
|
|
If ViewState("EsAgencia") Is Nothing Then
|
|
ViewState("EsAgencia") = False
|
|
End If
|
|
|
|
Return Boolean.Parse(ViewState("EsAgencia").ToString())
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("EsAgencia") = value
|
|
End Set
|
|
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
|
|
|
|
#Region "Carga Página"
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
|
|
|
|
If Not IsPostBack Then
|
|
|
|
If Request("CveContrato") Is Nothing Then
|
|
Response.Redirect($"~/Transportes/RepContratos.aspx")
|
|
End If
|
|
|
|
CveContrato = Request("CveContrato").ToEntero
|
|
|
|
If UsuarioActual.CveRol = 1583 Then
|
|
EsAgencia = True
|
|
End If
|
|
|
|
InicializaCombos()
|
|
CargaDatos()
|
|
CargaAuxiliarClienteCxC(DdlClientes.SelectedValue.ToEntero, CveVentaRemision)
|
|
AsientoSeleccionado = ""
|
|
CveViajePasajero = 0
|
|
Session("FileExtension") = ""
|
|
ArchivoUpdate = ""
|
|
CargaGvBitacora()
|
|
|
|
If CveContrato > 0 Then
|
|
HlEvento.Visible = True
|
|
HlEvento.NavigateUrl = "/OI/PopUpAgenda.aspx?CveTipoEvento=2&CveContrato=" & CveContrato & "&TB_iframe=true&height=370&width=600;"
|
|
ImgAddObs.Visible = True
|
|
LtlTareaNueva.Text = String.Format("<a class=""caption-subject bold font-light"" onclick=""OpenModalNewTareaUserControl(1,-1,{{CveContrato:{0}}});""> <i class=""fa fa-plus""'></i> Tarea</a>", CveContrato)
|
|
CargaEventoBitacora()
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
Private Sub InicializaCombos()
|
|
'Lista Tipo AF
|
|
DdlTipoAF.DataSource = GlobalDTTipoActivoFijo(UsuarioActual.CveEmpresa).FiltraParametros("MedidaVehicularClave IN (2,3)")
|
|
DdlTipoAF.DataBind()
|
|
DdlTipoAF.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
'Lista de Monedas
|
|
DdlMoneda.DataSource = GlobalDTMonedas
|
|
DdlMoneda.DataBind()
|
|
|
|
|
|
CargarCentrosDeCosto(Nothing, Nothing, Nothing, LblSubProyectoModal)
|
|
|
|
DdlSubProyecto.DataSource = GlobalDTSubProyectos(UsuarioActual.CveEmpresa)
|
|
DdlSubProyecto.DataBind()
|
|
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" Or DdlVendedor.Items(i).Value = "0" 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
|
|
If Contrato IsNot Nothing AndAlso Contrato.Rows.Count > 0 Then
|
|
Dim drc As DataRow = Contrato.Rows(0)
|
|
Dim Importe As Decimal = drc("Importe").ToString.ToDecimal
|
|
Dim Pesos As Decimal = drc("ImporteMax").ToString.ToDecimal
|
|
Dim Anticipo As Decimal = drc("ImporteMin").ToString.ToDecimal
|
|
CveContratoTipo = drc("CveContratoTipo").ToString.ToEntero
|
|
SubProyecto = drc("SubProyecto").ToString
|
|
CveMasivo = drc("CveMasivo").ToString.ToEntero
|
|
TxtFolio.Text = drc("NumeroContrato").ToString
|
|
|
|
DdlClientes.SelectedText = drc("NombreComercial").ToString
|
|
DdlClientes.SelectedValue = drc("CveCliente").ToString
|
|
DdlMoneda.SelectedValue = drc("CveMoneda").ToString
|
|
TxtDescripcion.Text = drc("DescripcionContrato").ToString
|
|
TxtObservaciones.Text = drc("Observaciones").ToString
|
|
TelefonoEmpresa = drc("Telefono").ToString
|
|
TxtUbicacion.Text = drc("Ubicacion").ToString
|
|
TxtFechaSalida.Text = drc("FechaInicial").ToString.ToDate.ToString("dd/MM/yyyy HH:mm:ss")
|
|
TxtFechaRegreso.Text = drc("FechaFinal").ToString.ToDate.ToString("dd/MM/yyyy HH:mm:ss")
|
|
TxtCantidadPasajeros.Text = drc("CantidadPasajeros").ToString
|
|
DdlTipoAF.SelectedValue = If(drc("CveTipoAF") Is Nothing, "", drc("CveTipoAF").ToString)
|
|
TxtImporte.Text = Math.Round(Importe, 2).ToString
|
|
TxtAnticipo.Text = Math.Round(Anticipo, 2).ToString
|
|
CveContratoEstatus = drc("CveContratosEstatus").ToString.ToEntero
|
|
DdlSubProyecto.SelectedValueExist(drc("CveSubProyecto").ToString)
|
|
If drc("CveAF").ToString <> "" Then
|
|
divAF.Visible = True
|
|
LblAF.Text = drc("CodigoNombreAF").ToString
|
|
End If
|
|
|
|
CveSubProyectoOriginal = drc("CveSubProyecto").ToString.ToEntero
|
|
CveMonedaOriginal = drc("CveMoneda").ToString.ToEntero
|
|
CveClienteOriginal = drc("CveCliente").ToString.ToEntero
|
|
ImporteOrigial = Importe
|
|
DescripcionOriginal = drc("DescripcionContrato").ToString
|
|
TipoAFOriginal = DdlTipoAF.SelectedItem.Text
|
|
FolioOriginal = TxtFolio.Text.Trim
|
|
|
|
CveVentaRemision = drc("CveVentaRemision").ToString.ToEntero
|
|
HypRemision.Text = drc("RemisionSerieFolio").ToString
|
|
HypRemision.NavigateUrl = $"/Ventas/Ventas.aspx?CveVenta={ CveVentaRemision}"
|
|
|
|
ChkEsPresupuestal.Checked = Boolean.Parse(drc("EsPresupuestal").ToString)
|
|
LblSaldo.Text = $"Saldo { drc("RemisionSaldo").ToString.ToDecimal.FormatoNumero}"
|
|
|
|
If Not IsDBNull(ObjContratos.Archivo) AndAlso ObjContratos.Archivo <> "" AndAlso ObjContratos.Archivo <> "-1" AndAlso ObjContratos.Archivo <> $"{ObjContratos.CveContrato}." Then
|
|
ViewState("FUrl") = Path.Combine(UsuarioActual.Empresa.Ruta, "CONTRATOS", ObjContratos.Archivo)
|
|
BtnDescargar.Visible = True
|
|
|
|
Dim File As New FileInfo(ViewState("FUrl").ToString)
|
|
BtnDescargar.NavigateUrl = $"~/Compras/PopUpVerFactura.aspx?ArchivoContrato={Encripta(File.FullName)}"
|
|
|
|
Else
|
|
BtnDescargar.Visible = False
|
|
A1.Visible = True
|
|
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
|
|
' GvEB.DataSource = ObjEventoBitacora.DtResultados
|
|
' GvEB.DataBind()
|
|
'End If
|
|
'ObjEventoBitacora.Dispose()
|
|
|
|
End If
|
|
Else
|
|
ObjContratos.Dispose()
|
|
Response.Redirect($"~/Transportes/RepContratos.aspx")
|
|
End If
|
|
ObjContratos.Dispose()
|
|
UpTabContainer.Update()
|
|
End Sub
|
|
|
|
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
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.RowIndex = 0 Then
|
|
e.Row.Cells(0).Width = Unit.Pixel(200)
|
|
e.Row.Cells(1).Width = Unit.Pixel(200)
|
|
e.Row.Cells(2).Width = Unit.Pixel(100)
|
|
e.Row.Cells(3).Width = Unit.Pixel(500)
|
|
End If
|
|
|
|
If e.Row.DBCampo("Archivo").ToString <> "" Then
|
|
e.Row.FCLinkButton("LinkArchivo").Visible = True
|
|
e.Row.FCLinkButton("LinkArchivo").CommandArgument = String.Format("OI\{0}", e.Row.DBCampo("Archivo").ToString)
|
|
ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LinkArchivo")) 'Registro un evento Postbacktrigger, que recargue toda la pagina para que funcione
|
|
End If
|
|
|
|
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub BtnGuardarEventoBitacora_Click(sender As Object, e As EventArgs) Handles BtnGuardarEventoBitacora.Click
|
|
Dim ObjEventoBitacora As New ClsOIEventos
|
|
|
|
Dim FileExtension As String = "-1"
|
|
Dim Filesgral As List(Of Archivo) = AnexoBit.getfiles().Archivos
|
|
Dim Filename As String = ""
|
|
For Each fileItem As Archivo In Filesgral
|
|
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
|
Filename = fileItem.filename
|
|
Next
|
|
|
|
If ObjEventoBitacora.AddEventoBitacora(TxtEventoDescripcion.Text.Trim, String.Format(".{0}", FileExtension), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveContrato:=CveContrato) Then
|
|
If Filename <> "" Then
|
|
Filename.FilesMove(String.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString), String.Format("{0}OI", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
|
|
End If
|
|
|
|
GvEB.DataSource = ObjEventoBitacora.DtResultados
|
|
TxtEventoDescripcion.Text = ""
|
|
AnexoBit.Text = "[]"
|
|
Alert("La bitácora/observación se guardó correctamente", TipoMensaje.MsgInformacion)
|
|
RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal")
|
|
|
|
End If
|
|
ObjEventoBitacora.Dispose()
|
|
GvEB.DataBind()
|
|
|
|
UPEventoBitacora.Update()
|
|
CargaEventoBitacora()
|
|
UPAddEventoBitacora.Update()
|
|
End Sub
|
|
Private Sub CargaEventoBitacora()
|
|
|
|
If CveContrato > 0 Then
|
|
Dim ObjEventoBitacora As New ClsOIEventos()
|
|
If ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveContrato:=CveContrato) Then
|
|
GvEB.DataSource = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento = 6 OR CveTipoEvento = 2")
|
|
Else
|
|
GvEB.DataSource = Nothing
|
|
End If
|
|
ObjEventoBitacora.Dispose()
|
|
GvEB.DataBind()
|
|
UPEventoBitacora.Update()
|
|
End If
|
|
|
|
End Sub
|
|
Protected Sub DownloadFile(ByVal sender As Object, ByVal e As EventArgs)
|
|
Dim filePath As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, CType(sender, LinkButton).CommandArgument)
|
|
Dim Archivo As New System.IO.FileInfo(filePath)
|
|
|
|
HttpContext.Current.Response.Clear()
|
|
HttpContext.Current.Response.ClearContent()
|
|
HttpContext.Current.Response.ContentType = "application/octet-stream"
|
|
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" + Path.GetFileName(filePath))
|
|
HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString())
|
|
HttpContext.Current.Response.TransmitFile(filePath)
|
|
HttpContext.Current.Response.Flush()
|
|
HttpContext.Current.Response.End()
|
|
|
|
Archivo = Nothing
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "Información General"
|
|
Protected Sub BtnGuardarArchivo_Click1(sender As Object, e As EventArgs) Handles BtnGuardarArchivo.Click
|
|
|
|
Dim FileExtension As String = "-1"
|
|
Dim Filesgral As List(Of Extensiones.Archivo) = Anexo.getfiles().Archivos
|
|
Dim Filename As String = ""
|
|
Dim folderContratosPath As String = Path.Combine(UsuarioActual.Empresa.Ruta, "Contratos")
|
|
|
|
If Not Directory.Exists(folderContratosPath) Then
|
|
Directory.CreateDirectory(folderContratosPath)
|
|
End If
|
|
|
|
If Not Directory.Exists(Path.Combine(folderContratosPath, "Temp")) Then
|
|
Directory.CreateDirectory(Path.Combine(folderContratosPath, "Temp"))
|
|
End If
|
|
|
|
For Each fileItem As Archivo In Filesgral
|
|
|
|
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
|
Session("FileExtension") = FileExtension
|
|
Dim tempArray() As String
|
|
tempArray = fileItem.filename.ToString().Split("-".ToCharArray())
|
|
|
|
|
|
ViewState("extencion") = FileExtension
|
|
ViewState("FUrl") = Path.Combine(UsuarioActual.Empresa.Ruta, "Contratos", $"{CveContrato.ToString}.{ FileExtension}")
|
|
|
|
If File.Exists(ViewState("FUrl").ToString) Then
|
|
File.Delete(ViewState("FUrl").ToString)
|
|
End If
|
|
|
|
File.Move(fileItem.FileUrl, ViewState("FUrl").ToString)
|
|
TxtArchivo.Text = tempArray(1)
|
|
|
|
Next
|
|
|
|
UPAFUL.Update()
|
|
|
|
RegistraScript("$('#ModalUpload').modal('hide')", "hidemodal1")
|
|
A1.Visible = True
|
|
If Not FileExtension = "-1" Then
|
|
BtnDescargar.Visible = True
|
|
End If
|
|
End Sub
|
|
Public Function ObtenerUrlCompleta() As String
|
|
|
|
Dim Solicitud As HttpRequest = HttpContext.Current.Request
|
|
Dim url As String = Solicitud.Url.Scheme & "://" & Solicitud.Url.Host
|
|
|
|
If (Solicitud.Url.Port <> 80 AndAlso Solicitud.Url.Port <> 443) Then
|
|
url &= ":" & Solicitud.Url.Port
|
|
End If
|
|
|
|
url &= Solicitud.ApplicationPath
|
|
|
|
If Not url.EndsWith("/") Then
|
|
url &= "/"
|
|
End If
|
|
|
|
Return url
|
|
|
|
End Function
|
|
Protected Sub UpdateContrato(sender As Object, e As EventArgs)
|
|
Dim ArchivoUpdate As String = "-1"
|
|
Dim ErrorProceso As Boolean = False
|
|
Dim SeGeneroRemision As Boolean = False
|
|
Dim SerieFolioRemision As String = ""
|
|
If Session("FileExtension").ToString <> "" Then
|
|
'ArchivoUpdate = $"{CveContrato.ToString}.{ Session("FileExtension")}"
|
|
ArchivoUpdate = $".{Session("FileExtension").ToString}"
|
|
Else
|
|
|
|
End If
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
ObjContratos.IniciaTransacSQL()
|
|
|
|
If Not ObjContratos.UpdateContratos(CveContrato, TxtFolio.Text, TxtDescripcion.Text, "", UsuarioActual.CveProveedor, DdlClientes.SelectedValue.ToEntero, -1, TxtFechaSalida.Text.ToDate, TxtFechaRegreso.Text.ToDate, TxtUbicacion.Text, "",
|
|
DdlSubProyecto.SelectedValue.ToEntero, -1, -1, -1, -1, ArchivoUpdate, "", -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, ChkEsPresupuestal.Checked, TxtAnticipo.Text.ToDecimal, -1, TxtImporte.Text.ToDecimal,
|
|
DdlMoneda.SelectedValue.ToEntero, 0, CveContratoTipo:=CveContratoTipo, CveTipoAF:=DdlTipoAF.SelectedValue.ToEntero, CveContratosEstatus:=CveContratoEstatus, Observaciones:=TxtObservaciones.Text, CantidadPasajeros:=TxtCantidadPasajeros.Text.ToEntero) Then
|
|
ErrorProceso = True
|
|
End If
|
|
|
|
If Not ErrorProceso Then
|
|
If CveVentaRemision > 0 AndAlso (CveSubProyectoOriginal <> DdlSubProyecto.SelectedValue.ToEntero OrElse
|
|
CveMonedaOriginal <> DdlMoneda.SelectedValue.ToEntero OrElse
|
|
ImporteOrigial <> TxtImporte.Text.ToDecimal OrElse
|
|
DescripcionOriginal <> TxtDescripcion.Text OrElse
|
|
TipoAFOriginal <> DdlTipoAF.SelectedItem.Text OrElse
|
|
FolioOriginal <> TxtFolio.Text.Trim OrElse
|
|
CveClienteOriginal <> DdlClientes.SelectedValue.ToEntero) Then
|
|
|
|
Dim ObsRemisionPartida As String = $"{DdlTipoAF.SelectedItem.Text}-{ TxtDescripcion.Text}-{TxtFolio.Text}"
|
|
If Not UpdateRemision(ObjContratos.IniciaTransacSQL(), DdlSubProyecto.SelectedValue.ToEntero, DdlMoneda.SelectedValue.ToEntero, TxtImporte.Text.ToDecimal, ObsRemisionPartida, DdlClientes.SelectedValue.ToEntero) Then
|
|
ErrorProceso = True
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorProceso AndAlso Not CveVentaRemision > 0 AndAlso ChkEsPresupuestal.Checked = False Then
|
|
'CveVentaRemision
|
|
Dim ObsRemisionPartida As String = $"{DdlTipoAF.SelectedItem.Text}-{ TxtDescripcion.Text}-{TxtFolio.Text}"
|
|
|
|
Dim Respuesta As New RespuestaFacturacion()
|
|
Dim CvePS As Integer = 907784
|
|
Respuesta = GeneraRemision(CveContrato, ObsRemisionPartida, TxtImporte.Text.ToDecimal, CvePS, ObjContratos.IniciaTransacSQL, DdlSubProyecto.SelectedValue.ToEntero)
|
|
|
|
If Respuesta.CveVenta > 0 Then
|
|
CveVentaRemision = Respuesta.CveVenta
|
|
SerieFolioRemision = Respuesta.SerieFolio
|
|
ErrorProceso = False
|
|
SeGeneroRemision = True
|
|
Else
|
|
ErrorProceso = True
|
|
Alert("se presento un error al generar la remisión", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorProceso Then
|
|
ObjContratos.Commit()
|
|
AgregarABitacora($"Actualización del contrato {CveContrato}")
|
|
|
|
If SeGeneroRemision Then
|
|
Alert($"Contrato actualizado correctamente..<br> Remisión Generada <a target='_blank' class='Texto' href='/Ventas/Ventas.aspx?CveVenta={CveVentaRemision}' ><b>{SerieFolioRemision}</b></a>", TipoMensaje.MsgInformacion, "window.location.reload();")
|
|
Else
|
|
Alert("Contrato actualizado correctamente", TipoMensaje.MsgInformacion, "window.location.reload();")
|
|
End If
|
|
|
|
|
|
Else
|
|
Alert("Ocurrió un ocurrió un error al actualizar su boleto", TipoMensaje.MsgError)
|
|
ObjContratos.RollBack()
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
|
|
If Not ErrorProceso Then
|
|
'CargaDatos()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Function UpdateRemision(ByRef transaccionSql As SqlTransaction, CveSubProyectoNew As Integer, CveMonedaNew As Integer, TotalNew As Decimal, DescripcionNew As String, CveClienteNew As Integer) As Boolean
|
|
|
|
Dim Respuesta As Boolean = False
|
|
Dim TmpDT As DataTable = New DataTable
|
|
Dim OcurrioError As Boolean = False
|
|
Dim ObjVentas As New ClsVentas(transaccionSql)
|
|
Dim FechaVenta As Date = MinFecha
|
|
Dim PorcentajeIVA As Decimal = 0D
|
|
Dim IVANew As Decimal = 0D
|
|
Dim SubTotalNew As Decimal = TotalNew
|
|
Dim CvePrePoliza As Integer = -1
|
|
|
|
If ObjVentas.GetVenta(CveVentaRemision, UsuarioActual.CveEmpresa) Then
|
|
FechaVenta = ObjVentas.DtResultados(0)("Fecha").ToString.ToDate
|
|
CvePrePoliza = ObjVentas.DtResultados(0)("CvePrePoliza").ToString.ToEntero
|
|
End If
|
|
|
|
If ObjVentas.GetVentaDetalle(CveVentaRemision) Then
|
|
TmpDT = ObjVentas.DtResultados
|
|
PorcentajeIVA = ObjVentas.DtResultados.MAX("PorcentajeIVA").ToDecimal
|
|
|
|
If PorcentajeIVA > 0 Then
|
|
IVANew = (TotalNew * (PorcentajeIVA * 100)) / (100 + (PorcentajeIVA * 100))
|
|
SubTotalNew = TotalNew - IVANew
|
|
End If
|
|
End If
|
|
|
|
If TmpDT Is Nothing OrElse TmpDT.Rows.Count = 0 Or FechaVenta = MinFecha Then
|
|
Alert("Error al obtener los datos de la remisión.", TipoMensaje.MsgAdvertencia)
|
|
Return False
|
|
End If
|
|
|
|
Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
|
|
Dim Moneda As Integer = DdlMoneda.SelectedValue.ToEntero()
|
|
'validación si es una fecha posterior, que tome el día actual
|
|
Dim TC As Decimal = If(CveMonedaNew = 2, GlobalTipoCambio(If(FechaVenta > Now, NowADS(), FechaVenta)).ToDecimal, 1)
|
|
|
|
Try
|
|
If Not ObjVentas.UpdateVentas(SubTotalNew, 0, IVANew, 0, TotalNew, CveMonedaNew, TC, FechaVenta, DescripcionNew,
|
|
UsuarioActual.CveEmpresa, CveVentaRemision,
|
|
Vigencia:=FechaVenta, CondicionesPago:=-1,
|
|
PedidoContrato:="-1", AtencionA:="-1", CveMetodoPago33:=-1,
|
|
CveFormaPago33:=-1, TipoDocto:="Rem", CveCliente:=CveClienteNew, CveClienteSucursal:=-1,
|
|
OrdenCompra:="-1", RetIVA:=0, RetISR:=0, Kilometraje:=0D, CveUsoCFDi:=-1,
|
|
CveVendedor:=-1, ServicioDomicilio:=False, CveMedico:=-1, CveProcedimiento:=-1,
|
|
FechaParaSurtir:=MinFecha, Paciente:="-1", Episodio:="-1", CveCondicionEntrega:=-1, FolioRemision:="-1") Then
|
|
OcurrioError = True
|
|
End If
|
|
|
|
'Cargo de nueva cuenta el detalle de Ventas (Conceptos)
|
|
If Not OcurrioError Then
|
|
Dim index As Integer = 0
|
|
For Each Row As DataRow In TmpDT.Rows
|
|
Dim CveVentaDetalle As Integer = Row("CveVentaDetalle").ToString().ToEntero()
|
|
If CveVentaDetalle > 0 Then
|
|
If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString().ToEntero(), Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, SubTotalNew, Row("ImporteIEPS").ToString().ToDecimal(), Row("PorcentajeIEPS").ToString().ToDecimal(), IVANew, PorcentajeIVA, 0, DescripcionNew, UsuarioActual.CveUsuario) Then
|
|
OcurrioError = True
|
|
End If
|
|
End If
|
|
Exit For ' solo debe de tener un detalle por eso se sale
|
|
index = index + 1
|
|
Next
|
|
End If
|
|
|
|
If Not OcurrioError Then
|
|
Dim DTPrePoliza As New DataTable
|
|
If ObjConta.GetPrePolizasDetalle(CvePrePoliza, UsuarioActual.CveEmpresa) Then
|
|
DTPrePoliza = ObjConta.DtResultados
|
|
If DTPrePoliza.Rows.Count = 0 Then
|
|
OcurrioError = True
|
|
Alert("No se encontraron datos de prepoliza", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
Else
|
|
OcurrioError = True
|
|
End If
|
|
|
|
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, Importe:=TotalNew, TipoCambio:=TC, CveCliente:=CveClienteNew) Then
|
|
OcurrioError = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If ObjConta.ValidacionesPrePoliza(-1, UsuarioActual, Opcion:=2, CveVenta:=CveVentaRemision) Then
|
|
If ObjConta.ValorPolizaDescuadre > 0 Then
|
|
If ObjConta.ValorPolizaDescuadre = 2 Then
|
|
OcurrioError = True
|
|
Alert(ObjConta.MensajePolizaDescuadre, TipoMensaje.MsgError)
|
|
End If
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
OcurrioError = True
|
|
OnError("Ocurrió un error al actualizar la remisión", ex)
|
|
End Try
|
|
|
|
If OcurrioError Then
|
|
'Alert("Ocurrió un error al guardar los cambios. Por favor intente de nuevo.", TipoMensaje.MsgError)
|
|
Return False
|
|
Else
|
|
' Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion, JSBtnAceptar:="BtnRefrescarPagina();")
|
|
CveSubProyectoOriginal = DdlSubProyecto.SelectedValue.ToEntero
|
|
CveMonedaOriginal = DdlMoneda.SelectedValue.ToEntero
|
|
ImporteOrigial = TxtImporte.Text.ToDecimal
|
|
DescripcionOriginal = TxtDescripcion.Text
|
|
TipoAFOriginal = DdlTipoAF.SelectedItem.Text
|
|
FolioOriginal = TxtFolio.Text.Trim
|
|
CveClienteOriginal = DdlClientes.SelectedValue.ToEntero
|
|
Return True
|
|
End If
|
|
End Function
|
|
|
|
Protected Sub EliminarContrato(sender As Object, e As EventArgs)
|
|
Dim ObjContratos As New ClsContratos
|
|
If (CveContratoTipo = 35) Then
|
|
If CveMasivo <> 0 Then
|
|
If ObjContratos.RemoveContrato(CveContrato, UsuarioActual.CveEmpresa, CveMasivo:=CveMasivo) Then
|
|
Alert("Viajes masivos eliminados correctamente")
|
|
AgregarABitacora($"Eliminación del contrato {CveContrato}")
|
|
|
|
ObjContratos.Dispose()
|
|
Response.Redirect("RepViajes.aspx")
|
|
End If
|
|
Else
|
|
If ObjContratos.RemoveContrato(CveContrato, UsuarioActual.CveEmpresa) Then
|
|
Alert("Viaje eliminado correctamente")
|
|
AgregarABitacora($"Eliminación de contratos masivos con clave {CveMasivo}")
|
|
|
|
ObjContratos.Dispose()
|
|
Response.Redirect("RepViajes.aspx")
|
|
End If
|
|
End If
|
|
Else
|
|
If ObjContratos.RemoveContrato(CveContrato, UsuarioActual.CveEmpresa) Then
|
|
Alert("Contrato eliminado correctamente")
|
|
ObjContratos.Dispose()
|
|
Response.Redirect("RepContratos.aspx")
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
Protected Sub ImprimirContrato(sender As Object, e As EventArgs)
|
|
Dim dtResult As New DataTable()
|
|
|
|
Dim params As New List(Of ReportParameter) From {
|
|
New ReportParameter("Folio", TxtFolio.Text),
|
|
New ReportParameter("Cliente", DdlClientes.SelectedText),
|
|
New ReportParameter("Servicio", TxtDescripcion.Text),
|
|
New ReportParameter("Observaciones", TxtObservaciones.Text),
|
|
New ReportParameter("Ubicacion", TxtUbicacion.Text),
|
|
New ReportParameter("FechaSalida", TxtFechaSalida.Text.ToDate.ToString("dd/MM/yyyy HH:mm tt")),
|
|
New ReportParameter("FechaRegreso", TxtFechaRegreso.Text.ToDate.ToString("dd/MM/yyyy HH:mm tt")),
|
|
New ReportParameter("CantidadPasajeros", TxtCantidadPasajeros.Text),
|
|
New ReportParameter("TipoAF", DdlTipoAF.SelectedItem.ToString()),
|
|
New ReportParameter("Pesos", TxtImporte.Text.ToDecimal.ToString("###,###,###.00")),
|
|
New ReportParameter("Moneda", DdlMoneda.SelectedItem.ToString),
|
|
New ReportParameter("Anticipo", TxtAnticipo.Text.ToDecimal.ToString("###,###,###.00")),
|
|
New ReportParameter("Total", (TxtImporte.Text.ToDecimal - (TxtAnticipo.Text.ToDecimal)).ToString("###,###,###.00")),
|
|
New ReportParameter("DiaSalida", TxtFechaSalida.Text.ToDate.ToString("HH:mm tt")),
|
|
New ReportParameter("TelefonoEmpresa", TelefonoEmpresa),
|
|
New ReportParameter("FechaImpresion", Date.Now.ToString("dd/MM/yyyy HH:mm:ss")),
|
|
New ReportParameter("Usuario", UsuarioActual.Nombre)
|
|
}
|
|
|
|
|
|
ImprimirPDFStimul($"{UsuarioActual.Empresa.Ruta}Formatos\Contrato.mrt", dtResult, params, NombreArchivo:=TxtFolio.Text)
|
|
End Sub
|
|
Protected Sub AgregarABitacora(Descripcion As String)
|
|
Dim ObjEventoBitacora As New ClsOIEventos
|
|
|
|
Dim FileExtension As String = "-1"
|
|
|
|
If ObjEventoBitacora.AddEventoBitacora(Descripcion, FileExtension, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveContrato:=CveContrato) Then
|
|
'Alert("Evento agregado a bitácora correctamente", TipoMensaje.MsgInformacion)
|
|
|
|
End If
|
|
ObjEventoBitacora.Dispose()
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "Boletos"
|
|
Protected Sub OnLinkButtonClick(sender As Object, e As EventArgs)
|
|
'Limpiamos la selección anterior
|
|
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
|
|
'Seleccionamos un asiento
|
|
Dim linkButton As LinkButton = DirectCast(sender, LinkButton)
|
|
Dim buttonID As String = linkButton.ID
|
|
linkButton.CssClass += " activo"
|
|
AsientoSeleccionado = buttonID
|
|
TxtAsiento.Text = buttonID.Substring(1)
|
|
|
|
UpTabContainer.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalEditar"))
|
|
End Sub
|
|
Protected Sub UpdateBoleto(sender As Object, e As EventArgs)
|
|
|
|
|
|
If PnEditarViaje.Visible = True Then
|
|
For Each boleto As DataRow In ViajeActual.Rows
|
|
If (boleto.Item("Asiento").ToString = TxtAsiento.Text) Then
|
|
Alert($"El asiento {boleto.Item("Asiento")} ya ha está ocupado", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
Dim ObjTransportes As New ClsTransportes
|
|
|
|
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), FechaNacimiento:=TxtFechaNacimiento.Text.ToDate) Then
|
|
ObjTransportes.Commit()
|
|
End If
|
|
Catch ex As ArgumentException
|
|
Alert($"Ocurrió un ocurrió un error al actualizar su boleto", TipoMensaje.MsgError)
|
|
ObjTransportes.RollBack()
|
|
Finally
|
|
Alert("Su asiento fue actualizado correctamente")
|
|
AgregarABitacora($"Cambio de asiento del pasajero {CveViajePasajero} del asiento al {TxtAsiento.Text} del contrato {CveContrato}")
|
|
|
|
ObjTransportes.Dispose()
|
|
|
|
End Try
|
|
|
|
CargaDatos()
|
|
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "ModalEditar"))
|
|
End Sub
|
|
Protected Sub OnChangeRuta(sender As Object, e As EventArgs)
|
|
Dim ObjTransportes As New ClsTransportes
|
|
|
|
If ObjTransportes.GetViajesPasajeros(DdlRuta.SelectedValue.ToEntero) Then
|
|
BusquedaSeleccionada(ObjTransportes.DtResultados)
|
|
End If
|
|
ObjTransportes.Dispose()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalEditar"))
|
|
End Sub
|
|
Protected Sub BusquedaSeleccionada(dt As DataTable)
|
|
'Limpiamos autobus
|
|
Dim cph As ContentPlaceHolder = CType(Me.Master.FindControl("C"), ContentPlaceHolder)
|
|
|
|
For i As Integer = 1 To 50
|
|
Dim lnk As LinkButton = CType(cph.FindControl($"A{i}"), LinkButton)
|
|
If lnk IsNot Nothing Then
|
|
lnk.Enabled = True
|
|
lnk.CssClass = "disponible"
|
|
End If
|
|
Next
|
|
'Si la dt DataTable tiene algo llenamos los asientos
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
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
|
|
UpTabContainer.Update()
|
|
|
|
ViajeActual = dt
|
|
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"))
|
|
|
|
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.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")
|
|
TxtNombre.Text = GvRow.DataKey("Nombre").ToString()
|
|
TxtVisa.Text = GvRow.DataKey("Visa").ToString()
|
|
TxtCelular.Text = GvRow.DataKey("Celular").ToString()
|
|
RblSexo.SelectedValue = If(CBool(GvRow.DataKey("Sexo").ToString), "1", "0")
|
|
TxtObservacion.Text = GvRow.DataKey("Observacion").ToString()
|
|
LbEstatus.Text = If(CBool(GvRow.DataKey("Estatus").ToString), "Activo", "Cancelado")
|
|
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("dd/MM/yyyy")
|
|
|
|
If EsAgencia Then
|
|
TxtFechaNacimiento.Enabled = False
|
|
TxtNombre.Enabled = False
|
|
End If
|
|
|
|
UpTabContainer.Update()
|
|
UpModal.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalEditar"))
|
|
|
|
End Sub
|
|
Protected Sub CambiarBoleto(sender As Object, e As EventArgs)
|
|
PnEditarViaje.Visible = True
|
|
PnEditarUsuario.Visible = False
|
|
PnAsientos.Visible = True
|
|
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
CveViajePasajero = GvRow.DataKey("CveViajePasajero").ToEntero
|
|
LbPartida.Text = GvRow.DataKey("Partida").ToString()
|
|
LbDestino.Text = GvRow.DataKey("Destino").ToString()
|
|
LbImporte.Text = Convert.ToDecimal(GvRow.DataKey("Importe")).ToString("C")
|
|
TxtNombre.Text = GvRow.DataKey("Nombre").ToString()
|
|
TxtVisa.Text = GvRow.DataKey("Visa").ToString()
|
|
TxtCelular.Text = GvRow.DataKey("Celular").ToString()
|
|
RblSexo.SelectedValue = If(CBool(GvRow.DataKey("Sexo").ToString), "1", "0")
|
|
TxtObservacion.Text = GvRow.DataKey("Observacion").ToString()
|
|
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()
|
|
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
|
|
Dim fecha As DateTime = row("FechaInicial").ToString.ToDateTime
|
|
'Asigna los valores de la columna deseada al ListItem
|
|
Dim listItem As New ListItem(row("SubProyecto").ToString() + " - " + fecha.ToShortDateString + " - " + fecha.ToShortTimeString, row("CveContrato").ToString())
|
|
'Agrega el ListItem al DropDownList
|
|
DdlRuta.Items.Add(listItem)
|
|
Next
|
|
End If
|
|
DdlRuta.SelectedValueExist(GvRow.DataKey("CveViaje"))
|
|
ObjContratos.Dispose()
|
|
UpTabContainer.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalEditar"))
|
|
End Sub
|
|
Protected Sub BtnCancelar_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
CveViajePasajero = GvRow.DataKey("CveViajePasajero").ToEntero
|
|
LbPartida.Text = GvRow.DataKey("Partida").ToString()
|
|
LbDestino.Text = GvRow.DataKey("Destino").ToString()
|
|
LbImporte.Text = Convert.ToDecimal(GvRow.DataKey("Importe")).ToString("C")
|
|
TxtNombre.Text = GvRow.DataKey("Nombre").ToString()
|
|
TxtVisa.Text = GvRow.DataKey("Visa").ToString()
|
|
TxtCelular.Text = GvRow.DataKey("Celular").ToString()
|
|
RblSexo.SelectedValue = If(CBool(GvRow.DataKey("Sexo").ToString), "1", "0")
|
|
TxtObservacion.Text = GvRow.DataKey("Observacion").ToString()
|
|
TxtEstatus.Text = GvRow.DataKey("Estatus").ToString()
|
|
LbCreado.Text = GvRow.DataKey("FechaIng").ToString()
|
|
TxtAsiento.Text = GvRow.DataKey("Asiento").ToString()
|
|
Dim Estatus As Boolean = Not CBool(TxtEstatus.Text)
|
|
Dim ObjTransportes As New ClsTransportes
|
|
Try
|
|
ObjTransportes.IniciaTransacSQL()
|
|
|
|
If ObjTransportes.UpdateViajesPasajeros(CveViajePasajero, CveContrato, UsuarioActual.CveVendedor, LbImporte.Text.ToDecimal, TxtAsiento.Text.ToEntero, TxtNombre.Text, TxtVisa.Text, TxtCelular.Text, TxtObservacion.Text, Estatus, UsuarioActual.CveUsuario, CBool(RblSexo.SelectedValue)) Then
|
|
Alert("Se ha modificado el estatus de su boleto correctamente.")
|
|
|
|
ObjTransportes.Commit()
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
ObjTransportes.RollBack()
|
|
Alert($"No se pudo cambiar el estatus del boleto", TipoMensaje.MsgError)
|
|
Finally
|
|
ObjTransportes.Dispose()
|
|
Dim toggleEstatus As String
|
|
If CBool(RblSexo.SelectedValue) Then
|
|
toggleEstatus = "Cancelación"
|
|
Else
|
|
toggleEstatus = "Reactivación"
|
|
|
|
End If
|
|
AgregarABitacora($"{toggleEstatus} del asiento {TxtAsiento.Text} del viaje {CveContrato} con clave de pasajero {CveViajePasajero}")
|
|
|
|
CargaDatos()
|
|
End Try
|
|
UpPasajeros.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "Bitacora historial"
|
|
Private Sub CargaGvBitacora()
|
|
' COMENTADO POR IPP PARA SUBIR 5 ABRIL 2017
|
|
If CveContrato > 0 Then
|
|
Dim ObjGral As New ClsGenerales()
|
|
If ObjGral.GetHistorialBitacora(-1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa, CveContrato:=CveContrato) Then
|
|
GvBitacora.DataSource = ObjGral.DtResultados
|
|
End If
|
|
ObjGral.Dispose()
|
|
End If
|
|
GvBitacora.DataBind()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "PAGOS"
|
|
Private Sub CargaAuxiliarClienteCxC(CveCliente As Integer, CveRemision As Integer)
|
|
|
|
If CveRemision > 0 Then
|
|
Dim ObjMovtos As New ClsMovimientos()
|
|
|
|
If ObjMovtos.GetCxCClienteAuxiliar(CveCliente, CveRemision) Then
|
|
|
|
Dim dtTemp As New DataTable
|
|
dtTemp = ObjMovtos.DtResultados.FiltraParametros("CveConceptoContable IN (193,2,292) ")
|
|
TotalPagos = dtTemp.SUM("Abono")
|
|
GVAuxiliar.DataSource = dtTemp
|
|
|
|
Else
|
|
GVAuxiliar.DataSource = Nothing
|
|
End If
|
|
|
|
ObjMovtos.Dispose()
|
|
GVAuxiliar.DataBind()
|
|
UpPagos.Update()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Protected Sub GVAuxiliar_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.DataKey("TipoReferencia").ToEntero = 1 Then
|
|
e.Row.FCHyperLink("HplReferencia").NavigateUrl = $"/Bancos/IE.aspx?CveIE={e.Row.DataKey("CveReferencia").ToEntero}"
|
|
End If
|
|
End If
|
|
If e.Row.RowType = DataControlRowType.Footer Then
|
|
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Right
|
|
e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Right
|
|
e.Row.Cells(1).Text = "Total"
|
|
e.Row.FCLabel("Lbltotal").Text = TotalPagos.ToString("###,###,###.00")
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " R E M I S I O N "
|
|
Private Function GeneraRemision(CveContrato As Integer, ObsPartida As String, Importe As Decimal, CvePS As Integer, ByRef TransaccionSQL As SqlClient.SqlTransaction, CveSubProyecto As Integer) As RespuestaFacturacion
|
|
|
|
Dim Respuesta As New RespuestaFacturacion()
|
|
Dim CveRemisionGenerada As Integer = -1
|
|
Dim ObjVentas As New ClsVentas(TransaccionSQL)
|
|
Dim ProcesoOK As Boolean = True
|
|
Dim CveMoneda As Integer = DdlMoneda.SelectedValue.ToEntero
|
|
|
|
Dim ObjFactura As Modelos.Factura = Modelos.Factura.CrearVentaNueva(UsuarioActual, CveSubProyecto, DdlClientes.SelectedValue.ToEntero, CveMoneda, "Rem")
|
|
|
|
If ObjFactura IsNot Nothing AndAlso ProcesoOK Then
|
|
|
|
ObjFactura.CveMoneda = CveMoneda
|
|
ObjFactura.CveContrato = CveContrato
|
|
ObjFactura.Observaciones = ObsPartida
|
|
ObjFactura.CveFormaPago = 20 ' por definir
|
|
If CveMoneda > 1 Then
|
|
ObjFactura.TipoCambio = GlobalTipoCambio(DateTime.Now).ToDecimal
|
|
End If
|
|
|
|
Dim TmpDTMat As New DataTable
|
|
TmpDTMat.Columns.Add("Consec", GetType(Integer))
|
|
TmpDTMat.Columns.Add("CvePS", GetType(Integer))
|
|
TmpDTMat.Columns.Add("CveUM", GetType(Integer))
|
|
TmpDTMat.Columns.Add("Cantidad", GetType(Integer))
|
|
TmpDTMat.Columns.Add("PU", GetType(Decimal))
|
|
TmpDTMat.Columns.Add("Lote", GetType(String))
|
|
TmpDTMat.Columns.Add("FechaCaducidad", GetType(Date))
|
|
TmpDTMat.Columns.Add("CveVentaDetalle", GetType(Integer))
|
|
|
|
Dim CantidadRegistro As Decimal = 1
|
|
Dim PorcentajeIVA As Decimal = GlobalDTSubProyectos(UsuarioActual.CveEmpresa, CveSubProyecto:=CveSubProyecto).FiltroPrimeroValor("IVA").ToDecimal
|
|
Dim SubTotal As Decimal = (Importe / (1D + PorcentajeIVA))
|
|
Dim PU As Decimal = SubTotal
|
|
Dim Descuento As Decimal = 0
|
|
Dim Obs As String = ObsPartida
|
|
|
|
If CantidadRegistro > 0 Then
|
|
If ObjFactura.AgregarPS(CvePS, CantidadRegistro, PU, Descuento, Obs, CveSubProyecto:=CveSubProyecto, PorcentajeIVA:=PorcentajeIVA) Then
|
|
Dim drp As DataRow = TmpDTMat.NewRow
|
|
drp("CvePS") = CvePS
|
|
drp("Cantidad") = CantidadRegistro
|
|
drp("PU") = PU
|
|
TmpDTMat.Rows.Add(drp)
|
|
Else
|
|
Alert("Error al agregar producto", TipoMensaje.MsgAdvertencia)
|
|
ProcesoOK = False
|
|
End If
|
|
End If
|
|
|
|
If ProcesoOK Then
|
|
ObjFactura.CalculaTotales()
|
|
Dim Resp As New Modelos.Factura.MMensajeFactura
|
|
Resp = ObjFactura.EmitirFactura(False, Transac:=TransaccionSQL)
|
|
|
|
If Resp.CveVenta > 0 Then
|
|
Respuesta.CveVenta = Resp.CveVenta
|
|
Respuesta.SerieFolio = Resp.SerieFolio
|
|
Respuesta.dtdetalle = TmpDTMat
|
|
Else
|
|
ProcesoOK = False
|
|
End If
|
|
End If
|
|
Else
|
|
ProcesoOK = False
|
|
End If
|
|
Return Respuesta
|
|
|
|
End Function
|
|
Friend Class RespuestaFacturacion
|
|
Public Property CveVenta As Integer = -1
|
|
Public Property SerieFolio As String = "-1"
|
|
Public Property dtdetalle As DataTable = Nothing
|
|
Public Sub New()
|
|
|
|
End Sub
|
|
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
|
|
|
|
|