--activar carga de documento en Roles

This commit is contained in:
2024-09-24 19:31:10 -07:00
parent 8a7c15f85b
commit d90a86351f
5 changed files with 258 additions and 62 deletions

View File

@@ -1,5 +1,7 @@
Imports System.Data
Imports System.Drawing
Imports DocumentFormat.OpenXml.Drawing.Diagrams
Imports System.IO
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Partial Class Sistemas_RolesDetalle
@@ -43,6 +45,11 @@ Partial Class Sistemas_RolesDetalle
TxtFecha.Text = DTRoles.FiltroPrimeroValor("FechaIng").ToDate.ToShortDateString
TxtUsuarioAlta.Text = DTRoles.FiltroPrimeroValor("Nombre")
DdlModulo.SelectedValueExist(DTRoles.FiltroPrimeroValor("CveModulo").ToEntero)
If UsuarioActual.Empresa.Funcionalidad(382) = "1" OrElse UsuarioActual.CveRol = 1 Then
CargaAdjunto(DTRoles.FiltroPrimeroValor("Adjunto"))
End If
Else
Dim Liga As String = $"document.location.href=""/Sistemas/CatRoles.aspx"";"
Alert("El Rol solicitado no existe.", TipoMensaje.MsgAdvertencia, Liga)
@@ -59,6 +66,18 @@ Partial Class Sistemas_RolesDetalle
End Sub
Private Sub CargaAdjunto(Adjunto As String)
DivManual.Visible = True
If Adjunto <> "" Then
BtnArchivoAdjunto.Text = Adjunto
BtnArchivoAdjunto.Visible = True
BtnAdjuntar.Visible = False
BtnReemplazarAdjunto.Visible = True
Else
BtnAdjuntar.Visible = True
End If
End Sub
Private Sub CargaUsuarios()
If CveRol > 0 Then
@@ -253,5 +272,57 @@ Partial Class Sistemas_RolesDetalle
GlobalDTRoles(UsuarioActual.CveEmpresa) = Nothing
End Sub
Private Sub GuardarArchivoAdjunto()
If Not txtAdjuntar.getfiles().Archivos.Count > 0 Then
Alert("Tiene que cargar un archivo.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim FileExtension As String = "-1"
Dim Filesgral As List(Of Archivo) = txtAdjuntar.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}", Me.CveRol, FileExtension)
Dim Path As String
Path = String.Format("{0}Roles", 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
If Me.CveRol > 0 Then
Using ObjRol As New ClsSisRoles
If ObjRol.UpdateRolAdjunto(Me.CveRol, Adjunto, UsuarioActual.CveEmpresa) Then
Alert("Documento cargado", TipoMensaje.MsgInformacion)
End If
End Using
Else
Alert("Documento cargado", TipoMensaje.MsgInformacion)
End If
End If
BtnAdjuntar.Visible = False
BtnArchivoAdjunto.Text = Adjunto
BtnArchivoAdjunto.Visible = True
BtnReemplazarAdjunto.Visible = True
Catch ex As Exception
OnError("Error al cargar archivo", ex)
End Try
End Sub
Protected Sub btnGuardarAdjunto_Click(sender As Object, e As EventArgs)
GuardarArchivoAdjunto()
End Sub
End Class