143 lines
5.4 KiB
VB.net
143 lines
5.4 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 tsl5.Datos
|
|
Imports tsWPFCore
|
|
Imports tsWPFCore.Comun
|
|
Imports bdGrupoSanchoToro.db
|
|
Imports bdGrupoSanchoToro.db.Utilidades
|
|
|
|
Public Class ucAsientosModelos
|
|
|
|
Dim bd As tscGrupoSanchoToro
|
|
|
|
|
|
|
|
Public Overrides ReadOnly Property idRegistroAplicacionActual As String
|
|
Get
|
|
Return "AsientosModelos"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property DescripcionRegistro As String
|
|
Get
|
|
Return "Asientos Modelos"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property NombreTablaBase As String
|
|
Get
|
|
Return "asientosmodelos"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides Sub EstableceDataContextSecundarios(Optional Background As Boolean = False)
|
|
End Sub
|
|
|
|
Public Overrides Sub EstableceTitulo()
|
|
Me.docpanel.Caption = "Asientos Modelos"
|
|
End Sub
|
|
|
|
Public Overrides Sub Cargado()
|
|
|
|
End Sub
|
|
|
|
Public Overrides Function EstableceDCPrincipal(Optional Background As Boolean = False, Optional FuerzaNuevo As Boolean = False, Optional Refrescar As Boolean = False) As tsUtilidades.EstadosAplicacion
|
|
If Background Or Refrescar Then ObtieneAsientosAsync(bd, False)
|
|
Return tsUtilidades.EstadosAplicacion.AplicacionSinIndice
|
|
End Function
|
|
|
|
|
|
Public Overrides Function ObtieneBD() As tsUtilidades.ItsContexto
|
|
bd = tscGrupoSanchoToro.NuevoContexto()
|
|
Return bd
|
|
End Function
|
|
|
|
|
|
|
|
Public Overrides Function ObtienePermisos() As tsUtilidades.Permisos
|
|
Return Comun.ObtienePermisos(Me.bd, "AP.CONTABILIDAD", idUsuario)
|
|
End Function
|
|
|
|
Public Function ObtieneAsientosModelos(BackGround As Boolean, TextoBusqueda As String) As List(Of asientosmodelos)
|
|
Dim rs As New List(Of asientosmodelos)
|
|
Dim parametros(0) As Object
|
|
Dim iNumExc As Integer = 0
|
|
Do
|
|
Try
|
|
If TextoBusqueda <> "" Then
|
|
Dim ExpresionBusqueda = tsWPFCore.Utilidades.Varias.GeneraExpresionBusqueda(TextoBusqueda, {"Importe"}, {"Codigo", "Descripcion"}, Nothing)
|
|
If ExpresionBusqueda <> "" Then
|
|
rs = bd.asientosmodelos.Where(ExpresionBusqueda, parametros).ToList
|
|
Else
|
|
rs = bd.asientosmodelos.ToList
|
|
End If
|
|
Dim Calfap() As String = {"NumeroDocumento", "Concepto"}
|
|
Dim Cnumap() As String = {"Debe", "Haber"}
|
|
Dim ExpBusAsi As String = tsWPFCore.Utilidades.Varias.GeneraExpresionBusqueda(TextoBusqueda, Cnumap, Calfap, Nothing)
|
|
Dim lap = bd.apuntesmodelo.Where(ExpBusAsi, parametros).Select(Function(x) x.idAsientoModeloNavigation).ToList
|
|
Dim ctas = TextoBusqueda.Split(" ").Where(Function(x) x.Length = bdGrupoSanchoToro.db.cuentas.LongitudCuentaFinal).ToArray
|
|
Dim lap2 = bd.apuntesmodelo.Where(Function(x) ctas.Contains(x.NumeroCuenta)).Select(Function(x) x.idAsientoModeloNavigation).ToList
|
|
rs = rs.Union(lap).Union(lap2).OrderBy(Function(x) x.Descripcion).ToList
|
|
Else
|
|
rs = bd.asientosmodelos.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 asientosmodelos)
|
|
Dim Busqueda As String
|
|
Busqueda = Me.teBusqueda.Text.Trim
|
|
If Background Then
|
|
Me.ContenedorAplicacion.IsEnabled = False
|
|
Await Task.Run(Sub()
|
|
rs = ObtieneAsientosModelos(Background, Busqueda)
|
|
End Sub)
|
|
Else
|
|
If DXSplashScreen.IsActive = False Then DXSplashScreen.Show(Of tsWPFCore.SplashScreenTecnosis)()
|
|
DXSplashScreen.SetState("Buscando Asientos Modelos ...")
|
|
rs = ObtieneAsientosModelos(Background, Busqueda)
|
|
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 ucAsientosModelos_BotonNuevoPulsado() Handles Me.BotonNuevoPulsado
|
|
FuncionesDinamicas.AbrirAP(New ucAsientoModelo, OtrosParametros)
|
|
|
|
End Sub
|
|
|
|
Private Sub ucAsientosModelos_Enlazar(Celda As EditGridCellData, Defecto As Boolean) Handles Me.Enlazar
|
|
Dim id As Integer = DirectCast(Me.gc.SelectedItems(0), asientosmodelos).idAsientoModelo
|
|
FuncionesDinamicas.AbrirAP(New ucAsientoModelo(id), OtrosParametros)
|
|
End Sub
|
|
Private Sub BtBuscar_Click(sender As Object, e As RoutedEventArgs)
|
|
ObtieneAsientosAsync(bd, False)
|
|
End Sub
|
|
|
|
|
|
|
|
End Class
|