174 lines
5.8 KiB
VB.net
174 lines
5.8 KiB
VB.net
|
|
Imports bdGrupoSanchoToro.db
|
|
Imports System.Data.Entity
|
|
Imports DevExpress.Xpf.Core
|
|
Imports tsWPFCore
|
|
Imports System.Collections
|
|
Imports DevExpress.Xpf.Bars
|
|
Imports System.Threading.Tasks
|
|
Imports System.Linq.Dynamic
|
|
Imports Microsoft.EntityFrameworkCore
|
|
Imports System.Linq.Dynamic.Core
|
|
Imports bdGrupoSanchoToro.db.Utilidades
|
|
Imports Microsoft.Win32
|
|
Imports DevExpress.Spreadsheet
|
|
Imports bdGrupoSanchoToro.db.modelosgruas
|
|
Imports System.Drawing
|
|
|
|
Public Class ucModelosGruas
|
|
|
|
|
|
Private bd As tscGrupoSanchoToro
|
|
|
|
Private CamposBusquedaAlfabeticos() As String = {"marcasgruas.Marca", "Modelo", "Codigo"}
|
|
|
|
|
|
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 ReadOnly Property CampoIndice As String
|
|
' Get
|
|
' Return ""
|
|
' End Get
|
|
'End Property
|
|
|
|
Public Overrides Sub Cargado()
|
|
Me.GridSeleccion = Me.gc
|
|
Me.HabilitarRefresco = True
|
|
'ContenedorAplicacion.btGuardar.IsVisible = False
|
|
'ContenedorAplicacion.siEstado.IsVisible = False
|
|
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 Refrescar OrElse Background Then ObtienemodelosgruasAsync(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 = "modelosgruas"
|
|
End Sub
|
|
|
|
Public Overrides ReadOnly Property idRegistroAplicacionActual As String
|
|
Get
|
|
Return "modelosgruas"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property NombreTablaBase As String
|
|
Get
|
|
Return "modelosgruas"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property DescripcionRegistro As String
|
|
Get
|
|
Return "modelosgruas"
|
|
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.ADMINISTRATIVOS", idUsuario)
|
|
End Function
|
|
|
|
Private Sub Nuevo() Handles Me.BotonNuevoPulsado
|
|
FuncionesDinamicas.AbrirAP(New ucProducto, OtrosParametros)
|
|
End Sub
|
|
|
|
Private Sub ap_Enlazar(Celda As DevExpress.Xpf.Grid.EditGridCellData, Defecto As Boolean) Handles Me.Enlazar
|
|
|
|
Dim pr As productos = gc.CurrentItem
|
|
'If pr.Tipo = TipoProductoEnum.TRIBUNA Then
|
|
' FuncionesDinamicas.AbrirAP(New ucProductoTribuna(pr.idProducto), OtrosParametros)
|
|
'Else
|
|
FuncionesDinamicas.AbrirAP(New ucProducto(pr.idProducto), OtrosParametros)
|
|
'End If
|
|
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 Obtienemodelosgruas(TextoBusqueda As String, IncluirBajas As Boolean) As List(Of productos)
|
|
|
|
Dim iqPr = bd.productos.AsQueryable
|
|
If IncluirBajas = False Then iqPr = iqPr.Where(Function(x) x.FechaBaja Is Nothing)
|
|
Dim rs As List(Of productos)
|
|
Do
|
|
Dim iNumExc As Integer = 0
|
|
Try
|
|
If TextoBusqueda.Trim <> "" Then
|
|
If TextoBusqueda <> "" Then
|
|
Dim ExpresionBusqueda = tsWPFCore.Utilidades.Varias.GeneraExpresionBusqueda(TextoBusqueda, Nothing, Me.CamposBusquedaAlfabeticos, Nothing)
|
|
iqPr = iqPr.Where(ExpresionBusqueda)
|
|
End If
|
|
End If
|
|
rs = iqPr.OrderBy(Function(x) x.idMarcaNavigation.Marca).ThenBy(Function(x) x.Modelo).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 ObtienemodelosgruasAsync(bd As tscGrupoSanchoToro, Background As Boolean)
|
|
Try
|
|
Dim rs As New List(Of productos)
|
|
Dim Busqueda = tsEFCore8.Extensiones.ObjetoNothingAVacio(Me.teBusqueda.EditValue)
|
|
Dim IncluirBajas = Me.cbIncluirBajas.IsChecked
|
|
If Background Then
|
|
Me.ContenedorAplicacion.IsEnabled = False
|
|
Await Task.Run(Sub()
|
|
rs = Obtienemodelosgruas(Busqueda, IncluirBajas)
|
|
End Sub)
|
|
Else
|
|
If DXSplashScreen.IsActive = False Then DXSplashScreen.Show(Of tsWPFCore.SplashScreenTecnosis)()
|
|
DXSplashScreen.SetState("Buscando Modelos de Grúas ...")
|
|
rs = Obtienemodelosgruas(Busqueda, IncluirBajas)
|
|
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)
|
|
ObtienemodelosgruasAsync(bd, False)
|
|
End Sub
|
|
|
|
Private Sub ucmodelosgruas_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
teBusqueda.SelectAll()
|
|
End Sub
|
|
|
|
|
|
|
|
End Class
|