664 lines
30 KiB
VB.net
664 lines
30 KiB
VB.net
Option Strict On
|
|
Option Explicit On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports System.Xml
|
|
Imports Microsoft.Reporting.WebForms
|
|
Imports System.Globalization
|
|
|
|
Partial Class Bancos_ConciliacionesBancariasaspx
|
|
Inherits ClsPaginas
|
|
|
|
#Region "PROPIEDADES"
|
|
|
|
Private Property DtDatosEdoCuenta As DataTable
|
|
Get
|
|
Return CType(ViewState("DtDatosEdoCuenta"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtDatosEdoCuenta") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtDatos As DataTable
|
|
Get
|
|
Return CType(ViewState("DtDatos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtDatos") = value
|
|
End Set
|
|
End Property
|
|
Private Property ModalidadConciliacion As String
|
|
Get
|
|
Return CType(ViewState("ModalidadConciliacion"), String)
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("ModalidadConciliacion") = value
|
|
End Set
|
|
End Property
|
|
Private Property ModalidadDesconciliar As String
|
|
Get
|
|
Return CType(ViewState("ModalidadDesconciliar"), String)
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("ModalidadDesconciliar") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveIEDesconciliar As Integer
|
|
Get
|
|
Return CType(ViewState("CveIEDesconciliar"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveIEDesconciliar") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property Formato As String
|
|
Get
|
|
Return CType(ViewState("Formato"), String)
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Formato") = 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
|
|
InicializaValores()
|
|
End If
|
|
End Sub
|
|
|
|
#Region "INICIALIZA VALORES / CONSULTAS"
|
|
|
|
Private Sub InicializaValores()
|
|
'Cargar Cuentas
|
|
DdlCuenta.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario)
|
|
DdlCuenta.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
DdlCuenta.DataBind()
|
|
|
|
txtFechaI.Text = Now.FirstDayOfMonth.ToShortDateString
|
|
txtFechaF.Text = Now.ToShortDateString
|
|
|
|
ModalidadConciliacion = ""
|
|
ModalidadDesconciliar = ""
|
|
CveIEDesconciliar = 0
|
|
End Sub
|
|
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
|
Consulta()
|
|
ConsultaEdoConciliacion()
|
|
End Sub
|
|
|
|
Private Sub Consulta()
|
|
Dim ObjBancos As New ClsBancos
|
|
If ObjBancos.GetIEConciliacion(-1, txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, DdlConciliado.SelectedValue.ToEntero,
|
|
DdlCuenta.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, ChkVerDuplicados.Checked) Then
|
|
GvDatos.DataSource = ObjBancos.DtResultados
|
|
DtDatos = ObjBancos.DtResultados
|
|
CargaTotales(ObjBancos.DtResultados)
|
|
End If
|
|
ObjBancos.Dispose()
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
If GvDatos.Rows.Count > 0 Then RegistraScript("CalculaSeleccionados();", "1")
|
|
End Sub
|
|
|
|
Private Sub ConsultaEdoConciliacion()
|
|
Dim ObjBancos As New ClsBancos
|
|
If ObjBancos.GetIEEstadoCuenta(-1, txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, DdlConciliado.SelectedValue.ToEntero,
|
|
DdlCuenta.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, VerDuplicados:=ChkVerDuplicados.Checked, Tipo:=2) Then
|
|
GvEdoConciliacion.DataSource = ObjBancos.DtResultados
|
|
DtDatosEdoCuenta = ObjBancos.DtResultados
|
|
CargaTotalesEdoCuenta(ObjBancos.DtResultados)
|
|
End If
|
|
ObjBancos.Dispose()
|
|
GvEdoConciliacion.DataBind()
|
|
UpDatosEdoConciliacion.Update()
|
|
If GvEdoConciliacion.Rows.Count > 0 Then RegistraScript("CalculaSeleccionadosEdoCuenta();", "2")
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaTotales(DtDatos As DataTable)
|
|
If DtDatos IsNot Nothing Then
|
|
If DtDatos.Rows.Count > 0 Then
|
|
LblConciliados.Text = DtDatos.SUM("Importe", "FueConciliado = 1 AND CveIE > 0").FormatoNumero
|
|
LblNoConciliados.Text = DtDatos.SUM("Importe", "FueConciliado = 0 AND CveIE > 0").FormatoNumero
|
|
LblTotal.Text = DtDatos.SUM("Importe", "CveIE > 0").FormatoNumero
|
|
LblCargos.Text = DtDatos.SUM("Cargo", "CveIE > 0").FormatoNumero
|
|
LblAbonos.Text = DtDatos.SUM("Abono", "CveIE > 0").FormatoNumero
|
|
End If
|
|
DivTotales.Visible = True
|
|
DivSeleccionado.Visible = True
|
|
Else
|
|
DivTotales.Visible = False
|
|
DivSeleccionado.Visible = False
|
|
End If
|
|
UpTotales.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaTotalesEdoCuenta(DtDatos As DataTable)
|
|
If DtDatos IsNot Nothing Then
|
|
If DtDatos.Rows.Count > 0 Then
|
|
LblConciliadosEdoCuenta.Text = DtDatos.SUM("Importe", "FueConciliado = 1 AND CveIEEstadoCuenta > 0").FormatoNumero
|
|
LblNoConciliadosEdoCuenta.Text = DtDatos.SUM("Importe", "FueConciliado = 0 AND CveIEEstadoCuenta > 0").FormatoNumero
|
|
LblTotalEdoCuenta.Text = DtDatos.SUM("Importe", "CveIEEstadoCuenta > 0").FormatoNumero
|
|
LblCargosEdoCuenta.Text = DtDatos.SUM("Cargo", "CveIEEstadoCuenta > 0").FormatoNumero
|
|
LblAbonosEdoCuenta.Text = DtDatos.SUM("Abono", "CveIEEstadoCuenta > 0").FormatoNumero
|
|
End If
|
|
DivTotales.Visible = True
|
|
DivSeleccionadoEdoConciliacion.Visible = True
|
|
Else
|
|
DivTotales.Visible = False
|
|
DivSeleccionadoEdoConciliacion.Visible = False
|
|
End If
|
|
UpTotales.Update()
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "CONCILIACION"
|
|
|
|
Private Sub ConciliacionAutomatica()
|
|
If Not DtDatos.Rows.Count > 0 Then
|
|
Alert("Tiene que tener movimientos para conciliar", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
If Not DtDatosEdoCuenta.Rows.Count > 0 Then
|
|
Alert("Tiene que tener movimientos cargados de excel para conciliar", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
Dim ObjBancos As New ClsBancos
|
|
Dim ObjOI As New ClsOIEventos(ObjBancos.IniciaTransacSQL())
|
|
Dim ErrorTrans As Boolean = False
|
|
Dim HuboConciliacion As Boolean = False
|
|
For Each Dr As DataRow In DtDatos.Rows
|
|
If Not CBool(Dr("FueConciliado").ToString) And Dr("CveIE").ToString.ToEntero > 0 Then
|
|
For Each DrE As DataRow In DtDatosEdoCuenta.Rows
|
|
If ((Dr("FechaDocumento").ToString.ToDate = DrE("FechaDocumento").ToString.ToDate And Dr("Importe").ToString.ToDouble = DrE("Importe").ToString.ToDouble And Dr("Tipo").ToString = DrE("Tipo").ToString And DdlCriterio.SelectedValue.ToEntero = 1) Or (Dr("Importe").ToString.ToDouble = DrE("Importe").ToString.ToDouble And Dr("Tipo").ToString = DrE("Tipo").ToString And DdlCriterio.SelectedValue.ToEntero = 2)) And Not CBool(DrE("Seleccionado").ToString) And Not CBool(DrE("FueConciliado").ToString) And Not CBool(Dr("Seleccionado").ToString) Then
|
|
If Not ObjBancos.UpdateConciliacionBancaria(Dr("CveIE").ToString.ToEntero, If(Dr("FechaDocumento").ToString.ToDate < txtFechaI.Text.ToDate, TxtFechaAplicado.Text.ToDate, Dr("FechaDocumento").ToString.ToDate)) Or Not ObjBancos.UpdateIEEstadoCuenta(DrE("CveIEEstadoCuenta").ToString.ToEntero, DrE("Importe").ToString.ToDouble, True, Dr("CveIE").ToString.ToEntero,
|
|
DrE("Referencia").ToString, DrE("Tipo").ToString, DrE("FechaDocumento").ToString.ToDate, DrE("CveCuenta").ToString.ToEntero) Then
|
|
ErrorTrans = True
|
|
Else
|
|
If Not ObjOI.AddEventoBitacora("El pago ha sido conciliado", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=Dr("CveIE").ToString.ToEntero) Then
|
|
ErrorTrans = True
|
|
Else
|
|
DrE("Seleccionado") = True
|
|
Dr("Seleccionado") = True
|
|
HuboConciliacion = True
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
End If
|
|
Next
|
|
If Not ErrorTrans Then
|
|
ObjBancos.Commit()
|
|
Consulta()
|
|
ConsultaEdoConciliacion()
|
|
If HuboConciliacion Then
|
|
Alert("Coinciliadas Correctamente")
|
|
Else
|
|
Alert("No hubo Conciliaciones Automaticas", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
Else
|
|
ObjBancos.RollBack()
|
|
For Each Dr As DataRow In DtDatos.Rows
|
|
Dr("Seleccionado") = False
|
|
Next
|
|
For Each Dr As DataRow In DtDatosEdoCuenta.Rows
|
|
Dr("Seleccionado") = False
|
|
Next
|
|
End If
|
|
ObjBancos.Dispose()
|
|
ObjOI.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub LnkConciliarManual_Click(sender As Object, e As EventArgs)
|
|
ModalidadConciliacion = "M"
|
|
DdlCriterio.SelectedIndex = 0
|
|
DivCriterio.Visible = True
|
|
TxtFechaAplicado.Text = txtFechaI.Text
|
|
UpModalCriterio.Update()
|
|
RegistraScript("$('#DModalCriterio').modal()")
|
|
End Sub
|
|
Private Sub ConciliacionManual()
|
|
Dim SumaSIGAbono As Double = 0
|
|
Dim SumaSIGCargo As Double = 0
|
|
Dim SumaExcelAbono As Double = 0
|
|
Dim SumaExcelCargo As Double = 0
|
|
Dim Seleccionados As Integer = 0
|
|
Dim Fecha As Date
|
|
For Each Gvr As GridViewRow In GvDatos.Rows
|
|
If Gvr.FCCheckBox("ChkConciliado").Checked And Gvr.FCCheckBox("ChkConciliado").Enabled Then
|
|
Seleccionados += 1
|
|
Fecha = Gvr.DataKey("FechaDocumento").ToDate
|
|
If Gvr.DataKey("Tipo") = "Cargo" Then
|
|
SumaSIGCargo += Gvr.DataKey("Importe").ToDouble
|
|
ElseIf Gvr.DataKey("Tipo") = "Abono" Then
|
|
SumaSIGAbono += Gvr.DataKey("Importe").ToDouble
|
|
End If
|
|
End If
|
|
Next
|
|
If Seleccionados > 1 Then
|
|
Alert("Tiene que tener seleccionado solamente un movimiento.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
ElseIf Not Seleccionados > 0 Then
|
|
Alert("Tiene que tener seleccionado .", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
For Each Gvr As GridViewRow In GvEdoConciliacion.Rows
|
|
If Gvr.FCCheckBox("ChkConciliado").Checked And Gvr.FCCheckBox("ChkConciliado").Enabled Then
|
|
If (Gvr.DataKey("FechaDocumento").ToDate = Fecha And DdlCriterio.SelectedValue.ToEntero = 1) Or DdlCriterio.SelectedValue.ToEntero = 2 Then
|
|
If Gvr.DataKey("Tipo") = "Cargo" Then
|
|
SumaExcelCargo += Gvr.DataKey("Importe").ToDouble
|
|
ElseIf Gvr.DataKey("Tipo") = "Abono" Then
|
|
SumaExcelAbono += Gvr.DataKey("Importe").ToDouble
|
|
End If
|
|
Else
|
|
Alert("Las fechas no coinciden.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
Next
|
|
If SumaSIGAbono <> SumaExcelAbono Or SumaSIGCargo <> SumaExcelCargo Then
|
|
Alert("La suma de los importes no cuadran", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
Dim ObjBancos As New ClsBancos
|
|
Dim ObjOI As New ClsOIEventos(ObjBancos.IniciaTransacSQL())
|
|
Dim ErrorTrans As Boolean = False
|
|
Dim CveIE As Integer = 0
|
|
For Each Gvr As GridViewRow In GvDatos.Rows
|
|
If Gvr.FCCheckBox("ChkConciliado").Checked And Gvr.FCCheckBox("ChkConciliado").Enabled Then
|
|
If Not ObjBancos.UpdateConciliacionBancaria(Gvr.DataKey("CveIE").ToEntero, If(Gvr.DataKey("FechaDocumento").ToString.ToDate < txtFechaI.Text.ToDate, TxtFechaAplicado.Text.ToDate, Gvr.DataKey("FechaDocumento").ToString.ToDate)) Then
|
|
ErrorTrans = True
|
|
Else
|
|
If Not ObjOI.AddEventoBitacora("El pago ha sido conciliado", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=Gvr.DataKey("CveIE").ToEntero) Then
|
|
ErrorTrans = True
|
|
Else
|
|
CveIE = Gvr.DataKey("CveIE").ToEntero
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
For Each Gvr As GridViewRow In GvEdoConciliacion.Rows
|
|
If Gvr.FCCheckBox("ChkConciliado").Checked And Gvr.FCCheckBox("ChkConciliado").Enabled Then
|
|
If Not ObjBancos.UpdateIEEstadoCuenta(Gvr.DataKey("CveIEEstadoCuenta").ToEntero, Gvr.DataKey("Importe").ToDouble, True, CveIE, Gvr.DataKey("Referencia").ToString,
|
|
Gvr.DataKey("Tipo").ToString, Gvr.DataKey("FechaDocumento").ToDate, Gvr.DataKey("CveCuenta").ToEntero) Then
|
|
ErrorTrans = True
|
|
End If
|
|
End If
|
|
Next
|
|
If Not ErrorTrans Then
|
|
ObjBancos.Commit()
|
|
Consulta()
|
|
ConsultaEdoConciliacion()
|
|
Alert("Conciliados Correctamente")
|
|
Else
|
|
ObjBancos.RollBack()
|
|
End If
|
|
ObjBancos.Dispose()
|
|
ObjOI.Dispose()
|
|
End Sub
|
|
Protected Sub LnlConciliarAutomaticamente_Click(sender As Object, e As EventArgs)
|
|
ModalidadConciliacion = "A"
|
|
DdlCriterio.SelectedIndex = 0
|
|
DivCriterio.Visible = True
|
|
TxtFechaAplicado.Text = txtFechaI.Text
|
|
UpModalCriterio.Update()
|
|
RegistraScript("$('#DModalCriterio').modal()")
|
|
End Sub
|
|
|
|
Protected Sub BtnConciliar_Click(sender As Object, e As EventArgs)
|
|
RegistraScript("$('#DModalCriterio').modal('hide')")
|
|
If ModalidadConciliacion = "A" Then
|
|
ConciliacionAutomatica()
|
|
ElseIf ModalidadConciliacion = "M" Then
|
|
ConciliacionManual()
|
|
ElseIf ModalidadConciliacion = "D" Then
|
|
ConciliacionDirecta()
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub LnbkConciliarDirectamente_Click(sender As Object, e As EventArgs)
|
|
ModalidadConciliacion = "D"
|
|
DdlCriterio.SelectedIndex = 0
|
|
DivCriterio.Visible = False
|
|
TxtFechaAplicado.Text = txtFechaI.Text
|
|
UpModalCriterio.Update()
|
|
RegistraScript("$('#DModalCriterio').modal()")
|
|
End Sub
|
|
|
|
Private Sub ConciliacionDirecta()
|
|
Dim ObjBancos As New ClsBancos
|
|
Dim ObjOI As New ClsOIEventos(ObjBancos.IniciaTransacSQL())
|
|
Dim ErrorTrans As Boolean = False
|
|
Dim Selecciono As Boolean = False
|
|
For Each Gvr As GridViewRow In GvDatos.Rows
|
|
If Gvr.FCCheckBox("ChkConciliado").Checked And Gvr.FCCheckBox("ChkConciliado").Enabled Then
|
|
Selecciono = True
|
|
If Not ObjBancos.UpdateConciliacionBancaria(Gvr.DataKey("CveIE").ToEntero, If(Gvr.DataKey("FechaDocumento").ToString.ToDate < txtFechaI.Text.ToDate, TxtFechaAplicado.Text.ToDate, Gvr.DataKey("FechaDocumento").ToString.ToDate)) Then
|
|
ErrorTrans = True
|
|
Else
|
|
If Not ObjOI.AddEventoBitacora("El pago ha sido conciliado", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=Gvr.DataKey("CveIE").ToEntero) Then
|
|
ErrorTrans = True
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
If Not ErrorTrans Then
|
|
ObjBancos.Commit()
|
|
If Selecciono Then
|
|
Consulta()
|
|
ConsultaEdoConciliacion()
|
|
Alert("Conciliados Correctamente")
|
|
Else
|
|
Alert("Tiene que tener al menos uno seleccionado.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
Else
|
|
ObjBancos.RollBack()
|
|
End If
|
|
ObjBancos.Dispose()
|
|
ObjOI.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "DESCONCILIAR"
|
|
|
|
Protected Sub LnkDesconciliar_Click(sender As Object, e As EventArgs)
|
|
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
ModalidadDesconciliar = "D"
|
|
TxtFechaDesconciliado.Text = Now.ToShortDateString
|
|
CveIEDesconciliar = gvRow.DataKey("CveIE").ToEntero
|
|
UpDesconciliar.Update()
|
|
RegistraScript("$('#DModalDesconciliar').modal()")
|
|
End Sub
|
|
|
|
Protected Sub LnkDesconciliarTodos_Click(sender As Object, e As EventArgs)
|
|
ModalidadDesconciliar = "DT"
|
|
TxtFechaDesconciliado.Text = Now.ToShortDateString
|
|
CveIEDesconciliar = 0
|
|
UpDesconciliar.Update()
|
|
RegistraScript("$('#DModalDesconciliar').modal()")
|
|
End Sub
|
|
|
|
Protected Sub BtnDesconciliar_Click(sender As Object, e As EventArgs)
|
|
Dim ObjBancos As New ClsBancos
|
|
Dim ObjOI As New ClsOIEventos(ObjBancos.IniciaTransacSQL())
|
|
Dim ErrorTrans As Boolean = False
|
|
|
|
If ModalidadDesconciliar = "D" Then
|
|
If ObjBancos.DesconciliarIE(CveIEDesconciliar, TxtFechaDesconciliado.Text.ToDate()) Then
|
|
If Not ObjOI.AddEventoBitacora("El pago ha sido desconciliado", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=CveIEDesconciliar) Then
|
|
ErrorTrans = True
|
|
End If
|
|
Else
|
|
ErrorTrans = True
|
|
End If
|
|
ElseIf ModalidadDesconciliar = "DT" Then
|
|
For Each Gvr As GridViewRow In GvDatos.Rows
|
|
If Gvr.FCCheckBox("ChkConciliado").Checked And Not Gvr.FCCheckBox("ChkConciliado").Enabled Then
|
|
If Not ObjBancos.DesconciliarIE(Gvr.DataKey("CveIE").ToEntero, TxtFechaDesconciliado.Text.ToDate()) Then
|
|
ErrorTrans = True
|
|
Else
|
|
If Not ObjOI.AddEventoBitacora("El pago ha sido desconciliado", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=Gvr.DataKey("CveIE").ToEntero) Then
|
|
ErrorTrans = True
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
End If
|
|
If Not ErrorTrans Then
|
|
ObjBancos.Commit()
|
|
Alert("Desconciliado correctamente")
|
|
Consulta()
|
|
ConsultaEdoConciliacion()
|
|
RegistraScript("$('#DModalDesconciliar').modal('hide')")
|
|
Else
|
|
ObjBancos.RollBack()
|
|
End If
|
|
ObjBancos.Dispose()
|
|
ObjOI.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "GRIDVIEW"
|
|
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.RowIndex = 0 Then
|
|
e.Row.CssClass = "Totales"
|
|
e.Row.Cells(0).Text = "Total"
|
|
Else
|
|
e.Row.Attributes.Add("data-cveie", e.Row.DBCampo("CveIE"))
|
|
e.Row.FCCheckBox("ChkConciliado").Attributes.Add("onclick", "CalculaSeleccionados();")
|
|
If Not e.Row.DBCampo("Cargo").ToDouble <> 0 Then
|
|
e.Row.Cells(4).Text = ""
|
|
End If
|
|
If Not e.Row.DBCampo("Abono").ToDouble <> 0 Then
|
|
e.Row.Cells(5).Text = ""
|
|
End If
|
|
If CBool(e.Row.DBCampo("FueConciliado").ToString) Then
|
|
e.Row.FCLinkButton("LnkDesconciliar").Visible = True
|
|
e.Row.FCLinkButton("LnkVerVinculadosIE").Visible = True
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvEdoConciliacion_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.RowIndex = 0 Then
|
|
e.Row.CssClass = "Totales"
|
|
e.Row.Cells(0).Text = "Total"
|
|
Else
|
|
e.Row.Attributes.Add("data-cveie", e.Row.DBCampo("CveIE"))
|
|
e.Row.FCCheckBox("ChkConciliado").Attributes.Add("onclick", "CalculaSeleccionadosEdoCuenta();")
|
|
If Not e.Row.DBCampo("Cargo").ToDouble > 0 Then
|
|
e.Row.Cells(3).Text = ""
|
|
End If
|
|
If Not e.Row.DBCampo("Abono").ToDouble > 0 Then
|
|
e.Row.Cells(4).Text = ""
|
|
End If
|
|
If CBool(e.Row.DBCampo("FueConciliado").ToString) Then
|
|
e.Row.FCLinkButton("LnkDesconciliarEdoConciliacion").Visible = True
|
|
e.Row.FCLinkButton("LnkVerVinculadosIEEstadoCuenta").Visible = True
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Protected Sub LnkVerVinculadosIEEstadoCuenta_Click(sender As Object, e As EventArgs)
|
|
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
If gvRow.DataKey("CveIE").ToEntero > 0 Then
|
|
Dim ObjBancos As New ClsBancos
|
|
If ObjBancos.GetBancosIE(gvRow.DataKey("CveIE").ToEntero, UsuarioActual.CveEmpresa) Then
|
|
If ObjBancos.DtResultados.Rows.Count > 0 Then
|
|
Dim Dr As DataRow = ObjBancos.DtResultados.Rows(0)
|
|
LblTituloObservaciones.Text = "Observaciones"
|
|
DivFolio.Visible = True
|
|
HlFolio.Text = Dr("Folio").ToString
|
|
HlFolio.NavigateUrl = $"/Bancos/IE.aspx?CveIE={gvRow.DataKey("CveIE").ToString}"
|
|
LblFecha.Text = Dr("FechaDocumento").ToString.ToDate.ToShortDateString
|
|
LblObservaciones.Text = Dr("Observaciones").ToString
|
|
LblTipo.Text = Dr("Tipo").ToString
|
|
LblImporte.Text = Dr("Importe").ToString.FormatoNumero
|
|
UpModalVinculado.Update()
|
|
RegistraScript("$('#DModalVinculado').modal()")
|
|
End If
|
|
End If
|
|
ObjBancos.Dispose()
|
|
End If
|
|
GvEdoConciliacion.DataSource = DtDatosEdoCuenta
|
|
GvEdoConciliacion.DataBind()
|
|
End Sub
|
|
|
|
Protected Sub LnkVerVinculadosIE_Click(sender As Object, e As EventArgs)
|
|
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
If gvRow.DataKey("CveIEEstadoCuenta").ToEntero > 0 Then
|
|
Dim ObjBancos As New ClsBancos
|
|
If ObjBancos.GetIEEstadoCuenta(gvRow.DataKey("CveIEEstadoCuenta").ToEntero, MinFecha, MaxFecha, 1, -1, UsuarioActual.CveEmpresa) Then
|
|
If ObjBancos.DtResultados.Rows.Count > 1 Then
|
|
Dim Dr As DataRow = ObjBancos.DtResultados.Rows(1)
|
|
LblTituloObservaciones.Text = "Referencia"
|
|
DivFolio.Visible = False
|
|
LblFecha.Text = Dr("FechaDocumento").ToString.ToDate.ToShortDateString
|
|
LblObservaciones.Text = Dr("Referencia").ToString
|
|
LblTipo.Text = Dr("Tipo").ToString
|
|
LblImporte.Text = Dr("Importe").ToString.FormatoNumero
|
|
UpModalVinculado.Update()
|
|
RegistraScript("$('#DModalVinculado').modal()")
|
|
End If
|
|
End If
|
|
ObjBancos.Dispose()
|
|
End If
|
|
GvDatos.DataSource = DtDatos
|
|
GvDatos.DataBind()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "IMPRESIONES"
|
|
|
|
Protected Sub LnkPdf_Click(sender As Object, e As EventArgs)
|
|
Formato = "PDF"
|
|
RegistraScript("$('#DModalSaldoFinalEdoCuenta').modal()")
|
|
End Sub
|
|
Protected Sub LnkExportar_Click(sender As Object, e As EventArgs)
|
|
Formato = "EXCEL"
|
|
RegistraScript("$('#DModalSaldoFinalEdoCuenta').modal()")
|
|
End Sub
|
|
|
|
Protected Sub BtnGenerarImpresion_Click(sender As Object, e As EventArgs)
|
|
RegistraScript("$('#DModalSaldoFinalEdoCuenta').modal('hide')")
|
|
GeneraPDF(Formato)
|
|
End Sub
|
|
Protected Sub GeneraPDF(Formato As String)
|
|
Dim params As List(Of ReportParameter) = New List(Of ReportParameter)()
|
|
Dim Imagen As System.IO.FileInfo = 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)
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", DateTime.Now.ToString()))
|
|
Dim FormatoFecha As DateTimeFormatInfo = CultureInfo.CurrentCulture.DateTimeFormat
|
|
Dim NombreMes As String = FormatoFecha.GetMonthName(txtFechaI.Text.ToDate.Month).ToUpper
|
|
params.Add(New ReportParameter("Encabezado", $"{DdlCuenta.SelectedItem.Text} {NombreMes} {txtFechaI.Text.ToDate.Year}"))
|
|
|
|
Dim Dt1 As New DataTable
|
|
Dt1 = DtDatos.FiltraParametros($"FueConciliado = 0 And Tipo = 'Abono'")
|
|
Dim TotalDt1 As Double = Dt1.SUM("Importe")
|
|
|
|
Dim Row1 As DataRow = Dt1.NewRow
|
|
Row1("Importe") = TotalDt1
|
|
Row1("Folio") = "Total"
|
|
Dt1.Rows.InsertAt(Row1, 0)
|
|
Dt1.AcceptChanges()
|
|
|
|
Dim Dt2 As New DataTable
|
|
Dt2 = DtDatosEdoCuenta.FiltraParametros($"FueConciliado = 0 And Tipo = 'Abono'")
|
|
Dim TotalDt2 As Double = Dt2.SUM("Importe")
|
|
|
|
Dim Row2 As DataRow = Dt2.NewRow
|
|
Row2("Importe") = TotalDt2
|
|
Row2("Folio") = "Total"
|
|
Dt2.Rows.InsertAt(Row2, 0)
|
|
Dt2.AcceptChanges()
|
|
|
|
Dim Dt3 As New DataTable
|
|
Dt3 = DtDatos.FiltraParametros($"FueConciliado = 0 And Tipo = 'Cargo'")
|
|
Dim TotalDt3 As Double = Dt3.SUM("Importe")
|
|
|
|
Dim Row3 As DataRow = Dt3.NewRow
|
|
Row3("Importe") = TotalDt3
|
|
Row3("Folio") = "Total"
|
|
Dt3.Rows.InsertAt(Row3, 0)
|
|
Dt3.AcceptChanges()
|
|
|
|
Dim Dt4 As New DataTable
|
|
Dt4 = DtDatosEdoCuenta.FiltraParametros($"FueConciliado = 0 And Tipo = 'Cargo'")
|
|
Dim TotalDt4 As Double = Dt4.SUM("Importe")
|
|
|
|
Dim Row4 As DataRow = Dt4.NewRow
|
|
Row4("Importe") = TotalDt4
|
|
Row4("Folio") = "Total"
|
|
Dt4.Rows.InsertAt(Row4, 0)
|
|
Dt4.AcceptChanges()
|
|
|
|
Dim lrds As List(Of ReportDataSource) = New List(Of ReportDataSource)()
|
|
Dim rds As ReportDataSource = New ReportDataSource()
|
|
rds.Name = "DataSet1"
|
|
rds.Value = Dt1
|
|
Dim rds2 As ReportDataSource = New ReportDataSource()
|
|
rds2.Name = "DataSet2"
|
|
rds2.Value = Dt2
|
|
Dim rds3 As ReportDataSource = New ReportDataSource()
|
|
rds3.Name = "DataSet3"
|
|
rds3.Value = Dt3
|
|
Dim rds4 As ReportDataSource = New ReportDataSource()
|
|
rds4.Name = "DataSet4"
|
|
rds4.Value = Dt4
|
|
lrds.Add(rds)
|
|
lrds.Add(rds2)
|
|
lrds.Add(rds3)
|
|
lrds.Add(rds4)
|
|
|
|
params.Add(New ReportParameter("SaldoFinalEstadoCuenta", (TxtSaldoFinal.Text.FormatoNumero)))
|
|
Dim SaldoFinalLibros As Double = (TxtSaldoFinal.Text.ToDouble - TotalDt1 + TotalDt2 + TotalDt3 - TotalDt4)
|
|
params.Add(New ReportParameter("SaldoFinalLibros", SaldoFinalLibros.FormatoNumero))
|
|
|
|
Dim SaldoFinalContabilidad As Double = 0
|
|
Dim SaldoFinalContabilidadComplementaria As Double = 0
|
|
If DdlCuenta.SelectedValue.ToEntero > 0 Then
|
|
Dim CveCuenta As Integer = 0
|
|
Dim CveCuentaComplementaria As Integer = 0
|
|
Dim CveMoneda As Integer = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros($"CveCuenta = {DdlCuenta.SelectedValue}").Rows(0)("CveMoneda").ToString.ToEntero
|
|
Dim ObjConta As New ClsContabilidad
|
|
If ObjConta.GetCuentas(-1, "-1", -1, UsuarioActual.CveEmpresa) Then
|
|
If ObjConta.DtResultados.FiltraParametros($"IdCompaq = {GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros($"CveCuenta = {DdlCuenta.SelectedValue}").Rows(0)("IdCtaContable").ToString}").Rows.Count > 0 Then
|
|
CveCuenta = ObjConta.DtResultados.FiltraParametros($"IdCompaq = {GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros($"CveCuenta = {DdlCuenta.SelectedValue}").Rows(0)("IdCtaContable").ToString}").Rows(0)("CveCuenta").ToString.ToEntero
|
|
If CveMoneda > 1 Then
|
|
CveCuentaComplementaria = ObjConta.DtResultados.FiltraParametros($"IdCompaq = {GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros($"CveCuenta = {DdlCuenta.SelectedValue}").Rows(0)("IdCtaContableComplementaria").ToString}").Rows(0)("CveCuenta").ToString.ToEntero
|
|
End If
|
|
End If
|
|
End If
|
|
If CveCuenta > 0 Then
|
|
If ObjConta.GetMovimientosAuxiliaresCatalogo(CveCuenta, txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, CveMoneda, "-1", UsuarioActual.CveEmpresa, "1") Then
|
|
If ObjConta.DtResultados.Rows.Count > 1 Then
|
|
SaldoFinalContabilidad = ObjConta.DtResultados.Rows(1)("SaldoActual").ToString.ToDouble
|
|
End If
|
|
End If
|
|
End If
|
|
If CveCuentaComplementaria > 0 Then
|
|
If ObjConta.GetMovimientosAuxiliaresCatalogo(CveCuentaComplementaria, txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, CveMoneda, "-1", UsuarioActual.CveEmpresa, "1") Then
|
|
If ObjConta.DtResultados.Rows.Count > 1 Then
|
|
SaldoFinalContabilidadComplementaria = ObjConta.DtResultados.Rows(1)("SaldoActual").ToString.ToDouble
|
|
End If
|
|
End If
|
|
End If
|
|
ObjConta.Dispose()
|
|
End If
|
|
|
|
params.Add(New ReportParameter("SaldoFinalContabilidad", (SaldoFinalContabilidad.FormatoNumero)))
|
|
params.Add(New ReportParameter("SaldoFinalContabilidadComplementaria", (SaldoFinalContabilidadComplementaria.FormatoNumero)))
|
|
params.Add(New ReportParameter("Diferencia", (SaldoFinalLibros - SaldoFinalContabilidad).FormatoNumero))
|
|
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", logouri))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
|
|
ImprimirPDF("Empresas/Grales/Formatos/Conciliacion.rdlc", lrds, params, $"Conciliacion Bancaria {NombreMes} {txtFechaI.Text.ToDate.Year}", Formato)
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
End Class
|