133 lines
4.7 KiB
VB.net
133 lines
4.7 KiB
VB.net
Imports tsWPFCore
|
|
Imports bdGrupoSanchoToro.db
|
|
Imports System.Collections
|
|
|
|
Imports bdGrupoSanchoToro.db.Utilidades
|
|
Imports DevExpress.Xpf.Bars
|
|
|
|
Public Class ucSerieFactura
|
|
|
|
|
|
Private bd As tscGrupoSanchoToro
|
|
|
|
Dim _idSerie As Integer?
|
|
|
|
|
|
|
|
Public Overrides Sub Cargado()
|
|
Me.Tipo_ucControlBusqueda = GetType(ucSeriesFacturas)
|
|
|
|
End Sub
|
|
|
|
Dim ra As seriesfacturas
|
|
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 FuerzaNuevo OrElse _idSerie Is Nothing Then
|
|
ra = New seriesfacturas
|
|
ra.idEmpresa = EmpresaActual.idEmpresa
|
|
Me.DataContext = ra
|
|
_idSerie = Nothing
|
|
NuevoEstado = tsUtilidades.EstadosAplicacion.Nuevo
|
|
Else
|
|
ra = bd.seriesfacturas.First(Function(x) x.idSerieFactura = _idSerie.Value)
|
|
NuevoEstado = tsUtilidades.EstadosAplicacion.ModificandoRegistro
|
|
End If
|
|
Me.DataContext = ra
|
|
Return NuevoEstado
|
|
End Function
|
|
|
|
Public Overrides Sub EstableceDataContextSecundarios(Optional Background As Boolean = False)
|
|
cbTipo.ItemsSource = tsUtilidades.DescripcionValor.EnumADescripcionValor(GetType(bdGrupoSanchoToro.db.seriesfacturas.TipoSerieFacturaEnum)).OrderBy(Function(x) x.Descripcion)
|
|
End Sub
|
|
|
|
Public Overrides Sub EstableceTitulo()
|
|
If Me.Estado = tsUtilidades.EstadosAplicacion.ModificandoRegistro Then
|
|
Me.docpanel.Caption = "Serie " & ra.Serie
|
|
Me.docpanel.Tag = "Serie." & ra.Serie.ToString
|
|
Else
|
|
Me.docpanel.Caption = "Serie nueva"
|
|
Me.docpanel.Tag = "Serie.Nuevo"
|
|
End If
|
|
End Sub
|
|
|
|
Public Overrides ReadOnly Property idRegistroAplicacionActual As String
|
|
Get
|
|
If Estado = tsUtilidades.EstadosAplicacion.Nuevo Then
|
|
Return "Serie.Nuevo"
|
|
Else
|
|
Return "Serie." & ra.Serie.ToString
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property NombreTablaBase As String
|
|
Get
|
|
Return "seriesfacturas"
|
|
End Get
|
|
End Property
|
|
|
|
Public Overrides ReadOnly Property DescripcionRegistro As String
|
|
Get
|
|
Return "Serie"
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
Public Sub New(Optional idSerie As Integer? = Nothing)
|
|
|
|
' Llamada necesaria para el diseñador.
|
|
InitializeComponent()
|
|
_idSerie = idSerie
|
|
|
|
' Agregue cualquier inicialización después de la llamada a InitializeComponent().
|
|
|
|
End Sub
|
|
|
|
Private Sub ucSerie_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
|
|
If Estado = tsUtilidades.EstadosAplicacion.ModificandoRegistro Then
|
|
If bd.seriesfacturas.Any(Function(x) x.idSerieFactura <> ra.idSerieFactura AndAlso x.idEmpresa = EmpresaActual.idEmpresa AndAlso x.Serie = ra.Serie) Then
|
|
hte.Add("ALMACENAR-SERIE_YA_EXISTENTE", "Ya existe esa serie de factura.")
|
|
End If
|
|
If ra.NumeroDigitos > 18 Or ra.NumeroDigitos < 4 Then
|
|
hte.Add("ALMACENAR-NUMERO_DIGITOS_INVÁLIDOS", "Los nº de dígitos deben estar entre 4 y 18")
|
|
End If
|
|
End If
|
|
If hte.Count > 0 Then
|
|
MensajesError = hte
|
|
Cancelar = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub ucSerie_DespuesGuardar(sender As Object, e As ItemClickEventArgs, OpcionGuardado As Integer) Handles Me.DespuesGuardar
|
|
Dim fi As seriesfacturas = Me.DataContext
|
|
_idSerie = fi.idSerieFactura
|
|
End Sub
|
|
|
|
Private Sub ucSerieFactura_AntesEliminar(sender As Object, e As ItemClickEventArgs, ByRef Cancelar As Boolean, ByRef MensajesError As Hashtable, ByRef OmitirPreguntaContinuar As Boolean) Handles Me.AntesEliminar
|
|
Dim hte As New Hashtable
|
|
If bd.facturas.Any(Function(x) x.idSerieFactura = ra.idSerieFactura) Then
|
|
hte.Add("ALMACENAR-SERIE_CON_FACTURAS", "No se puede eliminar una serie si ya tiene facturas.")
|
|
End If
|
|
If hte.Count > 0 Then
|
|
MensajesError = hte
|
|
Cancelar = True
|
|
End If
|
|
End Sub
|
|
End Class
|