Agregar archivos de proyecto.
This commit is contained in:
549
Obsoleto/ContenedorCabLin.xaml.vb
Normal file
549
Obsoleto/ContenedorCabLin.xaml.vb
Normal file
@@ -0,0 +1,549 @@
|
||||
Imports System.ComponentModel
|
||||
Imports DevExpress.Xpf.Core
|
||||
Imports DevExpress.Xpf.Docking
|
||||
Imports System.Windows.Media.Animation
|
||||
Imports DevExpress.Xpf.Core.Native
|
||||
Imports DevExpress.Xpf.Editors
|
||||
Imports System.IO
|
||||
Imports DevExpress.Xpf.Bars
|
||||
Imports DevExpress.Xpf.Grid
|
||||
Imports Microsoft.Win32
|
||||
Imports tsl5.Extensiones
|
||||
Imports DevExpress.Spreadsheet
|
||||
Imports System.Data.Entity.ModelConfiguration.Conventions
|
||||
|
||||
Public Class ContenedorCabLin
|
||||
' Public bd As System.Data.Objects.ObjectContext
|
||||
Public Aplicacion As ApCabLin
|
||||
Public dp As DocumentPanel
|
||||
Dim _DescripcionDiseño As String
|
||||
Dim _TodosUsuariosDiseño As Boolean
|
||||
|
||||
' Private VentanaError As VentanaErr
|
||||
Public Event CargaAplicacion(sender As System.Object, e As System.Windows.RoutedEventArgs)
|
||||
Public Event AntesDeGuardar(sender As System.Object, e As DevExpress.Xpf.Bars.ItemClickEventArgs)
|
||||
Public Event DespuesDeGuardar(sender As System.Object, e As DevExpress.Xpf.Bars.ItemClickEventArgs)
|
||||
'Public Shared ReadOnly EventoLanzaMensaje As RoutedEvent = EventManager.RegisterRoutedEvent("LanzaMensaje", RoutingStrategy.Bubble, GetType(RoutedEventHandler), GetType(ContenedorCabLin))
|
||||
'Public Custom Event LanzaMensaje As RoutedEventHandler
|
||||
' AddHandler(value As RoutedEventHandler)
|
||||
' Me.AddHandler(EventoLanzaMensaje, value)
|
||||
' End AddHandler
|
||||
|
||||
' RemoveHandler(value As RoutedEventHandler)
|
||||
' Me.RemoveHandler(EventoLanzaMensaje, value)
|
||||
' End RemoveHandler
|
||||
|
||||
' RaiseEvent(sender As Object, e As RoutedEventArgs)
|
||||
' Me.RaiseEvent(e)
|
||||
' End RaiseEvent
|
||||
'End Event
|
||||
|
||||
|
||||
Private Sub Cargado(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
|
||||
|
||||
Me.siMensaje.Content = ""
|
||||
RaiseEvent CargaAplicacion(sender, e)
|
||||
If DXSplashScreen.IsActive Then DXSplashScreen.Close()
|
||||
' Me.Aplicacion.ValidarControles = True
|
||||
End Sub
|
||||
Private Sub Guardar(sender As System.Object, e As DevExpress.Xpf.Bars.ItemClickEventArgs) Handles btGuardar.ItemClick
|
||||
'Dispatcher.BeginInvoke(New Action(Function() ucexpedientes.Estado = EstadosCablin.Nuevo), Windows.Threading.DispatcherPriority.Loaded)
|
||||
'Dispatcher.BeginInvoke(New Action(Sub() Aplicacion.Guardar(sender, e)), Windows.Threading.DispatcherPriority.ContextIdle)
|
||||
Dim Guardado As Boolean
|
||||
Try
|
||||
btGuardar.IsEnabled = False
|
||||
Guardado = Not Aplicacion.Guardar(sender, e)
|
||||
If Me.Aplicacion.Estado = EstadosCablin.AplicacionSinIndice Then btGuardar.IsEnabled = True
|
||||
Finally
|
||||
If Guardado Then
|
||||
Select Case Aplicacion.Estado
|
||||
Case EstadosCablin.ModificandoRegistro
|
||||
btGuardar.IsEnabled = Aplicacion.PermisosConcedidos.Modificar
|
||||
Case EstadosCablin.Nuevo
|
||||
btGuardar.IsEnabled = Aplicacion.PermisosConcedidos.Nuevos
|
||||
End Select
|
||||
Else
|
||||
btGuardar.IsEnabled = True
|
||||
End If
|
||||
End Try
|
||||
End Sub
|
||||
Public Sub New()
|
||||
|
||||
' Llamada necesaria para el diseñador.
|
||||
InitializeComponent()
|
||||
|
||||
' Agregue cualquier inicialización después de la llamada a InitializeComponent().
|
||||
|
||||
End Sub
|
||||
'Public Sub New(Contenido As ApCabLin, TablaBase As String, Registros As ListCollectionView, Busqueda As DevExpress.Xpf.LayoutControl.LayoutGroup, GridBusqueda As DevExpress.Xpf.Grid.GridControl)
|
||||
' If Not (System.ComponentModel.DesignerProperties.GetIsInDesignMode(Me)) Then
|
||||
|
||||
|
||||
' ' Llamada necesaria para el diseñador.
|
||||
' InitializeComponent()
|
||||
' Aplicacion = Contenido
|
||||
' ' Aplicacion.Contexto = Contexto
|
||||
' Contenido.ContenedorCL = Me
|
||||
' Contenido.Registros = Registros
|
||||
' ' Contenido.ObjetoEntidad = ModeloEntidad
|
||||
' Contenido.NombreTablaBase = TablaBase
|
||||
' Contenido.Busqueda = Busqueda
|
||||
' Contenido.GridBusqueda = GridBusqueda
|
||||
' Me.contenido.Children.Add(Contenido)
|
||||
' AddHandler Me.PreviewKeyDown, AddressOf Aplicacion.ApCabLin_PreviewKeyDown
|
||||
' End If
|
||||
' '' Agregue cualquier inicialización después de la llamada a InitializeComponent().
|
||||
|
||||
'End Sub
|
||||
|
||||
'Public Sub New(Contenido As ApCabLin)
|
||||
' If Not (System.ComponentModel.DesignerProperties.GetIsInDesignMode(Me)) Then
|
||||
|
||||
|
||||
' ' Llamada necesaria para el diseñador.
|
||||
' InitializeComponent()
|
||||
' Aplicacion = Contenido
|
||||
' Contenido.ContenedorCL = Me
|
||||
' Me.contenido.Children.Add(Contenido.Aplicacion)
|
||||
|
||||
' AddHandler Me.PreviewKeyDown, AddressOf Aplicacion.ApCabLin_PreviewKeyDown
|
||||
|
||||
' End If
|
||||
'End Sub
|
||||
Private sbDesvanecer As Storyboard = Nothing
|
||||
Public Sub New(Aplicacion As ApCabLin, uc As UserControl, dp As DocumentPanel)
|
||||
If Not (System.ComponentModel.DesignerProperties.GetIsInDesignMode(Me)) Then
|
||||
' Llamada necesaria para el diseñador.
|
||||
InitializeComponent()
|
||||
Me.contenido.Children.Add(uc)
|
||||
Me.Aplicacion = Aplicacion
|
||||
Me.dp = dp
|
||||
Aplicacion.ContenedorCL = Me
|
||||
Dim da As New DoubleAnimation
|
||||
With da
|
||||
.From = 1
|
||||
.To = 0
|
||||
.Duration = New Duration(TimeSpan.FromSeconds(2))
|
||||
.AutoReverse = False
|
||||
End With
|
||||
Storyboard.SetTargetProperty(da, New PropertyPath(OpacityProperty))
|
||||
sbDesvanecer = New Storyboard
|
||||
sbDesvanecer.Children.Add(da)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
' Private Sub mv_CurrentChanged(sender As Object, e As System.EventArgs) Handles mv.CurrentChanged
|
||||
' cabecera = Me.mv.CurrentEditItem
|
||||
'End Sub
|
||||
|
||||
Private Sub Nuevo(sender As System.Object, e As DevExpress.Xpf.Bars.ItemClickEventArgs) Handles btNuevo.ItemClick
|
||||
Me.Aplicacion.ValidarControles = False
|
||||
Me.Aplicacion.DocPanel.Tag = Me.Aplicacion.GetType.Name & "." & Me.Aplicacion.Titulo & ".NUEVO"
|
||||
Aplicacion.Estado = EstadosCablin.Nuevo
|
||||
Me.Aplicacion.ValidarControles = True
|
||||
'Busqueda.Visibility = Windows.Visibility.Collapsed
|
||||
'Busqueda.Visibility = Windows.Visibility.Hidden
|
||||
'btBuscar.IsChecked = False
|
||||
'Cabecera.AddNew()
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub btEliminar_ItemClick(sender As Object, e As DevExpress.Xpf.Bars.ItemClickEventArgs) Handles btEliminar.ItemClick
|
||||
Aplicacion.Eliminar(sender, e)
|
||||
|
||||
End Sub
|
||||
Friend Sub IniciaAnimacion(Mensaje As String, Color As Color)
|
||||
Try
|
||||
Me.siMensaje.Content = Mensaje
|
||||
Dim tbm As TextBlock = LayoutHelper.FindElementByName(Me.BarraBotones, "tbMensaje")
|
||||
tbm.Foreground = New SolidColorBrush(Color)
|
||||
Storyboard.SetTarget(sbDesvanecer, tbm)
|
||||
BeginStoryboard(sbDesvanecer)
|
||||
Catch ex As Exception
|
||||
Debug.Write(ex.Message)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub btImprimirPlantilla_ItemClick(sender As Object, e As DevExpress.Xpf.Bars.ItemClickEventArgs)
|
||||
Dim oa = Me.Aplicacion.ObjetoActual
|
||||
Dim be As BaseEdit = Nothing
|
||||
Try
|
||||
be = LayoutHelper.FindParentObject(Of BaseEdit)(oa)
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
If Not be Is Nothing Then
|
||||
Select Case be.GetType
|
||||
Case GetType(TextEdit), GetType(PasswordBoxEdit), GetType(ButtonEdit), GetType(DateEdit), GetType(ComboBoxEdit), GetType(DevExpress.Xpf.Grid.LookUp.LookUpEdit)
|
||||
Dim expression = be.GetBindingExpression(BaseEdit.EditValueProperty)
|
||||
If Configuracion.ComportamientoValidacion = Validation.InvalidValueBehavior.AllowLeaveEditor Then
|
||||
be.DoValidate()
|
||||
If Not expression Is Nothing AndAlso expression.IsDirty Then expression.UpdateSource()
|
||||
Else
|
||||
If Not expression Is Nothing AndAlso expression.IsDirty Then expression.UpdateSource()
|
||||
be.DoValidate()
|
||||
End If
|
||||
Case GetType(CheckEdit)
|
||||
End Select
|
||||
End If
|
||||
|
||||
|
||||
'Dim be As BaseEdit = LayoutHelper.FindParentObject(Of BaseEdit)(Keyboard.FocusedElement)
|
||||
'If Not be Is Nothing Then
|
||||
' Select Case be.GetType
|
||||
' Case GetType(TextEdit), GetType(PasswordBoxEdit), GetType(ButtonEdit), GetType(DateEdit), GetType(ComboBoxEdit), GetType(DevExpress.Xpf.Grid.LookUp.LookUpEdit)
|
||||
' Dim expression = be.GetBindingExpression(BaseEdit.EditValueProperty)
|
||||
' If Not expression Is Nothing Then expression.UpdateSource()
|
||||
' be.DoValidate()
|
||||
' Case GetType(CheckEdit)
|
||||
' End Select
|
||||
'End If
|
||||
Dim idPlantilla As Integer = bePlantilla.EditValue
|
||||
Me.Aplicacion.LanzaImprimirPlantilla(sender, e, idPlantilla)
|
||||
End Sub
|
||||
|
||||
' Private Function FindVisualChild(Of childItem As DependencyObject)(ByVal obj As DependencyObject) As childItem
|
||||
' For i As Integer = 0 To VisualTreeHelper.GetChildrenCount(obj) - 1
|
||||
' Dim child As DependencyObject = VisualTreeHelper.GetChild(obj, i)
|
||||
' If child IsNot Nothing AndAlso TypeOf child Is childItem Then
|
||||
' Return CType(child, childItem)
|
||||
' Else
|
||||
' Dim childOfChild As childItem = FindVisualChild(Of childItem)(child)
|
||||
' If childOfChild IsNot Nothing Then
|
||||
' Return childOfChild
|
||||
' End If
|
||||
' End If
|
||||
' Next i
|
||||
' Return Nothing
|
||||
' End Function
|
||||
|
||||
' Private Sub htIniciaAnimacion(Mensaje As String, Color As Color)
|
||||
|
||||
|
||||
Private Sub btAcciones_ItemClick(sender As Object, e As DevExpress.Xpf.Bars.ItemClickEventArgs)
|
||||
Dim oa = Me.Aplicacion.ObjetoActual
|
||||
Dim be As BaseEdit = Nothing
|
||||
Try
|
||||
be = LayoutHelper.FindParentObject(Of BaseEdit)(oa)
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
If Not be Is Nothing Then
|
||||
Select Case be.GetType
|
||||
Case GetType(TextEdit), GetType(PasswordBoxEdit), GetType(ButtonEdit), GetType(DateEdit), GetType(ComboBoxEdit), GetType(DevExpress.Xpf.Grid.LookUp.LookUpEdit)
|
||||
Dim expression = be.GetBindingExpression(BaseEdit.EditValueProperty)
|
||||
If Configuracion.ComportamientoValidacion = Validation.InvalidValueBehavior.AllowLeaveEditor Then
|
||||
be.DoValidate()
|
||||
If Not expression Is Nothing AndAlso expression.IsDirty Then expression.UpdateSource()
|
||||
Else
|
||||
If Not expression Is Nothing AndAlso expression.IsDirty Then expression.UpdateSource()
|
||||
be.DoValidate()
|
||||
End If
|
||||
Case GetType(CheckEdit)
|
||||
End Select
|
||||
End If
|
||||
'Dim be As BaseEdit = LayoutHelper.FindParentObject(Of BaseEdit)(Keyboard.FocusedElement)
|
||||
'If Not be Is Nothing Then
|
||||
' Select Case be.GetType
|
||||
' Case GetType(TextEdit), GetType(PasswordBoxEdit), GetType(ButtonEdit), GetType(DateEdit), GetType(ComboBoxEdit), GetType(DevExpress.Xpf.Grid.LookUp.LookUpEdit)
|
||||
' Dim expression = be.GetBindingExpression(BaseEdit.EditValueProperty)
|
||||
' If Not expression Is Nothing Then expression.UpdateSource()
|
||||
' be.DoValidate()
|
||||
' Case GetType(CheckEdit)
|
||||
' End Select
|
||||
'End If
|
||||
Dim idAccion As Integer = beAcciones.EditValue
|
||||
Me.Aplicacion.LanzaEjecutaAccion(sender, e, idAccion)
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub btActualizar_ItemClick(sender As Object, e As DevExpress.Xpf.Bars.ItemClickEventArgs)
|
||||
|
||||
Me.Aplicacion.RefrescaUC(True)
|
||||
End Sub
|
||||
|
||||
Private Sub beAcciones_EditValueChanged(sender As Object, e As RoutedEventArgs)
|
||||
Dim idAccion As Integer = beAcciones.EditValue
|
||||
Dim acs As List(Of Accion) = Me.cbAcciones.ItemsSource
|
||||
Dim ac As Accion = (From a In acs Where a.idAccion = idAccion).First
|
||||
Me.btAcciones.Hint = ac.Descripcion
|
||||
End Sub
|
||||
|
||||
Private Sub bePlantilla_EditValueChanged(sender As Object, e As RoutedEventArgs)
|
||||
Dim idPlantilla As Integer = bePlantilla.EditValue
|
||||
Dim plantillas As List(Of tsWPF.Plantilla) = Me.cbPlantillaAImprimir.ItemsSource
|
||||
Dim pl As Plantilla = (From p In plantillas Where p.idPlantilla = idPlantilla).First
|
||||
Me.btImprimirPlantilla.Hint = "Imprimir " & pl.Descripcion
|
||||
End Sub
|
||||
|
||||
Private Sub ContenedorCabLin_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded
|
||||
Try
|
||||
If Aplicacion IsNot Nothing Then
|
||||
If Aplicacion.bdEntidad.Connection.State <> System.Data.ConnectionState.Closed Then Aplicacion.bdEntidad.Connection.Close()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub btAyuda_ItemClick(sender As Object, e As DevExpress.Xpf.Bars.ItemClickEventArgs)
|
||||
Me.Aplicacion.DelegadoAyuda.Invoke(Me.Aplicacion.uc.GetType.ToString)
|
||||
End Sub
|
||||
|
||||
Private Sub btDiseño_ItemClick(sender As Object, e As DevExpress.Xpf.Bars.ItemClickEventArgs)
|
||||
Try
|
||||
Dim drs = ObtieneDiseñoActual()
|
||||
Me.Aplicacion.DelegadoDiseño.Invoke(Me.Aplicacion.bdEntidad, OperacionDiseñoEnum.GUARDAR, Me.Aplicacion.uc.GetType.ToString, _DescripcionDiseño, _TodosUsuariosDiseño, drs)
|
||||
Catch ex As Exception
|
||||
If Me.Aplicacion.DelegadoErrorNoControlado IsNot Nothing Then Me.Aplicacion.DelegadoErrorNoControlado.Invoke(Me.Aplicacion, ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Friend Function ObtieneDiseñoActual() As Byte()
|
||||
Dim ld As New DiseñoRejillas
|
||||
Dim i As Integer
|
||||
For Each l In Aplicacion.Lineas
|
||||
i += 1
|
||||
If l.Name = "" Then l.Name = "tsRejilla-" & i.ToString
|
||||
Dim dr As New DiseñoRejilla
|
||||
dr.Nombre = l.Name
|
||||
dr.Version = "1"
|
||||
Dim ms As New MemoryStream
|
||||
l.SaveLayoutToStream(ms)
|
||||
dr.Diseño = ms.ToArray
|
||||
ld.Rejillas.Add(dr)
|
||||
Next
|
||||
Dim drs = System.Text.Encoding.Unicode.GetBytes(tsl5.Utilidades.Serializar(ld))
|
||||
Return drs
|
||||
End Function
|
||||
|
||||
|
||||
Private Sub btRestaurarDiseño_ItemClick(sender As Object, e As DevExpress.Xpf.Bars.ItemClickEventArgs)
|
||||
|
||||
|
||||
If Aplicacion.DiseñoOriginal IsNot Nothing Then
|
||||
Try
|
||||
Dim ld As New DiseñoRejillas
|
||||
ld = tsl5.Utilidades.deserializar(System.Text.Encoding.Unicode.GetString(Aplicacion.DiseñoOriginal), ld.GetType)
|
||||
Dim i As Integer
|
||||
For Each l In Aplicacion.Lineas
|
||||
i += 1
|
||||
If l.Name = "" Then l.Name = "tsRejilla-" & i.ToString
|
||||
Try
|
||||
If ld.Rejillas.Any(Function(x) x.Nombre = l.Name) Then
|
||||
Dim dr As DiseñoRejilla = ld.Rejillas.Where(Function(x) x.Nombre = l.Name).First
|
||||
l.RestoreLayoutFromStream(New System.IO.MemoryStream(dr.Diseño))
|
||||
End If
|
||||
Catch ex As Exception
|
||||
If Me.Aplicacion.DelegadoErrorNoControlado IsNot Nothing Then Me.Aplicacion.DelegadoErrorNoControlado.Invoke(Me.Aplicacion, ex)
|
||||
' Debug.Write("Error DelegadoDiseño Rejilla")
|
||||
End Try
|
||||
Next
|
||||
Dim drs = System.Text.Encoding.Unicode.GetBytes(tsl5.Utilidades.Serializar(ld))
|
||||
Me.Aplicacion.DelegadoDiseño.Invoke(Me.Aplicacion.bdEntidad, OperacionDiseñoEnum.RESTAURAR_ORIGINAL, Me.Aplicacion.uc.GetType.ToString, _DescripcionDiseño, _TodosUsuariosDiseño, drs)
|
||||
Catch ex As Exception
|
||||
If Me.Aplicacion.DelegadoErrorNoControlado IsNot Nothing Then Me.Aplicacion.DelegadoErrorNoControlado.Invoke(Me.Aplicacion, ex)
|
||||
End Try
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub btGuardarDiseñoComo_ItemClick(sender As Object, e As ItemClickEventArgs)
|
||||
Try
|
||||
Dim drs = ObtieneDiseñoActual()
|
||||
Me.Aplicacion.DelegadoDiseño.Invoke(Me.Aplicacion.bdEntidad, OperacionDiseñoEnum.GUARDAR_COMO, Me.Aplicacion.uc.GetType.ToString, _DescripcionDiseño, _TodosUsuariosDiseño, drs)
|
||||
Catch ex As Exception
|
||||
If Me.Aplicacion.DelegadoErrorNoControlado IsNot Nothing Then Me.Aplicacion.DelegadoErrorNoControlado.Invoke(Me.Aplicacion, ex)
|
||||
DXMessageBox.Show(ex.Message, "Error btDiseñoComo_Itemclick")
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub btAbrirDiseñoGuardado_ItemClick(sender As Object, e As ItemClickEventArgs)
|
||||
Dim b = Me.Aplicacion.DelegadoDiseño.Invoke(Me.Aplicacion.bdEntidad, OperacionDiseñoEnum.ABRIR_DISEÑO_GUARDADO, Me.Aplicacion.uc.GetType.ToString, _DescripcionDiseño, _TodosUsuariosDiseño, Nothing)
|
||||
If b IsNot Nothing Then
|
||||
Dim ld As New DiseñoRejillas
|
||||
ld = tsl5.Utilidades.deserializar(System.Text.Encoding.Unicode.GetString(b), ld.GetType)
|
||||
Dim i As Integer
|
||||
Dim lg As List(Of tsGridControl) = Nothing
|
||||
tsWPF.ObtieneHijosDeTipo(Of tsGridControl)(Me, lg)
|
||||
For Each l In lg
|
||||
i += 1
|
||||
If l.Name = "" Then l.Name = "tsRejilla-" & i.ToString
|
||||
Try
|
||||
If ld.Rejillas.Any(Function(x) x.Nombre = l.Name) Then
|
||||
Dim dr As DiseñoRejilla = ld.Rejillas.Where(Function(x) x.Nombre = l.Name).First
|
||||
l.RestoreLayoutFromStream(New System.IO.MemoryStream(dr.Diseño))
|
||||
End If
|
||||
Catch ex As Exception
|
||||
If Me.Aplicacion.DelegadoErrorNoControlado IsNot Nothing Then Me.Aplicacion.DelegadoErrorNoControlado.Invoke(Me.Aplicacion, ex)
|
||||
DXMessageBox.Show(ex.Message, "Error btDiseñoGuardado_Itemclick")
|
||||
End Try
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub BtCapturar_ItemClick(sender As Object, e As ItemClickEventArgs)
|
||||
Dim sficherojpg = tsl5.Utilidades.ObtieneFicheroAleatorio("jpg")
|
||||
IO.File.WriteAllBytes(sficherojpg, Me.Aplicacion.uc.ObtieneImagen(1, 100))
|
||||
Process.Start(sficherojpg)
|
||||
End Sub
|
||||
|
||||
Private Sub BtExportar_ItemClick(sender As Object, e As ItemClickEventArgs)
|
||||
|
||||
Dim sfd As New SaveFileDialog
|
||||
sfd.FileName = "Exportacion.xlsx"
|
||||
sfd.Filter = "Fichero Excel (*.xls, *.xlsx|*.xls;*.xlsx"
|
||||
sfd.DefaultExt = ".xlsx"
|
||||
Dim ms As New List(Of Stream)
|
||||
Dim formato As DevExpress.Spreadsheet.DocumentFormat
|
||||
If sfd.ShowDialog Then
|
||||
Dim i As Integer = 0
|
||||
Dim ngc As New tsGridControl
|
||||
For Each oc In Me.Aplicacion.ControlesTS
|
||||
Try
|
||||
Dim gc As New tsGridColumn()
|
||||
gc.FieldName = oc.PropiedadesTS.NombreCampo
|
||||
gc.Header = oc.Label.ToString.TrimEnd(":")
|
||||
gc.Width = oc.Width
|
||||
ngc.Columns.Add(gc)
|
||||
Catch
|
||||
End Try
|
||||
Next
|
||||
ngc.ItemsSource = Me.Aplicacion.DataContext
|
||||
Dim ls = New MemoryStream
|
||||
ngc.View.ExportToXlsx(ls)
|
||||
ms.Add(ls)
|
||||
For Each l In Me.Aplicacion.Lineas
|
||||
Try
|
||||
ls = New MemoryStream
|
||||
ms.Add(ls)
|
||||
Dim vista As TableView = l.View
|
||||
Select Case IO.Path.GetExtension(sfd.FileName).ToLower
|
||||
Case ".xls"
|
||||
vista.ExportToXls(ls)
|
||||
formato = DevExpress.Spreadsheet.DocumentFormat.Xls
|
||||
Case ".xlsx"
|
||||
vista.ExportToXlsx(ls)
|
||||
formato = DevExpress.Spreadsheet.DocumentFormat.Xlsx
|
||||
End Select
|
||||
i += 1
|
||||
Catch
|
||||
End Try
|
||||
Next
|
||||
Dim wb As New Workbook
|
||||
For i = 0 To ms.Count - 1
|
||||
Try
|
||||
Dim wbc As New Workbook
|
||||
ms(i).Position = 0
|
||||
wbc.LoadDocument(ms(i), formato)
|
||||
wb.Worksheets(i).CopyFrom(wbc.Worksheets(0))
|
||||
If i = 0 Then
|
||||
wb.Worksheets(i).Name = Me.Aplicacion.Titulo
|
||||
Else
|
||||
If wb.Worksheets.Any(Function(x) x.Name = Me.Aplicacion.Lineas(i - 1).NombreTablaBase) Then
|
||||
wb.Worksheets(i).Name = (i - 1).ToString
|
||||
Else
|
||||
wb.Worksheets(i).Name = Me.Aplicacion.Lineas(i - 1).NombreTablaBase
|
||||
End If
|
||||
End If
|
||||
If i < ms.Count - 1 Then wb.Worksheets.Add()
|
||||
Catch
|
||||
End Try
|
||||
Next
|
||||
Dim nc As Integer = 0
|
||||
For Each c In Me.Aplicacion.ControlesTS
|
||||
Try
|
||||
Select Case c.Content.GetType
|
||||
Case GetType(CheckEdit)
|
||||
Dim Ce As CheckEdit = c.Content
|
||||
wb.Worksheets(0).Cells(1, nc).SetValue(If(Ce.IsChecked, "SI", "NO"))
|
||||
|
||||
Case GetType(ButtonEdit)
|
||||
Dim te As ButtonEdit = c.Content
|
||||
wb.Worksheets(0).Cells(1, nc).SetValue(te.EditValue)
|
||||
Case GetType(TextEdit)
|
||||
Dim te As TextEdit = c.Content
|
||||
wb.Worksheets(0).Cells(1, nc).SetValue(te.EditValue)
|
||||
Case GetType(DateEdit)
|
||||
Dim de As DateEdit = c.Content
|
||||
wb.Worksheets(0).Cells(1, nc).SetValue(de.EditValue)
|
||||
Case GetType(ComboBoxEdit)
|
||||
Dim cbe As ComboBoxEdit = c.Content
|
||||
wb.Worksheets(0).Cells(1, nc).SetValue(cbe.DisplayText)
|
||||
Case GetType(DevExpress.Xpf.Grid.LookUp.LookUpEdit)
|
||||
Dim le As DevExpress.Xpf.Grid.LookUp.LookUpEdit = c.Content
|
||||
wb.Worksheets(0).Cells(1, nc).SetValue(le.EditValue)
|
||||
End Select
|
||||
nc += 1
|
||||
Catch
|
||||
End Try
|
||||
Next
|
||||
|
||||
wb.SaveDocument(sfd.FileName, formato)
|
||||
Process.Start(sfd.FileName)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub bePlantilla_GotFocus(sender As Object, e As RoutedEventArgs) Handles bePlantilla.GotFocus
|
||||
Dim oa = Me.Aplicacion.ObjetoActual
|
||||
Dim be As BaseEdit = Nothing
|
||||
Try
|
||||
be = LayoutHelper.FindParentObject(Of BaseEdit)(oa)
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
If Not be Is Nothing Then
|
||||
Select Case be.GetType
|
||||
Case GetType(TextEdit), GetType(PasswordBoxEdit), GetType(ButtonEdit), GetType(DateEdit), GetType(ComboBoxEdit), GetType(DevExpress.Xpf.Grid.LookUp.LookUpEdit)
|
||||
Dim expression = be.GetBindingExpression(BaseEdit.EditValueProperty)
|
||||
If Configuracion.ComportamientoValidacion = Validation.InvalidValueBehavior.AllowLeaveEditor Then
|
||||
be.DoValidate()
|
||||
If Not expression Is Nothing AndAlso expression.IsDirty Then expression.UpdateSource()
|
||||
Else
|
||||
If Not expression Is Nothing AndAlso expression.IsDirty Then expression.UpdateSource()
|
||||
be.DoValidate()
|
||||
End If
|
||||
Case GetType(CheckEdit)
|
||||
End Select
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub beAcciones_GotFocus(sender As Object, e As RoutedEventArgs) Handles beAcciones.GotFocus
|
||||
Dim oa = Me.Aplicacion.ObjetoActual
|
||||
Dim be As BaseEdit = Nothing
|
||||
Try
|
||||
be = LayoutHelper.FindParentObject(Of BaseEdit)(oa)
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
If Not be Is Nothing Then
|
||||
Select Case be.GetType
|
||||
Case GetType(TextEdit), GetType(PasswordBoxEdit), GetType(ButtonEdit), GetType(DateEdit), GetType(ComboBoxEdit), GetType(DevExpress.Xpf.Grid.LookUp.LookUpEdit)
|
||||
Dim expression = be.GetBindingExpression(BaseEdit.EditValueProperty)
|
||||
If Configuracion.ComportamientoValidacion = Validation.InvalidValueBehavior.AllowLeaveEditor Then
|
||||
be.DoValidate()
|
||||
If Not expression Is Nothing AndAlso expression.IsDirty Then expression.UpdateSource()
|
||||
Else
|
||||
If Not expression Is Nothing AndAlso expression.IsDirty Then expression.UpdateSource()
|
||||
be.DoValidate()
|
||||
End If
|
||||
Case GetType(CheckEdit)
|
||||
End Select
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
|
||||
|
||||
<Serializable>
|
||||
Public Class DiseñoRejillas
|
||||
Property Rejillas As New List(Of DiseñoRejilla)
|
||||
Property Version As String
|
||||
End Class
|
||||
<Serializable>
|
||||
Public Class DiseñoRejilla
|
||||
Public Diseño() As Byte
|
||||
Public Version As String
|
||||
Public Nombre As String
|
||||
End Class
|
||||
Reference in New Issue
Block a user