Files
SIG/PortalProveedor/PortalProveedor.aspx.vb
2020-02-18 17:50:58 -07:00

1813 lines
73 KiB
VB.net

Option Explicit On
Option Strict On
Imports System.Data
Imports System.IO
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Partial Class Portal_PortalProveedor
Inherits ClsPaginas
#Region "PROPIEDADES"
Private Property CveProveedor As Integer
Get
Return ViewState("CveProveedor").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveProveedor") = value
End Set
End Property
Private Property DTGvCxPHistorial As DataTable
Get
If ViewState("GvCxPHistorial") Is Nothing Then
Return New DataTable
Else
Return DirectCast(ViewState("GvCxPHistorial"), DataTable)
End If
End Get
Set(value As DataTable)
ViewState("GvCxPHistorial") = value
End Set
End Property
Private Property DTGVHistorial As DataTable
Get
If ViewState("GVHistorial") Is Nothing Then
Return New DataTable
Else
Return DirectCast(ViewState("GVHistorial"), DataTable)
End If
End Get
Set(value As DataTable)
ViewState("GVHistorial") = value
End Set
End Property
Private Property DTCuentasBancos As DataTable
Get
If ViewState("DTCuentasBancos") Is Nothing Then
Return New DataTable
Else
Return DirectCast(ViewState("DTCuentasBancos"), DataTable)
End If
End Get
Set(value As DataTable)
ViewState("DTCuentasBancos") = value
End Set
End Property
Private Property DtBancos As DataTable
Get
If ViewState("DtBancos") Is Nothing Then
Return New DataTable
Else
Return DirectCast(ViewState("DtBancos"), DataTable)
End If
End Get
Set(value As DataTable)
ViewState("DtBancos") = value
End Set
End Property
Private Property DTGvA As DataTable
Get
If ViewState("DTGvA") Is Nothing Then
Return New DataTable
Else
Return DirectCast(ViewState("DTGvA"), DataTable)
End If
End Get
Set(value As DataTable)
ViewState("DTGvA") = value
End Set
End Property
Private Property DTGvAH As DataTable
Get
If ViewState("DTGvAH") Is Nothing Then
Return New DataTable
Else
Return DirectCast(ViewState("DTGvAH"), DataTable)
End If
End Get
Set(value As DataTable)
ViewState("DTGvAH") = value
End Set
End Property
#End Region
#Region " D O C U M E N T A C I O N"
Property CveDocumentacionElectronica As Integer
Get
If ViewState("CvePersonalClienteDocumentacion") Is Nothing Then
Return -1
Else
Return DirectCast(ViewState("CvePersonalClienteDocumentacion"), Integer)
End If
End Get
Set(value As Integer)
ViewState("CvePersonalClienteDocumentacion") = 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
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 AdjuntoDocumentacion As String
Get
If ViewState("AdjuntoDocumentacion") Is Nothing Then
Return ""
Else
Return ViewState("AdjuntoDocumentacion").ToString
End If
End Get
Set(value As String)
ViewState("AdjuntoDocumentacion") = value
End Set
End Property
Property DiasVigencia As Integer
Get
If ViewState("DiasVigencia") Is Nothing Then
Return 0
Else
Return DirectCast(ViewState("DiasVigencia"), Integer)
End If
End Get
Set(value As Integer)
ViewState("DiasVigencia") = 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
Private Property FechaVigencia As Date
Get
If ViewState("FechaVigencia") Is Nothing Then
Return Nothing
Else
Return ViewState("FechaVigencia").ToString.ToDate
End If
End Get
Set(value As Date)
ViewState("FechaVigencia") = value
End Set
End Property
Property Estatus As Integer
Get
If ViewState("Estatus") Is Nothing Then
Return 0
Else
Return DirectCast(ViewState("Estatus"), Integer)
End If
End Get
Set(value As Integer)
ViewState("Estatus") = value
End Set
End Property
Property ObservacionDocumentacion As String
Get
If ViewState("ObservacionDocumentacion") Is Nothing Then
Return ""
Else
Return ViewState("ObservacionDocumentacion").ToString
End If
End Get
Set(value As String)
ViewState("ObservacionDocumentacion") = value
End Set
End Property
Private Property FechaLimite As Date
Get
If ViewState("FechaLimite") Is Nothing Then
Return Date.Now.AddDays(15)
Else
Return ViewState("FechaLimite").ToString.ToDate
End If
End Get
Set(value As Date)
ViewState("FechaLimite") = value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
CveProveedor = UsuarioActual.CveProveedor
Session("FileUpload") = ""
ViewState("Orden") = ""
CargaDatos()
CargaDocumentacion()
'CARGAN PESTANIAS SEGUN PERMISOS
If UsuarioActual.TienePermisoProceso(236) Then ' CARGA TAB HISTORIAL DE VENTAS
TabHistorial.Visible = True
CargaHistorial("-1", 20)
End If
If UsuarioActual.TienePermisoProceso(237) Then ' CARGA TAB CUENTAS X COBRAR
TabCxP.Visible = True
CargaCxP()
End If
If UsuarioActual.TienePermisoProceso(238) Then ' CARGA TAB BANCOS
TabBancos.Visible = True
CargaBancos("", 20)
CargaCuentasBancarias()
End If
If UsuarioActual.TienePermisoProceso(239) Then ' CARGA TAB ANTICIPOS NC
TabAnticipos.Visible = True
CargaAnticipos("-1", 20)
End If
'??ESTE TAB VA DESAPARECER?? - PARA QUE SOLO LA EMPRESA GESTIONE A LOS USUARIOS POR CLIENTE??
If UsuarioActual.TienePermisoProceso(240) Then ' CARGA SISTEMA
TabSistema.Visible = False
' CargaUsuariosPortal()
End If
'CARGA TAB CONTRASENIA PARA TODOS LOS USUARIOS
If UsuarioActual.CvePlataforma = 7 Then TabContraseña.Visible = True
End If
End Sub
#Region "C A R G A - D A T O S"
Protected Sub CargaDatos()
GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimero($"CveProveedor = {CveProveedor}")
Dim ObjProveedor As New ClsCompProveedores()
If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, CveProveedor, "-1", "-1", "-1", "-1", "-1", "-1", "-1", 1, UsuarioActual.CveEmpresa) Then
If ObjProveedor.DtResultados.Rows.Count > 0 Then
'CxP
LtlProveedor.Text = ObjProveedor.RazonSocial
lblLimiteCredito.Text = ObjProveedor.LimiteCredito.ToString
lblPlazoCobranza.Text = ObjProveedor.PlazoPago.ToString
Else
Alert("Ocurrió un error al cargar los datos.", TipoMensaje.MsgError)
End If
End If
ObjProveedor.Dispose()
End Sub
#Region "CARGA GRIDS"
Private Sub CargaHistorial(SerieSucursal As String, SelectTop As Integer)
Dim ObjProveedores As New ClsCompProveedores()
If ObjProveedores.GetHistorialCompras(CveProveedor, -1, -1) Then
If ObjProveedores.DtResultados.Rows.Count > 0 Then
'Carga Generales
LtlCantidad.Text = ObjProveedores.DtResultados.Rows(0)("CountTotal").ToString
LtlTotalVendido.Text = ObjProveedores.DtResultados.Rows(0)("Total").ToString.FormatoNumero(2)
LtlMinima.Text = ObjProveedores.DtResultados.Rows(0)("MIN_Total").ToString.FormatoNumero(2)
LtlPromedio.Text = ObjProveedores.DtResultados.Rows(0)("AVG_Total").ToString.FormatoNumero(2)
LtlMaxima.Text = ObjProveedores.DtResultados.Rows(0)("MAX_Total").ToString.FormatoNumero(2)
'Carga Grid
' GVHistorial.DataSource = ObjProveedores.DtResultados.AsEnumerable().Take(SelectTop).CopyToDataTable
DTGVHistorial = ObjProveedores.DtResultados
GVHistorial.DataSource = DTGVHistorial.AsEnumerable.Take(20).CopyToDataTable
BtnVerMasVentas.Visible = If(ObjProveedores.DtResultados.Rows.Count > 20, True, False)
Else
LtlCantidad.Text = "0.00"
LtlTotalVendido.Text = "0.00"
LtlMinima.Text = "0.00"
LtlPromedio.Text = "0.00"
LtlMaxima.Text = "0.00"
GVHistorial.DataSource = Nothing
End If
Else
GVHistorial.DataSource = Nothing
End If
ObjProveedores.Dispose()
GVHistorial.DataBind()
End Sub
Private Sub CargaCxP()
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetCxPProveedor(CveProveedor, "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1) Then
GvCxP.DataSource = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act'", "Moneda,OrdenVencimiento, FechaVencimiento")
'solo tomo los 10 ultimos mas el totalizador general
Dim dt As DataTable = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act'")
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
' dtt = dtt.FiltraParametros("CveCompra > 0")
'Cargamos el portlet de Resumen de Cuenas por Pagar.
LBRCPVencidoP.Text = String.Format("{0}", dt.SUM("Saldo", "CveMoneda = 1 and DiasVencidos > 0")).FormatoNumero
LBRCPPorVencerP.Text = String.Format("{0}", dt.SUM("Saldo", "CveMoneda = 1 and DiasVencidos <= 0")).FormatoNumero
LBRCPSumaP.Text = String.Format("{0}", dt.SUM("Saldo", "CveMoneda = 1 and CveCompra > 0")).FormatoNumero
LBRCPVencidoD.Text = String.Format("{0}", dt.SUM("Saldo", "CveMoneda = 2 and DiasVencidos > 0")).FormatoNumero
LBRCPPorVencerD.Text = String.Format("{0}", dt.SUM("Saldo", "CveMoneda = 2 and DiasVencidos <= 0")).FormatoNumero
LBRCPSumaD.Text = String.Format("{0}", dt.SUM("Saldo", "CveMoneda = 2 and CveCompra > 0 ")).FormatoNumero
LBRCPTipoCambio.Text = GlobalTipoCambio.ToString.FormatoNumero
LBRCPTotal.Text = (LBRCPSumaP.Text.ToDouble + (LBRCPSumaD.Text.ToDouble * LBRCPTipoCambio.Text.ToDouble)).ToString.FormatoNumero
'= ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Hist'").
DTGvCxPHistorial = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Hist'")
GvCxPHistorial.DataSource = DTGvCxPHistorial.AsEnumerable().Take(11).CopyToDataTable()
End If
Else
DTGvCxPHistorial = Nothing
GvCxP.DataSource = Nothing
GvCxPHistorial.DataSource = Nothing
End If
ObjMovtos.Dispose()
GvCxP.DataBind()
GvCxPHistorial.DataBind()
End Sub
Private Sub CargaAnticipos(SerieSucursal As String, SelectTop As Integer)
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetAnticiposProveedor(CveProveedor, -1, SelectTop:=SelectTop) Then
If ObjMovtos.DtResultados.Rows.Count > 0 Then
Dim dtA, dtAH As DataTable
dtA = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act'")
dtAH = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Hist'")
If dtA IsNot Nothing AndAlso dtA.Rows.Count > 0 Then GvA.DataSource = dtA.AsEnumerable().Take(SelectTop).CopyToDataTable
If dtA IsNot Nothing AndAlso dtA.Rows.Count > 0 Then
DTGvA = dtA.AsEnumerable().Take(SelectTop).CopyToDataTable
End If
If dtAH IsNot Nothing AndAlso dtAH.Rows.Count > 0 Then GvAH.DataSource = dtAH.AsEnumerable.Take(SelectTop).CopyToDataTable
If dtAH IsNot Nothing AndAlso dtAH.Rows.Count > 0 Then
DTGvAH = dtAH.AsEnumerable.Take(SelectTop).CopyToDataTable
End If
End If
BtnVerMasAnticipos.Visible = ObjMovtos.DtResultados.Rows.Count > 20
Else
GvA.DataSource = Nothing
GvAH.DataSource = Nothing
DTGvA = Nothing
DTGvAH = Nothing
End If
ObjMovtos.Dispose()
GvA.DataBind()
GvAH.DataBind()
End Sub
Private Sub CargaBancos(SerieSucursal As String, SelectTop As Integer)
Dim ObjMovtos As New ClsMovimientos()
'CxC Activas
If ObjMovtos.GetProveedorBancos(CveProveedor, CveProveedorSucursal:=-1, SelectTop:=SelectTop) AndAlso ObjMovtos.DtResultados.Rows.Count > 0 Then
GvBancos.DataSource = ObjMovtos.DtResultados
BtnVerMasBancos.Visible = ObjMovtos.DtResultados.Rows.Count > 19
DtBancos = ObjMovtos.DtResultados
Else
DtBancos = Nothing
End If
ObjMovtos.Dispose()
GvBancos.DataBind()
End Sub
Private Sub CargaCuentasBancarias()
Dim ObjCuentasBancos As New ClsGenerales
If ObjCuentasBancos.GetCuentasDepositos(CveProveedor) Then
GvBancosCuentas.DataSource = ObjCuentasBancos.DtResultados
DTCuentasBancos = ObjCuentasBancos.DtResultados
Else
DTCuentasBancos = Nothing
Alert("No se pudieron cargar las cuentas bancarias. Por favor intente nuevamente.", TipoMensaje.MsgAdvertencia)
End If
ObjCuentasBancos.Dispose()
GvBancosCuentas.DataBind()
UpCuentasBancos.Update()
End Sub
#End Region
#Region "ROW DATA BOUND"
Protected Sub GVHistorial_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVHistorial.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowIndex = 0 Then
e.Row.BackColor = Drawing.Color.LightGray
End If
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right
e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right
End If
End Sub
Protected Sub GvAH_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvA.RowDataBound, GvAH.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowIndex = 0 Then
e.Row.BackColor = Drawing.Color.LightGray
e.Row.Cells(0).Width = Unit.Pixel(120)
e.Row.Cells(1).Width = Unit.Pixel(100)
e.Row.Cells(2).Width = Unit.Pixel(100)
e.Row.Cells(3).Width = Unit.Pixel(100)
End If
e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Right
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right
End If
End Sub
Protected Sub GvCxP_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxP.RowDataBound, GvCxPHistorial.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowIndex = 1 Then
e.Row.Cells(0).Width = Unit.Pixel(100)
e.Row.Cells(1).Width = Unit.Pixel(70)
e.Row.Cells(2).Width = Unit.Pixel(80)
e.Row.Cells(3).Width = Unit.Pixel(80)
e.Row.Cells(4).Width = Unit.Pixel(90)
e.Row.Cells(5).Width = Unit.Pixel(90)
e.Row.Cells(6).Width = Unit.Pixel(105)
e.Row.Cells(7).Width = Unit.Pixel(90)
e.Row.Cells(8).Width = Unit.Pixel(85)
End If
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right
e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right
e.Row.Cells(7).HorizontalAlign = HorizontalAlign.Right
e.Row.Cells(8).HorizontalAlign = HorizontalAlign.Right
If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(5).ForeColor = Drawing.Color.Red
If e.Row.DBCampo("DiasVencidos").ToDouble > 0 AndAlso CType(sender, GridView).ID = "GvCxP" Then e.Row.Cells(3).ForeColor = Drawing.Color.Red
If e.Row.DBCampo("CveCompra") = "" Then
e.Row.BackColor = Drawing.Color.LightGray
End If
If CType(sender, GridView).ID = "GvCxPHistorial" Then
If e.Row.DBCampo("CveCompra") = "" Then
e.Row.BackColor = Drawing.Color.LightGray
End If
e.Row.Cells(7).Font.Bold = True
e.Row.Cells(8).Font.Bold = True
End If
End If
End Sub
Protected Sub GvBancos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvBancos.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(70)
e.Row.Cells(2).Width = Unit.Pixel(80)
e.Row.Cells(3).Width = Unit.Pixel(80)
e.Row.Cells(4).Width = Unit.Pixel(90)
e.Row.Cells(5).Width = Unit.Pixel(70)
End If
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right
If e.Row.DBCampo("CveCompra") = "" Then
If e.Row.DBCampo("CveIE") <> "" Then
Dim tempNCuenta As String = ""
Try
If e.Row.DBCampo("NumCuenta").ToString <> "" Then
tempNCuenta = e.Row.DBCampo("NumCuenta").ToString.Substring(6, 4)
End If
Catch ex As Exception
Dim asd = ex.Message
End Try
e.Row.Cells(0).Text = String.Format("{0} - {1} - {2}", e.Row.DBCampo("Banco"), tempNCuenta, e.Row.DBCampo("Moneda"))
e.Row.Cells(2).Text = e.Row.DBCampo("FechaDocumento").ToDate.ToShortDateString
If e.Row.DBCampo("Comprobante") <> "" Then
e.Row.FCLinkButton("Lnkcomprobante").Visible = True
ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("Lnkcomprobante"))
e.Row.FCHiddenField("CveIe").Value = e.Row.DBCampo("CveIE")
End If
End If
e.Row.BackColor = Drawing.Color.LightGray
Else
e.Row.Cells(3).Text = ""
End If
End If
End Sub
Protected Sub GvBancos_comprobante(sender As Object, e As EventArgs)
Dim Gvr As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
Dim Path As String = String.Format("{0}{1}{2}{3}{4}{5}", AppDomain.CurrentDomain.BaseDirectory, "Empresas\", UsuarioActual.CveEmpresa, "\IE\", Gvr.FCHiddenField("CveIe").Value, ".png")
Dim Archivo As New System.IO.FileInfo(Path)
If Archivo.Exists Then
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ContentType = "application/png"
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=comprobante.png")
HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString())
HttpContext.Current.Response.TransmitFile(Path)
'HttpContext.Current.Response.Flush()
HttpContext.Current.Response.End()
End If
Archivo = Nothing
Alert("No se encontro el documento")
End Sub
#End Region
#End Region
#Region " BTNS VER MÁS"
Protected Sub BtnVerMasVentas_Click(sender As Object, e As EventArgs)
If BtnVerMasVentas.Text = "Ver Más" Then
GVHistorial.DataSource = DTGVHistorial
BtnVerMasVentas.Text = "Ver Menos"
Else
GVHistorial.DataSource = DTGVHistorial.AsEnumerable.Take(20).CopyToDataTable
BtnVerMasVentas.Text = "Ver Más"
End If
GVHistorial.DataBind()
'UpDatos.Update()
End Sub
Protected Sub BtnVerMasBancos_Click(sender As Object, e As EventArgs)
If BtnVerMasBancos.Text = "Ver Más" Then
CargaBancos("", 9999999)
BtnVerMasBancos.Text = "Ver Menos"
Else
CargaBancos("", 20)
BtnVerMasBancos.Text = "Ver Más"
End If
UpGvBancos.Update()
End Sub
Protected Sub BtnVerMasAnticipos_Click(sender As Object, e As EventArgs)
If BtnVerMasAnticipos.Text = "Ver Más" Then
CargaAnticipos("-1", 9999999)
BtnVerMasAnticipos.Text = "Ver Menos"
Else
CargaAnticipos("-1", 20)
BtnVerMasAnticipos.Text = "Ver Más"
End If
End Sub
Protected Sub BtnVerMasHistorialCompras_Click(sender As Object, e As EventArgs)
Dim tempDT As New DataTable
If BtnVerMasHistorialCompras.Text = "Ver Más" Then
BtnVerMasHistorialCompras.Text = "Ver Menos"
GvCxPHistorial.DataSource = DTGvCxPHistorial
Else GvCxPHistorial.DataSource = DTGvCxPHistorial.AsEnumerable().Take(11).CopyToDataTable()
BtnVerMasHistorialCompras.Text = "Ver Más"
End If
GvCxPHistorial.DataBind()
' UpDatos.Update()
End Sub
#End Region
#Region "Usuarios Portal"
'Private Sub CargaUsuariosPortal()
' Dim ObjUsrs As New ClsSisUsuarios()
' If ObjUsrs.GetUsuariosPortal(-1, -1, CveProveedor) Then
' Dim dtUsr As DataTable = ObjUsrs.DtResultados
' 'Dim dr As DataRow = dtUsr.FiltroPrimero(String.Format("CveUsuario = {0}", UsuarioActual.CveUsuario))
' 'If dr IsNot Nothing Then
' ' If True Then TabHistorial.Visible = True 'dr("Permiso1").ToString = "True"
' ' If True Then TabCxP.Visible = True
' ' If True Then TabAnticipos.Visible = True
' ' If True Then TabBancos.Visible = True
' ' If True Then TabSistema.Visible = True
' 'End If
' 'dtUsr = dtUsr '.FiltraParametros("Usuario <> 'Admin' AND CveUsuarioPortal <> " & UsuarioActual.CveUsuario)
' ViewState("OrdenUsuarios") = ""
' GvUsuariosPortal.DataSource = dtUsr
' ViewState("DTUsuariosProveedor") = dtUsr
' Else
' GvUsuariosPortal.DataSource = Nothing
' ViewState("DTUsuariosProveedor") = Nothing
' End If
' ObjUsrs.Dispose()
' GvUsuariosPortal.DataBind()
'End Sub
'Private Sub CargaGridUsuarios(Orden As String)
' If CType(ViewState("DTUsuariosProveedor"), DataTable).Rows.Count > 0 Then
' If Orden <> String.Empty Then
' Dim DV As New DataView(CType(ViewState("DTUsuariosProveedor"), DataTable), "", Orden, DataViewRowState.CurrentRows)
' GvUsuariosPortal.DataSource = DV.ToTable() '.FiltraParametros("Nombre <> 'Administrador' AND CveUsuario <> " & UsuarioActual.CveUsuario)
' DV.Dispose()
' Else
' GvUsuariosPortal.DataSource = CType(ViewState("DTUsuariosProveedor"), DataTable) '.FiltraParametros("Nombre <> 'Administrador' AND CveUsuario <> " & UsuarioActual.CveUsuario)
' End If
' End If
' GvUsuariosPortal.DataBind()
' UPPUsuarios.Update()
'End Sub
''ajustar el tamaño de las celdas de la GvUsuarios Portal
'Protected Sub GvUsuariosPortal_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvUsuariosPortal.RowDataBound
' If e.Row.RowType = DataControlRowType.DataRow Then
' 'El usuario Admin no se puede editar ni eliminar
' If e.Row.DataKey("Nombre") = "Admin" Then
' e.Row.FCLinkButton("imgE").Visible = False
' e.Row.FCLinkButton("imgD").Visible = False
' e.Row.FCLinkButton("imgC").Visible = False
' End If
' If e.Row.RowIndex = 0 Then
' '' e.Row.Cells(0).Width = Unit.Pixel(120)
' 'e.Row.Cells(0).Width = Unit.Pixel(120)
' 'e.Row.Cells(1).Width = Unit.Pixel(150)
' 'e.Row.Cells(2).Width = Unit.Pixel(55)
' 'e.Row.Cells(3).Width = Unit.Pixel(55)
' 'e.Row.Cells(4).Width = Unit.Pixel(55)
' 'e.Row.Cells(5).Width = Unit.Pixel(55)
' 'e.Row.Cells(6).Width = Unit.Pixel(55)
' 'e.Row.Cells(7).Width = Unit.Pixel(55)
' 'e.Row.Cells(8).Width = Unit.Pixel(75)
' 'e.Row.Cells(9).Width = Unit.Pixel(100)
' 'e.Row.Cells(10).Width = Unit.Pixel(150)
' End If
' End If
'End Sub
''Editar usuarios
'Protected Sub GvUsuariosPortal_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs) Handles GvUsuariosPortal.RowEditing
' GvUsuariosPortal.EditIndex = e.NewEditIndex
' If ViewState("OrdenUsuarios").ToString() <> String.Empty Then
' CargaGridUsuarios(ViewState("OrdenUsuarios").ToString())
' Else
' CargaGridUsuarios("")
' End If
'End Sub
'Protected Sub GvUsuariosPortal_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles GvUsuariosPortal.RowUpdating
' Dim ObjUsuario As New ClsSisUsuarios
' Dim Nombre, Correo As String
' Dim Estatus As Boolean
' Dim gvr As GridViewRow = GvUsuariosPortal.Rows(e.RowIndex)
' 'Usuario = gvr.FCLiteral("LtlUUsuario").Text.Trim
' Nombre = gvr.FCTextBox("TxtUsuarioPortalEdit").Text.Trim
' Correo = gvr.FCTextBox("TxtCorreoEdit").Text.Trim
' Estatus = gvr.FCCheckBox("ChkEstatus").Checked
' Dim CveUsuarioPortal As Integer = gvr.DataKey("CveUsuario").ToEntero
' Dim pCveProveedor As Integer = gvr.DataKey("CveProveedor").ToEntero
' If ObjUsuario.UpdateUsuarioPortal(Correo, Nombre, Correo, Estatus, "-1", -1, CveProveedor, CveUsuarioPortal, UsuarioActual.CveUsuario) Then
' GvUsuariosPortal.EditIndex = -1
' ObjUsuario.GetUsuariosPortal(-1, -1, CveProveedor) '.FiltraParametros("Usuario <> 'Admin' AND CveUsuarioPortal <> " & UsuarioActual.CveUsuario)
' ViewState("DTUsuariosProveedor") = ObjUsuario.DtResultados
' End If
' ObjUsuario.Dispose()
' If ViewState("OrdenUsuarios").ToString() <> String.Empty Then
' CargaGridUsuarios(ViewState("OrdenUsuarios").ToString())
' Else
' CargaGridUsuarios("")
' End If
'End Sub
''Cancelar Edición
'Protected Sub GvUsuariosPortal_RowCancelingEdit(ByVal sender As Object, ByVal e As GridViewCancelEditEventArgs) Handles GvUsuariosPortal.RowCancelingEdit
' GvUsuariosPortal.EditIndex = -1
' If ViewState("OrdenUsuarios").ToString() <> String.Empty Then
' CargaGridUsuarios(ViewState("OrdenUsuarios").ToString())
' Else
' CargaGridUsuarios("")
' End If
'End Sub
''Restablecer contraseña
'Protected Sub GvUsuariosPortal_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvUsuariosPortal.RowCommand
' If e.CommandName = "RestablecerContraseña" Then
' Dim cveUsuarioPortal As Integer = e.CommandArgument.ToString.ToEntero
' Dim Usuario As New ClsSisUsuarios
' If Usuario.GetUsuariosPortal(cveUsuarioPortal, -1, -1) Then
' Dim dr As DataRow = Usuario.DtResultados.FiltroPrimero("")
' If Usuario.UpdateUsuarioPortal(dr("Usuario").ToString, dr("Nombre").ToString, dr("Correo").ToString, CType(dr("Estatus"), Boolean), ContraseñaPredeterminadaEncriptada, -1, CveProveedor, cveUsuarioPortal, UsuarioActual.CveUsuario) Then
' GvUsuariosPortal.EditIndex = -1
' ViewState("DTUsuariosProveedor") = Usuario.DtResultados '.FiltraParametros("Usuario <> 'Admin' AND CveUsuarioPortal <> " & UsuarioActual.CveUsuario)
' Alert("Contraseña Restablecida.<br> La nueva contraseña es: """ & ContraseñaPredeterminada & "")
' End If
' End If
' Usuario.Dispose()
' End If
' If e.CommandName = "ReenviarCorreo" Then
' Dim cveUsuarioPortal As Integer = e.CommandArgument.ToString.ToEntero
' Dim Usuario As New ClsSisUsuarios
' Usuario.IniciaTransacSQL()
' Dim TieneError = False
' If Usuario.GetUsuariosPortal(cveUsuarioPortal, -1, -1) Then
' Dim dr As DataRow = Usuario.DtResultados.FiltroPrimero("")
' 'ACTUALIZA USUARIO, CONTRASEÑA Y ESTATUS
' If Not Usuario.UpdateUsuarioPortal(dr("Usuario").ToString, dr("Nombre").ToString, dr("Correo").ToString, True, ContraseñaPredeterminadaEncriptada, -1, CveProveedor, cveUsuarioPortal, UsuarioActual.CveUsuario) Then
' TieneError = True
' Alert("Ocurrió un error al actualizar el usuario. Por favor vuelva a intentar.", TipoMensaje.MsgError)
' End If
' 'MANDA CORREO ACTIVACION
' If Not TieneError Then
' Dim ObjParametro As SisParametro = GlobalDTParametros(SisParametros.URL)
' Dim Liga As String = ObjParametro.Cadena1 & "LogIn.aspx"
' Dim LigaActivar = Liga & "?p=" & Encripta("CveU=" & cveUsuarioPortal & "&Clave=" & "-acceso-" & "&Opcion=Activar&Hora=" & DateTime.Now.Ticks & "&CveE=" & UsuarioActual.CveEmpresa)
' Dim ObjMail As New ClsSisMail()
' If dr("Correo").ToString <> "" Then
' Dim Correos As String() = dr("Correo").ToString.Split(New Char() {";"c})
' Dim Texto = ""
' For Each Correo As String In Correos
' Texto = String.Format("Direccion de Acceso: <a href='{0}' target='_blank'>Portal del Proveedor</a><br>Usuario: {2}<br>Haga click para activar su cuenta <a href='{3}' target='_blank'>Activar</a>", Liga, CveProveedor, dr("Usuario").ToString, LigaActivar)
' 'If Not ObjMail.MandaCorreo(EmpresaNotificaciones, Correo, "Activación de cuenta", "", "", {""}, Texto) Then
' If Not ObjMail.SendMail(EmpresaNotificaciones, Correo, "Activación de cuenta", Texto) Then
' Alert("Error al mandar el correo. Por favor vuelva a intentar", TipoMensaje.MsgError)
' TieneError = True
' Exit For
' End If
' Next
' Else
' Alert("No se ha registrado ningún correo al usuario.", TipoMensaje.MsgAdvertencia)
' TieneError = True
' End If
' End If
' If Not TieneError Then
' Usuario.Commit()
' ViewState("DTUsuariosProveedor") = Usuario.DtResultados
' Alert(String.Format("Se envio correo al usuario y se restablecio contraseña .<br> La nueva contraseña es: ""{0}""", ContraseñaPredeterminada), TipoMensaje.MsgInformacion)
' Else
' Usuario.RollBack()
' End If
' End If
' Usuario.Dispose()
' End If
'End Sub
''Eliminar Usuarios
'Protected Sub GvUsuariosPortal_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs) Handles GvUsuariosPortal.RowDeleting
' Dim Usuario As New ClsSisUsuarios
' If Usuario.RemoveUsuarioPortal(GvUsuariosPortal.DataKeys(e.RowIndex).Value.ToString().ToEntero()) Then
' GvUsuariosPortal.EditIndex = -1
' ViewState("DTUsuariosProveedor") = Usuario.DtResultados
' End If
' Usuario.Dispose()
' Alert("Usuario Eliminado")
' If ViewState("OrdenUsuarios").ToString() <> String.Empty Then
' CargaGridUsuarios(ViewState("OrdenUsuarios").ToString())
' Else
' CargaGridUsuarios("")
' End If
'End Sub
''Agregar Usuario
'Protected Sub LnkAgregarUsuario_Click(sender As Object, e As EventArgs) Handles LnkAgregarUsuario.Click
' Dim ObjUsuario As New ClsSisUsuarios
' Dim CvePlataforma As Integer = 7
' ObjUsuario.IniciaTransacSQL()
' Dim CveUsuario As Integer = ObjUsuario.AddUsuarioPortal(TxtCorreo.Text.Trim, ContraseñaPredeterminadaEncriptada, TxtNombrePortal.Text.Trim, TxtCorreo.Text.Trim, -1, CveProveedor, CvePlataforma, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
' If CveUsuario > 0 Then
' If ObjUsuario.UpdateUsuariosModulos(CveUsuario, 1201, True, UsuarioActual.CveUsuario) Then
' If ObjUsuario.GetUsuariosPortal(-1, -1, CveProveedor) Then
' ViewState("DTUsuariosProveedor") = ObjUsuario.DtResultados.FiltraParametros("Nombre <> 'Admin' AND CveUsuario <> " & UsuarioActual.CveUsuario)
' End If
' TxtNombrePortal.Text = ""
' TxtCorreo.Text = ""
' Alert("Usuario Creado.<br>El usuario accesará con la contraseña '" & ContraseñaPredeterminada & "'")
' ObjUsuario.Commit()
' Else
' ObjUsuario.RollBack()
' End If
' Else
' ObjUsuario.RollBack()
' Alert("No se ha podido registrar al nuevo Usuario, Verifique si el Usuario ya está registrado")
' End If
' ObjUsuario.Dispose()
' If ViewState("OrdenUsuarios").ToString() <> String.Empty Then
' CargaGridUsuarios(ViewState("OrdenUsuarios").ToString())
' Else
' CargaGridUsuarios("")
' End If
'End Sub
#End Region
#Region "O R D E N A M I E N T O"
'Protected Sub LbOrden_Click(ByVal sender As Object, ByVal e As EventArgs)
' Dim Orden As String = ""
' Dim Campo As String = ""
' Dim Literal As Literal = Nothing
' Const OrdenInicial As String = ""
' Dim Arg(2) As String
' Arg = CType(sender, LinkButton).CommandArgument().ToString.Split(";"c)
' Campo = Arg(0)
' Literal = CType(CType(sender, LinkButton).NamingContainer.FindControl("Img" & Campo.Replace(",", "_")), Literal)
' If ViewState(String.Format("O{0}", Campo)) IsNot Nothing AndAlso ViewState(String.Format("O{0}", Campo)).ToString = String.Format("{0} DESC", Campo) Then
' ViewState(String.Format("O{0}", Campo)) = String.Format("{0} ASC", Campo)
' Literal.Text = String.Format("<i class='fa fa-sort-asc' style='color:#999' ></i>")
' Else
' ViewState(String.Format("O{0}", Campo)) = String.Format("{0} DESC", Campo)
' Literal.Text = String.Format("<i class='fa fa-sort-desc' style='color:#999' ></i>")
' End If
' Orden = OrdenInicial & ViewState(String.Format("O{0}", Campo)).ToString
' ViewState("Orden") = Orden
' CargaGridUsuarios(Orden)
'End Sub
#End Region
#Region " BANCOS"
Protected Sub BtnExcelGvBancosCuentas_Click(sender As Object, e As EventArgs)
Dim retorno As Byte() = ImprimirReporteGvBancosCuentas("EXCEL")
If retorno IsNot Nothing Then
ImprimirbytesPDF(retorno, "Reporte Bancos Cuentas", Descarga:=True, Formato:="EXCEL")
End If
End Sub
Protected Sub BtnExcelGvBancos_Click(sender As Object, e As EventArgs)
Dim retorno As Byte() = ImprimeReporteGvBancos("EXCEL")
If retorno IsNot Nothing Then
ImprimirbytesPDF(retorno, "Reporte Bancos", Descarga:=True, Formato:="EXCEL")
End If
End Sub
Protected Sub BtnPdfGvBancosCuentas_Click(sender As Object, e As EventArgs)
Dim retorno As Byte() = ImprimirReporteGvBancosCuentas()
If retorno IsNot Nothing Then
ImprimirbytesPDF(retorno, "Reporte Bancos Cuentas", Descarga:=True)
End If
End Sub
Private Function ImprimirReporteGvBancosCuentas(Optional Formato As String = "PDF") As Byte()
Dim retorno As Byte() = Nothing
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
Dim ImagenADSistemas As New System.IO.FileInfo(Server.MapPath("~") & "/Imagenes/LogoSinFondochico.png")
Dim LogoADSistemasUri As String = String.Format("{0}://{1}:{2}/Imagenes/LogoSinFondochico.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port)
Dim ObjMovtos As New ClsMovimientos()
If DTCuentasBancos.Rows.Count > 0 Then
Dim dr As DataRow = DTCuentasBancos.Rows(0)
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("DireccionEmpresa", UsuarioActual.Empresa.Direccion))
params.Add(New ReportParameter("TelefonoEmpresa", UsuarioActual.Empresa.Telefono))
If ImagenADSistemas.Exists Then
params.Add(New ReportParameter("LogoPathADS", LogoADSistemasUri))
Else
params.Add(New ReportParameter("LogoPathADS", ""))
End If
If Imagen.Exists Then
params.Add(New ReportParameter("LogoPath", logouri))
Else
params.Add(New ReportParameter("LogoPath", ""))
End If
retorno = StreamPDF("Empresas/Grales/Formatos/ProveedorCuentasBancos.rdlc", DTCuentasBancos, params, "Reporte de CxP Pagadas", Formato)
Else
Alert("Ocurrió un error.", TipoMensaje.MsgAdvertencia)
End If
ObjMovtos.Dispose()
Return retorno
End Function
Protected Sub BtnPdfGvBancos_Click(sender As Object, e As EventArgs)
Dim retorno As Byte() = ImprimeReporteGvBancos()
If retorno IsNot Nothing Then
ImprimirbytesPDF(retorno, "Reporte Bancos", Descarga:=True)
End If
End Sub
Private Function ImprimeReporteGvBancos(Optional Formato As String = "PDF") As Byte()
Dim retorno As Byte() = Nothing
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
Dim ImagenADSistemas As New System.IO.FileInfo(Server.MapPath("~") & "/Imagenes/LogoSinFondochico.png")
Dim LogoADSistemasUri As String = String.Format("{0}://{1}:{2}/Imagenes/LogoSinFondochico.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port)
Dim ObjMovtos As New ClsMovimientos()
If DtBancos.Rows.Count > 0 Then
Dim dr As DataRow = DtBancos.Rows(0)
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("DireccionEmpresa", UsuarioActual.Empresa.Direccion))
params.Add(New ReportParameter("TelefonoEmpresa", UsuarioActual.Empresa.Telefono))
If ImagenADSistemas.Exists Then
params.Add(New ReportParameter("LogoPathADS", LogoADSistemasUri))
Else
params.Add(New ReportParameter("LogoPathADS", ""))
End If
If Imagen.Exists Then
params.Add(New ReportParameter("LogoPath", logouri))
Else
params.Add(New ReportParameter("LogoPath", ""))
End If
retorno = StreamPDF("Empresas/Grales/Formatos/ProveedorBancos.rdlc", DtBancos, params, "Reporte de CxP Pagadas", Formato)
Else
Alert("Ocurrió un error.", TipoMensaje.MsgAdvertencia)
End If
ObjMovtos.Dispose()
Return retorno
End Function
#End Region
#Region "Crédito por Aplicar Impresión"
Protected Sub BtnExcelCredito_Click(sender As Object, e As EventArgs)
Dim retorno As Byte() = ImprimeReporteNTPorAplicar("EXCEL")
If retorno IsNot Nothing Then
ImprimirbytesPDF(retorno, "Reporte de Notas de Crédito", Descarga:=True, Formato:="EXCEL")
End If
End Sub
Protected Sub BtnExcelCreditoHistorial_Click(sender As Object, e As EventArgs)
Dim retorno As Byte() = ImprimeReporteNTPorHistorial("EXCEL")
If retorno IsNot Nothing Then
ImprimirbytesPDF(retorno, "Reporte de Historial Notas de Crédito", Descarga:=True, Formato:="EXCEL")
End If
End Sub
Protected Sub BtnPdfGvA_Click(sender As Object, e As EventArgs)
Dim retorno As Byte() = ImprimeReporteNTPorAplicar()
If retorno IsNot Nothing Then
ImprimirbytesPDF(retorno, "Reporte de Notas de Crédito", Descarga:=True)
End If
End Sub
Private Function ImprimeReporteNTPorAplicar(Optional Formato As String = "PDF") As Byte()
Dim retorno As Byte() = Nothing
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
Dim ImagenADSistemas As New System.IO.FileInfo(Server.MapPath("~") & "/Imagenes/LogoSinFondochico.png")
Dim LogoADSistemasUri As String = String.Format("{0}://{1}:{2}/Imagenes/LogoSinFondochico.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port)
'OBTENEMOS LOS DATOS
If DTGvA.Rows.Count > 0 Then
Dim dr As DataRow = DTGvA.Rows(0)
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("DireccionEmpresa", UsuarioActual.Empresa.Direccion))
params.Add(New ReportParameter("TelefonoEmpresa", UsuarioActual.Empresa.Telefono))
If ImagenADSistemas.Exists Then
params.Add(New ReportParameter("LogoPathADS", LogoADSistemasUri))
Else
params.Add(New ReportParameter("LogoPathADS", ""))
End If
If Imagen.Exists Then
params.Add(New ReportParameter("LogoPath", logouri))
Else
params.Add(New ReportParameter("LogoPath", ""))
End If
retorno = StreamPDF("Empresas/Grales/Formatos/ProveedorNTPorAplicar.rdlc", DTGvA, params, "Reporte de Ventas", Formato)
Else
Alert("Ocurrió un error.", TipoMensaje.MsgAdvertencia)
End If
Return retorno
End Function
Protected Sub BtnPdfGvAH_Click(sender As Object, e As EventArgs)
Dim retorno As Byte() = ImprimeReporteNTPorHistorial()
If retorno IsNot Nothing Then
ImprimirbytesPDF(retorno, "Reporte de Historial Notas de Crédito", Descarga:=True)
End If
End Sub
Private Function ImprimeReporteNTPorHistorial(Optional Formato As String = "PDF") As Byte()
Dim retorno As Byte() = Nothing
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
Dim ImagenADSistemas As New System.IO.FileInfo(Server.MapPath("~") & "/Imagenes/LogoSinFondochico.png")
Dim LogoADSistemasUri As String = String.Format("{0}://{1}:{2}/Imagenes/LogoSinFondochico.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port)
'OBTENEMOS LOS DATOS
If DTGvAH.Rows.Count > 0 Then
Dim dr As DataRow = DTGvAH.Rows(0)
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("DireccionEmpresa", UsuarioActual.Empresa.Direccion))
params.Add(New ReportParameter("TelefonoEmpresa", UsuarioActual.Empresa.Telefono))
If ImagenADSistemas.Exists Then
params.Add(New ReportParameter("LogoPathADS", LogoADSistemasUri))
Else
params.Add(New ReportParameter("LogoPathADS", ""))
End If
If Imagen.Exists Then
params.Add(New ReportParameter("LogoPath", logouri))
Else
params.Add(New ReportParameter("LogoPath", ""))
End If
retorno = StreamPDF("Empresas/Grales/Formatos/ProveedorNTPorAplicar.rdlc", DTGvAH, params, "Reporte de Ventas", Formato)
Else
Alert("Ocurrió un error.", TipoMensaje.MsgAdvertencia)
End If
Return retorno
End Function
#End Region
#Region "Historial de Ventas IMPRESION"
Protected Sub BtnExcelVentas_Click(sender As Object, e As EventArgs)
Dim retorno As Byte() = ImprimirReporteVentas("EXCEL")
If retorno IsNot Nothing Then
ImprimirbytesPDF(retorno, "Reporte de Ventas", Descarga:=True, Formato:="EXCEL")
End If
End Sub
Protected Sub LbPDFVentas_Click(sender As Object, e As EventArgs)
Dim retorno As Byte() = ImprimirReporteVentas()
If retorno IsNot Nothing Then
ImprimirbytesPDF(retorno, "Reporte de Ventas", Descarga:=True)
End If
End Sub
Protected Function ImprimirReporteVentas(Optional Formato As String = "PDF") As Byte()
Dim retorno As Byte() = Nothing
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
Dim ImagenADSistemas As New System.IO.FileInfo(Server.MapPath("~") & "/Imagenes/LogoSinFondochico.png")
Dim LogoADSistemasUri As String = String.Format("{0}://{1}:{2}/Imagenes/LogoSinFondochico.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port)
Dim ObjProveedores As New ClsCompProveedores()
'OBTENEMOS LOS DATOS
Dim DTCxCHistorial As DataTable
If ObjProveedores.GetHistorialCompras(CveProveedor, -1) Then
DTCxCHistorial = ObjProveedores.DtResultados
Else
DTCxCHistorial = Nothing
End If
If DTCxCHistorial.Rows.Count > 0 Then
Dim dr As DataRow = DTCxCHistorial.Rows(0)
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("DireccionEmpresa", UsuarioActual.Empresa.Direccion))
params.Add(New ReportParameter("TelefonoEmpresa", UsuarioActual.Empresa.Telefono))
If ImagenADSistemas.Exists Then
params.Add(New ReportParameter("LogoPathADS", LogoADSistemasUri))
Else
params.Add(New ReportParameter("LogoPathADS", ""))
End If
If Imagen.Exists Then
params.Add(New ReportParameter("LogoPath", logouri))
Else
params.Add(New ReportParameter("LogoPath", ""))
End If
retorno = StreamPDF("Empresas/Grales/Formatos/ProveedorHistorial.rdlc", DTCxCHistorial, params, "Reporte de Ventas", Formato)
Else
Alert("Ocurrió un error.", TipoMensaje.MsgAdvertencia)
End If
ObjProveedores.Dispose()
Return retorno
End Function
#End Region
#Region "CxP Pagadas IMPRESION"
Protected Sub BtnExcelPagadas_Click(sender As Object, e As EventArgs)
Dim retorno As Byte() = ImprimirReporteCxPPagadas("EXCEL")
If retorno IsNot Nothing Then
ImprimirbytesPDF(retorno, "Reporte de CxP Pagadas", Descarga:=True, Formato:="EXCEL")
End If
End Sub
Protected Sub LbPDFPagadas_Click(sender As Object, e As EventArgs)
Dim retorno As Byte() = ImprimirReporteCxPPagadas()
If retorno IsNot Nothing Then
ImprimirbytesPDF(retorno, "Reporte de CxP Pagadas", Descarga:=True)
End If
End Sub
Protected Function ImprimirReporteCxPPagadas(Optional Formato As String = "PDF") As Byte()
Dim retorno As Byte() = Nothing
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
Dim ImagenADSistemas As New System.IO.FileInfo(Server.MapPath("~") & "/Imagenes/LogoSinFondochico.png")
Dim LogoADSistemasUri As String = String.Format("{0}://{1}:{2}/Imagenes/LogoSinFondochico.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port)
Dim ObjMovtos As New ClsMovimientos()
'OBTENEMOS LOS DATOS
Dim DTCxCHistorial As DataTable
If ObjMovtos.GetCxPProveedor(CveProveedor, "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1) Then
DTCxCHistorial = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Hist'", "Moneda,OrdenVencimiento, FechaVencimiento")
Else
DTCxCHistorial = Nothing
End If
If DTCxCHistorial.Rows.Count > 0 Then
Dim dr As DataRow = DTCxCHistorial.Rows(0)
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("DireccionEmpresa", UsuarioActual.Empresa.Direccion))
params.Add(New ReportParameter("TelefonoEmpresa", UsuarioActual.Empresa.Telefono))
If ImagenADSistemas.Exists Then
params.Add(New ReportParameter("LogoPathADS", LogoADSistemasUri))
Else
params.Add(New ReportParameter("LogoPathADS", ""))
End If
If Imagen.Exists Then
params.Add(New ReportParameter("LogoPath", logouri))
Else
params.Add(New ReportParameter("LogoPath", ""))
End If
retorno = StreamPDF("Empresas/Grales/Formatos/ProveedorCxC.rdlc", DTCxCHistorial, params, "Reporte de CxP Pagadas", Formato)
Else
Alert("Ocurrió un error.", TipoMensaje.MsgAdvertencia)
End If
ObjMovtos.Dispose()
Return retorno
End Function
#End Region
#Region "CxCActivas IMPRESION"
Protected Sub BtnExcelHistorial_Click(sender As Object, e As EventArgs)
Dim retorno As Byte() = ImprimirReporteCxCHistorial("EXCEL")
If retorno IsNot Nothing Then
ImprimirbytesPDF(retorno, "Reporte de CxC Activa", Descarga:=True, Formato:="EXCEL")
End If
End Sub
Protected Sub LbPDFHistorial_Click(sender As Object, e As EventArgs)
Dim retorno As Byte() = ImprimirReporteCxCHistorial()
If retorno IsNot Nothing Then
ImprimirbytesPDF(retorno, "Reporte de CxC Activa", Descarga:=True)
End If
End Sub
Protected Function ImprimirReporteCxCHistorial(Optional Formato As String = "PDF") As Byte()
Dim retorno As Byte() = Nothing
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
Dim ImagenADSistemas As New System.IO.FileInfo(Server.MapPath("~") & "/Imagenes/LogoSinFondochico.png")
Dim LogoADSistemasUri As String = String.Format("{0}://{1}:{2}/Imagenes/LogoSinFondochico.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port)
Dim ObjMovtos As New ClsMovimientos()
'OBTENEMOS LOS DATOS
Dim DTCxCHistorial As DataTable
If ObjMovtos.GetCxPProveedor(CveProveedor, "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1) Then
DTCxCHistorial = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act'", "Moneda,OrdenVencimiento, FechaVencimiento")
Else
DTCxCHistorial = Nothing
End If
If DTCxCHistorial.Rows.Count > 0 Then
Dim dr As DataRow = DTCxCHistorial.Rows(0)
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("DireccionEmpresa", UsuarioActual.Empresa.Direccion))
params.Add(New ReportParameter("TelefonoEmpresa", UsuarioActual.Empresa.Telefono))
If ImagenADSistemas.Exists Then
params.Add(New ReportParameter("LogoPathADS", LogoADSistemasUri))
Else
params.Add(New ReportParameter("LogoPathADS", ""))
End If
If Imagen.Exists Then
params.Add(New ReportParameter("LogoPath", logouri))
Else
params.Add(New ReportParameter("LogoPath", ""))
End If
retorno = StreamPDF("Empresas/Grales/Formatos/ProveedorCxC.rdlc", DTCxCHistorial, params, "Reporte de CxC Activa", Formato)
Else
Alert("Ocurrió un error.", TipoMensaje.MsgAdvertencia)
End If
ObjMovtos.Dispose()
Return retorno
End Function
#End Region
#Region "TAB CONTRASENIA"
Protected Sub BtnGuardarContraseña_Click(sender As Object, e As EventArgs) Handles BtnGuardarContraseña.Click
If Decripta(UsuarioActual.Contraseña) = TxtContraseniaActual.Text Then
Dim ObjUsuario As New ClsSisUsuarios
Dim Usuario As Usuario = Nothing
If ObjUsuario.GetUsuariosPortal(UsuarioActual.CveUsuario, -1, -1) Then
Dim dr As DataRow = ObjUsuario.DtResultados.FiltroPrimero("")
If ObjUsuario.UpdateUsuarioPortal(dr("Usuario").ToString, dr("Nombre").ToString, dr("Correo").ToString, True, Encripta(TxtContrasenia1.Text), dr("CveCliente").ToString.ToEntero, dr("CveProveedor").ToString.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveUsuario) Then
UsuarioActual.Contraseña = Encripta(TxtContrasenia1.Text)
Alert("Contraseña Modificada.", TipoMensaje.MsgInformacion)
End If
End If
ObjUsuario.Dispose()
Else
Alert("La Contraseña Actual es incorrecta.", TipoMensaje.MsgAdvertencia)
End If
End Sub
#End Region
#Region "AUDITORIA"
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)
End Set
End Property
Private Sub CargaDocumentacion()
Dim ObjEDoc As New ClsEdocumentacion
'If objRH.DocumentacionElectronicaGet(-1, -1, CveProveedor, UsuarioActual.Empresa.CveEmpresa, -1, -1, 3) Then
If ObjEDoc.DocumentacionElectronicaAuditoriaGet(CveProveedor, MinFecha, MaxFecha, UsuarioActual.CveEmpresa, 3, -1) Then
DTDocumentacion = ObjEDoc.DtResultados
GvDocumentos.DataSource = ObjEDoc.DtResultados
Else
DTDocumentacion = Nothing
GvDocumentos.DataSource = Nothing
End If
ObjEDoc.Dispose()
GvDocumentos.DataBind()
UPGvDocumentos.Update()
End Sub
Public Sub UploadModal_ClickDocumentacion(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
' Dim chkEstatus As CheckBox
CveDocumentacionElectronica = GvRow.DataKey("CveDocumentacionElectronica").ToString.ToEntero
CveDocumentacion = GvRow.DataKey("CveDocumentacion").ToString.ToEntero
Documentacion = GvRow.DataKey("Documentacion")
AdjuntoDocumentacion = GvRow.DataKey("Adjunto")
'DiasVigencia = GvRow.DataKey("DiasVigencia").ToString.ToEntero
Dim x As String = GvRow.DataKey("AplicaFechaVencimiento")
If GvRow.DataKey("AplicaFechaVencimiento") = "1" Then AplicaFechaVencimiento = True Else AplicaFechaVencimiento = False
If GvRow.DataKey("Adjunto").ToString.Length > 0 Then
FechaVigencia = GvRow.DataKey("Adjunto").ToString.ToDate
Else
FechaVigencia = Nothing
End If
Estatus = GvRow.DataKey("Estatus").ToEntero
'If chkEstatus.Checked Then
' Estatus = 1
'Else
' Estatus = 0
'End If
ObservacionDocumentacion = GvRow.FCTextBox("TxtObservaciones").Text.Trim.ToUpper
FechaLimite = GvRow.FCTextBox("TxtFechaLimite").Text.ToDate
AdjuntoDocumentacion = GvRow.DataKey("Adjunto")
LtlModalUploadTitulo.Text = "Subir " & Documentacion
UpModalTitleUploadDocumento.Update()
RegistraScript("$('#ModalUploadDoc').modal({ backdrop: 'static', keyboard: false});")
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 ImgUpload As LinkButton = e.Row.FCLinkButton("ImgUpload")
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 CveDocumentacionElectronica As String = e.Row.DataKey("CveDocumentacionElectronica")
Dim requerido As Boolean = Boolean.Parse(e.Row.DBCampo("Requerido"))
'Dim chkEstatus As CheckBox = e.Row.FCCheckBox("chkEstatus")
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 AplicaFechaVencimiento And e.Row.DataKey("DiasVigencia").ToString.ToEntero > 0 Then
' txtFechaVigencia.Enabled = False
'End If
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.Contiene(3) Then
' chkEstatus.Checked = True
ImgUpload.Visible = False
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/" & CveProveedor & "/" & Adjunto
Dim linkDescargaArchivo = UsuarioActual.Empresa.Ruta & "Edoc/Proveedor/" & 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, CveDocumentacionElectronica & "." & 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, CveDocumentacionElectronica)
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 BtnUploadFileDoc_Click(sender As Object, e As EventArgs) Handles btnUploadFileDoc.Click
Dim FileExtension As String = "-1"
Dim Filesgral As List(Of Archivo) = TxtFileDocumentacion.getfiles().Archivos
Dim Filename As String = ""
Dim ErrorProceso As Boolean = False
If AplicaFechaVencimiento And DiasVigencia > 0 Then
FechaVigencia = DateTime.Today.AddDays(DiasVigencia)
End If
For Each fileItem As Archivo In Filesgral
Try
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 objEdoc As New ClsEdocumentacion
objEdoc.IniciaTransacSQL()
If CveDocumentacionElectronica = -1 Then
CveDocumentacionElectronica = objEdoc.DocumentacionElectronicaAdd(CveDocumentacion, -1, -1, CveProveedor, 2, ObservacionDocumentacion, "-1", UsuarioActual.CveUsuario, FechaLimite, FechaVigencia)
If CveDocumentacionElectronica > 0 Then
If Not objEdoc.DocumentacionElectronicaUpdate(CveDocumentacionElectronica, CveDocumentacion, -1, -1, CveProveedor, 2, ObservacionDocumentacion, CveDocumentacionElectronica & "." & FileExtension, UsuarioActual.CveUsuario, FechaLimite, FechaVigencia) Then
ErrorProceso = True
End If
End If
Else
If Not objEdoc.DocumentacionElectronicaUpdate(CveDocumentacionElectronica, CveDocumentacion, -1, -1, CveProveedor, 2, ObservacionDocumentacion, CveDocumentacionElectronica & "." & FileExtension, UsuarioActual.CveUsuario, FechaLimite, FechaVigencia) Then
ErrorProceso = True
End If
End If
If Not ErrorProceso = True Then
Dim rutaDestino As String = UsuarioActual.Empresa.Ruta & "Edoc\Proveedor\" & CveProveedor & "\" & CveDocumentacionElectronica & "." & FileExtension
Dim rutaAdjuntoAnterior As String = UsuarioActual.Empresa.Ruta & "Edoc\Proveedor\" & CveProveedor & "\" & AdjuntoDocumentacion
Try
If Not System.IO.Directory.Exists(UsuarioActual.Empresa.Ruta & "Edoc\Proveedor\" & CveProveedor & "\") Then
System.IO.Directory.CreateDirectory(UsuarioActual.Empresa.Ruta & "Edoc\Proveedor\" & CveProveedor & "\")
End If
If File.Exists(rutaAdjuntoAnterior) And AdjuntoDocumentacion.Trim.Length > 0 Then
File.Delete(rutaAdjuntoAnterior)
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
GuardaLog($"Error al gaurdar documento (moviendo archivo digital) --> Error{ ex.StackTrace}")
ErrorProceso = True
End Try
End If
If Not ErrorProceso Then
objEdoc.Commit()
Alert("Documento cargado correctamente")
Else
objEdoc.RollBack()
Alert("Error al cargar archivo", TipoMensaje.MsgError)
End If
objEdoc.Dispose()
CargaDocumentacion()
TxtFileDocumentacion.Text = ""
UPModalUploadDoc.Update()
Catch ex As Exception
OnError("Error al cargar archivo", ex)
End Try
Next
RegistraScript("$('#ModalUploadDoc').modal('hide')", "hidemodal3")
'Dim FileExtension As String = "-1"
'Dim Filesgral As List(Of Archivo) = TxtFileDocumentacion.getfiles().Archivos
'Dim Filename As String = ""
'If AplicaFechaVencimiento And DiasVigencia > 0 Then
' FechaVigencia = DateTime.Today.AddDays(DiasVigencia)
'End If
'For Each fileItem As Archivo In Filesgral
' Try
' 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 & "Edoc\Proveedor\" & CveProveedor & "\" & Documentacion & "." & FileExtension
' Dim rutaAdjuntoAnterior As String = UsuarioActual.Empresa.Ruta & "Edoc\Proveedor\" & CveProveedor & "\" & AdjuntoDocumentacion
' If Not System.IO.Directory.Exists(UsuarioActual.Empresa.Ruta & "Edoc\Proveedor\" & CveProveedor & "\") Then
' System.IO.Directory.CreateDirectory(UsuarioActual.Empresa.Ruta & "Edoc\Proveedor\" & CveProveedor & "\")
' End If
' If File.Exists(rutaAdjuntoAnterior) And AdjuntoDocumentacion.Trim.Length > 0 Then
' File.Delete(rutaAdjuntoAnterior)
' End If
' If System.IO.File.Exists(rutaDestino) Then
' System.IO.File.Delete(rutaDestino)
' End If
' System.IO.File.Move(fileItem.FileUrl, rutaDestino)
' Dim objEdoc As New ClsEdocumentacion
' If CveDocumentacionElectronica = -1 Then
' If objEdoc.DocumentacionElectronicaAdd(CveDocumentacion, -1, -1, CveProveedor, 2, ObservacionDocumentacion, Documentacion & "." & FileExtension, UsuarioActual.CveUsuario, FechaLimite, FechaVigencia) > 0 Then
' End If
' Else
' If objEdoc.DocumentacionElectronicaUpdate(CveDocumentacionElectronica, CveDocumentacion, -1, -1, CveProveedor, 2, ObservacionDocumentacion, Documentacion & "." & FileExtension, UsuarioActual.CveUsuario, FechaLimite, FechaVigencia) Then
' End If
' End If
' objEdoc.Dispose()
' 'GuardarDocumentos(CveDocumentacion)
' CargaDocumentacion()
' TxtFileDocumentacion.Text = ""
' UPModalUploadDoc.Update()
' Alert("Archivo cargado correctamente.")
' Catch ex As Exception
' OnError("Error al cargar archivo", ex)
' End Try
'Next
'RegistraScript("$('#ModalUploadDoc').modal('hide')", "hidemodal3")
End Sub
Private Sub GuardarDocumentos(Optional _CveDocumentacionExcluir As Integer = -1)
Dim hasError As Boolean = True
Dim objDocumentos As New ClsEdocumentacion
For Each dRow As GridViewRow In GvDocumentos.Rows
Dim _CveDocumentacion As Integer = dRow.DataKey("CveDocumentacion").ToString.ToEntero
Dim _Adjunto As String = dRow.DataKey("Adjunto")
Dim _CveDocumentacionElectronica As Integer = dRow.DataKey("CveDocumentacionElectronica").ToString.ToEntero
Dim _txtObservaciones As TextBox = dRow.FCTextBox("TxtObservaciones")
Dim _TxtFechaLimite As TextBox = dRow.FCTextBox("TxtFechaLimite")
Dim _TxtFechaVigencia As TextBox = dRow.FCTextBox("TxtFechaVigencia")
Dim _FechaVigencia As Date
Dim _FechaLimite As Date
Dim chkEstatus As CheckBox = dRow.FCCheckBox("chkEstatus")
Dim _estatus As Integer
If chkEstatus.Checked Then
_estatus = 1
Else
_estatus = 0
End If
Dim DiasLimite As Integer = dRow.DataKey("DiasLimite").ToString.ToEntero
Dim AplicaDiasLimite As Boolean = If(dRow.DataKey("AplicaDiasLimite").ToString = "1", True, False)
Dim AplicaFechaVencimiento As Boolean = If(dRow.DataKey("AplicaFechaVencimiento").ToString = "1", True, False)
If _TxtFechaVigencia.Text.Length = 10 Then
_FechaVigencia = _TxtFechaVigencia.Text.ToDate
Else
_FechaVigencia = Nothing
End If
If Not AplicaDiasLimite Then
_FechaLimite = MinFecha
Else
_FechaLimite = _TxtFechaLimite.Text.ToDate
End If
If Not AplicaFechaVencimiento Then
_FechaVigencia = MinFecha
End If
If Not _CveDocumentacionExcluir = _CveDocumentacion Then
Try
If _CveDocumentacionElectronica = -1 Then
If objDocumentos.DocumentacionElectronicaAdd(_CveDocumentacion, -1, -1, CveProveedor, -1, _txtObservaciones.Text.Trim, _Adjunto, UsuarioActual.CveUsuario, _FechaLimite, _FechaVigencia) > 0 Then
Else
hasError = True
Exit For
End If
Else
If objDocumentos.DocumentacionElectronicaUpdate(_CveDocumentacionElectronica, _CveDocumentacion, -1, -1, CveProveedor, -1, _txtObservaciones.Text.Trim, _Adjunto, UsuarioActual.CveUsuario, _FechaLimite, _FechaVigencia) Then
Else
hasError = True
Exit For
End If
End If
hasError = False
Catch ex As Exception
hasError = True
Exit For
End Try
End If
Next
CargaDocumentacion()
objDocumentos.Dispose()
End Sub
#End Region
End Class