158 lines
5.6 KiB
VB.net
158 lines
5.6 KiB
VB.net
|
|
|
|
Imports DevExpress.Xpf.Core
|
|
Imports tsWPFCore
|
|
Imports DevExpress.Xpf.Bars
|
|
Imports bdGrupoSanchoToro.db
|
|
Imports bdGrupoSanchoToro
|
|
Imports tsUtilidades
|
|
Imports System.Linq.Dynamic.Core
|
|
Imports bdGrupoSanchoToro.db.Utilidades
|
|
|
|
Public Class ucEntidades
|
|
Private bd As tscGrupoSanchoToro
|
|
Private _CamposBusquedaNumericos() As String = {"idEntidad"}
|
|
Private _CamposBusquedaAlfabeticos() As String = {"RazonSocial", "NIF", "Telefono1", "Telefono2", "Email"}
|
|
' Private _TextoBusqueda As String
|
|
|
|
|
|
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.GridSeleccion = Me.gc
|
|
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 Then ObtieneEntidadesAsync(bd, Background)
|
|
Return tsUtilidades.EstadosAplicacion.AplicacionSinIndice
|
|
End Function
|
|
|
|
Public Overrides Sub EstableceDataContextSecundarios(Optional Background As Boolean = False)
|
|
|
|
End Sub
|
|
|
|
Public Overrides Sub EstableceTitulo()
|
|
Me.docpanel.Caption = "Clientes/Proveedores"
|
|
End Sub
|
|
|
|
Public Overrides ReadOnly Property idRegistroAplicacionActual As String
|
|
Get
|
|
Return "Entidades"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property NombreTablaBase As String
|
|
Get
|
|
Return "entidades"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property DescripcionRegistro As String
|
|
Get
|
|
Return "Clientes / Proveedores"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides Function ObtieneBD() As ItsContexto
|
|
bd = tscGrupoSanchoToro.NuevoContexto
|
|
Return bd
|
|
End Function
|
|
|
|
|
|
Public Overrides Function ObtienePermisos() As tsUtilidades.Permisos
|
|
Return Comun.ObtienePermisos(Me.bd, "AP.ADMINISTRATIVOS", bdGrupoSanchoToro.db.Utilidades.idUsuario)
|
|
End Function
|
|
|
|
Private Sub Nuevo() Handles Me.BotonNuevoPulsado
|
|
FuncionesDinamicas.AbrirAP(New ucEntidad, OtrosParametros)
|
|
End Sub
|
|
|
|
Private Sub ap_Enlazar(Celda As DevExpress.Xpf.Grid.EditGridCellData, Defecto As Boolean) Handles Me.Enlazar
|
|
If Defecto = False AndAlso Celda.Column.FieldName.ToLower = "email" Then
|
|
tsUtilidades.Sistema.EjecutaFichero("mailto:" & DirectCast(Me.gc.CurrentItem, entidades).Email)
|
|
Else
|
|
Dim id As Integer = DirectCast(Me.gc.CurrentItem, entidades).idEntidad
|
|
FuncionesDinamicas.AbrirAP(New ucEntidad(id), OtrosParametros)
|
|
End If
|
|
End Sub
|
|
|
|
Public Function ObtieneEntidades(ByRef DataContext As Object, BackGround As Boolean, TextoBusqueda As String) As List(Of entidades)
|
|
Dim rs As New List(Of entidades)
|
|
Dim iqent = bd.entidades.Where(Function(x) x.idEmpresa = EmpresaActual.idEmpresa AndAlso x.NIF IsNot Nothing AndAlso x.NIF <> "").Include(Function(x) x.CodigoMunicipioNavigation.CodigoProvinciaNavigation).AsQueryable
|
|
If TextoBusqueda <> "" Then
|
|
Dim ExpresionBusqueda = tsWPFCore.Utilidades.Varias.GeneraExpresionBusqueda(TextoBusqueda, Me._CamposBusquedaNumericos, Me._CamposBusquedaAlfabeticos, Nothing)
|
|
iqent = iqent.Where(ExpresionBusqueda).ToList.OrderBy(Function(x) x.RazonSocial).AsQueryable
|
|
End If
|
|
|
|
Dim inumExc As Integer = 0
|
|
Do
|
|
|
|
Try
|
|
rs = iqent.ToList
|
|
Exit Do
|
|
Catch ex As Exception
|
|
iNumExc += 1
|
|
If iNumExc > 3 Then
|
|
rs = Nothing
|
|
Exit Do
|
|
End If
|
|
End Try
|
|
Loop
|
|
Return rs
|
|
End Function
|
|
|
|
Public Async Sub ObtieneEntidadesAsync(bd As tscGrupoSanchoToro, Background As Boolean)
|
|
Try
|
|
Dim rs As New List(Of entidades)
|
|
Dim Busqueda = tsEFCore8.Extensiones.ObjetoNothingAVacio(Me.teBusqueda.EditValue)
|
|
If Background Then
|
|
Me.ContenedorAplicacion.IsEnabled = False
|
|
Await Task.Run(Sub()
|
|
rs = ObtieneEntidades(bd, Background, Busqueda)
|
|
End Sub)
|
|
Else
|
|
If DXSplashScreen.IsActive = False Then DXSplashScreen.Show(Of tsWPFCore.SplashScreenTecnosis)()
|
|
DXSplashScreen.SetState("Buscando Entidades ...")
|
|
rs = ObtieneEntidades(bd, 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)
|
|
ObtieneEntidadesAsync(bd, False)
|
|
End Sub
|
|
|
|
Private Sub ucEntidades_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
teBusqueda.SelectAll()
|
|
End Sub
|
|
|
|
Private Sub gc_KeyDown(sender As Object, e As KeyEventArgs) Handles gc.KeyDown
|
|
Select Case e.Key
|
|
Case Key.Enter, Key.Space
|
|
If gc.CurrentItem IsNot Nothing Then ap_Enlazar(Nothing, True)
|
|
End Select
|
|
End Sub
|
|
|
|
|
|
End Class
|