Agregar archivos de proyecto.
This commit is contained in:
232
GestionGrupoSanchoToro/FicherosMaestros/ucAlmacen.xaml.vb
Normal file
232
GestionGrupoSanchoToro/FicherosMaestros/ucAlmacen.xaml.vb
Normal file
@@ -0,0 +1,232 @@
|
||||
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 bdGrupoSanchoToro.db.almacenes
|
||||
Imports tsEFCore8.Extensiones
|
||||
|
||||
Public Class ucAlmacen
|
||||
|
||||
|
||||
Private bd As tscGrupoSanchoToro
|
||||
Friend _idAlmacen As Nullable(Of Integer)
|
||||
Private ra As almacenes
|
||||
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 _idAlmacen Is Nothing OrElse FuerzaNuevo Then
|
||||
ra = New almacenes
|
||||
Me.DataContext = ra
|
||||
_idAlmacen = Nothing
|
||||
NuevoEstado = tsUtilidades.EstadosAplicacion.Nuevo
|
||||
Else
|
||||
ra = bd.almacenes.First(Function(x) x.idAlmacen = _idAlmacen.Value)
|
||||
NuevoEstado = tsUtilidades.EstadosAplicacion.ModificandoRegistro
|
||||
End If
|
||||
Me.DataContext = ra
|
||||
gcProductos.ItemsSource = ra.stocks
|
||||
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 "almacenes"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
|
||||
|
||||
|
||||
Public Overrides ReadOnly Property idRegistroAplicacionActual As String
|
||||
Get
|
||||
If Estado = tsUtilidades.EstadosAplicacion.Nuevo Then
|
||||
Return "Almacen.Nuevo"
|
||||
Else
|
||||
Return "Almacen." & DirectCast(Me.DataContext, almacenes).idAlmacen.ToString
|
||||
End If
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Overrides ReadOnly Property DescripcionRegistro As String
|
||||
Get
|
||||
Return "Almacén"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub New(Optional idAlmacen As Integer? = Nothing)
|
||||
|
||||
' Llamada necesaria para el diseñador.
|
||||
InitializeComponent()
|
||||
_idAlmacen = idAlmacen
|
||||
' 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(TipoAlmacenEnum))
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub EstableceTitulo()
|
||||
If Me.Estado = tsUtilidades.EstadosAplicacion.ModificandoRegistro Then
|
||||
Dim cj As almacenes = Me.DataContext
|
||||
Me.docpanel.Caption = "Almacen " & cj.Descripcion
|
||||
Me.docpanel.Tag = "Almacen." & cj.idAlmacen.ToString
|
||||
Else
|
||||
Me.docpanel.Caption = "Almacen Nuevo"
|
||||
Me.docpanel.Tag = "Almacen.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(ucAlmacenes)
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub ucAlmacen_Enlazar(Celda As EditGridCellData, Defecto As Boolean) Handles Me.Enlazar
|
||||
Select Case Celda.Column.FieldName.ToLower
|
||||
Case "producto"
|
||||
Dim st As stocks = gcProductos.CurrentItem
|
||||
FuncionesDinamicas.AbrirAP(New ucProducto(st.idProducto), OtrosParametros)
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub ucAlmacen_DespuesGuardar(sender As Object, e As ItemClickEventArgs, OpcionGuardado As Integer) Handles Me.DespuesGuardar
|
||||
|
||||
_idAlmacen = ra.idAlmacen
|
||||
End Sub
|
||||
Private Sub ap_ValidarControl(sender As Object, e As ValidationEventArgs, ByRef ev As ErrorValidacion, ByRef ValorOriginalCambiado As Object) Handles Me.ValidarControl
|
||||
|
||||
Dim pts As PropiedadesTS = sender.parent.propiedadests
|
||||
Try
|
||||
If Not pts Is Nothing Then
|
||||
ErroresValidacion.EliminaError("validando-" & pts.NombreCampo)
|
||||
|
||||
Select Case pts.NombreCampo.ToLower
|
||||
Case "email"
|
||||
If e.Value IsNot Nothing AndAlso e.Value.ToString <> "" Then
|
||||
If Not e.Value.ToString.Trim.ToLower.EsEmailValido Then Throw New Exception("El email es incorrecto")
|
||||
End If
|
||||
Case "codigopostal"
|
||||
If Not e.Value Is Nothing AndAlso e.Value.ToString <> "" AndAlso e.Value.ToString <> ra.CodigoPostal Then
|
||||
|
||||
Dim sCpo As String = e.Value.ToString
|
||||
If sCpo.Length <> 5 Then Throw New Exception("El código postal no es correcto")
|
||||
Dim sCodigoprovincia As String = sCpo.Substring(0, 2)
|
||||
If Not bd.provincias.Any(Function(x) x.CodigoProvincia = sCodigoprovincia) Then Throw New Exception("El código postal no es correcto")
|
||||
Select Case bd.codigospostales.Where(Function(x) x.CodigoPostal = sCpo).Count
|
||||
Case 0
|
||||
Dim vncp As New dxwAgregarNuevoCodigoPostal(sCpo, bd)
|
||||
If vncp.ShowDialog Then
|
||||
Dim pob = bd.codigospostales.First(Function(x) x.CodigoPostal = sCpo)
|
||||
ra.CodigoMunicipio = pob.CodigoMunicipio
|
||||
|
||||
Else
|
||||
ValorOriginalCambiado = ra.CodigoPostal
|
||||
Throw New Exception("El código postal no es correcto")
|
||||
End If
|
||||
Case 1
|
||||
Dim pob = bd.codigospostales.First(Function(x) x.CodigoPostal = sCpo)
|
||||
ra.CodigoMunicipio = pob.CodigoMunicipio
|
||||
|
||||
Case Else
|
||||
Dim wMunicipios As New dxwCodigosPostales(bd, sCpo)
|
||||
If wMunicipios.ShowDialog Then
|
||||
ra.CodigoMunicipio = wMunicipios.CodigoMunicipio
|
||||
Else
|
||||
Throw New Exception("El código postal no es correcto")
|
||||
End If
|
||||
End Select
|
||||
End If
|
||||
End Select
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Dim sCodigoError As String = "validando-"
|
||||
If pts IsNot Nothing Then
|
||||
sCodigoError &= pts.NombreCampo
|
||||
End If
|
||||
ev = New ErrorValidacion(sCodigoError, sender, ex.Message, ex, DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical)
|
||||
e.IsValid = False
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
Private Sub BeCodigoPostal_DefaultButtonClick(sender As Object, e As RoutedEventArgs)
|
||||
|
||||
Dim dxw As New dxwCodigosPostales(bd, "")
|
||||
If dxw.ShowDialog Then
|
||||
ra.CodigoMunicipio = dxw.CodigoMunicipio
|
||||
ra.CodigoPostal = dxw.CodigoPostal
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub BtCancelarCodigoPostal_Click(sender As Object, e As RoutedEventArgs)
|
||||
ra.CodigoMunicipio = ""
|
||||
End Sub
|
||||
|
||||
Private Sub ucAlmacen_CampoActualizado(sender As Object, e As DataTransferEventArgs) Handles Me.CampoActualizado
|
||||
Dim pts As PropiedadesTS = sender.parent.propiedadests
|
||||
If Not pts Is Nothing Then
|
||||
|
||||
Select Case pts.NombreCampo.ToLower
|
||||
Case "codigopostal"
|
||||
ra.RefrescaCamposSoloLectura()
|
||||
End Select
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub beCodigoPostal_LostFocus(sender As Object, e As RoutedEventArgs) Handles beCodigoPostal.LostFocus
|
||||
If Me.ErroresValidacion.Errores.Any(Function(x) x.id = "validando-CodigoPostal") Then
|
||||
Dim cp = beCodigoPostal.EditText.ToString
|
||||
If bd.codigospostales.Any(Function(x) x.CodigoPostal = cp) Then
|
||||
ErroresValidacion.EliminaError("validando-CodigoPostal")
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ucAlmacen_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.almacenes.FirstOrDefault(Function(x) x.idAlmacen <> ra.idAlmacen AndAlso x.Descripcion = ra.Descripcion AndAlso x.idEmpresa = EmpresaActual.idEmpresa)
|
||||
If almexi IsNot Nothing Then
|
||||
hte.Add("ALMACENAR-ALMACEN_DUPLIADO", "Almacén Duplicado")
|
||||
End If
|
||||
If hte.Count > 0 Then
|
||||
MensajesError = hte
|
||||
Cancelar = True
|
||||
End If
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user