JAM - cargar adjunto de comprobación
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
Option Strict On
|
||||
|
||||
Imports System.Data
|
||||
Imports DocumentFormat.OpenXml.Drawing.Diagrams
|
||||
Imports System.IO
|
||||
Imports Extensiones
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
|
||||
@@ -52,12 +54,31 @@ Partial Class Compras_RepRembolsoComprobaciones
|
||||
ViewState("DtCheques") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Private Property CveComprobacion As Integer
|
||||
Get
|
||||
Return (IfNull(ViewState("CveComprobacion"), "-1", ViewState("CveComprobacion"))).ToString().ToEntero()
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveComprobacion") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property Comprobante As String
|
||||
Get
|
||||
Return (IfNull(ViewState("Comprobante"), "", ViewState("Comprobante"))).ToString()
|
||||
End Get
|
||||
Set(value As String)
|
||||
ViewState("Comprobante") = value
|
||||
End Set
|
||||
End Property
|
||||
#End Region
|
||||
Private Sub Compras_RepRembolsoComprobaciones_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not Page.IsPostBack Then
|
||||
|
||||
ViewState("CveMoneda") = 1
|
||||
|
||||
CveComprobacion = -1
|
||||
'Cargar Filtros
|
||||
Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa)
|
||||
dt = dt.FiltraParametros(String.Format("CveTipoCuenta = 1")) 'caja chica = 1
|
||||
@@ -199,6 +220,10 @@ Partial Class Compras_RepRembolsoComprobaciones
|
||||
End Sub
|
||||
|
||||
Protected Sub CargaDatos()
|
||||
|
||||
CveComprobacion = -1
|
||||
Comprobante = ""
|
||||
|
||||
Dim ObjMovtos As New ClsMovimientos
|
||||
|
||||
GvCxP.Visible = True
|
||||
@@ -214,6 +239,11 @@ Partial Class Compras_RepRembolsoComprobaciones
|
||||
DtDatos = ObjMovtos.DtResultados
|
||||
GvCxP.DataSource = DtDatos
|
||||
|
||||
If DtDatos IsNot Nothing Then
|
||||
CveComprobacion = DtDatos.FiltroPrimeroValor("CveComprobacion").ToEntero()
|
||||
Comprobante = DtDatos.FiltroPrimeroValor("Comprobante")
|
||||
End If
|
||||
|
||||
'cargo si tiene cheques pendientes sin amortizar
|
||||
If CvePersonal > 0 Then
|
||||
If DtDatos.Rows.Count > 0 AndAlso TxtNumeroReembolso.Text.Trim <> "" Then
|
||||
@@ -244,8 +274,20 @@ Partial Class Compras_RepRembolsoComprobaciones
|
||||
ObjMovtos.Dispose()
|
||||
GvCxP.DataBind()
|
||||
|
||||
If Not String.IsNullOrEmpty(Comprobante) Then
|
||||
DivAdjunto.Visible = True
|
||||
Else
|
||||
DivAdjunto.Visible = False
|
||||
End If
|
||||
|
||||
LnkImprimir.Visible = True
|
||||
NumeroReembolso = TxtNumeroReembolso.Text
|
||||
|
||||
If UsuarioActual.CveEmpresa = 119 AndAlso UsuarioActual.CveRol = 1 Then
|
||||
HLAgregarComprobante.Visible = True
|
||||
End If
|
||||
|
||||
|
||||
If DtDatos IsNot Nothing AndAlso DtDatos.Rows.Count > 0 Then
|
||||
If NumeroReembolso <> "" AndAlso CvePersonal > 0 AndAlso DtDatos.MAX("CvePrePolizaComprobacionSinBancos").ToEntero > 0 Then
|
||||
DivVincularEgreso.Visible = True
|
||||
@@ -351,4 +393,86 @@ Partial Class Compras_RepRembolsoComprobaciones
|
||||
ObjIE.Dispose()
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Protected Sub BtnCargarComprobante_Click(sender As Object, e As System.EventArgs) Handles BtnCargarComprobante.Click
|
||||
GuardarArchivoAdjunto()
|
||||
End Sub
|
||||
|
||||
Private Sub GuardarArchivoAdjunto()
|
||||
If Not TxtComprobante.getfiles().Archivos.Count > 0 Then
|
||||
Alert("Tiene que cargar un archivo.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If TxtNumeroReembolso.Text = "" Then
|
||||
Alert("Debe asignar un numero de reembolso de subir el archivo.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim FileExtension As String = "-1"
|
||||
Dim Filesgral As List(Of Archivo) = TxtComprobante.getfiles().Archivos
|
||||
Dim Filename As String = ""
|
||||
Dim fileItem As Archivo = Filesgral(0)
|
||||
Try
|
||||
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
||||
Dim Adjunto = String.Format("{0}-{1}.{2}", CveComprobacion, TxtNumeroReembolso.Text, FileExtension)
|
||||
|
||||
Dim Path As String
|
||||
Path = String.Format("{0}Comprobaciones", UsuarioActual.Empresa.Ruta)
|
||||
If Not Directory.Exists(Path) Then
|
||||
Directory.CreateDirectory(Path)
|
||||
End If
|
||||
Path += $"/{Adjunto}"
|
||||
If File.Exists(Path) Then
|
||||
File.Delete(Path)
|
||||
End If
|
||||
My.Computer.FileSystem.MoveFile(fileItem.FileUrl, Path)
|
||||
|
||||
If File.Exists(Path) Then
|
||||
Using ObjMov As New ClsMovimientos
|
||||
If ObjMov.UpdateReembolsoComprobante(CveComprobacion, Adjunto) Then
|
||||
Alert("Documento cargado")
|
||||
End If
|
||||
End Using
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
OnError("Error al cargar archivo", ex)
|
||||
End Try
|
||||
|
||||
RegistraScript("$('#DivArchivo').modal('hide');", "A1")
|
||||
CargaDatos()
|
||||
End Sub
|
||||
|
||||
Protected Sub LnkDescargarAdjunto_Click(sender As Object, e As System.EventArgs) Handles LnkDescargarAdjunto.Click
|
||||
Dim ruta As String = HttpContext.Current.Request.ApplicationPath
|
||||
ruta = String.Format("{0}Comprobaciones", UsuarioActual.Empresa.Ruta)
|
||||
ruta += $"/{Comprobante}"
|
||||
|
||||
Dim Archivo As New System.IO.FileInfo(ruta)
|
||||
|
||||
Try
|
||||
If Archivo IsNot Nothing Then
|
||||
If Archivo.Exists Then
|
||||
|
||||
HttpContext.Current.Response.Clear()
|
||||
HttpContext.Current.Response.ClearContent()
|
||||
HttpContext.Current.Response.ContentType = "application/octet-stream"
|
||||
HttpContext.Current.Response.AppendHeader("Content-disposition", String.Format("attachment; filename={0}", Archivo.Name))
|
||||
HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString())
|
||||
HttpContext.Current.Response.TransmitFile(ruta)
|
||||
Response.Flush() ' send it to the client to download
|
||||
HttpContext.Current.Response.SuppressContent = True
|
||||
HttpContext.Current.ApplicationInstance.CompleteRequest()
|
||||
Response.End()
|
||||
|
||||
Else
|
||||
Alert("El archivo no existe", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
|
||||
End If
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user