Files
SIG/Bancos/CuentasBancarias.aspx.vb

168 lines
8.0 KiB
VB.net

Option Explicit On
Option Strict On
Imports System.Data
Imports System.Linq
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Partial Class Bancos_CuentasBancarias
Inherits ClsPaginas
Private Property DtBan As DataTable
Get
DtBan = DirectCast(ViewState("DtBan"), DataTable)
End Get
Set(ByVal value As DataTable)
ViewState("DtBan") = value
End Set
End Property
'Configuración
Private ReadOnly Property CveCuenta As Integer
Get
Return ViewState("CveCuenta").ToString.ToEntero
End Get
End Property
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
CargaDatos()
End If
End Sub
Public Sub CargaDatos()
Dim ObjBancos As New ClsBancos
If ObjBancos.GetBancosCuentas(-1) Then
Dim dt = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa, "", {"CveCuenta", "TipoCuenta", "Banco", "NumCuenta", "CLABE", "Moneda", "FInicial", "Estatus", "Fecha", "Usuario"})
ViewState("DTBancosCuentas") = dt
DtBan = dt
Else
Me.GvDatos.DataSource = Nothing
End If
ObjBancos.Dispose()
CargaGrid("")
End Sub
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowIndex = 0 Then
e.Row.Cells(1).Width = Unit.Pixel(75) 'CveBanco
e.Row.Cells(2).Width = Unit.Pixel(70) 'NumCuenta
e.Row.Cells(3).Width = Unit.Pixel(120) 'clabe
e.Row.Cells(4).Width = Unit.Pixel(50) 'Moneda
e.Row.Cells(5).Width = Unit.Pixel(51) 'FInicial
e.Row.Cells(6).Width = Unit.Pixel(60) 'estatus
e.Row.Cells(7).Width = Unit.Pixel(50) 'fecha
e.Row.Cells(8).Width = Unit.Pixel(50) 'Usuario
End If
e.Row.FCLiteral("LtlNumCuenta").Text = "<a class=""Texto"" target=""_blank"" href=""/Bancos/CuentasBancariasDetalle.aspx?CveCuenta=" & e.Row.DBCampo("CveCuenta") & """>" & e.Row.FCLiteral("LtlNumCuenta").Text & "</a>"
e.Row.FCLiteral("LtlBanco").Text = "<a class=""Texto"" target=""_blank"" href=""/Bancos/CuentasBancariasDetalle.aspx?CveCuenta=" & e.Row.DBCampo("CveCuenta") & """>" & e.Row.FCLiteral("LtlBanco").Text & "</a>"
End If
End Sub
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
Dim ObjBancos As New ClsBancos
If ObjBancos.RemoveBancosCuentas(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
GvDatos.EditIndex = -1
ViewState("DTBancosCuentas") = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
DtBan = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa) = Nothing
'If ObjBancos.GetBancosCuentasUsuarios(-1) Then
' GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa) = ObjBancos.DtResultados
'End If
Alert("El Banco se eliminó correctamente.", TipoMensaje.MsgInformacion)
End If
ObjBancos.Dispose()
If ViewState("Orden").ToString() <> String.Empty Then
CargaGrid(ViewState("Orden").ToString())
Else
CargaGrid("")
End If
End Sub
Protected Sub GvDatos_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit
GvDatos.EditIndex = -1
If ViewState("Orden").ToString() <> String.Empty Then
CargaGrid(ViewState("Orden").ToString())
Else
CargaGrid("")
End If
End Sub
'Protected Sub GvDatos_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvDatos.RowUpdating
' Dim ObjBancos As New ClsBancos
' Dim CveBanco As Integer = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("DdlCveBanco"), DropDownList).SelectedValue.ToEntero
' Dim NumCuenta As String = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtNumCuenta"), TextBox).Text.Trim
' Dim CLABE As String = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtCLABE"), TextBox).Text.Trim
' Dim CveMoneda As Integer = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("DdlCveMoneda"), DropDownList).SelectedValue.ToEntero
' Dim DiaCorte As Integer = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtDiaCorte"), TextBox).Text.Trim.ToEntero
' Dim FInicial As Integer = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtFInicial"), TextBox).Text.Trim.ToEntero
' Dim FActual As Integer = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtFActual"), TextBox).Text.Trim.ToEntero
' Dim FFinal As Integer = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtFFinal"), TextBox).Text.Trim.ToEntero
' Dim IdCtaContable As Integer = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtIdCtaContable"), TextBox).Text.Trim.ToEntero
' Dim FormatoCheque As String = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtFormatoCheque"), TextBox).Text.Trim
' Dim Estatus As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEstatus").Checked
' Dim CveCuenta As Integer = GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero
' If ObjBancos.UpdateBancosCuentas(CveBanco, NumCuenta, CLABE, CveMoneda, DiaCorte, FInicial, FActual, FFinal, IdCtaContable, FormatoCheque, Estatus, CveCuenta) Then
' GvDatos.EditIndex = -1
' ViewState("DTBancosCuentas") = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
' Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
' End If
' ObjBancos.Dispose()
' If ViewState("Orden").ToString() <> String.Empty Then
' CargaGrid(ViewState("Orden").ToString())
' Else
' CargaGrid("")
' End If
'End Sub
Protected Sub GvDatos_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvDatos.RowEditing
GvDatos.EditIndex = e.NewEditIndex
If ViewState("Orden").ToString() <> String.Empty Then
CargaGrid(ViewState("Orden").ToString())
Else
CargaGrid("")
End If
End Sub
Private Sub CargaGrid(Orden As String)
If Orden <> String.Empty Then
Dim DV As New DataView(CType(ViewState("DTBancosCuentas"), DataTable), "", Orden, DataViewRowState.CurrentRows)
GvDatos.DataSource = DV.ToTable()
DV.Dispose()
Else
GvDatos.DataSource = CType(ViewState("DTBancosCuentas"), DataTable)
End If
GvDatos.DataBind()
UpDatos.Update()
End Sub
Protected Sub LbPDF_Click(sender As Object, e As EventArgs)
Imprime("PDF")
End Sub
Protected Sub LbExcel_Click(sender As Object, e As EventArgs)
Imprime("Excel")
End Sub
Private Sub Imprime(Formato As String)
If DtBan IsNot Nothing AndAlso DtBan.Rows.Count > 0 Then
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
ImprimirPDF("Empresas/Grales/Formatos/CuentasBancarias.rdlc", DtBan, params, "Reporte de Cuentas Bancarias", Formato)
Else
Alert("No hay información para mostrar.", TipoMensaje.MsgAdvertencia)
End If
End Sub
End Class