2026-01-30-v2
This commit is contained in:
@@ -0,0 +1,189 @@
|
||||
|
||||
|
||||
Imports System.Data.Entity
|
||||
Imports DevExpress.Xpf.Core.ServerMode
|
||||
Imports bdGrupoSanchoToro
|
||||
Imports DevExpress.Xpf.Grid
|
||||
Imports DevExpress.Xpf.Core
|
||||
Imports System.Linq.Dynamic
|
||||
Imports tsl5.Datos
|
||||
Imports tsWPF
|
||||
Imports tsWPF.Comun
|
||||
Imports tsWPFCore.Comun
|
||||
Imports tsWPFCore
|
||||
Imports tsUtilidades
|
||||
Imports bdGrupoSanchoToro
|
||||
Imports bdGrupoSanchoToro.db
|
||||
Imports bdGrupoSanchoToro.db.Utilidades
|
||||
|
||||
Public Class ucDiarios
|
||||
|
||||
Dim bd As tscGrupoSanchoToro
|
||||
|
||||
Private _ListadoFiltrado As List(Of asientos)
|
||||
Public Overrides Sub EstableceTitulo()
|
||||
Me.docpanel.Caption = "Asientos"
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Public Overrides ReadOnly Property idRegistroAplicacionActual As String
|
||||
Get
|
||||
Return "Asientos"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Overrides ReadOnly Property DescripcionRegistro As String
|
||||
Get
|
||||
Return "Asientos Diarios"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Overrides ReadOnly Property NombreTablaBase As String
|
||||
Get
|
||||
Return "asientos"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Overrides Sub EstableceDataContextSecundarios(Optional Background As Boolean = False)
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Public Overrides Sub Cargado()
|
||||
Dim Ejercicios = bd.ejercicioscontables.OrderByDescending(Function(x) x.FechaInicio).ToList
|
||||
HabilitarRefresco = True
|
||||
Dim ejab = Ejercicios.Where(Function(x) x.FechaCierre Is Nothing)
|
||||
deFechaInicio.EditValue = ejab.OrderBy(Function(x) x.FechaInicio).First.FechaInicio
|
||||
deFechaFin.EditValue = ejab.OrderByDescending(Function(x) x.FechaFin).First.FechaFin
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Public Overrides Function EstableceDCPrincipal(Optional Background As Boolean = False, Optional FuerzaNuevo As Boolean = False, Optional Refrescar As Boolean = False) As EstadosAplicacion
|
||||
If Background Then ObtieneAsientosAsync(bd, Background)
|
||||
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(ListadoFiltrado As List(Of asientos), TextoBusqueda As String, TituloCamposBusqueda As String, CamposBusquedaAlfabeticos() As String, CamposBusquedaNumericos() As String, FechaInicio As Date, FechaFin As Date)
|
||||
|
||||
' InitializeComponent()
|
||||
' _ListadoFiltrado = ListadoFiltrado
|
||||
|
||||
' Me.lgFiltrosBusquedaRapida.Visibility = Visibility.Visible
|
||||
' Me.lgFiltrosBusquedaAvanzada.Visibility = Visibility.Collapsed
|
||||
' Me.teBusqueda.Text = TextoBusqueda
|
||||
' Me.tbCamposBusqueda.Text = TituloCamposBusqueda
|
||||
' Me.deFechaInicio.EditValue = FechaInicio
|
||||
' Me.deFechaFin.EditValue = FechaFin
|
||||
' _CamposBusquedaAlfabeticos = CamposBusquedaAlfabeticos
|
||||
' _CamposBusquedaNumericos = CamposBusquedaNumericos
|
||||
|
||||
'End Sub
|
||||
|
||||
Public Sub New()
|
||||
|
||||
' Esta llamada es exigida por el diseñador.
|
||||
InitializeComponent()
|
||||
|
||||
|
||||
|
||||
' Agregue cualquier inicialización después de la llamada a InitializeComponent().
|
||||
|
||||
End Sub
|
||||
Public Function ObtieneAsientos(BackGround As Boolean, TextoBusqueda As String, FechaInicio As Date, FechaFin As Date) As List(Of asientos)
|
||||
Dim rs As New List(Of asientos)
|
||||
Dim parametros(0) As Object
|
||||
Dim iNumExc As Integer = 0
|
||||
Do
|
||||
Try
|
||||
If TextoBusqueda <> "" Then
|
||||
Dim ExpresionBusqueda = tsWPFCore.Utilidades.Varias.GeneraExpresionBusqueda(TextoBusqueda, {"Importe"}, Nothing, Nothing)
|
||||
'If ExpresionBusqueda <> "" Then
|
||||
' rs = bd.asientos.Where(ExpresionBusqueda, parametros).Where(Function(x) x.Fecha >= FechaInicio And x.Fecha <= FechaFin).ToList
|
||||
'Else
|
||||
' rs = bd.asientos.Where(Function(x) x.Fecha >= FechaInicio And x.Fecha <= FechaFin).ToList
|
||||
'End If
|
||||
Dim Calfap() As String = {"NumeroDocumento", "Concepto"}
|
||||
Dim Cnumap() As String = {"idAsiento", "Debe", "Haber"}
|
||||
Dim ExpBusAsi As String = tsWPF.Utilidades.Varias.GeneraExpresionBusqueda(TextoBusqueda, Cnumap, Calfap, Nothing)
|
||||
Dim lap = bd.apuntes.Where(ExpBusAsi, parametros).Select(Function(x) x.asientos).Where(Function(x) x.Fecha >= FechaInicio And x.Fecha <= FechaFin).ToList
|
||||
Dim ctas = TextoBusqueda.Split(" ").Where(Function(x) x.Length = bdGrupoSanchoToro.db.cuentas.LongitudCuentaFinal).ToArray
|
||||
Dim lap2 = bd.apuntes.Where(Function(x) ctas.Contains(x.cuentas.NumeroCuenta)).Select(Function(x) x.asientos).Where(Function(x) x.Fecha >= FechaInicio And x.Fecha <= FechaFin).ToList
|
||||
rs = lap.Union(lap2).OrderBy(Function(x) x.Fecha).ThenBy(Function(x) x.Fecha).ToList
|
||||
Else
|
||||
rs = bd.asientos.Where(Function(x) x.Fecha >= FechaInicio And x.Fecha <= FechaFin).ToList
|
||||
End If
|
||||
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 rs
|
||||
End Function
|
||||
|
||||
Public Async Sub ObtieneAsientosAsync(bd As tscGrupoSanchoToro, Background As Boolean)
|
||||
Try
|
||||
|
||||
|
||||
Dim rs As New List(Of asientos)
|
||||
Dim fi, ff As Date?
|
||||
Dim Busqueda As String
|
||||
|
||||
Busqueda = Me.teBusqueda.Text.Trim
|
||||
fi = deFechaInicio.EditValue
|
||||
ff = deFechaFin.EditValue
|
||||
If Background Then
|
||||
Me.ContenedorAplicacion.IsEnabled = False
|
||||
Await Task.Run(Sub()
|
||||
rs = ObtieneAsientos(Background, Busqueda, fi, ff)
|
||||
End Sub)
|
||||
Else
|
||||
If DXSplashScreen.IsActive = False Then DXSplashScreen.Show(Of tsWPFCore.SplashScreenTecnosis)()
|
||||
DXSplashScreen.SetState("Buscando Asientos ...")
|
||||
rs = ObtieneAsientos(Background, Busqueda, fi, ff)
|
||||
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
|
||||
Dim r As New ucDiario
|
||||
FuncionesDinamicas.AbrirAP(r, 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), asientos).idAsiento
|
||||
FuncionesDinamicas.AbrirAP(New ucDiario(id), OtrosParametros)
|
||||
End Sub
|
||||
|
||||
Private Sub BtBuscar_Click(sender As Object, e As RoutedEventArgs)
|
||||
ObtieneAsientosAsync(bd, False)
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user