Agregar archivos de proyecto.
This commit is contained in:
272
GestionGrupoSanchoToro/ucMovimientosCaja.xaml.vb
Normal file
272
GestionGrupoSanchoToro/ucMovimientosCaja.xaml.vb
Normal file
@@ -0,0 +1,272 @@
|
||||
|
||||
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 bdGrupoSanchoToro.db.Utilidades
|
||||
Imports bdGrupoSanchoToro.db.tscGrupoSanchoToro
|
||||
Imports System.IO
|
||||
Imports tsEFCore8.Extensiones
|
||||
|
||||
Public Class ucMovimientosCaja
|
||||
|
||||
|
||||
Private bd As tscGrupoSanchoToro
|
||||
|
||||
Private _CamposBusquedaNumericos() As String = {"idAlbaranEntrega", "idMovimiento", "Importe"}
|
||||
Private _CamposBusquedaAlfabeticos() As String = {"movimientos.entidades.RazonSocial", "movimientos.entidades.NIF", "movimientos.NumeroFactura", "movimientosrecibidas.entidades.RazonSocial", "movimientosrecibidas.entidades.NIF", "movimientosrecibidas.NumeroFactura"}
|
||||
|
||||
|
||||
|
||||
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
|
||||
Dim Hoy = Date.Today
|
||||
teFechaFin.EditValue = Hoy
|
||||
teFechaInicio.EditValue = Hoy.AddDays(-30)
|
||||
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 OrElse Refrescar Then ObtienemovimientosAsync(bd, Background)
|
||||
Return tsUtilidades.EstadosAplicacion.AplicacionSinIndice
|
||||
End Function
|
||||
|
||||
Public Overrides Sub EstableceDataContextSecundarios(Optional Background As Boolean = False)
|
||||
Dim Acciones As New List(Of tsWPFCore.Accion)
|
||||
Acciones.Add(New Accion With {
|
||||
.idAccion = 1,
|
||||
.Descripcion = "ENVIA EXCEL DE MOVIMIENTOS SELECCIONADOS A ASESORIA"})
|
||||
Me.ContenedorAplicacion.cbAcciones.ItemsSource = Acciones
|
||||
Me.ContenedorAplicacion.beAcciones.EditValue = Acciones.First.idAccion
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub EstableceTitulo()
|
||||
Me.docpanel.Caption = "Movimientos Caja"
|
||||
End Sub
|
||||
|
||||
Public Overrides ReadOnly Property idRegistroAplicacionActual As String
|
||||
Get
|
||||
Return "movimientoscaja"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Overrides ReadOnly Property NombreTablaBase As String
|
||||
Get
|
||||
Return "movimientoscaja"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Overrides ReadOnly Property DescripcionRegistro As String
|
||||
Get
|
||||
Return "Movimientos Caja"
|
||||
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 ucMovimientoCaja, 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, movimientoscaja)
|
||||
Select Case Celda.Column.FieldName.ToLower
|
||||
Case "referenciadocumento"
|
||||
Dim id As Integer
|
||||
If ra.idFactura.HasValue Then
|
||||
id = ra.idFactura
|
||||
' FuncionesDinamicas.AbrirAP(New ucFacturaEmitida(id), OtrosParametros)
|
||||
Else
|
||||
id = ra.idFacturaRecibida
|
||||
FuncionesDinamicas.AbrirAP(New ucFacturaRecibida(id), OtrosParametros)
|
||||
End If
|
||||
Case "razonsocial"
|
||||
Dim id As Integer
|
||||
If ra.idFactura.HasValue Then
|
||||
id = ra.idFacturaNavigation.idCliente
|
||||
Else
|
||||
id = ra.idFacturaRecibidaNavigation.idProveedor
|
||||
End If
|
||||
FuncionesDinamicas.AbrirAP(New ucEntidad(id), OtrosParametros)
|
||||
Case "idmovimiento"
|
||||
Dim id As Integer
|
||||
id = ra.idMovimiento
|
||||
FuncionesDinamicas.AbrirAP(New ucMovimientoCaja(id), OtrosParametros)
|
||||
Case "impresion"
|
||||
Select Case DirectCast(ra.Tipo, TipoMovimientoEnum)
|
||||
Case TipoMovimientoEnum.CIERRE_CAJA
|
||||
Dim lm As New List(Of movimientoscaja)
|
||||
lm.Add(ra)
|
||||
Dim xr As New xrCierreCaja
|
||||
Informes.ImprimeInforme(xr, False, 1, bd.AhoraMySql, lm)
|
||||
Case TipoMovimientoEnum.RECIBO_CLIENTE
|
||||
|
||||
|
||||
Dim ds As List(Of movimientoscaja)
|
||||
Dim pl = bd.plantillas.AsNoTracking.Where(Function(x) x.Codigo = "RECIBO").Select(Function(x) New With {.Fichero = x.idFicheroNavigation.Fichero, .Tipo = x.idGrupoNavigation.Codigo}).FirstOrDefault
|
||||
If pl IsNot Nothing Then
|
||||
ds = New List(Of movimientoscaja)
|
||||
ds.Add(ra)
|
||||
Informes.ImprimirPlantilla(bd, pl.Fichero, ds, False, 1)
|
||||
End If
|
||||
|
||||
End Select
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
|
||||
Public Function ObtieneMovimientosCaja(ByRef DataContext As Object, BackGround As Boolean, TextoBusqueda As String) As List(Of movimientoscaja)
|
||||
Dim rs As IQueryable(Of movimientoscaja)
|
||||
Dim lf As New List(Of movimientoscaja)
|
||||
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.movimientoscaja.Include(Function(x) x.idFacturaNavigation.idClienteNavigation).Include(Function(x) x.idFacturaRecibidaNavigation.idProveedorNavigation).Include(Function(x) x.idCajaNavigation).Include(Function(x) x.idUsuarioNavigation).Where(ExpresionBusqueda)
|
||||
Else
|
||||
rs = bd.movimientoscaja.Include(Function(x) x.idFacturaNavigation.idClienteNavigation).Include(Function(x) x.idFacturaRecibidaNavigation.idProveedorNavigation).Include(Function(x) x.idCajaNavigation).Include(Function(x) x.idUsuarioNavigation).OrderByDescending(Function(x) x.Fecha)
|
||||
End If
|
||||
Dim fi As Date? = teFechaInicio.EditValue
|
||||
If fi.HasValue Then
|
||||
rs = rs.Where(Function(x) x.Fecha >= fi.Value)
|
||||
End If
|
||||
Dim ff As Date? = teFechaFin.EditValue
|
||||
If ff.HasValue Then
|
||||
ff = ff.Value.AddDays(1)
|
||||
rs = rs.Where(Function(x) x.Fecha < ff.Value)
|
||||
End If
|
||||
If cbIncluirTodos.IsChecked = False Then
|
||||
rs = rs.Where(Function(x) x.idMovimientoCierre Is Nothing)
|
||||
End If
|
||||
lf = rs.OrderBy(Function(x) x.FechaCreacion).ToList
|
||||
Exit Do
|
||||
Catch ex As Exception
|
||||
iNumExc += 1
|
||||
If iNumExc > 3 Then
|
||||
rs = Nothing
|
||||
Exit Do
|
||||
End If
|
||||
End Try
|
||||
Loop
|
||||
Return lf
|
||||
End Function
|
||||
|
||||
Public Async Sub ObtienemovimientosAsync(bd As tscGrupoSanchoToro, Background As Boolean)
|
||||
Try
|
||||
Dim rs As New List(Of movimientoscaja)
|
||||
Dim Busqueda = tsEFCore8.Extensiones.ObjetoNothingAVacio(Me.teBusqueda.EditValue)
|
||||
If Background Then
|
||||
Me.ContenedorAplicacion.IsEnabled = False
|
||||
Await Task.Run(Sub()
|
||||
rs = ObtieneMovimientosCaja(bd, Background, Busqueda)
|
||||
End Sub)
|
||||
Else
|
||||
If DXSplashScreen.IsActive = False Then DXSplashScreen.Show(Of tsWPFCore.SplashScreenTecnosis)()
|
||||
DXSplashScreen.SetState("Buscando Movimientos Caja ...")
|
||||
rs = ObtieneMovimientosCaja(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)
|
||||
ObtienemovimientosAsync(bd, False)
|
||||
End Sub
|
||||
|
||||
Private Sub ucMovimientosCaja_EjecutarAccion(sender As Object, e As ItemClickEventArgs, idAccion As Integer) Handles Me.EjecutarAccion
|
||||
Select Case idAccion
|
||||
Case 1
|
||||
Dim tm As List(Of movimientoscaja) = gc.ItemsSource
|
||||
Try
|
||||
|
||||
Dim movs = gc.ElementosSeleccionados.Cast(Of movimientoscaja).ToList
|
||||
Dim sCorreo = bd.enumeraciones.First(Function(x) x.Codigo = "CONF.EMAILASESORIA").ValorAlfabeticoLargo
|
||||
Dim dxnc = New dxwEnvioCorreo(sCorreo, "", "", EmpresaActual.RazonSocial & " - Adjunto le remitimos listado de movimientos de caja", "Distinguidos Sres., " & vbCrLf & "Adjunto le remitimos listado de movimientos de caja", "MovimientosCaja.xlsx")
|
||||
If dxnc.ShowDialog Then
|
||||
Dim cta = bd.cuentascorreo.First(Function(x) x.Codigo = "DEFECTO" AndAlso x.idEmpresa = EmpresaActual.idEmpresa)
|
||||
gc.ItemsSource = movs
|
||||
Dim ms As New MemoryStream
|
||||
tv.ExportToXlsx(ms)
|
||||
' gc.ItemsSource = tf
|
||||
Dim bFacturas = ms.ToArray
|
||||
bdGrupoSanchoToro.db.correos.GeneraRegistroCorreon(bd, dxnc._Asunto, dxnc._Cuerpo, cta, dxnc._Destinatarios, dxnc._CC, dxnc._BCC, bFacturas, dxnc._Adjunto,, "MOVIMIENTOSCAJA")
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Throw New Exception(ex.Message, ex)
|
||||
Finally
|
||||
gc.ItemsSource = tm
|
||||
End Try
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
'Private Sub ucMovimientosCaja_ImprimirPlantilla(sender As Object, e As ItemClickEventArgs, idPlantilla As Integer) Handles Me.ImprimirPlantilla
|
||||
' Select Case idPlantilla
|
||||
' Case 0
|
||||
' If Me.DataContext IsNot Nothing Then
|
||||
' Dim recs = gc.ElementosSeleccionados.Cast(Of movimientoscaja).ToList
|
||||
' If recs Is Nothing OrElse recs.Count = 0 Then
|
||||
' DXMessageBox.Show("Seleccione primero algún recibo a imprimir", "Atención")
|
||||
' Else
|
||||
' If recs.Any(Function(x) x.Tipo <> TipoMovimientoEnum.RECIBO_CLIENTE) Then
|
||||
' DXMessageBox.Show("Solo se pueden imprimir recibos de cliente", "Atención")
|
||||
' Else
|
||||
' Dim lr As New List(Of movimientoscaja)
|
||||
' Dim cp As String = "RECIBO"
|
||||
' If rec.idFactura.HasValue AndAlso rec.facturas.PorcentajeIVA = 0 Then cp = "RECIBOSC"
|
||||
' Dim idPl = bd.plantillas.First(Function(x) x.Codigo = cp).idPlantilla
|
||||
' Informes.ImprimirPlantilla(bd, idPlantilla, lr, False, 1)
|
||||
' End If
|
||||
' End If
|
||||
' End If
|
||||
' End If
|
||||
' End Select
|
||||
'End Sub
|
||||
|
||||
'Private Sub ap_ImprimirPlantilla(sender As Object, e As ItemClickEventArgs, idPlantilla As Integer) Handles me.ImprimirPlantilla
|
||||
' Dim ds As List(Of movimientos)
|
||||
' Dim pl As plantillas = (From p In bd.plantillas Where p.idPlantilla = idPlantilla).First
|
||||
' Dim sTipo As String = pl.enumeraciones.Codigo
|
||||
' Dim al As movimientos = Me.DataContext
|
||||
' ds = New List(Of movimientos)
|
||||
' ds.Add(al)
|
||||
' Select Case sTipo
|
||||
' Case "GRUPLA.AV-ALBARANES"
|
||||
' Informes.ImprimirPlantilla(bd, idPlantilla, ds, False)
|
||||
' End Select
|
||||
'End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user