Agregar archivos de proyecto.
This commit is contained in:
328
GestionGrupoSanchoToro/ucMovimientoCaja.xaml.vb
Normal file
328
GestionGrupoSanchoToro/ucMovimientoCaja.xaml.vb
Normal file
@@ -0,0 +1,328 @@
|
||||
Imports System.Data
|
||||
Imports DevExpress.Xpf.Core
|
||||
Imports bdGrupoSanchoToro.db
|
||||
Imports DevExpress.Xpf.Bars
|
||||
Imports bdGrupoSanchoToro.db.Utilidades
|
||||
Imports DevExpress.Xpf.Grid
|
||||
Imports tsEFCore8.Extensiones
|
||||
Imports Microsoft.Win32
|
||||
Imports tsUtilidades
|
||||
|
||||
Public Class ucMovimientoCaja
|
||||
|
||||
|
||||
Private bd As tscGrupoSanchoToro
|
||||
Friend _idMovimiento As Nullable(Of Integer)
|
||||
Friend idLog As Integer?
|
||||
Dim ra As movimientoscaja
|
||||
Public Overrides Function EstablecedcPrincipal(Optional Background As Boolean = False, Optional FuerzaNuevo As Boolean = False, Optional Refrescar As Boolean = False) As EstadosAplicacion
|
||||
|
||||
|
||||
Dim NuevoEstado As tsUtilidades.EstadosAplicacion
|
||||
|
||||
If idLog.HasValue Then
|
||||
Try
|
||||
Dim log = bd.logs.First(Function(x) x.idLog = idLog)
|
||||
ra = tsUtilidades.Utilidades.DeserializarSinErrores(log.Log, GetType(movimientoscaja))
|
||||
If ra.idUsuario.HasValue Then ra.idUsuarioNavigation = bd.usuarios.FirstOrDefault(Function(x) x.idUsuario = ra.idUsuario.Value)
|
||||
If ra.idFactura.HasValue Then
|
||||
ra.idFacturaNavigation = bd.facturas.FirstOrDefault(Function(x) x.idFactura = ra.idFactura)
|
||||
End If
|
||||
|
||||
If ra.idFacturaRecibida.HasValue Then
|
||||
ra.idFacturaRecibidaNavigation = bd.facturasrecibidas.FirstOrDefault(Function(x) x.idFactura = ra.idFacturaRecibida)
|
||||
End If
|
||||
Dim lfic = bd.logs.FirstOrDefault(Function(x) x.idRelacionado = log.idLog AndAlso x.Aplicacion = "FICHEROS")
|
||||
If lfic IsNot Nothing Then
|
||||
Dim fic As db.ficheros = tsUtilidades.Utilidades.DeserializarSinErrores(lfic.Log, GetType(db.ficheros))
|
||||
ra.idFicheroNavigation = fic
|
||||
End If
|
||||
NuevoEstado = tsUtilidades.EstadosAplicacion.ModificandoRegistro
|
||||
Catch EX As Exception
|
||||
Throw New Exception("No ha sido posible mostrar el registro del cambio (id " & idLog.Value.ToString & ").", EX)
|
||||
End Try
|
||||
Else
|
||||
If _idMovimiento.HasValue Then ra = bd.movimientoscaja.FirstOrDefault(Function(x) x.idMovimiento = _idMovimiento.Value)
|
||||
If Estado = tsUtilidades.EstadosAplicacion.Nuevo OrElse _idMovimiento Is Nothing OrElse FuerzaNuevo OrElse ra Is Nothing Then
|
||||
ra = New movimientoscaja
|
||||
ra.Tipo = bdGrupoSanchoToro.db.TipoMovimientoEnum.OTROS_GASTOS_O_INGRESOS
|
||||
Me.DataContext = ra
|
||||
_idMovimiento = Nothing
|
||||
ra.idUsuarioNavigation = bd.usuarios.First(Function(x) x.idUsuario = idUsuario)
|
||||
ra.FechaCreacion = bd.AhoraMySql
|
||||
ra.Fecha = ra.FechaCreacion
|
||||
If bd.cajas.Where(Function(x) x.idEmpresa = EmpresaActual.idEmpresa AndAlso x.FechaBaja.HasValue = False).Count = 1 Then
|
||||
ra.idCaja = bd.cajas.Where(Function(x) x.idEmpresa = EmpresaActual.idEmpresa AndAlso x.FechaBaja.HasValue = False).First.idCaja
|
||||
End If
|
||||
NuevoEstado = tsUtilidades.EstadosAplicacion.Nuevo
|
||||
Else
|
||||
|
||||
Select Case DirectCast(ra.Tipo, TipoMovimientoEnum)
|
||||
Case TipoMovimientoEnum.RECIBO_CLIENTE
|
||||
Dim plantillas As New List(Of tsWPFCore.Plantilla)
|
||||
plantillas.Add(New tsWPFCore.Plantilla With {.idPlantilla = 0, .Descripcion = "RECIBO"})
|
||||
Me.ContenedorAplicacion.cbPlantillaAImprimir.ItemsSource = plantillas
|
||||
Me.ContenedorAplicacion.bePlantilla.EditValue = plantillas.First.idPlantilla
|
||||
|
||||
Case TipoMovimientoEnum.CIERRE_CAJA
|
||||
Dim plantillas As New List(Of tsWPFCore.Plantilla)
|
||||
plantillas.Add(New tsWPFCore.Plantilla With {.idPlantilla = 0, .Descripcion = "IMPRIMIR CIERRE CAJA"})
|
||||
Me.ContenedorAplicacion.cbPlantillaAImprimir.ItemsSource = plantillas
|
||||
Me.ContenedorAplicacion.bePlantilla.EditValue = plantillas.First.idPlantilla
|
||||
Case Else
|
||||
Me.ContenedorAplicacion.cbPlantillaAImprimir.ItemsSource = Nothing
|
||||
End Select
|
||||
NuevoEstado = tsUtilidades.EstadosAplicacion.ModificandoRegistro
|
||||
End If
|
||||
End If
|
||||
Me.gcLogs.ItemsSource = bd.logs.Where(Function(x) x.id = ra.idMovimiento AndAlso x.Aplicacion = "MOVIMIENTOSCAJA").ToList
|
||||
Me.DataContext = ra
|
||||
Return NuevoEstado
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Public Overrides Function ObtieneBD() As tsUtilidades.ItsContexto
|
||||
bd = tscGrupoSanchoToro.NuevoContexto
|
||||
Return bd
|
||||
End Function
|
||||
|
||||
Public Overrides ReadOnly Property NombreTablaBase As String
|
||||
Get
|
||||
Return "movimientoscaja"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
|
||||
|
||||
|
||||
Public Overrides ReadOnly Property idRegistroAplicacionActual As String
|
||||
Get
|
||||
If idLog.HasValue Then
|
||||
Return "MovimientosCaja R.C.:" & idLog.ToString
|
||||
Else
|
||||
If Estado = tsUtilidades.EstadosAplicacion.Nuevo Then
|
||||
Return "MovimientosCaja.Nuevo"
|
||||
Else
|
||||
Return "MovimientosCaja." & DirectCast(Me.DataContext, movimientoscaja).idMovimiento.ToString
|
||||
End If
|
||||
End If
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Overrides ReadOnly Property DescripcionRegistro As String
|
||||
Get
|
||||
Return "Movimiento Caja"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub New(Optional idMovimiento As Integer? = Nothing)
|
||||
|
||||
' Llamada necesaria para el diseñador.
|
||||
InitializeComponent()
|
||||
_idMovimiento = idMovimiento
|
||||
' Agregue cualquier inicialización después de la llamada a InitializeComponent().
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Public Overrides Sub EstableceDataContextSecundarios(Optional Background As Boolean = False)
|
||||
Me.cbTipo.ItemsSource = tsUtilidades.DescripcionValor.EnumADescripcionValor(GetType(TipoMovimientoEnum))
|
||||
Me.cbCaja.ItemsSource = bd.cajas.Where(Function(x) x.idEmpresa = EmpresaActual.idEmpresa AndAlso x.FechaBaja.HasValue = False OrElse x.idCaja = ra.idCaja).OrderBy(Function(x) x.Descripcion).ToList
|
||||
|
||||
'Dim plantillas As New List(Of tsWPFCore.Plantilla)
|
||||
'plantillas.Add(New tsWPFCore.Plantilla With {.idPlantilla = 0, .Descripcion = "RECIBO"})
|
||||
'Me.ContenedorAplicacion.cbPlantillaAImprimir.ItemsSource = plantillas
|
||||
'If plantillas.Count > 0 Then
|
||||
' Me.ContenedorAplicacion.bePlantilla.EditValue = plantillas.First.idPlantilla
|
||||
'End If
|
||||
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub EstableceTitulo()
|
||||
|
||||
If idLog.HasValue Then
|
||||
Dim mv As movimientoscaja = Me.DataContext
|
||||
Me.docpanel.Caption = "R.C. Movimiento Caja " & mv.idMovimiento.ToString
|
||||
Me.docpanel.Tag = "R.C. Movimiento Caja." & mv.idMovimiento.ToString
|
||||
Else
|
||||
If Me.Estado = tsUtilidades.EstadosAplicacion.ModificandoRegistro Then
|
||||
Dim mv As movimientoscaja = Me.DataContext
|
||||
Me.docpanel.Caption = "Movimiento Caja " & mv.idMovimiento.ToString
|
||||
Me.docpanel.Tag = "MovimientoCaja." & mv.idMovimiento.ToString
|
||||
Else
|
||||
Me.docpanel.Caption = "Movimiento Caja Nuevo"
|
||||
Me.docpanel.Tag = "MovimientoCaja.Nuevo"
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Overrides Function ObtienePermisos() As tsUtilidades.Permisos
|
||||
Dim per = Comun.ObtienePermisos(Me.bd, "AP.ADMINISTRATIVOS", idUsuario)
|
||||
per.Eliminar = False
|
||||
Return per
|
||||
End Function
|
||||
|
||||
|
||||
Public Overrides Sub Cargado()
|
||||
Me.Tipo_ucControlBusqueda = GetType(ucCajas)
|
||||
End Sub
|
||||
|
||||
Private Sub HlMovimientoCierre_Click(sender As Object, e As RoutedEventArgs)
|
||||
|
||||
FuncionesDinamicas.AbrirAP(New ucMovimientoCaja(ra.idMovimientoCierre), OtrosParametros)
|
||||
End Sub
|
||||
|
||||
Private Sub HlAlbaranEntrega_Click(sender As Object, e As RoutedEventArgs)
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub HlFacturaRecibida_Click(sender As Object, e As RoutedEventArgs)
|
||||
|
||||
FuncionesDinamicas.AbrirAP(New ucFacturaRecibida(ra.idFacturaRecibida), OtrosParametros)
|
||||
End Sub
|
||||
|
||||
Private Sub HlFacturaEmitida_Click(sender As Object, e As RoutedEventArgs)
|
||||
'Dim ra As movimientoscaja = Me.DataContext
|
||||
'FuncionesDinamicas.AbrirAP(New ucFacturaEmitida(ra.idFactura), OtrosParametros)
|
||||
End Sub
|
||||
|
||||
Private Sub ucMovimientoCaja_AntesGuardar(sender As Object, e As ItemClickEventArgs, ByRef Cancelar As Boolean, ByRef MensajesError As Hashtable, OpcionGuardado As Integer) Handles Me.AntesGuardar
|
||||
|
||||
Dim hte As New Hashtable
|
||||
If ra.Observaciones.NothingAVacio = "" AndAlso Estado = tsUtilidades.EstadosAplicacion.Nuevo Then
|
||||
hte.Add("ALMACENAR-OBSERVACIONES_OBLIGATORIAS", "Las observaciones son obligatorias en caso de Movimientos Nuevos")
|
||||
End If
|
||||
If ra.Importe = 0 Then
|
||||
hte.Add("ALMACENAR-IMPORTE_DISTINTO_0", "El importe no puede ser 0")
|
||||
End If
|
||||
|
||||
If hte.Count > 0 Then
|
||||
MensajesError = hte
|
||||
Cancelar = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ucMovimientoCaja_ImprimirPlantilla(sender As Object, e As ItemClickEventArgs, idPlantilla As Integer) Handles Me.ImprimirPlantilla
|
||||
Dim rec As movimientoscaja = Me.DataContext
|
||||
|
||||
Select Case DirectCast(rec.Tipo, TipoMovimientoEnum)
|
||||
Case TipoMovimientoEnum.RECIBO_CLIENTE
|
||||
|
||||
If Not Guardar(Nothing, Nothing) Then
|
||||
Dim lr As New List(Of movimientoscaja)
|
||||
If rec.Fecha = Date.MinValue Then
|
||||
rec.Fecha = bd.AhoraMySql
|
||||
rec.FechaCreacion = rec.Fecha
|
||||
End If
|
||||
lr.Add(rec)
|
||||
Dim cp As String = "RECIBO"
|
||||
Dim pl = bd.plantillas.AsNoTracking.Where(Function(x) x.Codigo = cp).Select(Function(x) New With {.Fichero = x.idFicheroNavigation.Fichero, .Tipo = x.idGrupoNavigation.Codigo}).FirstOrDefault
|
||||
Informes.ImprimirPlantilla(bd, pl.Fichero, lr, False, 1)
|
||||
|
||||
End If
|
||||
Case TipoMovimientoEnum.CIERRE_CAJA
|
||||
Dim lm As New List(Of movimientoscaja)
|
||||
lm.Add(rec)
|
||||
Dim xr As New xrCierreCaja
|
||||
Informes.ImprimeInforme(xr, False, 1, bd.AhoraMySql, lm)
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub ap_EstadoCambiado(EstadoAnterior As tsUtilidades.EstadosAplicacion, EstadoNuevo As tsUtilidades.EstadosAplicacion) Handles Me.EstadoCambiado
|
||||
Select Case EstadoNuevo
|
||||
Case EstadosAplicacion.ModificandoRegistro
|
||||
|
||||
If Me.ObtienePermisos.Modificar Then
|
||||
If ra.FechaSupervision.HasValue OrElse ra.idMovimientoCierre.HasValue OrElse ra.Tipo = bdGrupoSanchoToro.db.TipoMovimientoEnum.CIERRE_CAJA Then
|
||||
Dim per = Comun.ObtienePermisos(Me.bd, "AP.SUPERADMINISTRATIVOS", idUsuario)
|
||||
If Not per.Modificar Then
|
||||
Me.EstableceSoloLectura()
|
||||
End If
|
||||
' Me.ContenedorAplicacion.btGuardar.IsEnabled = True
|
||||
' Me.ContenedorAplicacion.btGuardarYBuscar.IsEnabled = True
|
||||
End If
|
||||
End If
|
||||
End Select
|
||||
If idLog.HasValue Then EstableceSoloLectura()
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub ucMovimientoCaja_DespuesGuardar(sender As Object, e As ItemClickEventArgs, OpcionGuardado As Integer) Handles Me.DespuesGuardar
|
||||
|
||||
Me.gcLogs.ItemsSource = bd.logs.Where(Function(x) x.id = ra.idMovimiento AndAlso x.Aplicacion = "MOVIMIENTOSCAJA").ToList
|
||||
_idMovimiento = ra.idMovimiento
|
||||
End Sub
|
||||
|
||||
Private Sub ucMovimientoCaja_Enlazar(Celda As EditGridCellData, Defecto As Boolean) Handles Me.Enlazar
|
||||
Select Case Celda.Column.FieldName.ToLower
|
||||
Case "idlog"
|
||||
Dim log As logs = gcLogs.CurrentItem
|
||||
Dim id As Integer = log.idLog
|
||||
Dim uc As New ucMovimientoCaja
|
||||
uc.idLog = log.idLog
|
||||
FuncionesDinamicas.AbrirAP(uc, OtrosParametros)
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub hlConciliacion_Click(sender As Object, e As RoutedEventArgs)
|
||||
|
||||
FuncionesDinamicas.AbrirAP(New ucConciliacionBancaria(ra.idConciliacion), OtrosParametros)
|
||||
End Sub
|
||||
Private Sub BeDocumentoAdjunto_DefaultButtonClick(sender As Object, e As RoutedEventArgs)
|
||||
Try
|
||||
Dim ofd As New OpenFileDialog
|
||||
If ofd.ShowDialog Then
|
||||
|
||||
If ra.idFicheroNavigation Is Nothing Then
|
||||
ra.idFicheroNavigation = New db.ficheros
|
||||
End If
|
||||
ra.idFicheroNavigation.NombreFichero = IO.Path.GetFileName(ofd.FileName)
|
||||
ra.idFicheroNavigation.Fichero = IO.File.ReadAllBytes(ofd.FileName)
|
||||
ra.idFicheroNavigation.idTipo = bd.enumeraciones.First(Function(x) x.Codigo = "TIPFIC.MC").idEnumeracion
|
||||
ra.FicheroAdjuntoTMP = ra.idFicheroNavigation.NombreFichero
|
||||
End If
|
||||
Catch EX As Exception
|
||||
FuncionesDinamicas.ErrorNoControladoAp(Me, EX)
|
||||
DXMessageBox.Show(EX.Message, "Error")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub BiEliminar_Click(sender As Object, e As RoutedEventArgs)
|
||||
Try
|
||||
|
||||
If ra.idFicheroNavigation Is Nothing OrElse ra.idFicheroNavigation.Fichero Is Nothing Then
|
||||
DXMessageBox.Show("La factura actual no tiene ningún documento adjunto.", "Atención")
|
||||
Else
|
||||
Try
|
||||
bd.ficheros.Remove(ra.idFicheroNavigation)
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
ra.idFicheroNavigation = Nothing
|
||||
ra.FicheroAdjuntoTMP = ""
|
||||
End If
|
||||
Catch EX As Exception
|
||||
FuncionesDinamicas.ErrorNoControladoAp(Me, EX)
|
||||
DXMessageBox.Show(EX.Message, "Error")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub BiVer_Click(sender As Object, e As RoutedEventArgs)
|
||||
Try
|
||||
|
||||
If ra.idFicheroNavigation Is Nothing OrElse ra.idFicheroNavigation.Fichero Is Nothing Then
|
||||
DXMessageBox.Show("La factura actual no tiene ningún documento adjunto.", "Atención")
|
||||
Else
|
||||
Dim sFicAleatorio As String = tsUtilidades.Utilidades.ObtieneDirectorioAleatorio("GrupoSanchoToro") & ra.idFicheroNavigation.NombreFichero
|
||||
IO.File.WriteAllBytes(sFicAleatorio, ra.idFicheroNavigation.Fichero)
|
||||
tsUtilidades.Sistema.EjecutaFichero(sFicAleatorio)
|
||||
End If
|
||||
Catch EX As Exception
|
||||
FuncionesDinamicas.ErrorNoControladoAp(Me, EX)
|
||||
DXMessageBox.Show(EX.Message, "Error")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user