SMS - Cargar Documento al registrar material en OS

This commit is contained in:
rakcsle
2024-04-20 13:35:26 -07:00
parent 378b6f6890
commit ba613e02d8
2 changed files with 143 additions and 64 deletions

View File

@@ -4,6 +4,7 @@ Option Strict On
Imports Extensiones
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Partial Class OS_OrdenesServicios
Inherits ClsPaginas
@@ -1608,21 +1609,7 @@ Partial Class OS_OrdenesServicios
End If
Return Mostrar
End Function
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
Protected Sub BtnPSEspecificaciones_Click(sender As Object, e As EventArgs) Handles BtnPSEspecificaciones.Click
Dim Especificaciones As String = ""
Dim Mostrar As String = ""
@@ -1817,17 +1804,17 @@ Partial Class OS_OrdenesServicios
#End Region
#Region "E V E N T O - B I T A C O R A"
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 = 200
e.Row.Cells(1).Width = 200
e.Row.Cells(2).Width = 100
e.Row.Cells(3).Width = 500
End If
e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Left
End If
End Sub
'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 = 200
' e.Row.Cells(1).Width = 200
' e.Row.Cells(2).Width = 100
' e.Row.Cells(3).Width = 500
' End If
' e.Row.Cells(2).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
@@ -3068,6 +3055,8 @@ Partial Class OS_OrdenesServicios
Protected Sub LnkModalMaterialUtilizado_Click(sender As Object, e As EventArgs)
Dim ProcesoOK As Boolean = True
If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then
If TxtPacienteModal.Text.Trim.Length = 0 Then
Alert("Debe de proporcionar el paciente.", TipoMensaje.MsgAdvertencia)
@@ -3104,7 +3093,7 @@ Partial Class OS_OrdenesServicios
End If
End If
Dim ProcesoOK As Boolean = True
Dim ObjV As New ClsVentas
Dim ObjOS As New ClsOS(ObjV.IniciaTransacSQL())
Dim ObjInventario As New ClsInventarios(ObjV.IniciaTransacSQL())
@@ -3308,6 +3297,10 @@ Partial Class OS_OrdenesServicios
End If
End If
If ProcesoOK Then
ProcesoOK = GuardarArchivoConfirmacion(ObjV.IniciaTransacSQL, CveOS)
End If
If ProcesoOK Then
ObjV.Commit()
@@ -3323,6 +3316,7 @@ Partial Class OS_OrdenesServicios
End If
RegistraScript("$('#DivModalMaterialUtilizado').modal('hide');")
CargaEventoBitacora()
Else
ObjV.RollBack()
Alert("Se presento un error al guardar el material", TipoMensaje.MsgAdvertencia)
@@ -3332,6 +3326,48 @@ Partial Class OS_OrdenesServicios
End Sub
Private Function GuardarArchivoConfirmacion(ByRef transaccion As SqlTransaction, CveOSActual As Integer) As Boolean
Dim respuesta As Boolean = False
Dim ObjEventoBitacora As New ClsOIEventos(transaccion)
Dim FileExtension As String = "-1"
Dim Filesgral As List(Of Archivo) = AnexoManerialUtilizado.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 Filename = String.Empty Then
respuesta = True
Else
If ObjEventoBitacora.AddEventoBitacora("Documento de Confirmación", String.Format(".{0}", FileExtension), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveOS:=CveOSActual) Then
If Filename <> "" Then
Try
Filename.FilesMove(String.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString), String.Format("{0}OI", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
respuesta = True
Catch ex As Exception
Alert("Error al mover archivo de confirmación", TipoMensaje.MsgAdvertencia)
respuesta = False
End Try
End If
AnexoManerialUtilizado.Text = "[]"
End If
End If
Return respuesta
End Function
Private Function GeneraRemision(CveVentaPedido As Integer, ByRef TransaccionSQL As SqlClient.SqlTransaction) As RespuestaFacturacion
Dim Respuesta As New RespuestaFacturacion()
@@ -3428,4 +3464,40 @@ Partial Class OS_OrdenesServicios
ObjOs.Dispose()
End Sub
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 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 Class