Transportes Mejoras

This commit is contained in:
rakcsle
2024-11-05 08:25:18 -07:00
parent d5b93be073
commit f92083edcd
13 changed files with 678 additions and 89 deletions

View File

@@ -201,6 +201,22 @@ Partial Class RepContratoDetalle
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
@@ -209,20 +225,42 @@ Partial Class RepContratoDetalle
#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")
End If
CveContrato = Request("CveContrato").ToEntero
If Not IsPostBack Then
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
If CveVentaRemision > 0 Then
DVFactura.Visible = True
End If
End If
End Sub
Private Sub InicializaCombos()
'Lista Tipo AF
@@ -297,6 +335,14 @@ Partial Class RepContratoDetalle
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)}"
'If File.Exists Then
' RegistraScript($"window.open({Url}, ""_blank"");")
'End If
Else
BtnDescargar.Visible = False
A1.Visible = True
@@ -313,13 +359,13 @@ Partial Class RepContratoDetalle
ObjTransportes.Dispose()
GvViajesPasajeros.DataBind()
End If
'Bitácora
Dim ObjEventoBitacora As New ClsOIEventos
If ObjEventoBitacora.GetEventos(-1, -1, -1, "-1", "-1", -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveContrato:=CveContrato) Then
GvEventosBitacora.DataSource = ObjEventoBitacora.DtResultados
GvEventosBitacora.DataBind()
End If
ObjEventoBitacora.Dispose()
''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
@@ -332,8 +378,113 @@ Partial Class RepContratoDetalle
End Sub
#End Region
#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 CargarArchivo(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles AFU.UploadedComplete
' If AFU.HasFile Then
' Dim UploadFolder As String = String.Format("{0}\Temp\", UsuarioActual.Empresa.Ruta)
' UploadFolder.DirectoryExistsCreate()
' Dim Extension As String = System.IO.Path.GetExtension(AFU.PostedFile.FileName)
' If File.Exists(String.Format("{0}{1}{2}", UploadFolder, UsuarioActual.CveUsuario.ToString, Extension)) Then File.Delete(String.Format("{0}{1}{2}", UploadFolder, UsuarioActual.CveUsuario.ToString, Extension))
' AFU.SaveAs(UploadFolder & UsuarioActual.CveUsuario.ToString & Extension)
' Session("FileUpload") = UploadFolder & UsuarioActual.CveUsuario.ToString & Extension
' Session("FileExtension") = Extension
' Session("FileFolder") = UploadFolder
' 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 = ""
@@ -375,32 +526,61 @@ Partial Class RepContratoDetalle
BtnDescargar.Visible = True
End If
End Sub
Private Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles BtnDescargar.Click
DescargarArchivo()
End Sub
Private Sub DescargarArchivo()
Dim File As New FileInfo(ViewState("FUrl").ToString)
'Private Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles BtnDescargar.Click
' Dim File As New FileInfo(ViewState("FUrl").ToString)
' Dim Url As String = $"{ObtenerUrlCompleta()}Compras/PopUpVerFactura.aspx?ArchivoContrato={Encripta(File.FullName)}"
' If File.Exists Then
' RegistraScript($"window.open({Url}, ""_blank"");")
' End If
If File.Exists Then 'set appropriate headers
Response.Clear()
Response.ClearHeaders()
Response.ClearContent()
Response.AddHeader("Content-Disposition", "attachment; filename=" & TxtFolio.Text & $"{File.Extension}")
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 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
'Private Sub DescargaArchivo(urlArchivo As String)
' Dim File As New FileInfo(urlArchivo)
' If File.Exists Then 'set appropriate headers
' Response.Clear()
' Response.ClearHeaders()
' Response.ClearContent()
' Response.AddHeader("Content-Disposition", "inline; filename=" & TxtFolio.Text & $"{File.Extension}")
' 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()
' Else
' Alert("Ocurrio un error al descargar el archivo", TipoMensaje.MsgAdvertencia, "window.close()")
' End If
'End Sub
End If 'nothing in the URL as HTTP GET
End Sub
Protected Sub UpdateContrato(sender As Object, e As EventArgs)
Dim ArchivoUpdate As String = "-1"
Dim ErrorProceso As Boolean = False
@@ -886,6 +1066,52 @@ Partial Class RepContratoDetalle
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(" Conceptocontable = 'Pago del Cliente' ")
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
End Class