206 lines
7.8 KiB
VB.net
206 lines
7.8 KiB
VB.net
Imports DevExpress.Xpf.Editors
|
|
Imports tsWPFCore
|
|
Imports DevExpress.Xpf.Core
|
|
Imports bdGrupoSanchoToro.db
|
|
Imports DevExpress.Xpf.Bars
|
|
Imports bdGrupoSanchoToro.db.Utilidades
|
|
Imports DevExpress.Xpf.Grid
|
|
Imports Microsoft.EntityFrameworkCore
|
|
Imports GrupoSanchoToro.GrupoSanchoToro
|
|
|
|
Public Class ucCaja
|
|
|
|
|
|
Private bd As tscGrupoSanchoToro
|
|
Friend _idCaja As Nullable(Of Integer)
|
|
Dim ra As cajas
|
|
Public Overrides Function EstablecedcPrincipal(Optional Background As Boolean = False, Optional FuerzaNuevo As Boolean = False, Optional Refrescar As Boolean = False) As tsUtilidades.EstadosAplicacion
|
|
|
|
|
|
Dim NuevoEstado As tsUtilidades.EstadosAplicacion
|
|
If Estado = tsUtilidades.EstadosAplicacion.Nuevo OrElse _idCaja Is Nothing OrElse FuerzaNuevo Then
|
|
ra = New cajas
|
|
ra.idEmpresa = EmpresaActual.idEmpresa
|
|
Me.DataContext = ra
|
|
_idCaja = Nothing
|
|
NuevoEstado = tsUtilidades.EstadosAplicacion.Nuevo
|
|
Else
|
|
ra = bd.cajas.First(Function(x) x.idCaja = _idCaja.Value)
|
|
NuevoEstado = tsUtilidades.EstadosAplicacion.ModificandoRegistro
|
|
End If
|
|
Me.DataContext = ra
|
|
ObtieneMovimientos()
|
|
|
|
Dim Acciones As New List(Of tsWPFCore.Accion)
|
|
Acciones.Add(New Accion With {
|
|
.idAccion = 1,
|
|
.Descripcion = "CERRAR CAJA"})
|
|
Me.ContenedorAplicacion.cbAcciones.ItemsSource = Acciones
|
|
Me.ContenedorAplicacion.beAcciones.EditValue = Acciones.First.idAccion
|
|
ra = Me.DataContext
|
|
|
|
|
|
Return NuevoEstado
|
|
|
|
End Function
|
|
Private Sub ObtieneMovimientos()
|
|
If Me.DataContext IsNot Nothing Then
|
|
Dim ra As cajas = Me.DataContext
|
|
Dim rs = bd.movimientoscaja.Include(Function(x) x.idMovimientoCierreNavigation).Where(Function(x) x.idCaja = ra.idCaja)
|
|
Dim fi As Date? = teFechaInicial.EditValue
|
|
If cbIncluirCerrados.IsChecked = False Then
|
|
rs = rs.Where(Function(x) x.idMovimientoCierre.HasValue = False)
|
|
End If
|
|
If fi.HasValue Then
|
|
rs = rs.Where(Function(x) x.Fecha >= fi.Value)
|
|
End If
|
|
Dim ff As Date? = teFechaFinal.EditValue
|
|
If ff.HasValue Then
|
|
ff = ff.Value.AddDays(1)
|
|
rs = rs.Where(Function(x) x.Fecha < ff.Value)
|
|
End If
|
|
gcMovimientos.ItemsSource = rs.Include(Function(x) x.idFacturaNavigation.idClienteNavigation).Include(Function(x) x.idFacturaRecibidaNavigation.idProveedorNavigation).OrderBy(Function(x) x.Fecha).ToList
|
|
Else
|
|
gcMovimientos.ItemsSource = Nothing
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Public Overrides Function ObtieneBD() As tsUtilidades.ItsContexto
|
|
bd = tscGrupoSanchoToro.NuevoContexto()
|
|
Return bd
|
|
End Function
|
|
|
|
Public Overrides ReadOnly Property NombreTablaBase As String
|
|
Get
|
|
Return "cajas"
|
|
End Get
|
|
End Property
|
|
|
|
|
|
|
|
|
|
Public Overrides ReadOnly Property idRegistroAplicacionActual As String
|
|
Get
|
|
If Estado = tsUtilidades.EstadosAplicacion.Nuevo Then
|
|
Return "Caja.Nuevo"
|
|
Else
|
|
Return "Caja." & DirectCast(Me.DataContext, cajas).idCaja.ToString
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property DescripcionRegistro As String
|
|
Get
|
|
Return "Caja"
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub New(Optional idCaja As Integer? = Nothing)
|
|
|
|
' Llamada necesaria para el diseñador.
|
|
InitializeComponent()
|
|
_idCaja = idCaja
|
|
' 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(bdGrupoSanchoToro.db.cajas.TipoCajaEnum))
|
|
'Try
|
|
' Dim ra As cajas = Me.DataContext
|
|
'Catch ex As Exception
|
|
' Throw New Exception(ex.Message, ex)
|
|
'End Try
|
|
End Sub
|
|
|
|
Public Overrides Sub EstableceTitulo()
|
|
If Me.Estado = tsUtilidades.EstadosAplicacion.ModificandoRegistro Then
|
|
Dim cj As cajas = Me.DataContext
|
|
Me.docpanel.Caption = "Caja " & cj.Descripcion
|
|
Me.docpanel.Tag = "Caja." & cj.idCaja.ToString
|
|
Else
|
|
Me.docpanel.Caption = "Caja Nuevo"
|
|
Me.docpanel.Tag = "Caja.Nuevo"
|
|
End If
|
|
End Sub
|
|
|
|
Public Overrides Function ObtienePermisos() As tsUtilidades.Permisos
|
|
Return Comun.ObtienePermisos(Me.bd, "AP.ADMINISTRATIVOS", idUsuario)
|
|
End Function
|
|
|
|
|
|
Public Overrides Sub Cargado()
|
|
Me.Tipo_ucControlBusqueda = GetType(ucCajas)
|
|
End Sub
|
|
|
|
Private Sub TeFechaFinal_EditValueChanged(sender As Object, e As EditValueChangedEventArgs)
|
|
ObtieneMovimientos()
|
|
End Sub
|
|
|
|
Private Sub CbIncluirCerrados_EditValueChanged(sender As Object, e As EditValueChangedEventArgs)
|
|
Dim fi As Date? = teFechaInicial.EditValue
|
|
If fi.HasValue = False Then
|
|
teFechaInicial.EditValue = Now.AddDays(-30).Date
|
|
End If
|
|
Dim ff As Date? = teFechaFinal.EditValue
|
|
If ff.HasValue = False Then
|
|
teFechaFinal.EditValue = Now.Date
|
|
End If
|
|
ObtieneMovimientos()
|
|
End Sub
|
|
|
|
Private Sub TeFechaInicial_EditValueChanged(sender As Object, e As EditValueChangedEventArgs)
|
|
ObtieneMovimientos()
|
|
End Sub
|
|
|
|
Private Sub ucCaja_Enlazar(Celda As EditGridCellData, Defecto As Boolean) Handles Me.Enlazar
|
|
Dim ra As movimientoscaja = Me.gcMovimientos.CurrentItem
|
|
Select Case Celda.Column.FieldName.ToLower
|
|
Case "idmovimiento"
|
|
FuncionesDinamicas.AbrirAP(New ucMovimientoCaja(ra.idMovimiento), OtrosParametros)
|
|
Case "referenciadocumento"
|
|
Dim tipom As TipoMovimientoEnum = ra.Tipo
|
|
Select Case tipom
|
|
Case TipoMovimientoEnum.RECIBO_CLIENTE
|
|
' FuncionesDinamicas.AbrirAP(New ucFacturaEmitida(ra.idFactura), OtrosParametros)
|
|
Case TipoMovimientoEnum.RECIBO_PROVEEDOR
|
|
FuncionesDinamicas.AbrirAP(New ucFacturaRecibida(ra.idFacturaRecibida), OtrosParametros)
|
|
End Select
|
|
Case "razonsocial"
|
|
FuncionesDinamicas.AbrirAP(New ucEntidad(ra.idEntidad), OtrosParametros)
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub ucCaja_EjecutarAccion(sender As Object, e As ItemClickEventArgs, idAccion As Integer) Handles Me.EjecutarAccion
|
|
Select Case idAccion
|
|
Case 1 ' CIERRE CAJA
|
|
|
|
If DXMessageBox.Show("¿Está seguro de querer cerrar la caja " & ra.Descripcion & "?", "Atención", vbYesNo) = MessageBoxResult.Yes Then
|
|
DXMessageBox.Show(ListadosYProcesos.CierraCaja(ra.idCaja, True), "Cierre de Caja " & ra.Descripcion)
|
|
RefrescaUC()
|
|
End If
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub ucCaja_DespuesGuardar(sender As Object, e As ItemClickEventArgs, OpcionGuardado As Integer) Handles Me.DespuesGuardar
|
|
|
|
_idCaja = ra.idCaja
|
|
End Sub
|
|
|
|
Private Sub ucCaja_AntesGuardar(sender As Object, e As ItemClickEventArgs, ByRef Cancelar As Boolean, ByRef MensajesError As Hashtable, EliminacionManual As Integer) Handles Me.AntesGuardar
|
|
Dim hte As New Hashtable
|
|
ra.idEmpresa = EmpresaActual.idEmpresa
|
|
Dim almexi = bd.cajas.FirstOrDefault(Function(x) x.idCaja <> ra.idCaja AndAlso x.Descripcion = ra.Descripcion AndAlso x.idEmpresa = EmpresaActual.idEmpresa)
|
|
If almexi IsNot Nothing Then
|
|
hte.Add("ALMACENAR-CAJA_DUPLICADA", "Caja Duplicada")
|
|
End If
|
|
If hte.Count > 0 Then
|
|
MensajesError = hte
|
|
Cancelar = True
|
|
End If
|
|
End Sub
|
|
End Class
|