280 lines
12 KiB
VB.net
280 lines
12 KiB
VB.net
|
|
|
|
Imports System.Data.Entity
|
|
Imports DevExpress.Xpf.Core.ServerMode
|
|
Imports bdGrupoSanchoToro
|
|
Imports DevExpress.Xpf.Grid
|
|
Imports DevExpress.Xpf.Core
|
|
Imports System.Linq.Dynamic
|
|
Imports DevExpress.Xpf.Bars
|
|
Imports tsUtilidades.Datos
|
|
Imports tsWPF
|
|
Imports tsWPF.Comun
|
|
Imports tsWPFCore.Comun
|
|
Imports tsWPFCore
|
|
Imports tsUtilidades
|
|
Imports bdGrupoSanchoToro.db
|
|
Imports bdGrupoSanchoToro.db.Utilidades
|
|
Public Class ucCuentas
|
|
|
|
|
|
Dim bd As tscGrupoSanchoToro
|
|
|
|
|
|
Dim EjerContables As List(Of ejercicioscontables)
|
|
' Private _Ejercicios As List(Of Integer)
|
|
' Private _NivelCuentas As Integer
|
|
|
|
|
|
|
|
Public Overrides ReadOnly Property idRegistroAplicacionActual As String
|
|
Get
|
|
Return "CuentasContables"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property DescripcionRegistro As String
|
|
Get
|
|
Return "Cuentas"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property NombreTablaBase As String
|
|
Get
|
|
Return "cuentas"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides Sub EstableceDataContextSecundarios(Optional Background As Boolean = False)
|
|
If Me.ContenedorAplicacion.cbAcciones.ItemsSource Is Nothing Then
|
|
Dim Acciones As New List(Of tsWPFCore.Accion)
|
|
Acciones.Add(New Accion With {
|
|
.idAccion = 1,
|
|
.Descripcion = "LISTADO DIARIO CUENTAS SELECCIONADAS"})
|
|
Acciones.Add(New Accion With {
|
|
.idAccion = 2,
|
|
.Descripcion = "LISTADO DIARIO CUENTAS SELECCIONADAS (ANTES CIERRE)"})
|
|
Acciones.Add(New Accion With {
|
|
.idAccion = 3,
|
|
.Descripcion = "EXTRACTO DE CUENTAS (MAYOR)"})
|
|
|
|
Me.ContenedorAplicacion.cbAcciones.ItemsSource = Acciones
|
|
|
|
Me.ContenedorAplicacion.beAcciones.EditValue = Acciones.First.idAccion
|
|
End If
|
|
End Sub
|
|
|
|
Public Overrides Sub EstableceTitulo()
|
|
Me.docpanel.Caption = "Cuentas"
|
|
End Sub
|
|
|
|
Public Overrides Sub Cargado()
|
|
GridSeleccion = Me.gc
|
|
'Dim Ejercicios = bd.ejercicioscontables.OrderByDescending(Function(x) x.FechaInicio).ToList
|
|
|
|
'If Me.lgFiltrosBusquedaAvanzada.Visibility = Visibility.Visible Then
|
|
' cbEjerciciosBA.ItemsSource = Ejercicios
|
|
' Dim ejab = Ejercicios.Where(Function(x) x.FechaCierre Is Nothing)
|
|
' Me.cbEjerciciosBA.EditValue = ejab.Select(Function(x) x.idEjercicio).ToList
|
|
' cbNivelBA.ItemsSource = bdGrupoSanchoToro.cuentas.ListadoGruposCuentas
|
|
' cbNivelBA.EditValue = bdGrupoSanchoToro.cuentas.LongitudCuentaFinal
|
|
'Else
|
|
' cbEjercicios.ItemsSource = Ejercicios
|
|
' Me.cbEjercicios.EditValue = _Ejercicios
|
|
' cbNivel.ItemsSource = bdGrupoSanchoToro.cuentas.ListadoGruposCuentas
|
|
' cbNivel.EditValue = _NivelCuentas
|
|
'End If
|
|
End Sub
|
|
|
|
|
|
Public Overrides Function EstableceDCPrincipal(Optional Background As Boolean = False, Optional FuerzaNuevo As Boolean = False, Optional Refrescar As Boolean = False) As EstadosAplicacion
|
|
Dim Ejercicios = bd.ejercicioscontables.OrderByDescending(Function(x) x.FechaInicio).ToList
|
|
cbEjercicios.ItemsSource = Ejercicios
|
|
Me.cbEjercicios.EditValue = Ejercicios.Where(Function(x) x.FechaCierre.HasValue = False).Select(Function(x) x.idEjercicio).ToList
|
|
cbNivel.ItemsSource = bdGrupoSanchoToro.db.cuentas.ListadoGruposCuentas
|
|
cbNivel.EditValue = bdGrupoSanchoToro.db.cuentas.LongitudCuentaFinal
|
|
Return EstadosAplicacion.AplicacionSinIndice
|
|
End Function
|
|
|
|
Public Overrides Function ObtieneBD() As tsUtilidades.ItsContexto
|
|
bd = tscGrupoSanchoToro.NuevoContexto()
|
|
Return bd
|
|
End Function
|
|
|
|
'Public Overrides Function ObtieneConexionBD() As BBDD
|
|
' Return bdGrupoSanchoToro.gestionasegasaEntities.bdga
|
|
'End Function
|
|
|
|
Public Overrides Function ObtienePermisos() As tsUtilidades.Permisos
|
|
Return Comun.ObtienePermisos(Me.bd, "AP.CONTABILIDAD", idUsuario)
|
|
End Function
|
|
|
|
'Public Sub New(TextoBusqueda As String, TituloCamposBusqueda As String, CamposBusquedaAlfabeticos() As String, CamposBusquedaNumericos() As String, Ejercicios As List(Of Integer), NivelCuentas As Integer)
|
|
|
|
' InitializeComponent()
|
|
' ' _ListadoFiltrado = ListadoFiltrado
|
|
|
|
' Me.lgFiltrosBusquedaRapida.Visibility = Visibility.Visible
|
|
' Me.lgFiltrosBusquedaAvanzada.Visibility = Visibility.Collapsed
|
|
' Me.teBusqueda.Text = TextoBusqueda
|
|
' Me.tbCamposBusqueda.Text = TituloCamposBusqueda
|
|
' _Ejercicios = Ejercicios
|
|
' _CamposBusquedaAlfabeticos = CamposBusquedaAlfabeticos
|
|
' _CamposBusquedaNumericos = CamposBusquedaNumericos
|
|
' _NivelCuentas = NivelCuentas
|
|
'End Sub
|
|
|
|
Public Sub New()
|
|
|
|
' Esta llamada es exigida por el diseñador.
|
|
InitializeComponent()
|
|
'Me.lgFiltrosBusquedaRapida.Visibility = Visibility.Collapsed
|
|
'Me.lgFiltrosBusquedaAvanzada.Visibility = Visibility.Visible
|
|
' Agregue cualquier inicialización después de la llamada a InitializeComponent().
|
|
|
|
End Sub
|
|
|
|
Public Function ObtieneCuentas(BackGround As Boolean, TextoBusqueda As String, Ejercicios() As Integer, Nivel As Integer) As List(Of vf_cuentas)
|
|
Dim iNumExc As Integer = 0
|
|
Dim ctas As List(Of vf_cuentas)
|
|
Do
|
|
Try
|
|
Dim ExpresionBusqueda As String = ""
|
|
If TextoBusqueda <> "" Then
|
|
'Dim CamposBusquedaNumericos() As String = {"TotalDebe", "TotalHaber"}
|
|
Dim CamposBusquedaAlfabeticos() As String = {"Denominacion", "Mote"}
|
|
Dim CamposBusquedaAlfabeticosPorComienzo() As String = {"NumeroCuenta"}
|
|
ExpresionBusqueda = tsWPFCore.Utilidades.Varias.GeneraExpresionBusqueda(TextoBusqueda, Nothing, CamposBusquedaAlfabeticos, Nothing, CamposBusquedaAlfabeticosPorComienzo)
|
|
End If
|
|
ctas = bdGrupoSanchoToro.db.vf_cuentas.Obtiene_vf_cuentas(bd, Ejercicios, Nivel, ExpresionBusqueda)
|
|
Exit Do
|
|
Catch ex As Exception
|
|
If BackGround = False Then Throw New Exception(ex.Message, ex)
|
|
iNumExc += 1
|
|
If iNumExc > 3 Then
|
|
Throw New Exception(ex.Message, ex)
|
|
End If
|
|
End Try
|
|
Loop
|
|
Return ctas
|
|
End Function
|
|
Public Async Sub ObtienecuentasAsync(bd As tscGrupoSanchoToro, Background As Boolean)
|
|
Try
|
|
Dim rs As New List(Of vf_cuentas)
|
|
Dim ejercicios As New List(Of Integer)
|
|
Dim Nivel As Integer
|
|
Dim Busqueda As String
|
|
Busqueda = Me.teBusqueda.Text.Trim
|
|
If cbEjercicios.EditValue IsNot Nothing Then
|
|
If cbEjercicios.EditValue.GetType Is GetType(List(Of Object)) Then
|
|
Dim loej As List(Of Object) = cbEjercicios.EditValue
|
|
For Each ej In loej
|
|
ejercicios.Add(CType(ej, Integer))
|
|
Next
|
|
Else
|
|
ejercicios = TryCast(cbEjercicios.EditValue, List(Of Integer))
|
|
End If
|
|
End If
|
|
Nivel = cbNivel.EditValue
|
|
If Background Then
|
|
Me.ContenedorAplicacion.IsEnabled = False
|
|
Await Task.Run(Sub()
|
|
rs = ObtieneCuentas(Background, Busqueda, ejercicios.ToArray, Nivel)
|
|
End Sub)
|
|
Else
|
|
If DXSplashScreen.IsActive = False Then DXSplashScreen.Show(Of tsWPFCore.SplashScreenTecnosis)()
|
|
DXSplashScreen.SetState("Buscando cuentas ...")
|
|
rs = ObtieneCuentas(Background, Busqueda, ejercicios.ToArray, Nivel)
|
|
End If
|
|
gc.ItemsSource = rs
|
|
DataContext = rs
|
|
Catch ex As Exception
|
|
If DXSplashScreen.IsActive Then DXSplashScreen.Close()
|
|
DXMessageBox.Show(ex.Message, "Error")
|
|
Finally
|
|
Me.ContenedorAplicacion.IsEnabled = True
|
|
If DXSplashScreen.IsActive Then DXSplashScreen.Close()
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub Nuevo() Handles Me.BotonNuevoPulsado
|
|
FuncionesDinamicas.AbrirAP(New ucCuenta(), OtrosParametros)
|
|
End Sub
|
|
|
|
Private Sub ApLineas_Enlazar(Celda As EditGridCellData, Defecto As Boolean) Handles Me.Enlazar
|
|
Dim id As Integer = DirectCast(Me.gc.SelectedItems(0), vf_cuentas).idCuenta
|
|
Dim uc As New ucCuenta(id)
|
|
FuncionesDinamicas.AbrirAP(uc, OtrosParametros)
|
|
End Sub
|
|
|
|
Private Sub BtBuscar_Click(sender As Object, e As RoutedEventArgs)
|
|
'Dim Nivel As Integer = cbNivel.EditValue
|
|
'gcGrupo1.Visible = Nivel > 1
|
|
'gcGrupo2.Visible = Nivel > 2
|
|
'gcGrupo3.Visible = Nivel > 3
|
|
'gcGrupo4.Visible = Nivel > 4
|
|
|
|
ObtienecuentasAsync(bd, False)
|
|
End Sub
|
|
'Private Sub CbEjerciciosBA_EditValueChanged(sender As Object, e As DevExpress.Xpf.Editors.EditValueChangedEventArgs)
|
|
' ObtienecuentasAsync(bd, False, True)
|
|
'End Sub
|
|
|
|
Private Sub CbNivelBA_EditValueChanged(sender As Object, e As DevExpress.Xpf.Editors.EditValueChangedEventArgs)
|
|
'Dim Nivel = CInt(e.NewValue)
|
|
'gcGrupo1.Visible = Nivel > 1
|
|
'gcGrupo2.Visible = Nivel > 2
|
|
'gcGrupo3.Visible = Nivel > 3
|
|
'gcGrupo4.Visible = Nivel > 4
|
|
|
|
End Sub
|
|
|
|
Private Sub ApLineas_EjecutarAccion(sender As Object, e As ItemClickEventArgs, idAccion As Integer) Handles Me.EjecutarAccion
|
|
Try
|
|
Select Case idAccion
|
|
Case 1 'LISTADO DE DIARIO INCLUIDO CIERRE
|
|
Dim vf_ctas = gc.ElementosSeleccionados.Cast(Of vf_cuentas).ToList
|
|
If vf_ctas.Count = 0 Then
|
|
DXMessageBox.Show("Antes debe seleccionar las cuentas para el listado.", "Atención")
|
|
Else
|
|
If DXSplashScreen.IsActive = False Then DXSplashScreen.Show(Of tsWPFCore.SplashScreenTecnosis)()
|
|
DXSplashScreen.SetState("Buscando cuentas ...")
|
|
Dim lc As New List(Of cuentas)
|
|
For Each ct In vf_ctas
|
|
Dim CUENTA = bd.cuentas.First(Function(x) x.idCuenta = ct.idCuenta)
|
|
CUENTA.RellenaApuntesTemporales(True)
|
|
lc.Add(CUENTA)
|
|
Next
|
|
Dim idp = bd.plantillas.First(Function(x) x.Codigo = "CONTA.DIACUEN").idPlantilla
|
|
DXSplashScreen.Close()
|
|
Informes.MuestraImpresos(bd, idp, lc, Me.GrupoDocumentos, dm.DockController)
|
|
End If
|
|
Case 2 'LISTADO DE DIARIO SIN CIERRE
|
|
Dim vf_ctas = gc.ElementosSeleccionados.Cast(Of vf_cuentas).ToList
|
|
If vf_ctas.Count = 0 Then
|
|
DXMessageBox.Show("Antes debe seleccionar las cuentas para el listado.", "Atención")
|
|
Else
|
|
If DXSplashScreen.IsActive = False Then DXSplashScreen.Show(Of tsWPFCore.SplashScreenTecnosis)()
|
|
DXSplashScreen.SetState("Buscando cuentas ...")
|
|
Dim lc As New List(Of cuentas)
|
|
For Each ct In vf_ctas
|
|
Dim CUENTA = bd.cuentas.First(Function(x) x.idCuenta = ct.idCuenta)
|
|
CUENTA.RellenaApuntesTemporales(False)
|
|
lc.Add(CUENTA)
|
|
Next
|
|
Dim idp = bd.plantillas.First(Function(x) x.Codigo = "CONTA.DIACUEN").idPlantilla
|
|
DXSplashScreen.Close()
|
|
Informes.MuestraImpresos(bd, idp, lc, Me.GrupoDocumentos, dm.DockController)
|
|
End If
|
|
Case 3
|
|
Dim uc As New ucApuntes
|
|
FuncionesDinamicas.AbrirAP(uc, OtrosParametros)
|
|
End Select
|
|
Catch ex As Exception
|
|
If DXSplashScreen.IsActive Then DXSplashScreen.Close()
|
|
FuncionesDinamicas.ErrorNoControladoAp(Me, ex)
|
|
DXMessageBox.Show(ex.Message, "Error")
|
|
End Try
|
|
End Sub
|
|
End Class
|