158 lines
5.7 KiB
VB.net
158 lines
5.7 KiB
VB.net
Imports DevExpress.Xpf.Editors
|
|
Imports DevExpress.Xpf.LayoutControl
|
|
Imports tsWPFCore
|
|
Imports System.ComponentModel
|
|
Imports System.Data
|
|
Imports DevExpress.Xpf.Editors.Validation
|
|
Imports DevExpress.Xpf.Editors.Helpers
|
|
Imports DevExpress.Xpf.Core
|
|
Imports tsWPFCore.modExtensiones
|
|
Imports System.Data.Common
|
|
Imports System.Data.Entity
|
|
Imports bdGrupoSanchoToro.db
|
|
Imports tsUtilidades.Datos
|
|
Imports DevExpress.Xpf.Bars
|
|
Imports System.Collections.ObjectModel
|
|
Imports bdGrupoSanchoToro.db.tscGrupoSanchoToro
|
|
Imports bdGrupoSanchoToro.db.Utilidades
|
|
Imports DevExpress.Xpf.Grid
|
|
Imports System.Collections
|
|
Imports tsEFCore8.Extensiones
|
|
|
|
Public Class ucTraspasoCaja
|
|
|
|
|
|
Private bd As tscGrupoSanchoToro
|
|
|
|
Public Overrides Function EstablecedcPrincipal(Optional Background As Boolean = False, Optional FuerzaNuevo As Boolean = False, Optional Refrescar As Boolean = False) As tsUtilidades.EstadosAplicacion
|
|
Dim cjs = bd.cajas.Where(Function(x) x.idEmpresa = EmpresaActual.idEmpresa AndAlso x.FechaBaja.HasValue = False).OrderBy(Function(x) x.Descripcion).ToList
|
|
|
|
Me.cbCajaOrigen.ItemsSource = cjs
|
|
Me.cbCajaDestino.ItemsSource = cjs
|
|
Me.teImporte.EditValue = 0
|
|
Return tsUtilidades.EstadosAplicacion.AplicacionSinIndice
|
|
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
|
|
Return "TraspasoCaja"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property DescripcionRegistro As String
|
|
Get
|
|
Return "Traspaso Entre Cajas"
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub New()
|
|
|
|
' Llamada necesaria para el diseñador.
|
|
InitializeComponent()
|
|
|
|
' Agregue cualquier inicialización después de la llamada a InitializeComponent().
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Public Overrides Sub EstableceDataContextSecundarios(Optional Background As Boolean = False)
|
|
|
|
End Sub
|
|
|
|
Public Overrides Sub EstableceTitulo()
|
|
Me.docpanel.Caption = "Traspaso Entre Cajas"
|
|
Me.docpanel.Tag = "Traspaso Entre Cajas"
|
|
End Sub
|
|
|
|
Public Overrides Function ObtienePermisos() As tsUtilidades.Permisos
|
|
Dim per = Comun.ObtienePermisos(Me.bd, "AP.ADMINISTRATIVOS", idUsuario)
|
|
per.Eliminar = False
|
|
per.Nuevos = False
|
|
per.Impresion = False
|
|
per.Exportar = False
|
|
per.Modificar = False
|
|
Return per
|
|
End Function
|
|
|
|
|
|
Public Overrides Sub Cargado()
|
|
|
|
End Sub
|
|
|
|
Private Sub HlMovimientoCierre_Click(sender As Object, e As RoutedEventArgs)
|
|
Dim ra As movimientoscaja = Me.DataContext
|
|
FuncionesDinamicas.AbrirAP(New ucMovimientoCaja(ra.idMovimientoCierre), OtrosParametros)
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub HlFacturaRecibida_Click(sender As Object, e As RoutedEventArgs)
|
|
Dim ra As movimientoscaja = Me.DataContext
|
|
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.idFacturaRecibida), OtrosParametros)
|
|
End Sub
|
|
|
|
|
|
Private Sub btTraspaso_Click(sender As Object, e As RoutedEventArgs)
|
|
Try
|
|
If Me.teImporte.EditValue Is Nothing OrElse Me.cbCajaOrigen.EditValue Is Nothing OrElse Me.cbCajaDestino.EditValue Is Nothing Then DXMessageBox.Show("La caja de origen, de destino e importe son obligatorios")
|
|
Dim Importe As Double = Me.teImporte.EditValue
|
|
If Importe = 0 Then Throw New Exception("El importe no puede ser 0")
|
|
Dim idCajaOrigen As Integer = Me.cbCajaOrigen.EditValue
|
|
Dim idCajaDestino As Integer = Me.cbCajaDestino.EditValue
|
|
Dim Observaciones As String = Me.teObservaciones.EditValue
|
|
If idCajaOrigen = idCajaDestino Then Throw New Exception("La caja destino no puede ser la misma que la caja de origen")
|
|
Dim movcajori As New movimientoscaja
|
|
With movcajori
|
|
.Importe = -Importe
|
|
.idCaja = idCajaOrigen
|
|
.Tipo = bdGrupoSanchoToro.db.TipoMovimientoEnum.TRASPASO_CAJA
|
|
.Fecha = bd.AhoraMysql
|
|
.FechaCreacion = .Fecha
|
|
.idUsuario = idUsuario
|
|
.Observaciones = ("TRASPASO A CAJA " & cbCajaDestino.DisplayText & ". " & Observaciones).Acortar(200)
|
|
End With
|
|
bd.movimientoscaja.Add(movcajori)
|
|
Dim movcajdes As New movimientoscaja
|
|
With movcajdes
|
|
.Importe = Importe
|
|
.idCaja = idCajaDestino
|
|
.Tipo = bdGrupoSanchoToro.db.TipoMovimientoEnum.TRASPASO_CAJA
|
|
.Fecha = bd.AhoraMysql
|
|
.FechaCreacion = .Fecha
|
|
.idUsuario = idUsuario
|
|
.Observaciones = ("TRASPASO DE CAJA " & cbCajaOrigen.DisplayText & ". " & Observaciones).Acortar(200)
|
|
End With
|
|
bd.movimientoscaja.Add(movcajdes)
|
|
bd.GuardarCambios()
|
|
DXMessageBox.Show("Traspaso de caja " & cbCajaOrigen.DisplayText & " a " & cbCajaDestino.DisplayText & " de " & Importe.ToString("c2") & " realizado correctamente.")
|
|
teImporte.EditValue = 0
|
|
cbCajaDestino.EditValue = Nothing
|
|
cbCajaOrigen.EditValue = Nothing
|
|
teObservaciones.EditValue = ""
|
|
Catch ex As Exception
|
|
DXMessageBox.Show(ex.Message, "Atención")
|
|
End Try
|
|
End Sub
|
|
End Class
|