2026-01-30-v2

This commit is contained in:
2026-01-30 11:10:56 +01:00
parent 12039e9ae4
commit 6034845e65
46 changed files with 9717 additions and 356 deletions

View File

@@ -0,0 +1,312 @@
Imports DevExpress.Xpf.Editors
Imports DevExpress.Xpf.LayoutControl
Imports tsWPF
Imports System.ComponentModel
Imports System.Data
Imports DevExpress.Xpf.Editors.Validation
Imports DevExpress.Xpf.Editors.Helpers
Imports DevExpress.Xpf.Core
Imports tsWPF.modExtensiones
Imports System.Data.Common
Imports System.Data.Entity
Imports bdGrupoSanchoToro
Imports tsl5.Datos
Imports DevExpress.Xpf.Bars
Imports DevExpress.Xpf.Grid
Imports System.IO
Imports DevExpress.Spreadsheet
Imports Microsoft.Win32
Imports System.Drawing
Imports tsWPF.Comun
Imports tsWPFCore.Comun
Imports tsWPFCore
Imports tsUtilidades
Imports bdGrupoSanchoToro.db
Imports bdGrupoSanchoToro.db.Utilidades
Public Class ucInformeContables
Private bd As tscGrupoSanchoToro
Friend _idInforme As Nullable(Of Integer)
'
Public Overrides Sub Cargado()
Me.Tipo_ucControlBusqueda = GetType(ucInformesContables)
End Sub
Public Overrides Function EstablecedcPrincipal(Optional Background As Boolean = False, Optional FuerzaNuevo As Boolean = False, Optional Refrescar As Boolean = False) As EstadosAplicacion
Dim NuevoEstado As EstadosAplicacion
Dim ra As informescontables
If FuerzaNuevo OrElse _idInforme Is Nothing Then
ra = New bdGrupoSanchoToro.db.informescontables
'ra.FechaApertura = Now.Date
'ra.Descripcion = Now.Year.ToString
'ra.FechaInicio = New Date(Now.Year, 1, 1)
'ra.FechaFin = New Date(Now.Year, 12, 31)
'ra.idEmpresa = bd.empresascontables.First(Function(x) x.FechaBaja.HasValue = False).idEmpresaContable
Me.DataContext = ra
_idInforme = Nothing
' ra.idEjercicio = Nothing
NuevoEstado = EstadosAplicacion.Nuevo
Else
ra = bd.informescontables.First(Function(x) x.idInforme = _idInforme)
NuevoEstado = EstadosAplicacion.ModificandoRegistro
End If
Me.DataContext = ra
gcCeldas.ItemsSource = ra.celdasinformescontables
'gcCuentasCeldas.ItemsSource = ra.celdasinformescontables.
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 "informescontables"
End Get
End Property
Public Overrides ReadOnly Property idRegistroAplicacionActual As String
Get
If Estado = EstadosAplicacion.Nuevo Then
Return "informescontables.Nuevo"
Else
Return "informescontables." & DirectCast(Me.DataContext, informescontables).idInforme.ToString
End If
End Get
End Property
Public Overrides ReadOnly Property DescripcionRegistro As String
Get
Return "Informe Contable"
End Get
End Property
Public Sub New(Optional idInforme As Integer? = Nothing)
' Llamada necesaria para el diseñador.
InitializeComponent()
_idInforme = idInforme
' Agregue cualquier inicialización después de la llamada a InitializeComponent().
End Sub
'Public Sub EstableceAplicacion(ap As Aplicacion) Implements IAplicacion.EstableceAplicacion
' Me.ap = ap
'End Sub
Public Overrides Sub EstableceTitulo()
If Me.docpanel Is Nothing Then
Dim w As dxwGenerica = Window.GetWindow(Me)
w.Title = "Agregar nuevo informe"
Else
If Me.Estado = EstadosAplicacion.ModificandoRegistro Then
Dim ej As informescontables = Me.DataContext
Me.docpanel.Caption = "Informe " & ej.Descripcion
Me.docpanel.Tag = "Informe." & ej.Descripcion
Else
Me.docpanel.Caption = "Informe Nuevo"
Me.docpanel.Tag = "Informe.Nuevo"
End If
End If
End Sub
Public Overrides Function ObtienePermisos() As tsUtilidades.Permisos
Return Comun.ObtienePermisos(Me.bd, "AP.CONTABILIDAD", idUsuario)
End Function
'Public Overrides Function ObtieneConexionBD() As BBDD
' Return bdGrupoSanchoToro.gestionasegasaEntities.bdga
'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
If Not pts Is Nothing Then
Dim ra As informescontables = Me.DataContext
' Select Case pts.NombreCampo.ToLower
' End Select
End If
End Sub
'Private Sub ObtieneCuentas(ra As informescontables)
' 'Dim Nivel As Integer = cbNivel.EditValue
' 'Dim ctas = ra.cuentas.Where(Function(x) x.NumeroCuenta.Length = Nivel).ToList
' 'gcCuentas.ItemsSource = ctas
'End Sub
'Private Sub cbNivel_EditValueChanged(sender As Object, e As EditValueChangedEventArgs) Handles cbNivel.EditValueChanged
' Dim ra As ejercicioscontables = Me.DataContext
' ObtieneCuentas(ra)
'End Sub
'Private Sub HlAsientoRegularizacion_Click(sender As Object, e As RoutedEventArgs)
' Dim id = DirectCast(Me.DataContext, informescontables).AsientoRegularizacion.idAsiento
' Dim uc As New ucDiario
' FuncionesDinamicas.AbrirUcCL(uc, Comun.dwi.grupodoc, Nothing, Comun.dcfg, Comun.dcn, 0, bdGrupoSanchoToro.Utilidades.dsc, Comun.OtrosParametros, id)
'End Sub
Public Overrides Sub EstableceDataContextSecundarios(Optional Background As Boolean = False)
Dim Acciones As New List(Of tsWPFCore.Accion)
'Acciones.Add(New Accion With {
' .idAccion = 1,
' .Descripcion = "GENERA ASIENTO CIERRE Y DE APERTURA"})
'Acciones.Add(New Accion With {
' .idAccion = 2,
' .Descripcion = "REENUMERA Nº ASIENTO OFICIAL"})
'Acciones.Add(New Accion With {
' .idAccion = 3,
' .Descripcion = "GENERA BALANCE DE SITUACION"})
Me.cbCampos.ItemsSource = CampoInforme.ObtieneCamposInformes
Me.ContenedorAplicacion.cbAcciones.ItemsSource = Acciones
If Acciones.Count > 0 Then Me.ContenedorAplicacion.beAcciones.EditValue = Acciones.First.idAccion
End Sub
'Private Sub HlAsientoApertura_Click(sender As Object, e As RoutedEventArgs)
' Dim id = DirectCast(Me.DataContext, informescontables).AsientoApertura.idAsiento
' Dim uc As New ucDiario
' FuncionesDinamicas.AbrirUcCL(uc, Comun.dwi.grupodoc, Nothing, Comun.dcfg, Comun.dcn, 0, bdGrupoSanchoToro.Utilidades.dsc, Comun.OtrosParametros, id)
'End Sub
Private Sub ap_Enlazar(Celda As EditGridCellData, Defecto As Boolean) Handles Me.Enlazar
Select Case Celda.Column.FieldName.ToLower
'Case "idCelda"
' Dim id As Integer = DirectCast(Me.gcGestiones.CurrentItem, asientos).idAsiento
' Dim uc As New ucDiario
' FuncionesDinamicas.AbrirUcCL(uc, Comun.dwi.grupodoc, Nothing, Comun.dcfg, Comun.dcn, 0, bdGrupoSanchoToro.Utilidades.dsc, Comun.OtrosParametros, id)
End Select
End Sub
Private Sub ap_DespuesGuardar(sender As Object, e As ItemClickEventArgs, OpcionGuardado As Integer) Handles Me.DespuesGuardar
Dim ra As informescontables = Me.DataContext
_idInforme = ra.idInforme
'Dim NuevoInforme As informescontables = Me.DataContext
'_idInforme = NuevoInforme.idInforme
'If NuevoInforme.FechaCierre.HasValue = False AndAlso NuevoInforme.FechaApertura.Year = Now.Year Then
' Dim ea = bd.ejercicioscontables.OrderByDescending(Function(x) x.FechaInicio).FirstOrDefault(Function(x) x.FechaInicio < NuevoInforme.FechaInicio)
' If DXMessageBox.Show("¿Desea copiar las cuentas del Ejercicio Anterior?", "Atención", vbYesNo) = MessageBoxResult.Yes Then
' CopiaCuentas(NuevoInforme)
' ap.RefrescaUC(True)
' End If
'End If
End Sub
Private Sub ap_EjecutarAccion(sender As Object, e As ItemClickEventArgs, idAccion As Integer) Handles Me.EjecutarAccion
'Select Case idAccion
' Case 1 ' GENERA ASIENTO DE CIERRE Y APERTURA
' GeneraAsientoRegularizacionYApertura()
' Case 2 ' REENUMERA ASIENTOS OFICIALES Y CIERRA EL EJERCCIO
' ReenumeraAsientosOficiales()
' Case 3
' GeneraInformeContable("BALSIT")
'End Select
End Sub
Private Sub EstableceEstiloGrupo(rg As DevExpress.Spreadsheet.CellRange)
Dim rgf As Formatting = rg.BeginUpdateFormatting
rgf.Font.Bold = True
rgf.Fill.BackgroundColor = Color.LightCyan
rgf.Borders.BottomBorder.LineStyle = BorderLineStyle.DashDot
rgf.Borders.TopBorder.LineStyle = BorderLineStyle.DashDot
rgf.Borders.LeftBorder.LineStyle = BorderLineStyle.DashDot
rgf.Borders.RightBorder.LineStyle = BorderLineStyle.DashDot
End Sub
Private Sub RutaDocumentoAdjunto_DefaultButtonClick(sender As Object, e As RoutedEventArgs) Handles RutaDocumentoAdjunto.DefaultButtonClick
Dim ra As informescontables = Me.DataContext
Dim ofd As New OpenFileDialog
ofd.CheckPathExists = True
ofd.Filter = "Documento .xlsx|*.xlsx"
If ofd.ShowDialog Then
Dim fic As db.ficheros
If ra.idFicheroNavigation Is Nothing Then
fic = New db.ficheros
ra.idFicheroNavigation = fic
Else
fic = ra.idFicheroNavigation
End If
fic.NombreFichero = IO.Path.GetFileName(ofd.FileName)
fic.Fichero = IO.File.ReadAllBytes(ofd.FileName)
fic.Fecha = Now
fic.idTipo = bd.enumeraciones.Where(Function(x) x.Codigo = "TIPFIC.PLANTILLA").First.idEnumeracion
RutaDocumentoAdjunto.Text = IO.Path.GetFileName(ofd.FileName)
End If
End Sub
Private Sub BiVerFicheroEscaneado_Click(sender As Object, e As RoutedEventArgs)
Dim ra As informescontables = Me.DataContext
If ra.idFicheroNavigation IsNot Nothing AndAlso ra.idFicheroNavigation.Fichero IsNot Nothing Then
IO.File.WriteAllBytes("c:\tmp\" + ra.idFicheroNavigation.NombreFichero, ra.idFicheroNavigation.Fichero)
Process.Start("c:\tmp\" + ra.idFicheroNavigation.NombreFichero)
Else
DXMessageBox.Show("No se ha asignado ningún documento externo", "Atención")
End If
End Sub
Private Sub gcCeldas_CurrentItemChanged(sender As Object, e As CurrentItemChangedEventArgs) Handles gcCeldas.CurrentItemChanged
Dim celdainformes As celdasinformescontables = CType(gcCeldas.CurrentItem, celdasinformescontables)
If celdainformes IsNot Nothing Then
gcCuentasCeldas.ItemsSource = celdainformes.cuentasceldasinformescontables
Else
gcCuentasCeldas.ItemsSource = Nothing
End If
End Sub
'Private Sub tvCuentasCeldas_CellValueChanged(sender As Object, e As CellValueChangedEventArgs) Handles tvCuentasCeldas.CellValueChanged
' Select Case e.Column.FieldName.ToLower
' Case "numerocuenta"
' Dim dre As cuentasceldasinformescontables = e.Row
' Dim valor As String = tvCuentasCeldas.Grid.GetCellValue(e.RowHandle, "NumeroCuenta")
' If (Not valor.Length = 0) OrElse (valor.Length > 4 And valor.Length < 8) OrElse valor.Length > 8 Then
' tvCuentasCeldas.Grid.SetCellValue(e.RowHandle, "NumeroCuenta", "")
' End If
' End Select
'End Sub
Private Sub tvCuentasCeldas_ValidateRow(sender As Object, e As GridRowValidationEventArgs) Handles tvCuentasCeldas.ValidateRow
Dim htErrores = New Hashtable
Dim ap As cuentasceldasinformescontables = e.Row
Dim valor As String = ap.NumeroCuenta
If (Not valor.Length = 0) OrElse (valor.Length > 4 And valor.Length < 8) OrElse valor.Length > 8 Then
htErrores.Add("CuentasCeldas", "El numero de cuenta tiene que tener longitud de 1,2,3,4 u 8 caratéres")
End If
If htErrores.Count > 0 Then If htErrores.Count > 0 Then Me.AgregaErroresTSGC(gcCuentasCeldas, htErrores, e)
End Sub
Private Sub tvCuentasCeldas_ValidateCell(sender As Object, e As GridCellValidationEventArgs) Handles tvCuentasCeldas.ValidateCell
'Dim ap As cuentasceldasinformescontables = tvCuentasCeldas.Grid.GetCellValue(e.RowHandle, "NumeroCuenta")
If (e.Cell.Property = "NumeroCuenta") Then
Dim valor As String = e.Value
If (valor.Length = 0) OrElse ((valor.Length > 4 And valor.Length < 8) OrElse valor.Length > 8) Then
e.ErrorContent = "El numero de cuenta tiene que tener longitud de 1,2,3,4 u 8 caratéres"
e.IsValid = False
End If
End If
End Sub
End Class
Public Class CampoInforme
Property Campo As String
Property Descripcion As String
Public Shared Function ObtieneCamposInformes() As List(Of CampoInforme)
Dim lc As New List(Of CampoInforme)
lc.Add(New CampoInforme With {.Campo = "TOTALSALDO", .Descripcion = "TOTAL SALDO CUENTA"})
lc.Add(New CampoInforme With {.Campo = "TOTALSALDOEJANT", .Descripcion = "TOTAL SALDO CUENTA EJERCICIO ANTERIOR"})
lc.Add(New CampoInforme With {.Campo = "TOTALSALDOAC", .Descripcion = "TOTAL SALDO CUENTA (ANTES DE CIERRE)"})
lc.Add(New CampoInforme With {.Campo = "TOTALSALDOACEJANT", .Descripcion = "TOTAL SALDO CUENTA EJERCICIO ANTERIOR (ANTES DE CIERRE)"})
lc.Add(New CampoInforme With {.Campo = "EJERCICIO", .Descripcion = "EJERCICIO ACTUAL"})
lc.Add(New CampoInforme With {.Campo = "EJERCICIOANT", .Descripcion = "EJERCICIO ANTERIOR"})
Return lc
End Function
End Class