460 lines
15 KiB
VB.net
460 lines
15 KiB
VB.net
|
|
|
|
Imports System.Data
|
|
Imports System.Linq
|
|
Imports Extensiones
|
|
Imports System.IO
|
|
|
|
Partial Class Vta_CatDocumentosClientes
|
|
Inherits ClsPaginas
|
|
|
|
Private Property DTDocumentacion As DataTable
|
|
Get
|
|
If ViewState("DTDocumentacion") Is Nothing Then
|
|
Return New DataTable
|
|
Else
|
|
Return DirectCast(ViewState("DTDocumentacion"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTDocumentacion") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Property Documentacion As String
|
|
Get
|
|
If ViewState("Documentacion") Is Nothing Then
|
|
Return "-1"
|
|
Else
|
|
Return ViewState("Documentacion").ToString
|
|
End If
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Documentacion") = value
|
|
End Set
|
|
End Property
|
|
Property CveDocumentacion As Integer
|
|
Get
|
|
If ViewState("CveDocumentacion") Is Nothing Then
|
|
Return -1
|
|
Else
|
|
Return DirectCast(ViewState("CveDocumentacion"), Integer)
|
|
End If
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveDocumentacion") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property DocumentacionTipo As String
|
|
Get
|
|
If ViewState("DocumentacionTipo") Is Nothing Then
|
|
Return ""
|
|
Else
|
|
Return ViewState("DocumentacionTipo").ToString
|
|
End If
|
|
End Get
|
|
Set(value As String)
|
|
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property CveDocumentacionTipo As Integer
|
|
Get
|
|
If ViewState("CveDocumentacionTipo") Is Nothing Then
|
|
Return -1
|
|
Else
|
|
Return DirectCast(ViewState("CveDocumentacionTipo"), Integer)
|
|
End If
|
|
End Get
|
|
|
|
Set(value As Integer)
|
|
ViewState("CveDocumentacionTipo") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Property ActualizarDocumentacion As Boolean
|
|
Get
|
|
If ViewState("ActualizarDocumentacion") Is Nothing Then
|
|
Return True
|
|
Else
|
|
Return DirectCast(ViewState("ActualizarDocumentacion"), Boolean)
|
|
End If
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("ActualizarDocumentacion") = value
|
|
End Set
|
|
End Property
|
|
|
|
Property Estatus As Boolean
|
|
Get
|
|
If ViewState("Estatus") Is Nothing Then
|
|
Return False
|
|
Else
|
|
Return DirectCast(ViewState("Estatus"), Boolean)
|
|
End If
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("Estatus") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Property DocumentacionFormato As String
|
|
Get
|
|
If ViewState("DocumentacionFormato") Is Nothing Then
|
|
Return ""
|
|
Else
|
|
Return ViewState("DocumentacionFormato").ToString
|
|
End If
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("DocumentacionFormato") = value
|
|
End Set
|
|
End Property
|
|
|
|
Property Requerido As Boolean
|
|
Get
|
|
If ViewState("Requerido") Is Nothing Then
|
|
Return True
|
|
Else
|
|
Return DirectCast(ViewState("Requerido"), Boolean)
|
|
End If
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("Requerido") = value
|
|
End Set
|
|
End Property
|
|
|
|
Property DiasLimite As Integer
|
|
Get
|
|
If ViewState("DiasLimite") Is Nothing Then
|
|
Return 1
|
|
Else
|
|
Return DirectCast(ViewState("DiasLimite"), Integer)
|
|
End If
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("DiasLimite") = value
|
|
End Set
|
|
End Property
|
|
Property AplicaDiasLimite As Boolean
|
|
Get
|
|
If ViewState("AplicaDiasLimite") Is Nothing Then
|
|
Return True
|
|
Else
|
|
Return DirectCast(ViewState("AplicaDiasLimite"), Boolean)
|
|
End If
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("AplicaDiasLimite") = value
|
|
End Set
|
|
End Property
|
|
Property AplicaFechaVencimiento As Boolean
|
|
Get
|
|
If ViewState("AplicaFechaVencimiento") Is Nothing Then
|
|
Return True
|
|
Else
|
|
Return DirectCast(ViewState("AplicaFechaVencimiento"), Boolean)
|
|
End If
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("AplicaFechaVencimiento") = value
|
|
End Set
|
|
End Property
|
|
|
|
Property Orden As Integer
|
|
Get
|
|
If ViewState("Orden") Is Nothing Then
|
|
Return -1
|
|
Else
|
|
Return DirectCast(ViewState("Orden"), Integer)
|
|
End If
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("Orden") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
CargaDocumentacion()
|
|
CargaComboDocumentacion()
|
|
|
|
|
|
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#Region "D O C U M E N T A C I O N"
|
|
|
|
Protected Sub BtnAgregarDocumento_Click(sender As Object, e As EventArgs) Handles BtnAgregarDocumento.Click
|
|
ResetFormDocumentacion()
|
|
RegistraScript("$('#divAgregarDocumentacion').modal({ backdrop: 'static', keyboard: false});")
|
|
End Sub
|
|
|
|
Private Sub ResetFormDocumentacion()
|
|
|
|
|
|
Txtdocumentacion.Text = ""
|
|
TxtOrden.Text = ""
|
|
BtnAgregarDocumentoModal.Text = "Agregar"
|
|
LtlTituloModalDocumentacion.Text = "Agregar documentación"
|
|
'TxtDocumentacionFormato.Text = ""
|
|
DdlDocumentacionTipo.SelectedIndex = 0
|
|
chkEstatus.Checked = True
|
|
chkRequerido.Checked = True
|
|
|
|
TxtDiasLimite.Text = ""
|
|
ChkAplicaDiasLimite.Checked = False
|
|
ChkAplicaFechaVencimiento.Checked = False
|
|
|
|
|
|
ActualizarDocumentacion = False
|
|
UpModalDocumentacion.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaDocumentacion()
|
|
|
|
Dim objRH As New ClsEdocumentacion
|
|
|
|
If objRH.DocumentacionGet(-1, -1, -1, UsuarioActual.Empresa.CveEmpresa, Modulo:=2) Then
|
|
|
|
DTDocumentacion = objRH.DtResultados
|
|
GvDocumentos.DataSource = objRH.DtResultados
|
|
Else
|
|
DTDocumentacion = Nothing
|
|
GvDocumentos.DataSource = Nothing
|
|
End If
|
|
|
|
objRH.Dispose()
|
|
GvDocumentos.DataBind()
|
|
UPGvDocumentos.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaComboDocumentacion()
|
|
Dim objDocumentacion As New ClsEdocumentacion
|
|
|
|
If objDocumentacion.DocumentacionTipoGet(UsuarioActual.CveEmpresa, Modulo:=2) Then
|
|
|
|
DdlDocumentacionTipo.DataSource = objDocumentacion.DtResultados
|
|
|
|
End If
|
|
|
|
objDocumentacion.Dispose()
|
|
DdlDocumentacionTipo.DataBind()
|
|
DdlDocumentacionTipo.Items.Insert(0, New ListItem("Seleccione un tipo", "-1"))
|
|
End Sub
|
|
|
|
Public Sub Edit_ClickDocumentacion(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
CveDocumentacion = GvRow.DataKey("CveDocumentacion").ToEntero
|
|
Documentacion = GvRow.DataKey("Documentacion")
|
|
DocumentacionFormato = GvRow.DataKey("DocumentacionFormato")
|
|
CveDocumentacionTipo = GvRow.DataKey("CveDocumentacionTipo").ToEntero
|
|
DocumentacionTipo = GvRow.DataKey("DocumentacionTipo")
|
|
Orden = GvRow.DataKey("Orden").ToEntero
|
|
Estatus = GvRow.DataKey("Estatus") = "True"
|
|
Requerido = GvRow.DataKey("Requerido") = "True"
|
|
|
|
DiasLimite = GvRow.DataKey("DiasLimite").ToEntero
|
|
AplicaDiasLimite = If(GvRow.DataKey("AplicaDiasLimite").ToEntero = 1, True, False)
|
|
AplicaFechaVencimiento = If(GvRow.DataKey("AplicaFechaVencimiento").ToEntero = 1, True, False)
|
|
|
|
Txtdocumentacion.Text = Documentacion
|
|
TxtOrden.Text = Orden.ToString
|
|
DdlDocumentacionTipo.SelectedValueExist(CveDocumentacionTipo)
|
|
chkEstatus.Checked = Estatus
|
|
chkRequerido.Checked = Requerido
|
|
|
|
TxtDiasLimite.Text = DiasLimite.ToString
|
|
ChkAplicaDiasLimite.Checked = AplicaDiasLimite
|
|
ChkAplicaFechaVencimiento.Checked = AplicaFechaVencimiento
|
|
|
|
LtlTituloModalDocumentacion.Text = "Actualizar Documento: " & Documentacion
|
|
BtnAgregarDocumentoModal.Text = "Actualizar"
|
|
|
|
UpModalDocumentacion.Update()
|
|
ActualizarDocumentacion = True
|
|
|
|
RegistraScript("$('#divAgregarDocumentacion').modal({ backdrop: 'static', keyboard: false});")
|
|
|
|
End Sub
|
|
|
|
Private Function GuardarArchivo(_CveDocumentacion As Integer) As String
|
|
|
|
Dim respuesta As String = ""
|
|
|
|
Dim FileExtension As String = "-1"
|
|
Dim Filesgral As List(Of Archivo) = TxtFileDocumentacion.getfiles().Archivos
|
|
Dim Filename As String = ""
|
|
|
|
For Each fileItem As Archivo In Filesgral
|
|
Try
|
|
respuesta = fileItem.filenameO
|
|
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
|
Dim tempArray() As String
|
|
tempArray = fileItem.filename.ToString().Split("-".ToCharArray())
|
|
|
|
Dim rutaDestino As String = UsuarioActual.Empresa.Ruta & "Formatos\" & _CveDocumentacion & "_" & fileItem.filenameO
|
|
Dim docAnterior As String = UsuarioActual.Empresa.Ruta & "Formatos\" & _CveDocumentacion & "_" & DocumentacionFormato
|
|
|
|
If DocumentacionFormato.Trim.Length > 0 Then
|
|
If File.Exists(docAnterior) Then
|
|
File.Delete(docAnterior)
|
|
End If
|
|
End If
|
|
|
|
If Not Directory.Exists(UsuarioActual.Empresa.Ruta & "\Formatos") Then
|
|
Directory.CreateDirectory(UsuarioActual.Empresa.Ruta & "\Formatos")
|
|
|
|
End If
|
|
|
|
If System.IO.File.Exists(rutaDestino) Then
|
|
System.IO.File.Delete(rutaDestino)
|
|
End If
|
|
|
|
System.IO.File.Move(fileItem.FileUrl, rutaDestino)
|
|
|
|
Catch ex As Exception
|
|
OnError("Error al cargar archivo", ex)
|
|
End Try
|
|
TxtFileDocumentacion.Text = ""
|
|
UpModalDocumentacion.Update()
|
|
Next
|
|
|
|
|
|
Return respuesta
|
|
End Function
|
|
|
|
Public Sub Remove_ClickDocumentacion(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
Dim _CveDocumentacion As Integer = GvRow.DataKey("CveDocumentacion").ToEntero
|
|
Dim _documetacionFormato As String = GvRow.DataKey("DocumentacionFormato")
|
|
|
|
|
|
|
|
Dim objEdoc As New ClsEdocumentacion
|
|
|
|
If objEdoc.DocumentacionRemove(_CveDocumentacion, UsuarioActual.Empresa.CveEmpresa) Then
|
|
EliminarDocumentoDisco(_documetacionFormato)
|
|
Alert("Documento eliminado correctamente", TipoMensaje.MsgInformacion)
|
|
CargaDocumentacion()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub EliminarDocumentoDisco(documento As String)
|
|
|
|
Dim archivo As String = UsuarioActual.Empresa.Ruta & "Formatos\" & documento
|
|
|
|
If File.Exists(archivo) Then
|
|
File.Delete(archivo)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub BtnAgregarDocumentoModal_Click(sender As Object, e As EventArgs) Handles BtnAgregarDocumentoModal.Click
|
|
|
|
Dim objRH As New ClsEdocumentacion
|
|
Dim intCompleto As Integer = 0
|
|
Dim _estatus As Integer = 0
|
|
Dim _requerido As Integer = 0
|
|
Dim _formato As String = ""
|
|
|
|
|
|
If chkEstatus.Checked Then
|
|
_estatus = 1
|
|
End If
|
|
|
|
If chkRequerido.Checked Then
|
|
_requerido = 1
|
|
End If
|
|
|
|
If ActualizarDocumentacion Then
|
|
|
|
_formato = GuardarArchivo(CveDocumentacion)
|
|
If objRH.DocumentacionUpdate(CveDocumentacion, Txtdocumentacion.Text.Trim, _formato, DdlDocumentacionTipo.SelectedValue.ToEntero, _estatus, TxtOrden.Text.ToEntero, _requerido, TxtDiasLimite.Text.ToEntero, ChkAplicaDiasLimite.Checked, ChkAplicaFechaVencimiento.Checked, UsuarioActual.CveEmpresa) Then
|
|
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAgregarDocumentacion"))
|
|
Alert("Documento Actualizado correctamente.", TipoMensaje.MsgInformacion)
|
|
|
|
End If
|
|
|
|
Else
|
|
If objRH.DocumentacionAdd(Txtdocumentacion.Text.Trim, _formato, DdlDocumentacionTipo.SelectedValue.ToEntero, _estatus, TxtOrden.Text.ToEntero, _requerido, TxtDiasLimite.Text.ToEntero, ChkAplicaDiasLimite.Checked, ChkAplicaFechaVencimiento.Checked, UsuarioActual.CveEmpresa) Then
|
|
|
|
CveDocumentacion = objRH.DtResultados(0)(0).ToString.ToEntero
|
|
_formato = GuardarArchivo(CveDocumentacion)
|
|
If objRH.DocumentacionUpdate(CveDocumentacion, Txtdocumentacion.Text.Trim, _formato, DdlDocumentacionTipo.SelectedValue.ToEntero, _estatus, TxtOrden.Text.ToEntero, _requerido, TxtDiasLimite.Text.ToEntero, ChkAplicaDiasLimite.Checked, ChkAplicaFechaVencimiento.Checked, UsuarioActual.CveEmpresa) Then
|
|
|
|
End If
|
|
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAgregarDocumentacion"))
|
|
Alert("Documento agregado correctamente.", TipoMensaje.MsgInformacion)
|
|
|
|
End If
|
|
End If
|
|
|
|
objRH.Dispose()
|
|
|
|
ActualizarDocumentacion = False
|
|
|
|
CargaDocumentacion()
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub GvDocumentos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDocumentos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
Dim _CveDocumentacion As Integer = e.Row.DBCampo("CveDocumentacion").ToString.ToEntero
|
|
Dim DocumetacionFormato As String = e.Row.DBCampo("DocumentacionFormato").ToString
|
|
Dim ImgDownLoad As Literal = e.Row.FCLiteral("ImgDownLoad")
|
|
Dim separado As Char() = {"."c}
|
|
Dim array() As String = DocumetacionFormato.Split(separado)
|
|
Dim extencion As String = ""
|
|
|
|
If array.Length > 0 Then
|
|
extencion = array(array.Length - 1)
|
|
End If
|
|
|
|
If DocumetacionFormato.Trim.Length > 0 Then
|
|
|
|
Dim linkDescarga = "/Empresas/" & UsuarioActual.Empresa.CveEmpresa & "/Formatos/" & _CveDocumentacion & "_" & DocumetacionFormato
|
|
Dim linkDescargaArchivo = UsuarioActual.Empresa.Ruta & "\Formatos\" & _CveDocumentacion & "_" & DocumetacionFormato
|
|
If File.Exists(linkDescargaArchivo) Then
|
|
ImgDownLoad.Visible = True
|
|
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 Formato'></i></a>", linkDescarga, DocumetacionFormato)
|
|
Else
|
|
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 Formato'></i></a>", linkDescarga, DocumetacionFormato)
|
|
End If
|
|
Else
|
|
ImgDownLoad.Visible = False
|
|
End If
|
|
|
|
Else
|
|
ImgDownLoad.Visible = False
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
End Class
|
|
|