Documnetación
This commit is contained in:
380
Compras/RepDocumentacionProveedor.aspx.vb
Normal file
380
Compras/RepDocumentacionProveedor.aspx.vb
Normal file
@@ -0,0 +1,380 @@
|
||||
Option Strict On
|
||||
|
||||
|
||||
Imports System.Data
|
||||
Imports System.IO
|
||||
Imports Extensiones
|
||||
Imports GemBox.Spreadsheet
|
||||
|
||||
|
||||
|
||||
|
||||
Partial Class Proveedores_RepDocumentacionProveedor
|
||||
Inherits ClsPaginas
|
||||
|
||||
Private Property DTDatos As DataTable
|
||||
Get
|
||||
If ViewState("DTDatos") Is Nothing Then
|
||||
Return New DataTable
|
||||
Else
|
||||
Return DirectCast(ViewState("DTDatos"), DataTable)
|
||||
End If
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DTDatos") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Private Property DTHeaders As DataTable
|
||||
Get
|
||||
If ViewState("DTHeaders") Is Nothing Then
|
||||
Return New DataTable
|
||||
Else
|
||||
Return DirectCast(ViewState("DTHeaders"), DataTable)
|
||||
End If
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DTHeaders") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Private Sub Proveedores_RepDocumentacionProveedor_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not Page.IsPostBack Then
|
||||
CargaCombos()
|
||||
|
||||
'TxtFechaI.Text = Now.AddMonths(-3).ToString("dd/MM/yyyy")
|
||||
'TxtFechaF.Text = Now.ToString("dd/MM/yyyy")
|
||||
|
||||
TxtFechaI.Text = ""
|
||||
TxtFechaF.Text = ""
|
||||
|
||||
LnkDescargarExcel.Visible = False
|
||||
End If
|
||||
'ExportaExcel()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaCombos()
|
||||
|
||||
|
||||
DdlProveedores.setEsWebService(True)
|
||||
DdlProveedores.Attributes.Add("data-metodo", "getproveedores")
|
||||
DdlProveedores.SelectedText = "Todos"
|
||||
DdlProveedores.SelectedValue = "-1"
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Protected Sub btConsultar_Click(sender As Object, e As EventArgs) Handles btConsultar.Click
|
||||
CargaDocumentacion()
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub CargaDocumentacion()
|
||||
|
||||
Dim CveProveedor As Integer = -1
|
||||
|
||||
Dim FechaInicio As Date
|
||||
Dim FechaFin As Date
|
||||
|
||||
If TxtFechaI.Text = "" Then
|
||||
FechaInicio = MinFecha
|
||||
Else
|
||||
FechaInicio = TxtFechaI.Text.ToDate
|
||||
End If
|
||||
|
||||
If TxtFechaF.Text = "" Then
|
||||
FechaFin = MaxFecha
|
||||
Else
|
||||
FechaFin = TxtFechaF.Text.ToDate
|
||||
End If
|
||||
|
||||
If DdlProveedores.txtValue.Value.ToEntero > 0 Then
|
||||
CveProveedor = DdlProveedores.txtValue.Value.ToEntero
|
||||
End If
|
||||
|
||||
Dim obEDoc As New ClsEdocumentacion
|
||||
|
||||
If obEDoc.DocumentacionElectronicaAuditoriaGet(CveProveedor, TxtFechaI.Text.ToDate, TxtFechaF.Text.ToDate, UsuarioActual.CveEmpresa, 3, DdlEstatus.SelectedValue.ToEntero) Then
|
||||
GvDocumentos.DataSource = obEDoc.DtResultados
|
||||
Else
|
||||
GvDocumentos.DataSource = Nothing
|
||||
End If
|
||||
|
||||
obEDoc.Dispose()
|
||||
|
||||
GvDocumentos.DataBind()
|
||||
UPGvDocumentos.Update()
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Protected Sub GvDocumentos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDocumentos.RowDataBound
|
||||
|
||||
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
|
||||
Dim Adjunto As String = e.Row.DBCampo("Adjunto").ToString
|
||||
Dim ImgDownLoad As Literal = e.Row.FCLiteral("ImgDownLoad")
|
||||
Dim ImgRequired As Literal = e.Row.FCLiteral("ImgRequired")
|
||||
Dim txtFechaLimite As TextBox = e.Row.FCTextBox("TxtFechaLimite")
|
||||
Dim txtFechaVigencia As TextBox = e.Row.FCTextBox("TxtFechaVigencia")
|
||||
Dim Documentacion As String = e.Row.DataKey("Documentacion")
|
||||
|
||||
Dim ImgRechazar As LinkButton = e.Row.FCLinkButton("ImgRechazar")
|
||||
|
||||
Dim ImgAceptar As LinkButton = e.Row.FCLinkButton("ImgAceptar")
|
||||
|
||||
Dim requerido As Boolean = Boolean.Parse(e.Row.DBCampo("Requerido"))
|
||||
'Dim chkEstatus As CheckBox = e.Row.FCCheckBox("chkEstatus")
|
||||
'Dim RDBAcptar As RadioButton = e.Row.FCRadioButton("RDBAcptar")
|
||||
'Dim RDBRechazar As RadioButton = e.Row.FCRadioButton("RDBRechazar")
|
||||
|
||||
Dim separado As Char() = ".".ToCharArray
|
||||
Dim array() As String = Adjunto.Split(separado)
|
||||
Dim extencion As String = ""
|
||||
|
||||
Dim DiasLimite As Integer = e.Row.DataKey("DiasLimite").ToString.ToEntero
|
||||
Dim AplicaDiasLimite As Boolean = If(e.Row.DataKey("AplicaDiasLimite").ToString = "1", True, False)
|
||||
Dim AplicaFechaVencimiento As Boolean = If(e.Row.DataKey("AplicaFechaVencimiento").ToString = "1", True, False)
|
||||
|
||||
txtFechaLimite.Visible = If(AplicaDiasLimite, True, False)
|
||||
txtFechaVigencia.Visible = If(AplicaFechaVencimiento, True, False)
|
||||
|
||||
|
||||
|
||||
If e.Row.DBCampo("FechaVigencia").ToString.Length > 0 Then
|
||||
txtFechaVigencia.Text = e.Row.DBCampo("FechaVigencia").ToString.ToDate.ToString("dd/MM/yyyy")
|
||||
If DateTime.Today > e.Row.DBCampo("FechaVigencia").ToString.ToDateTime Then
|
||||
txtFechaVigencia.ForeColor = Drawing.Color.Red
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
If array.Length > 0 Then
|
||||
extencion = array(array.Length - 1)
|
||||
End If
|
||||
|
||||
'If e.Row.DBCampo("Estatus").ToString.ToEntero = 3 Then
|
||||
' RDBAcptar.Checked = True
|
||||
'Else
|
||||
' chkEstatus.Checked = False
|
||||
'End If
|
||||
|
||||
txtFechaLimite.Text = e.Row.DBCampo("FechaLimite").ToString.ToDate.ToString("dd/MM/yyyy")
|
||||
|
||||
If e.Row.DBCampo("FechaVigencia").ToString.Length > 0 Then
|
||||
txtFechaVigencia.Text = e.Row.DBCampo("FechaVigencia").ToString.ToDate.ToString("dd/MM/yyyy")
|
||||
End If
|
||||
|
||||
Dim scripMascara = "$('#" & txtFechaLimite.ClientID & "').mask('00/00/0000');$('#" & txtFechaVigencia.ClientID & "').mask('00/00/0000');"
|
||||
RegistraScript(scripMascara, "scriptMascara")
|
||||
|
||||
If Adjunto.Trim.Length > 0 Then
|
||||
|
||||
Dim linkDescarga = "/Empresas/" & UsuarioActual.Empresa.CveEmpresa & "/Edoc/Proveedor/" & e.Row.DataKey("CveProveedor") & "/" & Adjunto
|
||||
Dim linkDescargaArchivo = UsuarioActual.Empresa.Ruta & "Edoc/Proveedor/" & e.Row.DataKey("CveProveedor") & "/" & Adjunto
|
||||
|
||||
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 documento'></i></a>", linkDescarga, Documentacion & "." & extencion)
|
||||
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 documento'></i></a>", linkDescarga, Documentacion)
|
||||
End If
|
||||
|
||||
|
||||
If e.Row.DBCampo("Estatus").ToString.ToEntero.Contiene(2, 3) Then
|
||||
ImgRechazar.Visible = True
|
||||
End If
|
||||
|
||||
|
||||
If e.Row.DBCampo("Estatus").ToString.ToEntero.Contiene(2) Then
|
||||
ImgAceptar.Visible = True
|
||||
End If
|
||||
|
||||
'If e.Row.DBCampo("Estatus").ToString.ToEntero.Contiene(3) Then
|
||||
' chkEstatus.Checked = True
|
||||
'End If
|
||||
|
||||
Else
|
||||
ImgDownLoad.Visible = False
|
||||
End If
|
||||
|
||||
Else
|
||||
ImgDownLoad.Visible = False
|
||||
End If
|
||||
|
||||
If requerido Then
|
||||
ImgRequired.Text = " <a class='btn btn-circle btn-sm yelow' href='#' data-toggle='tooltip' title=' Requerido!' ><i class='fa fa-asterisk '></i></a>"
|
||||
End If
|
||||
|
||||
'chkEstatus.Checked = ImgDownLoad.Visible
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Sub ImgRechazar_Click(sender As Object, e As EventArgs)
|
||||
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
|
||||
Dim Obsebaciones As String = GvRow.FCTextBox("TxtObservaciones").Text
|
||||
If Obsebaciones.Trim.Length = 0 Then
|
||||
Alert("Debe de proporcionar una obserbación o motivo de rechazo.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim Correo As String = GvRow.DataKey("ContactoMail")
|
||||
Dim Documentacion As String = GvRow.DataKey("Documentacion")
|
||||
Dim Obserbaciones As String = GvRow.FCTextBox("TxtObservaciones").Text
|
||||
|
||||
Dim Adjunto As String = GvRow.DataKey("Adjunto")
|
||||
Dim CveProveedor As Integer = GvRow.DataKey("CveProveedor").ToEntero
|
||||
Dim Archivo As String = UsuarioActual.Empresa.Ruta & $"Edoc\Proveedor\{CveProveedor}\{Adjunto}"
|
||||
|
||||
|
||||
Dim objEdoc As New ClsEdocumentacion
|
||||
Dim ErrorProceso As Boolean = False
|
||||
|
||||
objEdoc.IniciaTransacSQL()
|
||||
|
||||
If objEdoc.DocumentacionElectronicaUpdate(GvRow.DataKey("CveDocumentacionElectronica").ToEntero, GvRow.DataKey("CveDocumentacion").ToEntero, -1, -1, GvRow.DataKey("CveProveedor").ToEntero, 1,
|
||||
If(Obsebaciones.Trim.Length > 0, Obsebaciones, GvRow.DataKey("Observacion")), "-1",
|
||||
UsuarioActual.CveUsuario, GvRow.DataKey("FechaLimite").ToDate, GvRow.DataKey("FechaVigencia").ToDate) Then
|
||||
|
||||
Try
|
||||
File.Delete(Archivo)
|
||||
Catch ex As Exception
|
||||
ErrorProceso = True
|
||||
End Try
|
||||
|
||||
If Not ErrorProceso Then
|
||||
|
||||
Dim Cuerpo As String = $"<p>Por medio del presente correo se le notifica que el documento <b>{Documentacion}</b> ha sido rechazado por la siguiente causa: <b>{Obserbaciones}</b> por favor ingrese nuevamente al portal y agréguelo nuevamente. </p>
|
||||
<p>Atentamente:</p>
|
||||
<p>Saludos.</p>"
|
||||
|
||||
If Not MandaCorreo(Correo, $"{ UsuarioActual.Empresa.Empresa } documento Rechazado", Cuerpo) Then
|
||||
ErrorProceso = True
|
||||
End If
|
||||
|
||||
Alert($"El documento {GvRow.DataKey("Documentacion") } fue rechazado.")
|
||||
|
||||
End If
|
||||
|
||||
|
||||
Else
|
||||
ErrorProceso = True
|
||||
End If
|
||||
|
||||
If ErrorProceso Then
|
||||
objEdoc.RollBack()
|
||||
Else
|
||||
objEdoc.Commit()
|
||||
End If
|
||||
|
||||
objEdoc.Dispose()
|
||||
|
||||
CargaDocumentacion()
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub ImgAceptar_Click(sender As Object, e As EventArgs)
|
||||
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
|
||||
Dim objEdoc As New ClsEdocumentacion
|
||||
|
||||
If objEdoc.DocumentacionElectronicaUpdate(GvRow.DataKey("CveDocumentacionElectronica").ToEntero, GvRow.DataKey("CveDocumentacion").ToEntero, -1, -1, GvRow.DataKey("CveProveedor").ToEntero, 3,
|
||||
"", "-1", UsuarioActual.CveUsuario, GvRow.DataKey("FechaLimite").ToDate, GvRow.DataKey("FechaVigencia").ToDate) Then
|
||||
Alert("Dcumento Aceptado.")
|
||||
End If
|
||||
|
||||
|
||||
objEdoc.Dispose()
|
||||
|
||||
CargaDocumentacion()
|
||||
End Sub
|
||||
|
||||
Private Function MandaCorreo(Para As String, Asunto As String, Body As String) As Boolean
|
||||
Dim Respuesta As Boolean = False
|
||||
|
||||
Dim Mail As New ClsSisMail()
|
||||
|
||||
Para = If(Para IsNot Nothing, Para, "")
|
||||
Asunto = If(Asunto IsNot Nothing, Asunto, "")
|
||||
Body = If(Body IsNot Nothing, Body, "")
|
||||
|
||||
Dim ListaArchivos As New List(Of ClsSisMail.ArchivoMail)
|
||||
|
||||
If Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, Archivos:=ListaArchivos) Then
|
||||
Respuesta = True
|
||||
End If
|
||||
|
||||
Return Respuesta
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
'Protected Sub BrnProcesar_Click(sender As Object, e As EventArgs)
|
||||
|
||||
' Dim objEdoc As New ClsEdocumentacion
|
||||
' objEdoc.IniciaTransacSQL()
|
||||
|
||||
' Dim ErrorProceso As Boolean = False
|
||||
|
||||
' For Each GvRow As GridViewRow In GvDocumentos.Rows
|
||||
|
||||
' Dim RDBAcptar As RadioButton = GvRow.FCRadioButton("RDBAcptar")
|
||||
' Dim RDBRechazar As RadioButton = GvRow.FCRadioButton("RDBRechazar")
|
||||
' Dim ContactoMail As String = GvRow.DataKey("ContactoMail")
|
||||
|
||||
' If RDBAcptar.Checked Or RDBRechazar.Checked Then
|
||||
|
||||
' Dim Estatus As Integer = If(RDBAcptar.Checked, 3, 1)
|
||||
' Dim Obsebaciones As String = If(RDBAcptar.Checked, "", GvRow.FCTextBox("TxtObservaciones").Text)
|
||||
|
||||
|
||||
|
||||
' If Not objEdoc.DocumentacionElectronicaUpdate(GvRow.DataKey("CveDocumentacionElectronica").ToEntero, GvRow.DataKey("CveDocumentacion").ToEntero, -1, -1, GvRow.DataKey("CveProveedor").ToEntero, Estatus,
|
||||
' If(Obsebaciones.Trim.Length > 0, Obsebaciones, GvRow.DataKey("Observacion")), "-1", UsuarioActual.CveUsuario, GvRow.DataKey("FechaLimite").ToDate,
|
||||
' GvRow.DataKey("FechaVigencia").ToDate) Then
|
||||
' ErrorProceso = True
|
||||
' Exit For
|
||||
' Else
|
||||
|
||||
' If Estatus = 1 Then
|
||||
' 'Enviar correo rechazo con obserbación
|
||||
' End If
|
||||
' End If
|
||||
|
||||
' Else
|
||||
' 'Enviar correo archivo pediente
|
||||
' End If
|
||||
|
||||
' Next
|
||||
|
||||
' If ErrorProceso Then
|
||||
' objEdoc.RollBack()
|
||||
' Else
|
||||
' objEdoc.Commit()
|
||||
' Alert("Proceso Terminado correctamente.")
|
||||
' End If
|
||||
|
||||
' objEdoc.Dispose()
|
||||
|
||||
|
||||
'End Sub
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user