209 lines
8.0 KiB
VB.net
209 lines
8.0 KiB
VB.net
|
|
Imports bdGrupoSanchoToro.db
|
|
Imports DevExpress.Xpf.Core
|
|
Imports tsWPFCore
|
|
Imports System.Collections
|
|
Imports DevExpress.Xpf.Bars
|
|
Imports System.Threading.Tasks
|
|
Imports System.Linq.Dynamic
|
|
Imports bdGrupoSanchoToro.db.Utilidades
|
|
Imports bdGrupoSanchoToro.tscGrupoSanchoToro
|
|
Imports tsUtilidades
|
|
'Imports tsUtilidades.Extensiones
|
|
|
|
Public Class ucAlbaranes
|
|
|
|
Private bd As tscGrupoSanchoToro
|
|
Private _CamposBusquedaNumericos() As String = {"idAlbaran"}
|
|
Private _CamposBusquedaAlfabeticos() As String = {"RazonSocial", "NIF"}
|
|
|
|
|
|
|
|
|
|
Public Sub New()
|
|
|
|
' Esta llamada es exigida por el diseñador.
|
|
InitializeComponent()
|
|
' Me.BusquedaRapida.Visibility = Visibility.Collapsed
|
|
' 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
|
|
GridBusqueda = Me.gc
|
|
'Dim Hoy = Date.Today
|
|
'teFechaFin.EditValue = Hoy
|
|
'teFechaInicio.EditValue = New Date(Hoy.Year, 1, 1)
|
|
End Sub
|
|
|
|
|
|
Public Overrides Function EstablecedcPrincipal(Optional Background As Boolean = False, Optional FuerzaNuevo As Boolean = False, Optional Refrescar As Boolean = False) As tsUtilidades.EstadosAplicacion
|
|
Try
|
|
If cbTipos.ItemsSource Is Nothing Then
|
|
Dim tipos = tsUtilidades.DescripcionValor.EnumADescripcionValor(GetType(bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum))
|
|
cbTipos.ItemsSource = tipos
|
|
cbTipos.EditValue = tipos.Cast(Of DescripcionValor).Select(Function(x) x.Valor).ToList
|
|
End If
|
|
If Background OrElse Refrescar Then ObtieneAlbaranesAsync(bd, Background)
|
|
Return tsUtilidades.EstadosAplicacion.AplicacionSinIndice
|
|
Catch ex As Exception
|
|
Throw New Exception(ex.Message, ex)
|
|
End Try
|
|
End Function
|
|
|
|
Public Overrides Sub EstableceDataContextSecundarios(Optional Background As Boolean = False)
|
|
|
|
End Sub
|
|
|
|
Public Overrides Sub EstableceTitulo()
|
|
Me.docpanel.Caption = "Albaranes"
|
|
End Sub
|
|
|
|
Public Overrides ReadOnly Property idRegistroAplicacionActual As String
|
|
Get
|
|
Return "Albaranes"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property NombreTablaBase As String
|
|
Get
|
|
Return "albaranes"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property DescripcionRegistro As String
|
|
Get
|
|
Return "Albaranes"
|
|
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 ucAlbaran, 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, v_albaranesextendidos)
|
|
If Defecto Then
|
|
Dim id As Integer = ra.idAlbaran
|
|
FuncionesDinamicas.AbrirAP(New ucAlbaran(id), OtrosParametros)
|
|
Else
|
|
Select Case Celda.Column.FieldName.ToLower
|
|
Case "numeroalbaran"
|
|
Dim id As Integer = ra.idAlbaran
|
|
FuncionesDinamicas.AbrirAP(New ucAlbaran(id), OtrosParametros)
|
|
Case "razonsocial"
|
|
Dim id As Integer = ra.idEntidad
|
|
FuncionesDinamicas.AbrirAP(New ucEntidad(id), OtrosParametros)
|
|
|
|
End Select
|
|
End If
|
|
End Sub
|
|
|
|
Public Function ObtieneAlbaranes(TextoBusqueda As String, FechaInicio As DateOnly?, FechaFin As DateOnly?, Tipos As List(Of Integer)) As List(Of v_albaranesextendidos)
|
|
Dim rs As IQueryable(Of v_albaranesextendidos)
|
|
Dim la As New List(Of v_albaranesextendidos)
|
|
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.v_albaranesextendidos.Where(ExpresionBusqueda)
|
|
Else
|
|
rs = bd.v_albaranesextendidos.AsQueryable
|
|
End If
|
|
|
|
If FechaInicio.HasValue Then
|
|
rs = rs.Where(Function(x) x.Fecha >= FechaInicio.Value)
|
|
End If
|
|
If FechaFin.HasValue Then
|
|
FechaFin = FechaFin.Value.AddDays(1)
|
|
rs = rs.Where(Function(x) x.Fecha < FechaFin.Value)
|
|
End If
|
|
la = rs.Where(Function(x) Tipos.Contains(x.Tipo)).OrderByDescending(Function(x) x.Fecha).ToList
|
|
Exit Do
|
|
Catch ex As Exception
|
|
iNumExc += 1
|
|
If iNumExc > 3 Then
|
|
FuncionesDinamicas.ErrorNoControladoAp(Me, ex)
|
|
|
|
rs = Nothing
|
|
Exit Do
|
|
End If
|
|
End Try
|
|
Loop
|
|
Return la
|
|
End Function
|
|
|
|
Public Async Sub ObtieneAlbaranesAsync(bd As tscGrupoSanchoToro, Background As Boolean)
|
|
Try
|
|
Dim rs As New List(Of v_albaranesextendidos)
|
|
Dim Busqueda = tsEFCore8.Extensiones.ObjetoNothingAVacio(Me.teBusqueda.EditValue)
|
|
Dim fi As DateOnly? : If teFechaInicio.EditValue IsNot Nothing Then fi = DateOnly.FromDateTime(teFechaInicio.EditValue)
|
|
Dim ff As DateOnly? : If teFechaFin.EditValue IsNot Nothing Then ff = DateOnly.FromDateTime(teFechaFin.EditValue)
|
|
Dim Tipos = cbTipos.SelectedItems.Cast(Of DescripcionValor).Select(Function(x) x.Valor).ToList
|
|
If Background Then
|
|
Me.ContenedorAplicacion.IsEnabled = False
|
|
Await Task.Run(Sub()
|
|
rs = ObtieneAlbaranes(Busqueda, fi, ff, Tipos)
|
|
End Sub)
|
|
Else
|
|
If DXSplashScreen.IsActive = False Then DXSplashScreen.Show(Of tsWPFCore.SplashScreenTecnosis)()
|
|
DXSplashScreen.SetState("Buscando Albaranes de Entrega ...")
|
|
rs = ObtieneAlbaranes(Busqueda, fi, ff, Tipos)
|
|
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)
|
|
ObtieneAlbaranesAsync(bd, False)
|
|
End Sub
|
|
|
|
Private Sub ucAlbaranes_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
teBusqueda.SelectAll()
|
|
End Sub
|
|
|
|
Private Sub cbIncluirTodos_Checked(sender As Object, e As RoutedEventArgs)
|
|
Dim Hoy = Date.Today
|
|
If teFechaFin.EditValue Is Nothing Then teFechaFin.EditValue = Hoy
|
|
If teFechaInicio.EditValue Is Nothing Then teFechaInicio.EditValue = New Date(Hoy.Year, 1, 1)
|
|
End Sub
|
|
|
|
|
|
|
|
'Private Sub ap_ImprimirPlantilla(sender As Object, e As ItemClickEventArgs, idPlantilla As Integer) Handles ImprimirPlantilla
|
|
' Dim ds As List(Of Albaranes)
|
|
' Dim pl As plantillas = (From p In bd.plantillas Where p.idPlantilla = idPlantilla).First
|
|
' Dim sTipo As String = pl.enumeraciones.Codigo
|
|
' Dim al As Albaranes = Me.DataContext
|
|
' ds = New List(Of Albaranes)
|
|
' ds.Add(al)
|
|
' Select Case sTipo
|
|
' Case "GRUPLA.AV-ALBARANES"
|
|
' Informes.ImprimirPlantilla(bd, idPlantilla, ds, False)
|
|
' End Select
|
|
'End Sub
|
|
End Class
|