Correciones Documentos Clientes

This commit is contained in:
rakcsle
2021-06-01 21:07:55 -07:00
parent 5fa98be72c
commit 119cbe3ef5
3 changed files with 97 additions and 43 deletions

View File

@@ -7072,18 +7072,38 @@ Partial Class Clientes
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
Dim Adjunto As String = GvRow.DataKey("Adjunto")
Dim stringDescargaDocumento As String = ""
If GvRow.DataKey("Documentacion") = "Pagaré" AndAlso UsuarioActual.CveEmpresa = 140 Then
stringDescargaDocumento = ModExtensiones.DirectorioBaseEmpresas & String.Format("Empresas\{0}\Formatos\Pagaré.docx", UsuarioActual.CveEmpresa)
Dim stringDescargaDocumento As String = ""
If GvRow.DataKey("Documentacion") = "Pagaré" AndAlso UsuarioActual.CveEmpresa = 140 Then
stringDescargaDocumento = ModExtensiones.DirectorioBaseEmpresas & String.Format("Empresas\{0}\Formatos\Pagaré.docx", UsuarioActual.CveEmpresa)
TxtDireccionAval.Text = ""
TxtAval.Text = ""
RegistraScript("$('#ModalDivPagare').modal('show')")
Else
stringDescargaDocumento = ModExtensiones.DirectorioBaseEmpresas & String.Format("Empresas\{0}\DocElectronica\Clientes\{1}\{2}", UsuarioActual.CveEmpresa, CveCliente, Adjunto)
End If
linkDescargaPagare = stringDescargaDocumento
TxtDireccionAval.Text = ""
TxtAval.Text = ""
RegistraScript("$('#ModalDivPagare').modal('show')")
stringDescargaDocumento = ModExtensiones.DirectorioBaseEmpresas & String.Format("Empresas\{0}\DocElectronica\Clientes\{1}\{2}", UsuarioActual.CveEmpresa, CveCliente, Adjunto)
linkDescargaPagare = stringDescargaDocumento
Dim File = New FileInfo(linkDescargaPagare)
If File.Exists Then
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" + File.Name)
Response.AddHeader("Content-Length", File.Length.ToString())
Response.ContentType = "text/octet-stream"
Response.Flush()
Response.TransmitFile(File.FullName)
Response.End()
End If
End If
End Sub
Protected Sub ImprimirPagare(sender As Object, e As EventArgs) Handles BtnAgregarPagare.Click
@@ -7153,7 +7173,7 @@ Partial Class Clientes
Dim Adjunto As String = e.Row.DBCampo("Adjunto").ToString()
Dim ImgDownLoadFormato As LinkButton = e.Row.FCLinkButton("ImgDownLoadFormato")
'Dim ImgDownLoad As Literal = e.Row.FCLiteral("ImgDownLoad")
Dim ImgDownLoad As Literal = e.Row.FCLiteral("ImgDownLoad")
Dim LnkDownLoadDoc As LinkButton = e.Row.FCLinkButton("LnkDownLoadDoc")
Dim ImgRequired As Literal = e.Row.FCLiteral("ImgRequired")
Dim txtFechaLimite As TextBox = e.Row.FCTextBox("TxtFechaLimite")
@@ -7204,11 +7224,13 @@ Partial Class Clientes
End If
If documentacionFormato = "" Then
'ImgDownLoadFormato.Visible = False
ImgDownLoadFormato.Visible = False
LnkDownLoadDoc.Visible = False
Else
Dim linkDescarga = "/Empresas/" & UsuarioActual.Empresa.CveEmpresa & "/Formatos/" & CveDocumentacion & "" & documentacionFormato
LnkDownLoadDoc.Visible = True
Else
LnkDownLoadDoc.Visible = True
ScriptManager.GetCurrent(Me).RegisterPostBackControl(ImgDownLoadFormato)
End If
txtFechaLimite.Text = e.Row.DBCampo("FechaLimite").ToString().ToDate().ToString("dd/MM/yyyy")
@@ -7221,6 +7243,7 @@ Partial Class Clientes
LnkDownLoadDoc.Visible = True
ScriptManager.GetCurrent(Me).RegisterPostBackControl(LnkDownLoadDoc)
'If extencion.Length > 0 Then
' ImgDownLoad.Text = String.Format(" <a class='btn btn-circle btn-sm blue' href='{0}' target='_black' download='{1}'><i class='fa fa-download' title='Descargar documento'></i></a>", linkDescarga, CveCliente & Documentacion & "." & extencion)
'Else
@@ -7261,6 +7284,7 @@ Partial Class Clientes
Dim PathRoot As String = Server.MapPath("/")
Dim PathSource As String
Dim pathDesti As String
Dim fname As String = ""
PathSource = UsuarioActual.Empresa.Ruta & "Formatos\" & documento
pathDesti = PathRoot & "Temp\" & CveCliente & documento
@@ -7269,26 +7293,46 @@ Partial Class Clientes
File.Delete(pathDesti)
End If
File.Copy(PathSource, pathDesti)
Dim objDoc As New clsGemBoxDocument(pathDesti)
Dim objRH As New ClsRH
Dim FechaActual As String = Now.Day.ToString("0#") & " de " & CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(1).ToString() & " del " & Now.Year.ToString()
objDoc.SustituirTags(objRH.GetDatosTagsDocumentos(-1, UsuarioActual.CveEmpresa)) ' Pendiente
objRH.Dispose()
objDoc.Guardar(pathDesti)
File.Copy(PathSource, pathDesti)
Dim fileinfo As New FileInfo(pathDesti)
fname = fileinfo.Name
Dim baseUrl As String = Request.Url.GetLeftPart(UriPartial.Authority)
baseUrl = baseUrl & "/temp/" & fileinfo.Name
RegistraDescargaJavaScript(baseUrl)
If fileinfo.Extension.ToUpper = ".XLS" Or fileinfo.Extension.ToUpper = ".XLSX" Then
Try
Dim objDoc As New clsGemBoxDocument(pathDesti)
Dim objRH As New ClsRH
Dim FechaActual As String = Now.Day.ToString("0#") & " de " & CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(1).ToString() & " del " & Now.Year.ToString()
objDoc.SustituirTags(objRH.GetDatosTagsDocumentos(-1, UsuarioActual.CveEmpresa)) ' Pendiente
objRH.Dispose()
objDoc.Guardar(pathDesti)
Catch ex As Exception
End Try
End If
Dim FileD = New FileInfo(pathDesti)
If FileD.Exists Then
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" + FileD.Name)
Response.AddHeader("Content-Length", FileD.Length.ToString())
Response.ContentType = "text/octet-stream"
Response.Flush()
Response.TransmitFile(FileD.FullName)
Response.End()
End If
End Sub