159 lines
5.4 KiB
VB.net
159 lines
5.4 KiB
VB.net
Imports System.Data.Entity
|
|
Imports DevExpress.Xpf.Core
|
|
|
|
|
|
Imports System.Collections
|
|
Imports DevExpress.Xpf.Bars
|
|
Imports System.Threading.Tasks
|
|
Imports System.Linq.Dynamic
|
|
Imports tsWPFCore.Comun
|
|
Imports tsWPFCore
|
|
Imports tsUtilidades
|
|
Imports bdGrupoSanchoToro
|
|
Imports bdGrupoSanchoToro.db
|
|
Imports bdGrupoSanchoToro.db.Utilidades
|
|
|
|
Public Class ucConceptosApuntes
|
|
|
|
Private bd As tscGrupoSanchoToro
|
|
|
|
Private _CamposBusquedaNumericos() As String = {"idConcepto"}
|
|
Private _CamposBusquedaAlfabeticos() As String = {"Codigo", "Concepto"}
|
|
|
|
|
|
|
|
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 Overrides Sub Cargado()
|
|
ContenedorAplicacion.btGuardar.IsVisible = False
|
|
ContenedorAplicacion.siEstado.IsVisible = False
|
|
Me.HabilitarRefresco = True
|
|
|
|
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 Or Refrescar Then ObtieneConceptosApuntesAsync(Background)
|
|
Return EstadosAplicacion.AplicacionSinIndice
|
|
End Function
|
|
|
|
Public Overrides Sub EstableceDataContextSecundarios(Optional Background As Boolean = False)
|
|
|
|
End Sub
|
|
|
|
Public Overrides Sub EstableceTitulo()
|
|
Me.docpanel.Caption = "Conceptos Apuntes"
|
|
End Sub
|
|
|
|
Public Overrides ReadOnly Property idRegistroAplicacionActual As String
|
|
Get
|
|
Return "ConceptosApuntes"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property NombreTablaBase As String
|
|
Get
|
|
Return "conceptosapuntes"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property DescripcionRegistro As String
|
|
Get
|
|
Return "Conceptos Apuntes"
|
|
End Get
|
|
End Property
|
|
|
|
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
|
|
|
|
Private Sub Nuevo() Handles Me.BotonNuevoPulsado
|
|
Dim r As New ucConceptoApuntes
|
|
FuncionesDinamicas.AbrirAP(r, OtrosParametros)
|
|
End Sub
|
|
|
|
Private Sub ap_Enlazar(Celda As DevExpress.Xpf.Grid.EditGridCellData, Defecto As Boolean) Handles Me.Enlazar
|
|
Dim ra = DirectCast(Me.gc.CurrentItem, conceptosapuntes)
|
|
Select Case Celda.Column.FieldName.ToLower
|
|
Case "idconcepto"
|
|
Dim id As Integer = ra.idConcepto
|
|
FuncionesDinamicas.AbrirAP(New ucConceptoApuntes(id), OtrosParametros)
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub ap_AntesGuardar(sender As Object, e As ItemClickEventArgs, ByRef Cancelar As Boolean, ByRef MensajesError As Hashtable, OpcionGuardado As Integer) Handles Me.AntesGuardar
|
|
|
|
End Sub
|
|
Public Function ObtieneConceptosApuntes(ByRef Background As Boolean, TextoBusqueda As String) As List(Of conceptosapuntes)
|
|
Dim rs As IQueryable(Of conceptosapuntes)
|
|
Dim lf As New List(Of conceptosapuntes)
|
|
Dim iNumExc As Integer = 0
|
|
Do
|
|
Try
|
|
If TextoBusqueda <> "" Then
|
|
Dim parametros(0) As Object
|
|
Dim ExpresionBusqueda = tsWPFCore.Utilidades.Varias.GeneraExpresionBusqueda(TextoBusqueda, Me._CamposBusquedaNumericos, Me._CamposBusquedaAlfabeticos, Nothing)
|
|
rs = bd.conceptosapuntes.Where(ExpresionBusqueda, parametros)
|
|
Else
|
|
rs = bd.conceptosapuntes.OrderByDescending(Function(x) x.Concepto)
|
|
End If
|
|
lf = rs.ToList
|
|
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 lf
|
|
End Function
|
|
|
|
Public Async Sub ObtieneConceptosApuntesAsync(Background As Boolean)
|
|
Try
|
|
Dim rs As New List(Of conceptosapuntes)
|
|
Dim Busqueda As String = Me.teBusqueda.EditValue.ToString
|
|
If Background Then
|
|
Me.ContenedorAplicacion.IsEnabled = False
|
|
Await Task.Run(Sub()
|
|
rs = ObtieneConceptosApuntes(Background, Busqueda)
|
|
End Sub)
|
|
Else
|
|
If DXSplashScreen.IsActive = False Then DXSplashScreen.Show(Of tsWPFCore.SplashScreenTecnosis)()
|
|
DXSplashScreen.SetState("Buscando Facturas Recibidas ...")
|
|
rs = ObtieneConceptosApuntes(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 BtBuscar_Click(sender As Object, e As RoutedEventArgs)
|
|
ObtieneConceptosApuntesAsync(False)
|
|
End Sub
|
|
|
|
|
|
End Class
|