This commit is contained in:
AbrahamCastilloV
2024-02-28 18:43:47 -07:00
parent 4758fa190d
commit c860d9fda5
5 changed files with 387 additions and 99 deletions

View File

@@ -1,6 +1,7 @@
Option Explicit On
Option Strict On
Imports System.Data
Imports System.IO
Imports ADSNetLibrary.Helpers
Imports ADSNetLibrary.SIGAPI.Helpers
Imports Extensiones
@@ -18,6 +19,22 @@ Partial Class RepContratoDetalle
ViewState("CveContrato") = 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 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)
@@ -60,6 +77,7 @@ Partial Class RepContratoDetalle
End Property
#End Region
#Region "Carga Página"
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Request("CveContrato") Is Nothing Then
Response.Redirect($"~/Transportes/RepContratos.aspx")
@@ -85,8 +103,11 @@ Partial Class RepContratoDetalle
If ObjContratos.GetContratos(CveContrato, UsuarioActual.CveEmpresa) Then
Contrato = ObjContratos.DtResultados
If Contrato IsNot Nothing AndAlso Contrato.Rows.Count > 0 Then
CveContratoTipo = Contrato.Rows(0)("CveContratoTipo").ToString.ToEntero
SubProyecto = Contrato.Rows(0)("SubProyecto").ToString
CveMasivo = Contrato.Rows(0)("CveMasivo").ToString.ToEntero
LbFolio.Text = Contrato.Rows(0)("NumeroContrato").ToString
LbCveSubProyecto.Text = Contrato.Rows(0)("CveSubProyecto").ToString
DdlClientes.SelectedText = Contrato.Rows(0)("NombreComercial").ToString
DdlClientes.SelectedValue = Contrato.Rows(0)("CveCliente").ToString
TxtDescripcion.Text = Contrato.Rows(0)("DescripcionContrato").ToString
@@ -99,6 +120,12 @@ Partial Class RepContratoDetalle
TxtDolares.Text = Contrato.Rows(0)("Importe").ToString
TxtPesos.Text = Contrato.Rows(0)("ImporteMax").ToString
TxtAnticipo.Text = Contrato.Rows(0)("ImporteMin").ToString
If Not String.IsNullOrEmpty(Contrato.Rows(0)("Archivo").ToString) Then
BtnDescargar.Visible = True
LbArchivo.Text = Contrato.Rows(0)("Archivo").ToString
LbArchivo.Visible = True
ViewState("FUrl") = Path.Combine(UsuarioActual.Empresa.Ruta, "CONTRATOS", ObjContratos.Archivo)
End If
'Boletos Vendidos
If Contrato.Rows(0)("CveContratoTipo").ToString() = "35" Then
TabBoletos.Visible = True
@@ -117,73 +144,133 @@ Partial Class RepContratoDetalle
Response.Redirect($"~/Transportes/RepContratos.aspx")
End If
ObjContratos.Dispose()
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")
LbNombre.Text = GvRow.DataKey("Nombre").ToString()
LbVisa.Text = GvRow.DataKey("Visa").ToString()
LbCelular.Text = GvRow.DataKey("Celular").ToString()
LbSexo.Text = GvRow.DataKey("Sexo").ToString()
LbObservacion.Text = GvRow.DataKey("Observacion").ToString()
LbEstatus.Text = GvRow.DataKey("Estatus").ToString()
LbCreado.Text = GvRow.DataKey("FechaIng").ToString()
TxtAsiento.Text = GvRow.DataKey("Asiento").ToString()
Dim Estatus As Boolean = Not LbEstatus.Text.ToBool
Dim ObjTransportes As New ClsTransportes
#End Region
#Region "Información General"
Protected Sub GuardarArchivo(sender As Object, e As EventArgs)
Dim FileExtension As String = "-1"
Dim Filesgral As List(Of 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($"{AppDomain.CurrentDomain.BaseDirectory}Temp\{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", "Temp", fileItem.filename)
File.Move(fileItem.FileUrl, ViewState("FUrl").ToString)
TxtArchivo.Text = tempArray(1)
' imgFileOk.Visible = True
'ImgArchivo.Src = "/imagenes/accept.png"
Next
UpTabContainer.Update()
RegistraScript("$('#ModalUpload').modal('hide')", "hidemodal1")
Button1.Visible = True
If Not FileExtension = "-1" Then
BtnDescargar.Visible = True
End If
UpdateContrato(sender, e)
End Sub
Protected Sub DescargarArchivo(sender As Object, e As EventArgs)
Dim File As New FileInfo(ViewState("FUrl").ToString)
If File.Exists Then 'set appropriate headers
Response.Clear()
Response.ClearHeaders()
Response.ClearContent()
Response.AddHeader("Content-Disposition", "attachment; filename=" & LbFolio.Text & ".pdf")
Response.AddHeader("Content-Length", File.Length.ToString())
'Response.ContentType = "text/plain"
Response.ContentType = "application/octet-stream"
Response.Flush()
' Response.TransmitFile(File.FullName)
Response.WriteFile(File.FullName)
Response.End()
'if file does not exist
Alert("Descargado Correctamente.", TipoMensaje.MsgInformacion)
Else
Alert("Ocurrio un error al descargar el archivo", TipoMensaje.MsgAdvertencia, "window.close()")
End If 'nothing in the URL as HTTP GET
End Sub
Protected Sub UpdateContrato(sender As Object, e As EventArgs)
Dim ObjContratos As New ClsContratos
Try
ObjTransportes.IniciaTransacSQL()
If ObjTransportes.UpdateViajesPasajeros(CveViajePasajero, CveContrato, UsuarioActual.CveVendedor, LbImporte.Text.ToDecimal, TxtAsiento.Text.ToEntero, LbNombre.Text, LbVisa.Text, LbCelular.Text, LbObservacion.Text, Estatus, UsuarioActual.CveUsuario, LbSexo.Text.ToBool) Then
Alert($"El boleto ha modificado el estatus de su boleto correctamente.")
ObjTransportes.Commit()
If ObjContratos.UpdateContratos(CveContrato, LbFolio.Text, TxtDescripcion.Text, "", -1, DdlClientes.SelectedValue.ToEntero, -1, TxtFechaSalida.Text.ToDate, TxtFechaRegreso.Text.ToDate, TxtUbicacion.Text, "", LbCveSubProyecto.Text.ToEntero, -1, -1, -1, -1, LbArchivo.Text, "", -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, TxtAnticipo.Text.ToDecimal, TxtPesos.Text.ToDecimal, TxtDolares.Text.ToDecimal, -1, -1) Then
Alert("Contrato actualizado correctamente")
End If
ObjContratos.Commit()
Catch ex As Exception
ObjTransportes.RollBack()
Alert($"No se pudo cambiar el estatus del boleto", TipoMensaje.MsgError)
Alert($"Ocurrió un ocurrió un error al actualizar su boleto", TipoMensaje.MsgError)
ObjContratos.RollBack()
Finally
ObjTransportes.Dispose()
Alert("Contrato actualizado correctamente")
ObjContratos.Dispose()
CargaDatos()
End Try
End Sub
Protected Sub CambiarBoleto(sender As Object, e As EventArgs)
DdlRuta.ClearSelection()
PnEditarViaje.Visible = True
PnEditarUsuario.Visible = False
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")
LbNombre.Text = GvRow.DataKey("Nombre").ToString()
LbVisa.Text = GvRow.DataKey("Visa").ToString()
LbCelular.Text = GvRow.DataKey("Celular").ToString()
LbSexo.Text = GvRow.DataKey("Sexo").ToString()
LbObservacion.Text = GvRow.DataKey("Observacion").ToString()
LbEstatus.Text = GvRow.DataKey("Estatus").ToString()
LbCreado.Text = GvRow.DataKey("FechaIng").ToString()
TxtAsiento.Text = GvRow.DataKey("Asiento").ToString()
'Seleccionamos la ruta que tiene el usuario actual
DdlRuta.ClearSelection()
Protected Sub EliminarContrato(sender As Object, e As EventArgs)
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
If (CveContratoTipo = 35) Then
If CveMasivo <> 0 Then
If ObjContratos.RemoveContrato(CveContrato, UsuarioActual.CveEmpresa, CveMasivo:=CveMasivo) Then
Alert("Viajes masivos eliminados correctamente")
ObjContratos.Dispose()
Response.Redirect("RepViajes.aspx")
End If
Else
If ObjContratos.RemoveContrato(CveContrato, UsuarioActual.CveEmpresa) Then
Alert("Viaje eliminado correctamente")
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
DdlRuta.SelectedValue = GvRow.DataKey("CveViaje")
ObjContratos.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)
UpBoletos.Update()
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalEditar"))
End Sub
Protected Sub UpdateBoleto(sender As Object, e As EventArgs)
@@ -211,26 +298,6 @@ Partial Class RepContratoDetalle
CargaDatos()
End Try
End Sub
Protected Sub EditarBoleto(sender As Object, e As EventArgs)
End Sub
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)
UpBoletos.Update()
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalEditar"))
End Sub
Protected Sub OnChangeRuta(sender As Object, e As EventArgs)
Dim ObjTransportes As New ClsTransportes
@@ -292,6 +359,79 @@ Partial Class RepContratoDetalle
'Empresas/188/Formatos/Boleto.mrt
End Sub
Protected Sub EditarBoleto(sender As Object, e As EventArgs)
End Sub
Protected Sub CambiarBoleto(sender As Object, e As EventArgs)
DdlRuta.ClearSelection()
PnEditarViaje.Visible = True
PnEditarUsuario.Visible = False
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")
LbNombre.Text = GvRow.DataKey("Nombre").ToString()
LbVisa.Text = GvRow.DataKey("Visa").ToString()
LbCelular.Text = GvRow.DataKey("Celular").ToString()
LbSexo.Text = GvRow.DataKey("Sexo").ToString()
LbObservacion.Text = GvRow.DataKey("Observacion").ToString()
LbEstatus.Text = GvRow.DataKey("Estatus").ToString()
LbCreado.Text = GvRow.DataKey("FechaIng").ToString()
TxtAsiento.Text = GvRow.DataKey("Asiento").ToString()
'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.SelectedValue = GvRow.DataKey("CveViaje")
ObjContratos.Dispose()
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")
LbNombre.Text = GvRow.DataKey("Nombre").ToString()
LbVisa.Text = GvRow.DataKey("Visa").ToString()
LbCelular.Text = GvRow.DataKey("Celular").ToString()
LbSexo.Text = GvRow.DataKey("Sexo").ToString()
LbObservacion.Text = GvRow.DataKey("Observacion").ToString()
LbEstatus.Text = GvRow.DataKey("Estatus").ToString()
LbCreado.Text = GvRow.DataKey("FechaIng").ToString()
TxtAsiento.Text = GvRow.DataKey("Asiento").ToString()
Dim Estatus As Boolean = Not LbEstatus.Text.ToBool
Dim ObjTransportes As New ClsTransportes
Try
ObjTransportes.IniciaTransacSQL()
If ObjTransportes.UpdateViajesPasajeros(CveViajePasajero, CveContrato, UsuarioActual.CveVendedor, LbImporte.Text.ToDecimal, TxtAsiento.Text.ToEntero, LbNombre.Text, LbVisa.Text, LbCelular.Text, LbObservacion.Text, Estatus, UsuarioActual.CveUsuario, LbSexo.Text.ToBool) Then
Alert($"El boleto 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()
CargaDatos()
End Try
End Sub
#End Region
End Class