diff --git a/GestionGrupoSanchoToro/Almacen/ucAlbaran.xaml b/GestionGrupoSanchoToro/Almacen/ucAlbaran.xaml
index 6a38ef6..08ff6b6 100644
--- a/GestionGrupoSanchoToro/Almacen/ucAlbaran.xaml
+++ b/GestionGrupoSanchoToro/Almacen/ucAlbaran.xaml
@@ -1,4 +1,4 @@
-
@@ -24,84 +24,84 @@
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
+
@@ -113,19 +113,19 @@
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
@@ -133,37 +133,37 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
@@ -171,37 +171,37 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
@@ -210,19 +210,19 @@
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
@@ -230,38 +230,38 @@
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
@@ -269,37 +269,37 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
@@ -309,76 +309,86 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/GestionGrupoSanchoToro/Almacen/ucAlbaran.xaml.vb b/GestionGrupoSanchoToro/Almacen/ucAlbaran.xaml.vb
index 5024897..11be7b5 100644
--- a/GestionGrupoSanchoToro/Almacen/ucAlbaran.xaml.vb
+++ b/GestionGrupoSanchoToro/Almacen/ucAlbaran.xaml.vb
@@ -38,7 +38,7 @@ Public Class ucAlbaran
Try
lProductos = bd.productos.OrderBy(Function(x) x.Descripcion).ToList
- Dim lProductosAlb = ra.detallesalbaranes.Select(Function(x) x.idProducto).ToArray
+ Dim lProductosAlb = ra.detallesalbaranesidAlbaranNavigation.Select(Function(x) x.idProducto).ToArray
lProductos = lProductos.Where(Function(x) x.FechaBaja Is Nothing OrElse lProductosAlb.Contains(x.idProducto)).ToList
cbProducto.ItemsSource = lProductos
@@ -131,8 +131,8 @@ Public Class ucAlbaran
cbAlmacenOrigen.ItemsSource = Comun.ObtieneListaAlmacenes(bd)
cbAlmacenDestino.ItemsSource = Comun.ObtieneListaAlmacenes(bd)
End If
- Me.gcLogs.ItemsSource = bd.logs.Where(Function(x) x.id = ra.idAlbaran AndAlso x.Aplicacion = "albaranes").ToList
- gcProductos.ItemsSource = ra.detallesalbaranes
+ 'Me.gcLogs.ItemsSource = bd.logs.Where(Function(x) x.id = ra.idAlbaran AndAlso x.Aplicacion = "albaranes").ToList
+ gcProductos.ItemsSource = ra.detallesalbaranesidAlbaranNavigation
Me.DataContext = ra
Return NuevoEstado
Catch ex As Exception
@@ -349,20 +349,20 @@ Public Class ucAlbaran
Private Sub ap_DespuesGuardar(sender As Object, e As ItemClickEventArgs, OpcionGuardado As Integer) Handles Me.DespuesGuardar
Dim ae As albaranes = Me.DataContext
_idAlbaran = DirectCast(Me.DataContext, albaranes).idAlbaran
- Me.gcLogs.ItemsSource = bd.logs.Where(Function(x) x.id = ae.idAlbaran AndAlso x.Aplicacion = "albaranes").ToList
+ 'Me.gcLogs.ItemsSource = bd.logs.Where(Function(x) x.id = ae.idAlbaran AndAlso x.Aplicacion = "albaranes").ToList
End Sub
Private Sub ap_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 ucAlbaran
- uc.idLog = log.idLog
- FuncionesDinamicas.AbrirAP(uc, OtrosParametros)
- End Select
+ 'Select Case Celda.Column.FieldName.ToLower
+ ' Case "idlog"
+ ' Dim log As logs = gcLogs.CurrentItem
+ ' Dim id As Integer = log.idLog
+ ' Dim uc As New ucAlbaran
+ ' uc.idLog = log.idLog
+ ' FuncionesDinamicas.AbrirAP(uc, OtrosParametros)
+ 'End Select
End Sub
@@ -610,8 +610,8 @@ Public Class ucAlbaran
Friend Shared Function GeneraPdfAlbaran(bd As tscGrupoSanchoToro, Albaran As albaranes) As Byte()
Dim albes As New List(Of albaranes)
albes.Add(Albaran)
- Dim idplae = bd.plantillas.First(Function(x) x.Codigo = "ALBENTV").idPlantilla
- If Albaran.entidades.TipoImpresionAlbaranEntrega = db.albaranes.TipoImpresionAlbaranEntregaEnum.IMPRIMIR_CONTRATO Then idplae = bd.plantillas.First(Function(x) x.Codigo = "CONTAE").idPlantilla
+ Dim tipo As String = "ALB_" & Albaran.Tipo.ToString
+ Dim idplae = bd.plantillas.First(Function(x) x.Codigo = tipo).idPlantilla
Dim bAes = Informes.GuardaInformeEnPdf(bd, idplae, albes)
Return bAes
End Function
@@ -653,10 +653,10 @@ Public Class ucAlbaran
gcEsventa.ReadOnly = False
Select Case DirectCast(ra.Tipo, bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum)
Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.COMPRA
- For Each d In ra.detallesalbaranes.Where(Function(x) x.EsVenta)
+ For Each d In ra.detallesalbaranesidAlbaranNavigation.Where(Function(x) x.EsVenta)
d.EsVenta = False
Next
- gcEsventa.ReadOnly = True
+ gcEsVenta.ReadOnly = True
ra.idAlmacenOrigen = Nothing
EstableceSoloLectura(cbAlmacenOrigen, True)
EstableceSoloLectura(cbAlmacenDestino, False)
@@ -679,7 +679,7 @@ Public Class ucAlbaran
ra.idAlmacenOrigen = Nothing
EstableceSoloLectura(cbAlmacenOrigen, True)
EstableceSoloLectura(cbAlmacenDestino, False)
- Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.STOCK_INICIAL_O_FABRICACION
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.REGULARIZACION_STOCK
ra.idAlmacenOrigen = Nothing
EstableceSoloLectura(cbAlmacenOrigen, True)
EstableceSoloLectura(cbAlmacenDestino, False)
@@ -718,7 +718,7 @@ Public Class ucAlbaran
Dim hte As New Hashtable
Select Case DirectCast(ra.Tipo, bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum)
Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.COMPRA
- For Each d In ra.detallesalbaranes.Where(Function(x) x.EsVenta)
+ For Each d In ra.detallesalbaranesidAlbaranNavigation.Where(Function(x) x.EsVenta)
d.EsVenta = False
Next
If ra.idAlmacenDestino.HasValue = False Then hte.Add("ALMACENAR-ALMACEN_DESTINO_OBLIGATORIO", "El almacén destino es obligatorio")
@@ -733,7 +733,7 @@ Public Class ucAlbaran
If ra.idAlmacenOrigen.HasValue = False Then hte.Add("ALMACENAR-ALMACEN_ORIGEN_OBLIGATORIO", "El almacén origen es obligatorio")
Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.RECOGIDA
If ra.idAlmacenDestino.HasValue = False Then hte.Add("ALMACENAR-ALMACEN_DESTINO_OBLIGATORIO", "El almacén destino es obligatorio")
- Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.STOCK_INICIAL_O_FABRICACION
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.REGULARIZACION_STOCK
If ra.idAlmacenDestino.HasValue = False Then hte.Add("ALMACENAR-ALMACEN_DESTINO_OBLIGATORIO", "El almacén destino es obligatorio")
End Select
If hte.Count > 0 Then
@@ -745,7 +745,7 @@ Public Class ucAlbaran
Select Case Estado
Case tsUtilidades.EstadosAplicacion.Nuevo
- For Each d In ra.detallesalbaranes
+ For Each d In ra.detallesalbaranesidAlbaranNavigation
d.idAlbaranNavigation = ra
d.ActualizaProducto(bdtmp, 1)
Next
@@ -754,7 +754,7 @@ Public Class ucAlbaran
For Each d In das
d.ActualizaProducto(bdtmp, -1)
Next
- For Each d In ra.detallesalbaranes
+ For Each d In ra.detallesalbaranesidAlbaranNavigation
d.ActualizaProducto(bdtmp, 1)
Next
End Select
@@ -781,5 +781,32 @@ Public Class ucAlbaran
ra.idPresupuestoNavigation = Nothing
End Sub
+ Private Sub BiBuscarArticulo_Click(sender As Object, e As RoutedEventArgs)
+
+ Try
+ If gcProductos.CurrentItem IsNot Nothing Then
+ Dim dea As detallesalbaranes = gcProductos.CurrentItem
+ If dea.idProducto > 0 Then
+ If tvProductos.ActiveEditor Is Nothing Then
+ Dispatcher.BeginInvoke(New Action(Sub() tvProductos.ShowEditor()), System.Windows.Threading.DispatcherPriority.Render)
+ End If
+ Dim dxw As New dxwArticulos(lArticulos, dea.idProducto)
+ If dxw.ShowDialog Then
+ Dim art = lArticulos.First(Function(x) x.idArticulo = dxw.idArticulo)
+ dea.idArticulo = art.idArticulo
+ dea.Cantidad = 1
+ If tvProductos.ActiveEditor IsNot Nothing Then tvProductos.ActiveEditor.EditValue = art.idArticulo
+ tvProductos.PostEditor()
+ tvProductos.CloseEditor()
+ gcProductos.RefreshRow(tvProductos.FocusedRowHandle)
+ End If
+ End If
+ End If
+ Catch ex As Exception
+ FuncionesDinamicas.ErrorNoControladoAp(Me, ex)
+ DXMessageBox.Show(ex.Message, "Error")
+ End Try
+ End Sub
+
End Class
diff --git a/GestionGrupoSanchoToro/Almacen/ucAlbaranE.xaml b/GestionGrupoSanchoToro/Almacen/ucAlbaranE.xaml
new file mode 100644
index 0000000..352b9cf
--- /dev/null
+++ b/GestionGrupoSanchoToro/Almacen/ucAlbaranE.xaml
@@ -0,0 +1,388 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/GestionGrupoSanchoToro/Almacen/ucAlbaranE.xaml.vb b/GestionGrupoSanchoToro/Almacen/ucAlbaranE.xaml.vb
new file mode 100644
index 0000000..9e00174
--- /dev/null
+++ b/GestionGrupoSanchoToro/Almacen/ucAlbaranE.xaml.vb
@@ -0,0 +1,808 @@
+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 bdGrupoSanchoToro.db
+Imports tsUtilidades.Datos
+Imports DevExpress.Xpf.Bars
+Imports DevExpress.Xpf.Grid
+Imports System.Collections
+Imports tsUtilidades.Extensiones
+Imports tsUtilidades.Enumeraciones
+Imports bdGrupoSanchoToro.db.Utilidades
+Imports System.Drawing
+Imports bdGrupoSanchoToro.db.albaranes
+
+Public Class ucAlbaranE
+ Private bd As tscGrupoSanchoToro
+ Friend _idAlbaran As Nullable(Of Integer)
+ Private lProductos As List(Of productos)
+ Private lArticulos As List(Of articulos)
+ Friend idLog As Integer?
+
+
+ Public Overrides Sub Cargado()
+
+ Me.Tipo_ucControlBusqueda = GetType(ucAlbaranes)
+ End Sub
+ Dim ra As albaranes
+ Public Overrides Sub EstableceDataContextSecundarios(Optional Background As Boolean = False)
+ Try
+
+ lProductos = bd.productos.OrderBy(Function(x) x.Descripcion).ToList
+ Dim lProductosAlb = ra.detallesalbaranesidAlbaranNavigation.Select(Function(x) x.idProducto).ToArray
+ lProductos = lProductos.Where(Function(x) x.FechaBaja Is Nothing OrElse lProductosAlb.Contains(x.idProducto)).ToList
+ cbProducto.ItemsSource = lProductos
+
+ cbRazonSocial.ItemsSource = bd.entidades.Where(Function(X) X.FechaBaja.HasValue = False OrElse X.idEntidad = ra.idEntidad).ToList.Select(Function(x) New With {x.idEntidad, x.RazonSocial}).OrderBy(Function(x) x.RazonSocial).ToList
+
+ Dim plantillas As List(Of tsWPFCore.Plantilla) = Comun.ObtienePlantillas(bd, {"GRUPLA.ALBENT"}, False)
+ Me.ContenedorAplicacion.cbPlantillaAImprimir.ItemsSource = plantillas
+ If plantillas.Count > 0 Then
+ Me.ContenedorAplicacion.bePlantilla.EditValue = plantillas.First.idPlantilla
+ End If
+
+ Dim Acciones As New List(Of tsWPFCore.Accion)
+ Acciones.Add(New Accion With {
+ .idAccion = 1,
+ .Descripcion = "GENERA ALBARÁN DE RECOGIDA Y FACTURA RÁPIDA (F10)"})
+ Acciones.Add(New Accion With {
+ .idAccion = 3,
+ .Descripcion = "GENERA ALBARÁN DE RECOGIDA DE PRODUCTOS PENDIENTES (F11)"})
+ Acciones.Add(New Accion With {
+ .idAccion = 2,
+ .Descripcion = "ENVIAR ALBARÁN POR CORREO ELECTRÓNICO (F12)"})
+ Me.ContenedorAplicacion.cbAcciones.ItemsSource = Acciones
+ Me.ContenedorAplicacion.beAcciones.EditValue = Acciones.First.idAccion
+
+ Catch ex As Exception
+ Throw New Exception(ex.Message, ex)
+ End Try
+ End Sub
+
+
+ Public Overrides Function EstablecedcPrincipal(Optional Background As Boolean = False, Optional FuerzaNuevo As Boolean = False, Optional Refrescar As Boolean = False) As tsUtilidades.EstadosAplicacion
+ Try
+ 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.LogXML, GetType(albaranes))
+ ' If ra.idUsuario.HasValue Then ra.idUsuarioNavigation = bd.usuarios.FirstOrDefault(Function(x) x.idUsuario = ra.idUsuario.Value)
+ ' Dim df = bd.logs.FirstOrDefault(Function(x) x.idRelacionado = log.idLog AndAlso x.Aplicacion = "detallesalbaranes_AE")
+ ' If df IsNot Nothing Then
+ ' Dim ld As List(Of detallesalbaranes) = tsUtilidades.Utilidades.DeserializarSinErrores(df.LogXML, GetType(List(Of detallesalbaranes)))
+ ' For Each d In ld
+ ' Dim pr = bd.productos.FirstOrDefault(Function(x) x.idProducto = d.idProducto)
+ ' d.productos = pr
+ ' If d.idArticulo.HasValue Then
+ ' Dim art = bd.articulos.FirstOrDefault(Function(x) x.idArticulo = d.idArticulo)
+ ' d.articulos = art
+ ' End If
+ ' ra.detallesalbaranes.Add(d)
+ ' Next
+ ' End If
+ ' Dim mv = bd.logs.FirstOrDefault(Function(x) x.idRelacionado = log.idLog AndAlso x.Aplicacion = "MOVIMIENTOSCAJA_AE")
+ ' If mv IsNot Nothing Then
+ ' Dim ld = tsUtilidades.Utilidades.DeserializarSinErrores(mv.LogXML, GetType(List(Of movimientoscaja)))
+ ' For Each d In ld
+ ' ra.movimientoscaja.Add(d)
+ ' Next
+ ' End If
+ ' Dim lent = bd.logs.FirstOrDefault(Function(x) x.idRelacionado = log.idLog AndAlso x.Aplicacion = "ENTIDADES")
+ ' If lent IsNot Nothing Then
+ ' Dim ent = tsUtilidades.Utilidades.DeserializarSinErrores(lent.LogXML, GetType(entidades))
+ ' ra.entidades = ent
+ ' ' lgDatosCliente.DataContext = ra.entidades
+ ' End If
+ ' Dim lobr = bd.logs.FirstOrDefault(Function(x) x.idRelacionado = log.idLog AndAlso x.Aplicacion = "OBRAS")
+ ' If lobr IsNot Nothing Then
+ ' Dim obr = tsUtilidades.Utilidades.DeserializarSinErrores(lobr.LogXML, GetType(destinomontajes))
+ ' ra.destinomontajes = obr
+ ' ' lgDatosObra.DataContext = ra.destinomontajes
+ ' 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 FuerzaNuevo OrElse _idAlbaran Is Nothing Then
+ ra = New albaranes
+ _idAlbaran = Nothing
+ ra.Fecha = DateOnly.FromDateTime(Today)
+ ra.NumeroBultos = 1
+ NuevoEstado = tsUtilidades.EstadosAplicacion.Nuevo
+ Else
+ ra = bd.albaranes.First(Function(x) x.idAlbaran = _idAlbaran)
+ NuevoEstado = tsUtilidades.EstadosAplicacion.ModificandoRegistro
+ End If
+ End If
+ If Me.cbTipo.ItemsSource Is Nothing Then
+ cbTipo.ItemsSource = tsUtilidades.DescripcionValor.EnumADescripcionValor(GetType(bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum))
+ cbAlmacenOrigen.ItemsSource = Comun.ObtieneListaAlmacenes(bd)
+ End If
+ 'Me.gcLogs.ItemsSource = bd.logs.Where(Function(x) x.id = ra.idAlbaran AndAlso x.Aplicacion = "albaranes").ToList
+ gcProductos.ItemsSource = ra.detallesalbaranesidAlbaranNavigation
+ Me.DataContext = ra
+ Return NuevoEstado
+ Catch ex As Exception
+ Throw New Exception(ex.Message, ex)
+ End Try
+ 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 "albaranes"
+ End Get
+ End Property
+
+ Private ReadOnly Property IAplicacion_CampoIndice As String
+ Get
+ Return "idAlbaran"
+ End Get
+ End Property
+ Public Overrides ReadOnly Property idRegistroAplicacionActual As String
+ Get
+ If idLog.HasValue Then
+ Return "Albarán R.C.:" & idLog.ToString
+ Else
+ If Me.Estado = tsUtilidades.EstadosAplicacion.Nuevo Then
+ Return "Albarán.Nuevo"
+ Else
+ Return "Albarán." & DirectCast(Me.DataContext, albaranes).idAlbaran.ToString
+ End If
+ End If
+ End Get
+ End Property
+
+ Public Overrides ReadOnly Property DescripcionRegistro As String
+ Get
+ Return "Albarán"
+ End Get
+ End Property
+
+ 'Public Overrides ReadOnly Property CampoIndice As String
+ ' Get
+ ' Return "idAlbaranEntrega"
+ ' End Get
+ 'End Property
+
+ Public Sub New(Optional idAlbaran As Integer? = Nothing)
+
+ ' Llamada necesaria para el diseñador.
+ InitializeComponent()
+ _idAlbaran = idAlbaran
+ ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
+
+ End Sub
+
+
+ Public Overrides Sub EstableceTitulo()
+ If idLog.HasValue Then
+ Me.docpanel.Caption = "R.C. Albarán " & ra.idAlbaran
+ Me.docpanel.Tag = "R.C. Albarán." & ra.idAlbaran
+ Else
+ If Me.Estado = tsUtilidades.EstadosAplicacion.ModificandoRegistro Then
+ Me.docpanel.Caption = "Albarán " & ra.idAlbaran
+ Me.docpanel.Tag = "Albarán." & ra.idAlbaran.ToString
+ Else
+ Me.docpanel.Caption = "Albarán Nuevo"
+ Me.docpanel.Tag = "Albaran.Nuevo"
+ End If
+ End If
+ End Sub
+
+ Public Overrides Function obtienePermisos() As tsUtilidades.Permisos
+ Return Comun.ObtienePermisos(Me.bd, "AP.ADMINISTRATIVOS", bdGrupoSanchoToro.db.Utilidades.idUsuario)
+ End Function
+
+
+ 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
+ Me.ErroresValidacion.EliminaError("validando-" & pts.NombreCampo)
+
+ Select Case pts.NombreCampo.ToLower
+
+ Case "codigopostalcarga"
+ If Not e.Value Is Nothing AndAlso e.Value.ToString <> "" AndAlso e.Value.ToString <> ra.CodigoMunicipioCarga 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 If sCpo.Length <> 5 Then Throw New Exception("El código postal del Cliente 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.CodigoMunicipioCarga = pob.CodigoMunicipio
+ Else
+ Throw New Exception("El código postal de la carga no es correcto")
+ End If
+ Case 1
+ Dim pob = bd.codigospostales.First(Function(x) x.CodigoPostal = sCpo)
+ ra.CodigoMunicipioCarga = pob.CodigoMunicipio
+ Case Else
+ Dim wMunicipios As New dxwCodigosPostales(bd, sCpo)
+ If wMunicipios.ShowDialog Then
+ ra.CodigoMunicipioCarga = wMunicipios.CodigoMunicipio
+ Else
+ Throw New Exception("El código postal de la carga no es correcto")
+ End If
+ End Select
+ ra.CodigoMunicipioCargaNavigation = bd.municipios.First(Function(x) x.CodigoMunicipio = ra.CodigoMunicipioCarga)
+ ' ra.CodigoPostalCarga = sCpo
+ ra.RefrescaCamposSoloLectura()
+ End If
+ Case "codigopostaldescarga"
+ If Not e.Value Is Nothing AndAlso e.Value.ToString <> "" AndAlso e.Value.ToString <> ra.CodigoMunicipioDescarga 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 If sCpo.Length <> 5 Then Throw New Exception("El código postal del Cliente 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.CodigoMunicipioDescarga = pob.CodigoMunicipio
+ Else
+ Throw New Exception("El código postal de la descarga no es correcto")
+ End If
+ Case 1
+ Dim pob = bd.codigospostales.First(Function(x) x.CodigoPostal = sCpo)
+ ra.CodigoMunicipioDescarga = pob.CodigoMunicipio
+ Case Else
+ Dim wMunicipios As New dxwCodigosPostales(bd, sCpo)
+ If wMunicipios.ShowDialog Then
+ ra.CodigoMunicipioDescarga = wMunicipios.CodigoMunicipio
+ Else
+ Throw New Exception("El código postal de la descarga no es correcto")
+ End If
+ End Select
+ ra.CodigoMunicipioDescargaNavigation = bd.municipios.First(Function(x) x.CodigoMunicipio = ra.CodigoMunicipioCarga)
+ ' ra.CodigoPostalDescarga = sCpo
+ ra.RefrescaCamposSoloLectura()
+
+ End If
+ Case "emailcarga"
+ 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 "emaildescarga"
+ 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
+
+ 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 BtAñadirCodigoPostalCarga_Click(sender As Object, e As RoutedEventArgs)
+ If ContenedorAplicacion.btGuardar.IsEnabled Then
+ Dim vncp As New dxwAgregarNuevoMunicipio("")
+ If vncp.ShowDialog Then
+ Dim pob = bd.codigospostales.AsNoTracking.First(Function(x) x.CodigoPostal = vncp._CodigoPostal)
+ ra.CodigoMunicipioCarga = pob.CodigoMunicipio
+ ra.CodigoPostalCarga = vncp._CodigoPostal
+ ra.CodigoMunicipioCargaNavigation = bd.municipios.AsNoTracking.First(Function(x) x.CodigoMunicipio = ra.CodigoMunicipioCarga)
+ ra.RefrescaCamposSoloLectura()
+ End If
+ End If
+ End Sub
+ Private Sub BtAñadirCodigoPostalDesCarga_Click(sender As Object, e As RoutedEventArgs)
+ If ContenedorAplicacion.btGuardar.IsEnabled Then
+ Dim vncp As New dxwAgregarNuevoMunicipio("")
+ If vncp.ShowDialog Then
+ Dim pob = bd.codigospostales.First(Function(x) x.CodigoPostal = vncp._CodigoPostal)
+ ra.CodigoMunicipioDescarga = pob.CodigoMunicipio
+ ra.CodigoPostalDescarga = vncp._CodigoPostal
+ ra.CodigoMunicipioDescargaNavigation = bd.municipios.AsNoTracking.First(Function(x) x.CodigoMunicipio = ra.CodigoMunicipioDescarga)
+ ra.RefrescaCamposSoloLectura()
+ End If
+ End If
+ End Sub
+ Private Sub BtCancelarCodigoPostalCarga_Click(sender As Object, e As RoutedEventArgs)
+ If ContenedorAplicacion.btGuardar.IsEnabled Then
+ ra.CodigoPostalCarga = ""
+ ra.CodigoMunicipioCarga = ""
+ ra.CodigoMunicipioCarga = Nothing
+ ra.RefrescaCamposSoloLectura()
+ End If
+ End Sub
+ Private Sub BtCancelarCodigoPostalDescarga_Click(sender As Object, e As RoutedEventArgs)
+ If ContenedorAplicacion.btGuardar.IsEnabled Then
+ ra.CodigoPostalDescarga = ""
+ ra.CodigoMunicipioDescarga = ""
+ ra.CodigoMunicipioDescargaNavigation = Nothing
+ ra.RefrescaCamposSoloLectura()
+ End If
+ End Sub
+
+ Private Sub ap_DespuesGuardar(sender As Object, e As ItemClickEventArgs, OpcionGuardado As Integer) Handles Me.DespuesGuardar
+ Dim ae As albaranes = Me.DataContext
+ _idAlbaran = DirectCast(Me.DataContext, albaranes).idAlbaran
+ 'Me.gcLogs.ItemsSource = bd.logs.Where(Function(x) x.id = ae.idAlbaran AndAlso x.Aplicacion = "albaranes").ToList
+ End Sub
+
+
+ Private Sub ap_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 ucAlbaran
+ ' uc.idLog = log.idLog
+ ' FuncionesDinamicas.AbrirAP(uc, OtrosParametros)
+ 'End Select
+ End Sub
+
+
+ Private Sub ap_EstadoCambiado(EstadoAnterior As tsUtilidades.EstadosAplicacion, EstadoNuevo As tsUtilidades.EstadosAplicacion) Handles Me.EstadoCambiado
+ If idLog.HasValue Then EstableceSoloLectura()
+ Select Case EstadoNuevo
+ Case tsUtilidades.EstadosAplicacion.ModificandoRegistro
+ If ra.Tipo = TipoAlbaranEnum.COMPRA Then
+ gcEsVenta.ReadOnly = True
+ Else
+ gcEsVenta.ReadOnly = False
+ End If
+ End Select
+ End Sub
+
+
+ Private Sub BiBuscarProducto_Click(sender As Object, e As RoutedEventArgs)
+
+
+ If tvProductos.ActiveEditor Is Nothing Then
+ Dispatcher.BeginInvoke(New Action(Sub() tvProductos.ShowEditor()), System.Windows.Threading.DispatcherPriority.Render)
+ End If
+ Dim dxw As New dxwProductos(lProductos)
+ If dxw.ShowDialog Then
+ Dim dea As detallesalbaranes = gcProductos.CurrentItem
+ Dim prod = lProductos.First(Function(x) x.idProducto = dxw.idProducto)
+ If tvProductos.ActiveEditor IsNot Nothing Then
+ tvProductos.ActiveEditor.EditValue = prod.idProducto
+ Else
+ Debug.Write("no")
+ End If
+ tvProductos.PostEditor()
+ tvProductos.CloseEditor()
+ gcProductos.RefreshRow(tvProductos.FocusedRowHandle)
+ End If
+ End Sub
+
+ Private Sub BiBuscarCliente_Click(sender As Object, e As RoutedEventArgs)
+ 'If Me.Estado = EstadosAplicacion.Nuevo Then
+ Dim dxw As New dxwEntidades(bd, True, False)
+ If dxw.ShowDialog Then
+ Dim ent = bd.entidades.First(Function(x) x.idEntidad = dxw.Entidad.idEntidad)
+ ra.idEntidadNavigation = ent
+ ra.idEntidad = ent.idEntidad
+ End If
+ ' End If
+ End Sub
+
+
+
+ Private Sub RellenaDatosProducto(dea As detallesalbaranes)
+ If dea IsNot Nothing AndAlso dea.idProducto <> 0 Then
+ Dim ae As albaranes = Me.DataContext
+ Dim pr = lProductos.First(Function(x) x.idProducto = dea.idProducto)
+ If dea.Cantidad = 0 Then dea.Cantidad = 1
+ dea.EsVenta = False
+ End If
+ End Sub
+
+
+
+
+
+
+
+
+
+ Private Sub BeCodigoPostalCarga_DefaultButtonClick(sender As Object, e As RoutedEventArgs)
+
+ Dim dxw As New dxwCodigosPostales(bd, "")
+ If dxw.ShowDialog Then
+ ra.CodigoMunicipioCarga = dxw.CodigoMunicipio
+ ra.CodigoMunicipioCargaNavigation = bd.municipios.First(Function(x) x.CodigoMunicipio = ra.CodigoMunicipioCarga)
+ ra.CodigoPostalCarga = dxw.CodigoPostal
+ ra.RefrescaCamposSoloLectura()
+ End If
+ End Sub
+
+ Private Sub BeCodigoPostalDescarga_DefaultButtonClick(sender As Object, e As RoutedEventArgs)
+
+ Dim dxw As New dxwCodigosPostales(bd, "")
+ If dxw.ShowDialog Then
+ ra.CodigoMunicipioDescarga = dxw.CodigoMunicipio
+ ra.CodigoPostalDescarga = dxw.CodigoPostal
+ ra.CodigoMunicipioDescargaNavigation = bd.municipios.First(Function(x) x.CodigoMunicipio = ra.CodigoMunicipioDescarga)
+ ra.RefrescaCamposSoloLectura()
+ End If
+ End Sub
+
+
+
+ Private Sub uc_ImprimirPlantilla(sender As Object, e As ItemClickEventArgs, idPlantilla As Integer, Previsualizar As Boolean) Handles Me.ImprimirPlantilla
+
+ If Me.Estado = tsUtilidades.EstadosAplicacion.ModificandoRegistro Then
+ Dim bdtmp = tscGrupoSanchoToro.NuevoContexto
+ Dim ae = bdtmp.albaranes.First(Function(x) x.idAlbaran = ra.idAlbaran)
+ Imprimir(ra, idPlantilla, 1, False)
+ Else
+ DXMessageBox.Show("Antes debe almacenar", "Atención")
+ End If
+ End Sub
+
+ Private Sub Imprimir(ra As albaranes, idPlantilla As Integer, Copias As Integer, ImpresoraDefecto As Boolean)
+ Dim ds As List(Of albaranes)
+ ' Dim pl As plantillas = (From p In bd.plantillas Where p.idPlantilla = idPlantilla).First
+ Dim pl = bd.plantillas.AsNoTracking.Where(Function(x) x.idPlantilla = idPlantilla).Select(Function(x) New With {.Fichero = x.idFicheroNavigation.Fichero, .Tipo = x.idGrupoNavigation.Codigo}).FirstOrDefault
+ ds = New List(Of albaranes)
+ ds.Add(ra)
+ Select Case pl.Tipo
+ Case Else ' "GRUPLA.ALBENT"
+ tsWPFCore.tsXtraReport.ImprimirPlantilla(pl.Fichero, ImpresoraDefecto, Copias, ds)
+ End Select
+ End Sub
+
+ Private Sub tvProductos_ShowingEditor(sender As Object, e As ShowingEditorEventArgs) Handles tvProductos.ShowingEditor
+
+ 'If ra.detallesalbaranes.ToList.Any(Function(x) x.idAlbaranRecogida.HasValue OrElse (x.idUltimaFactura.HasValue AndAlso (x.facturas.Fecha > ra.Fecha.Date))) Then
+ ' If e.RowHandle <> DataControlBase.NewItemRowHandle Then
+ ' Dim da As detallesalbaranes = gcProductos.GetRow(e.RowHandle)
+ ' If e.Column.FieldName.ToLower <> "observaciones" AndAlso e.Column.FieldName.ToLower <> "fechacancelacion" AndAlso e.Column.FieldName.ToLower <> "motivocancelacion" AndAlso e.Column.FieldName.ToLower <> "precio" AndAlso e.Column.FieldName.ToLower <> "cantidad" Then
+ ' If da.idAlbaranRecogida.HasValue OrElse da.idUltimaFactura.HasValue Then
+ ' e.Cancel = True
+ ' e.Handled = True
+ ' End If
+ ' End If
+ ' End If
+ 'End If
+ End Sub
+
+ Private Sub beCodigoPostalCarga_PreviewKeyDown(sender As Object, e As KeyEventArgs) Handles beCodigoPostalCarga.PreviewKeyDown
+ If e.Key = Key.F6 Then
+ BeCodigoPostalCarga_DefaultButtonClick(Nothing, Nothing)
+ End If
+
+ End Sub
+
+ Private Sub beCodigoPostalDescarga_PreviewKeyDown(sender As Object, e As KeyEventArgs) Handles beCodigoPostalDescarga.PreviewKeyDown
+ If e.Key = Key.F6 Then
+ BeCodigoPostalDescarga_DefaultButtonClick(Nothing, Nothing)
+ End If
+ End Sub
+
+ Private Sub tvProductos_ValidateRow(sender As Object, e As GridRowValidationEventArgs) Handles tvProductos.ValidateRow
+ 'Dim da As detallesalbaranes = e.Row
+ 'Dim Errores As String = ""
+ 'If da.Cantidad <> 1 AndAlso da.idArticulo.HasValue Then
+ ' Errores &= "Si es un artículo en concreto la cantidad tiene que ser 1" & vbCrLf
+ 'End If
+ 'If Errores <> "" Then
+ ' DXMessageBox.Show(Errores, "Error")
+ ' e.SetError(Errores)
+ ' e.IsValid = False
+ 'End If
+
+ Try
+ Dim htErrores = New Hashtable
+ ErroresValidacion.LimpiarErrores("TSGC-" & gcProductos.PropiedadesTS.NumeroObjeto.ToString & ":" & e.RowHandle.ToString & ":")
+ Dim da As detallesalbaranes = e.Row
+
+ If da.Cantidad <> 1 AndAlso da.idArticulo.HasValue Then
+ htErrores.Add("Cantidad1", "Si es un artículo en concreto la cantidad tiene que ser 1")
+ End If
+ If htErrores.Count > 0 Then
+ Me.AgregaErroresTSGC(gcProductos, htErrores, e)
+ End If
+ Catch ex As Exception
+ FuncionesDinamicas.ErrorNoControladoAp(Me, ex)
+ DXMessageBox.Show(ex.Message, "Error")
+ End Try
+
+ End Sub
+
+ Private Sub tvProductos_InitNewRow(sender As Object, e As InitNewRowEventArgs) Handles tvProductos.InitNewRow
+ gcProductos.SetCellValue(e.RowHandle, "Cantidad", 1)
+ End Sub
+
+ Private Sub ucAlbaranEntrega_EjecutarAccion(sender As Object, e As ItemClickEventArgs, idAccion As Integer) Handles Me.EjecutarAccion
+ 'Select Case idAccion
+ ' Case 1 ' GENERA ALBARÁN DE RECOGIDA Y FACTURA RAPIDA
+ ' Try
+ ' If Not Guardar(Nothing, Nothing,,, 3) Then
+ ' Dim ae As albaranes = Me.DataContext
+ ' ' If ae.detallesalbaranes.Any(Function(x) x.idAlbaranRecogida.HasValue) Then
+ ' ' DXMessageBox.Show("Sólo se puede generar una factura rápida si no se ha recogido ningún producto del albarán", "Atención")
+ ' ' Else
+ ' Dim ar As albaranesrecogida = New albaranesrecogida
+ ' With ar
+ ' .Fecha = Now
+ ' .idCliente = ae.idCliente
+ ' .idUsuario = idUsuario
+ ' .EstableceNumeroAlbaran(bd)
+ ' End With
+ ' bd.albaranesrecogida.Add(ar)
+ ' For Each d In ae.detallesalbaranes.Where(Function(x) x.EsVenta = False AndAlso x.idAlbaranRecogida.HasValue = False)
+ ' d.albaranesrecogida = ar
+ ' Next
+ ' bd.GuardarCambios()
+ ' Dim id As Integer = ae.idAlbaranEntrega
+ ' Dim uc As New ucFacturaEmitida(,, id)
+ ' FuncionesDinamicas.AbrirAP(uc, OtrosParametros)
+ ' tsWPFCore.Comun.dm.DockController.RemovePanel(docpanel)
+ ' End If
+ ' Catch ex As Exception
+ ' FuncionesDinamicas.ErrorNoControladoAp(Me, ex)
+ ' DXMessageBox.Show(ex.Message, "Error")
+ ' End Try
+ ' Case 2 ' ENVIA ALBARÁN DE ENTREGA POR EMAIL
+
+ ' Dim bCancelar As Boolean = False
+ ' If Me.ContenedorAplicacion.btGuardar.IsEnabled Then
+ ' bCancelar = Me.Guardar(Nothing, Nothing,, True, 5)
+ ' End If
+ ' If Not bCancelar Then
+ ' Dim dxnc = New dxwEnvioCorreo(ra.entidades.Email, ra.entidades.Email2, "", "Producciones Romian, S.L. - Adjunto le remitimos albarán de entrega nº " & ra.NumeroAlbaran, "Distinguidos Sres., " & vbCrLf & "Adjunto le remitimos albarán entrega nº " & ra.NumeroAlbaran, "AlbaranEntrega_" & ra.NumeroAlbaran.Replace("/", "-") & ".pdf")
+ ' If dxnc.ShowDialog Then
+ ' Dim cta = bd.cuentascorreo.First(Function(x) x.Codigo = "DEFECTO")
+ ' Dim bAlbaran = GeneraPdfAlbaran(bd, ra)
+ ' bdGrupoSanchoToro.db.correos.GeneraRegistroCorreon(bd, dxnc._Asunto, dxnc._Cuerpo, cta, dxnc._Destinatarios, dxnc._CC, dxnc._BCC, bAlbaran, dxnc._Adjunto, ra.idAlbaranEntrega, "albaranes", ra.idCliente)
+ ' End If
+ ' End If
+ 'Case 3 ' GENERA ALBARÁN DE RECOGIDA RÁPIDO
+ ' Try
+ ' If Not Guardar(Nothing, Nothing,,, 3) Then
+ ' Dim ae As albaranes = Me.DataContext
+ ' Dim uc As New ucAlbaranRecogida(, ae.idAlbaranEntrega)
+ ' FuncionesDinamicas.AbrirAP(uc, OtrosParametros)
+ ' tsWPFCore.Comun.dm.DockController.RemovePanel(docpanel)
+ ' End If
+ ' Catch ex As Exception
+ ' FuncionesDinamicas.ErrorNoControladoAp(Me, ex)
+ ' DXMessageBox.Show(ex.Message, "Error")
+ ' End Try
+
+ ' End Select
+ End Sub
+
+ Friend Shared Function GeneraPdfAlbaran(bd As tscGrupoSanchoToro, Albaran As albaranes) As Byte()
+ Dim albes As New List(Of albaranes)
+ albes.Add(Albaran)
+ Dim tipo As String = "ALB_" & Albaran.Tipo.ToString
+ Dim idplae = bd.plantillas.First(Function(x) x.Codigo = tipo).idPlantilla
+ Dim bAes = Informes.GuardaInformeEnPdf(bd, idplae, albes)
+ Return bAes
+ End Function
+
+
+
+ Private Sub ucAlbaranEntrega_TeclaFuncionPulsada(sender As Object, e As KeyEventArgs) Handles Me.TeclaFuncionPulsada
+ Select Case e.Key
+ Case Key.F12
+ ValidaControlObjetoActual()
+ ucAlbaranEntrega_EjecutarAccion(Nothing, Nothing, 2)
+ Case Key.F11
+ ValidaControlObjetoActual()
+ ucAlbaranEntrega_EjecutarAccion(Nothing, Nothing, 3)
+
+ Case Key.System
+ Select Case e.SystemKey
+ Case Key.F10
+ ValidaControlObjetoActual()
+ ucAlbaranEntrega_EjecutarAccion(Nothing, Nothing, 1)
+ e.Handled = True
+ End Select
+
+ End Select
+ End Sub
+
+ Private Sub gcProductos_AntesEliminar(gc As tsGridControl, ByRef Cancelar As Boolean) Handles gcProductos.AntesEliminar
+
+ End Sub
+
+
+
+ Private Sub ucAlbaranEntrega_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 "tipo"
+ gcEsVenta.ReadOnly = False
+ Select Case DirectCast(ra.Tipo, bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum)
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.COMPRA
+ For Each d In ra.detallesalbaranesidAlbaranNavigation.Where(Function(x) x.EsVenta)
+ d.EsVenta = False
+ Next
+ gcEsVenta.ReadOnly = True
+ ra.idAlmacenOrigen = Nothing
+ EstableceSoloLectura(cbAlmacenOrigen, True)
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.CAMBIO_ALMACEN
+ EstableceSoloLectura(cbAlmacenOrigen, False)
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.SUBALQUILER
+ ra.idAlmacenOrigen = Nothing
+ EstableceSoloLectura(cbAlmacenOrigen, True)
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.DEVOLUCION_SUBALQUILER
+ EstableceSoloLectura(cbAlmacenOrigen, False)
+ ra.idAlmacenDestino = Nothing
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.ENTREGA
+ EstableceSoloLectura(cbAlmacenOrigen, False)
+ ra.idAlmacenDestino = Nothing
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.RECOGIDA
+ ra.idAlmacenOrigen = Nothing
+ EstableceSoloLectura(cbAlmacenOrigen, True)
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.REGULARIZACION_STOCK
+ ra.idAlmacenOrigen = Nothing
+ EstableceSoloLectura(cbAlmacenOrigen, True)
+ End Select
+ End Select
+ End If
+ End Sub
+
+
+ Private Sub hlVale_Click(sender As Object, e As RoutedEventArgs)
+ 'Dim uc As New ucPresupuesto(ra.idPresupuesto)
+ 'FuncionesDinamicas.AbrirAP(uc, OtrosParametros)
+ End Sub
+
+ 'Private Sub hlPresupuesto_Click(sender As Object, e As RoutedEventArgs)
+ ' If ra.idPresupuesto.HasValue Then
+ ' Dim uc As New ucPresupuesto(ra.idPresupuesto)
+ ' FuncionesDinamicas.AbrirAP(uc, OtrosParametros)
+ ' End If
+ 'End Sub
+
+ Private Sub beContrato_DefaultButtonClick(sender As Object, e As RoutedEventArgs)
+ 'Dim dxw As New dxwAsignarContrato(bd, ra.idEntidad)
+ 'If dxw.ShowDialog Then
+ ' Dim ctr = bd.presupuestos.First(Function(x) x.idPresupuesto = dxw.idPresupuesto)
+ ' ra.idPresupuestoNavigation = ctr
+ ' If ra.idEntidad.HasValue = False Then
+ ' ra.idEntidadNavigation = ctr.idClienteNavigation
+ ' ra.idEntidad = ctr.idCliente
+ ' End If
+
+ 'End If
+ End Sub
+
+ Private Sub ucAlbaran_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
+ Select Case DirectCast(ra.Tipo, bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum)
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.COMPRA
+ For Each d In ra.detallesalbaranesidAlbaranNavigation.Where(Function(x) x.EsVenta)
+ d.EsVenta = False
+ Next
+ If ra.idAlmacenDestino.HasValue = False Then hte.Add("ALMACENAR-ALMACEN_DESTINO_OBLIGATORIO", "El almacén destino es obligatorio")
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.CAMBIO_ALMACEN
+ If ra.idAlmacenOrigen.HasValue = False Then hte.Add("ALMACENAR-ALMACEN_ORIGEN_OBLIGATORIO", "El almacén origen es obligatorio")
+ If ra.idAlmacenDestino.HasValue = False Then hte.Add("ALMACENAR-ALMACEN_DESTINO_OBLIGATORIO", "El almacén destino es obligatorio")
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.SUBALQUILER
+ If ra.idAlmacenDestino.HasValue = False Then hte.Add("ALMACENAR-ALMACEN_DESTINO_OBLIGATORIO", "El almacén destino es obligatorio")
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.DEVOLUCION_SUBALQUILER
+ If ra.idAlmacenOrigen.HasValue = False Then hte.Add("ALMACENAR-ALMACEN_ORIGEN_OBLIGATORIO", "El almacén origen es obligatorio")
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.ENTREGA
+ If ra.idAlmacenOrigen.HasValue = False Then hte.Add("ALMACENAR-ALMACEN_ORIGEN_OBLIGATORIO", "El almacén origen es obligatorio")
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.RECOGIDA
+ If ra.idAlmacenDestino.HasValue = False Then hte.Add("ALMACENAR-ALMACEN_DESTINO_OBLIGATORIO", "El almacén destino es obligatorio")
+ Case bdGrupoSanchoToro.db.albaranes.TipoAlbaranEnum.REGULARIZACION_STOCK
+ If ra.idAlmacenDestino.HasValue = False Then hte.Add("ALMACENAR-ALMACEN_DESTINO_OBLIGATORIO", "El almacén destino es obligatorio")
+ End Select
+ If hte.Count > 0 Then
+ MensajesError = hte
+ Cancelar = True
+ Else
+ ra.idUsuario = bdGrupoSanchoToro.db.Utilidades.idUsuario
+ Dim bdtmp = tscGrupoSanchoToro.NuevoContexto
+
+ Select Case Estado
+ Case tsUtilidades.EstadosAplicacion.Nuevo
+ For Each d In ra.detallesalbaranesidAlbaranNavigation
+ d.idAlbaranNavigation = ra
+ d.ActualizaProducto(bdtmp, 1)
+ Next
+ Case tsUtilidades.EstadosAplicacion.ModificandoRegistro
+ Dim das = bdtmp.detallesalbaranes.Where(Function(x) x.idAlbaran = ra.idAlbaran).ToList
+ For Each d In das
+ d.ActualizaProducto(bdtmp, -1)
+ Next
+ For Each d In ra.detallesalbaranesidAlbaranNavigation
+ d.ActualizaProducto(bdtmp, 1)
+ Next
+ End Select
+ End If
+ End Sub
+
+ Private Sub ucAlbaran_AntesEliminar(sender As Object, e As ItemClickEventArgs, ByRef Cancelar As Boolean, ByRef MensajesError As Hashtable, ByRef OmitirPreguntaContinuar As Boolean) Handles Me.AntesEliminar
+ Dim bdtmp = tscGrupoSanchoToro.NuevoContexto
+ Dim das = bdtmp.detallesalbaranes.Where(Function(x) x.idAlbaran = ra.idAlbaran).ToList
+ For Each d In das
+ d.ActualizaProducto(bdtmp, -1)
+ Next
+ End Sub
+
+ Private Sub btIrAContrato_Click(sender As Object, e As RoutedEventArgs)
+ If ra.idPresupuesto.HasValue Then
+ 'Dim uc As New ucPresupuesto(ra.idPresupuesto)
+ 'FuncionesDinamicas.AbrirAP(uc, OtrosParametros)
+ End If
+ End Sub
+
+ Private Sub btQuitarContrato_Click(sender As Object, e As RoutedEventArgs)
+ ra.idPresupuesto = Nothing
+ ra.idPresupuestoNavigation = Nothing
+ End Sub
+
+ Private Sub tvProductos_PreviewKeyDown(sender As Object, e As KeyEventArgs) Handles tvProductos.PreviewKeyDown
+ If e.Key = Key.F6 Then
+
+ If Not ra.detallesalbaranesidAlbaranNavigation.ToList.Any(Function(x) x.idAlbaranRecogida.HasValue OrElse (x.idUltimaFactura.HasValue AndAlso (x.idUltimaFacturaNavigation.FechaFactura > ra.Fecha))) Then
+ Select Case gcProductos.CurrentColumn.FieldName.ToLower
+ Case "idproducto"
+ BiBuscarProducto_Click(Nothing, Nothing)
+ Case "idarticulo"
+ BiBuscarArticulo_Click(Nothing, Nothing)
+ End Select
+
+ End If
+ End If
+ End Sub
+ Private Sub BiBuscarArticulo_Click(sender As Object, e As RoutedEventArgs)
+
+ Try
+ If gcProductos.CurrentItem IsNot Nothing Then
+ Dim dea As detallesalbaranes = gcProductos.CurrentItem
+ If dea.idProducto > 0 Then
+ If tvProductos.ActiveEditor Is Nothing Then
+ Dispatcher.BeginInvoke(New Action(Sub() tvProductos.ShowEditor()), System.Windows.Threading.DispatcherPriority.Render)
+ End If
+ Dim dxw As New dxwArticulos(lArticulos, dea.idProducto)
+ If dxw.ShowDialog Then
+ Dim art = lArticulos.First(Function(x) x.idArticulo = dxw.idArticulo)
+ dea.idArticulo = art.idArticulo
+ dea.Cantidad = 1
+ If tvProductos.ActiveEditor IsNot Nothing Then tvProductos.ActiveEditor.EditValue = art.idArticulo
+ tvProductos.PostEditor()
+ tvProductos.CloseEditor()
+ gcProductos.RefreshRow(tvProductos.FocusedRowHandle)
+ End If
+ End If
+ End If
+ Catch ex As Exception
+ FuncionesDinamicas.ErrorNoControladoAp(Me, ex)
+ DXMessageBox.Show(ex.Message, "Error")
+ End Try
+ End Sub
+
+
+End Class
diff --git a/bdGrupoSanchoToro/db/albaranes.cs b/bdGrupoSanchoToro/db/albaranes.cs
index 3c79dfb..89225b2 100644
--- a/bdGrupoSanchoToro/db/albaranes.cs
+++ b/bdGrupoSanchoToro/db/albaranes.cs
@@ -75,7 +75,9 @@ public partial class albaranes
public virtual municipios? CodigoMunicipioDescargaNavigation { get; set; }
- public virtual ICollection detallesalbaranes { get; set; } = new List();
+ public virtual ICollection detallesalbaranesidAlbaranNavigation { get; set; } = new List();
+
+ public virtual ICollection detallesalbaranesidAlbaranRecogidaNavigation { get; set; } = new List();
public virtual almacenes? idAlmacenDestinoNavigation { get; set; }
diff --git a/bdGrupoSanchoToro/db/detallesalbaranes.cs b/bdGrupoSanchoToro/db/detallesalbaranes.cs
index 40f72fb..2959f42 100644
--- a/bdGrupoSanchoToro/db/detallesalbaranes.cs
+++ b/bdGrupoSanchoToro/db/detallesalbaranes.cs
@@ -25,9 +25,17 @@ public partial class detallesalbaranes
public bool IncluidoEnPresupuesto { get; set; }
+ public int? idAlbaranRecogida { get; set; }
+
+ public int? idUltimaFactura { get; set; }
+
public virtual albaranes idAlbaranNavigation { get; set; } = null!;
+ public virtual albaranes? idAlbaranRecogidaNavigation { get; set; }
+
public virtual articulos? idArticuloNavigation { get; set; }
public virtual productos idProductoNavigation { get; set; } = null!;
+
+ public virtual facturas? idUltimaFacturaNavigation { get; set; }
}
diff --git a/bdGrupoSanchoToro/db/facturas.cs b/bdGrupoSanchoToro/db/facturas.cs
index 462b243..1a387ec 100644
--- a/bdGrupoSanchoToro/db/facturas.cs
+++ b/bdGrupoSanchoToro/db/facturas.cs
@@ -77,6 +77,8 @@ public partial class facturas
public virtual municipios? CodigoMunicipioNavigation { get; set; }
+ public virtual ICollection detallesalbaranes { get; set; } = new List();
+
public virtual ICollection detallesfacturas { get; set; } = new List();
public virtual ICollection documentosfacturas { get; set; } = new List();
diff --git a/bdGrupoSanchoToro/dbcontext/GrupoSanchoToroContext.cs b/bdGrupoSanchoToro/dbcontext/GrupoSanchoToroContext.cs
index 864e406..92a3ba1 100644
--- a/bdGrupoSanchoToro/dbcontext/GrupoSanchoToroContext.cs
+++ b/bdGrupoSanchoToro/dbcontext/GrupoSanchoToroContext.cs
@@ -836,14 +836,23 @@ public partial class GrupoSanchoToroContext : DbContext
entity.HasIndex(e => e.idAlbaran, "detallesalbaranes_albaranes_idx");
+ entity.HasIndex(e => e.idAlbaranRecogida, "detallesalbaranes_albaranrecogida_idx");
+
entity.HasIndex(e => e.idArticulo, "detallesalbaranes_articulos_idx");
+ entity.HasIndex(e => e.idUltimaFactura, "detallesalbaranes_facturas_idx");
+
entity.HasIndex(e => e.idProducto, "detallesalbaranes_productos_idx");
- entity.HasOne(d => d.idAlbaranNavigation).WithMany(p => p.detallesalbaranes)
+ entity.HasOne(d => d.idAlbaranNavigation).WithMany(p => p.detallesalbaranesidAlbaranNavigation)
.HasForeignKey(d => d.idAlbaran)
.HasConstraintName("detallesalbaranes_albaranes");
+ entity.HasOne(d => d.idAlbaranRecogidaNavigation).WithMany(p => p.detallesalbaranesidAlbaranRecogidaNavigation)
+ .HasForeignKey(d => d.idAlbaranRecogida)
+ .OnDelete(DeleteBehavior.SetNull)
+ .HasConstraintName("detallesalbaranes_albaranrecogida");
+
entity.HasOne(d => d.idArticuloNavigation).WithMany(p => p.detallesalbaranes)
.HasForeignKey(d => d.idArticulo)
.OnDelete(DeleteBehavior.SetNull)
@@ -853,6 +862,11 @@ public partial class GrupoSanchoToroContext : DbContext
.HasForeignKey(d => d.idProducto)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("detallesalbaranes_productos");
+
+ entity.HasOne(d => d.idUltimaFacturaNavigation).WithMany(p => p.detallesalbaranes)
+ .HasForeignKey(d => d.idUltimaFactura)
+ .OnDelete(DeleteBehavior.SetNull)
+ .HasConstraintName("detallesalbaranes_facturas");
});
modelBuilder.Entity(entity =>
diff --git a/bdGrupoSanchoToro/efpt.config.json b/bdGrupoSanchoToro/efpt.config.json
index 3f48bd6..e2e1553 100644
--- a/bdGrupoSanchoToro/efpt.config.json
+++ b/bdGrupoSanchoToro/efpt.config.json
@@ -4,18 +4,15 @@
"ContextNamespace": null,
"FilterSchemas": false,
"IncludeConnectionString": false,
- "IrregularWords": null,
"MinimumProductVersion": "2.6.1301",
"ModelNamespace": null,
"OutputContextPath": "dbcontext",
"OutputPath": "db",
- "PluralRules": null,
"PreserveCasingWithRegex": true,
"ProjectRootNamespace": "bdGrupoSanchoToro",
"Schemas": null,
"SelectedHandlebarsLanguage": 2,
"SelectedToBeGenerated": 0,
- "SingularRules": null,
"T4TemplatePath": null,
"Tables": [
{
diff --git a/bdGrupoSanchoToro/extensiones/albaranes.cs b/bdGrupoSanchoToro/extensiones/albaranes.cs
index 9f798fb..0eedffa 100644
--- a/bdGrupoSanchoToro/extensiones/albaranes.cs
+++ b/bdGrupoSanchoToro/extensiones/albaranes.cs
@@ -157,29 +157,29 @@ namespace bdGrupoSanchoToro.db
public enum TipoAlbaranEnum : int
{
ENTREGA = 0,
- RECOGIDA = 1,
- CAMBIO_ALMACEN = 2,
- SUBALQUILER = 3,
- DEVOLUCION_SUBALQUILER = 4,
- STOCK_INICIAL_O_FABRICACION = 100,
- COMPRA = 101
+ ENTREGA_DESDE_OBRA = 1,
+ RECOGIDA = 2,
+ CAMBIO_ALMACEN = 3,
+ SUBALQUILER = 4,
+ DEVOLUCION_SUBALQUILER = 5,
+ REGULARIZACION_STOCK = 100,
+ FABRICACION = 101,
+ COMPRA = 102
}
public enum PrefijoAlbaranEnum : int
{
- AENT = 0,
- AREC = 1,
- ACMA = 2,
- ASBA = 3,
- ADSA = 4,
- ASIOF = 100,
- ACMP = 101
+ AE = 0,
+ AEO =1,
+ AR = 2,
+ ACA = 3,
+ AS = 4,
+ ADS = 5,
+ ARS = 100,
+ AF = 101,
+ AC = 102
+
}
- public enum TipoImpresionAlbaranEntregaEnum : int
- {
- IMPRIMIR_CONTRATO = 0,
- IMPRIMIR_ALBARAN_NO_VALORADO = 1,
- IMPRIMIR_ALBARAN_VALORADO = 2,
- }
+
}
}
\ No newline at end of file
diff --git a/bdGrupoSanchoToro/extensiones/detallesalbaranes.cs b/bdGrupoSanchoToro/extensiones/detallesalbaranes.cs
index 21bc7c3..248e51c 100644
--- a/bdGrupoSanchoToro/extensiones/detallesalbaranes.cs
+++ b/bdGrupoSanchoToro/extensiones/detallesalbaranes.cs
@@ -75,7 +75,7 @@ namespace bdGrupoSanchoToro.db
switch ((albaranes.TipoAlbaranEnum)this.idAlbaranNavigation.Tipo)
{
case albaranes.TipoAlbaranEnum.COMPRA:
- case albaranes.TipoAlbaranEnum.STOCK_INICIAL_O_FABRICACION:
+ case albaranes.TipoAlbaranEnum.REGULARIZACION_STOCK:
{
this.ActStockPorAlmacen(bd, Factor, almd.idAlmacen, pr.idProducto);
pr.UnidadesInicialesOFabricadas += this.Cantidad * (double)Factor;