Agregar archivos de proyecto.

This commit is contained in:
2026-01-23 12:45:41 +01:00
parent 5ed4e0bc46
commit c8d1044267
237 changed files with 34721 additions and 0 deletions

View File

@@ -0,0 +1,202 @@

Imports bdGrupoSanchoToro.tscGrupoSanchoToro
Imports DevExpress.Xpf.Core
Imports tsWPFCore
Imports Microsoft.Win32
Imports DevExpress.Xpf.Grid
Imports bdGrupoSanchoToro.db.Utilidades
Imports bdGrupoSanchoToro.db
Public Class ucPagoMultipleFacturas
Private bd As bdGrupoSanchoToro.tscGrupoSanchoToro
Public Sub New()
' Esta llamada es exigida por el diseñador.
InitializeComponent()
' Agregue cualquier inicialización después de la llamada a InitializeComponent().
End Sub
Public Overrides Sub Cargado()
ContenedorAplicacion.btGuardar.IsVisible = True
ContenedorAplicacion.btNuevo.IsVisible = False
ContenedorAplicacion.siEstado.IsVisible = False
Me.HabilitarRefresco = False
End Sub
Public Overrides Function EstablecedcPrincipal(Optional Background As Boolean = False, Optional FuerzaNuevo As Boolean = False, Optional Refrescar As Boolean = False) As tsUtilidades.EstadosAplicacion
cbRazonSocial.ItemsSource = bd.entidades.Where(Function(x) x.EsCliente AndAlso x.idEmpresa = EmpresaActual.idEmpresa).ToList
cbCaja.ItemsSource = bd.cajas.OrderBy(Function(x) x.Descripcion AndAlso x.idEmpresa = EmpresaActual.idEmpresa).ToList
deFechaPago.EditValue = Now.Date
Return tsUtilidades.EstadosAplicacion.AplicacionSinIndice
End Function
Public Overrides Sub EstableceDataContextSecundarios(Optional Background As Boolean = False)
End Sub
Public Overrides Sub EstableceTitulo()
Me.docpanel.Caption = "Cobro Múltiple de Fras. Clientes"
End Sub
Public Overrides ReadOnly Property idRegistroAplicacionActual As String
Get
Return "PagoMultiple"
End Get
End Property
Public Overrides ReadOnly Property NombreTablaBase As String
Get
Return "facturas"
End Get
End Property
Public Overrides ReadOnly Property DescripcionRegistro As String
Get
Return "Cobro Multiple de Facturas A Clientes"
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
Dim per = Comun.ObtienePermisos(Me.bd, "AP.ADMINISTRATIVOS", idUsuario)
per.Eliminar = False
per.Nuevos = False
per.Modificar = False
Return per
End Function
Private Sub ap_Enlazar(Celda As DevExpress.Xpf.Grid.EditGridCellData, Defecto As Boolean) Handles Me.Enlazar
Dim ra = DirectCast(Me.gcFacturas.CurrentItem, facturas)
Select Case Celda.Column.FieldName.ToLower
Case "numerofactura"
Dim id As Integer = ra.idFactura
FuncionesDinamicas.AbrirAP(New ucFacturaEmitida(id), OtrosParametros)
Case "idclientenavigation.razonsocial"
Dim id As Integer = ra.idCliente
FuncionesDinamicas.AbrirAP(New ucEntidad(id), OtrosParametros)
End Select
End Sub
Private Sub btMostrar_Click(sender As Object, e As RoutedEventArgs)
Try
If cbRazonSocial.EditValue Is Nothing Then
DXMessageBox.Show("Seleccione primero el cliente", "Atención")
Else
If DXSplashScreen.IsActive = False Then DXSplashScreen.Show(Of SplashScreenTecnosis)()
DXSplashScreen.SetState("Buscando facturas ...")
Dim idcliente As Integer = cbRazonSocial.EditValue
Dim facs = bd.facturas.Include(Function(x) x.movimientoscaja).Include(Function(x) x.idClienteNavigation).Include(Function(x) x.idUsuarioNavigation).Where(Function(x) x.idCliente = idcliente).OrderBy(Function(x) x.FechaFactura).ToList.Where(Function(x) x.ImportePendiente <> 0).ToList
Me.gcFacturas.ItemsSource = facs
CalculaTotalAPagar()
End If
If DXSplashScreen.IsActive Then DXSplashScreen.Close()
Catch ex As Exception
If DXSplashScreen.IsActive Then DXSplashScreen.Close()
FuncionesDinamicas.ErrorNoControladoAp(Me, ex)
DXMessageBox.Show(ex.Message, "Error")
End Try
End Sub
Private Sub BiBuscarCliente_Click(sender As Object, e As RoutedEventArgs)
Dim dxw As New dxwEntidades(bd, True, False)
If dxw.ShowDialog Then
cbRazonSocial.EditValue = dxw.Entidad.idEntidad
End If
End Sub
Private Sub CalculaTotalAPagar()
Dim lf As List(Of facturas) = Me.gcFacturas.ItemsSource
lf = lf.Where(Function(x) x.Marca_TMP).ToList
Dim TotalFacturas = lf.Sum(Function(x) x.ImportePendiente)
teTotalAPagar.EditValue = Math.Round(TotalFacturas, 2, MidpointRounding.AwayFromZero)
End Sub
Private Sub tvMovimientos_CellValueChanging(sender As Object, e As CellValueChangedEventArgs) Handles tv.CellValueChanging
tv.CommitEditing()
CalculaTotalAPagar()
End Sub
Private Sub btPagar_Click(sender As Object, e As RoutedEventArgs)
Try
If deFechaPago.EditValue Is Nothing Then Throw New Exception("La fecha de pago es obligatoria")
Dim FechaPago As Date = deFechaPago.EditValue
If cbCaja.EditValue Is Nothing Then Throw New Exception("La caja de pago es obligatoria")
Dim lf As List(Of facturas) = Me.gcFacturas.ItemsSource
lf = lf.Where(Function(x) x.Marca_TMP).ToList
Dim idCaja As Integer = cbCaja.EditValue
Dim cj = bd.cajas.First(Function(x) x.idCaja = idCaja)
If lf.Count = 0 Then Throw New Exception("Seleccione al menos una factura para pagar")
Dim lr As New List(Of movimientoscaja)
For Each f In lf
Dim nm As New movimientoscaja
With nm
.idFacturaNavigation = f
.Importe = f.ImportePendiente
.Tipo = TipoMovimientoEnum.RECIBO_CLIENTE
.idCaja = idCaja
.Fecha = FechaPago
.FechaCreacion = Now
.idUsuario = idUsuario
.Observaciones = If(teObservaciones.EditValue IsNot Nothing, teObservaciones.EditValue.ToString, "")
.EstableceNumeroRecibo()
End With
f.ImportePagado = Math.Round(f.movimientoscaja.Sum(Function(x) x.Importe), 2, MidpointRounding.AwayFromZero)
f.FechaPago = New DateOnly(FechaPago.Year, FechaPago.Month, FechaPago.Day)
f.movimientoscaja.Add(nm)
bd.SaveChanges()
lr.Add(nm)
Next
teObservaciones.EditValue = ""
Dim cp As String = "RECIBO"
Dim pl = bd.plantillas.First(Function(x) x.Codigo = cp)
DXMessageBox.Show("Se han pagado " & lf.Count.ToString & " facturas. Seleccione ahora el fichero dónde se guardará el pdf de los recibos correspondientes.", "Atención")
Dim b() As Byte = Informes.GuardaInformeEnPdf(bd, pl.idPlantilla, lr)
Dim sfd As New SaveFileDialog
sfd.FileName = "Pago Facturas " & FechaPago.ToString("yyyy-MM-dd") & ".pdf"
sfd.Filter = "Fichero PDF|*.pdf"
sfd.DefaultExt = ".pdf"
If sfd.ShowDialog Then
IO.File.WriteAllBytes(sfd.FileName, b)
tsUtilidades.Sistema.EjecutaFichero(sfd.FileName)
End If
' Informes.ImprimirPlantilla(bd, pl.idFicheroNavigation.Fichero, lr, False, 1)
RefrescaAplicaciones()
btMostrar_Click(Nothing, Nothing)
Catch ex As Exception
DXMessageBox.Show(ex.Message, "Atención")
End Try
End Sub
Private Sub cbRazonSocial_PreviewKeyDown(sender As Object, e As KeyEventArgs) Handles cbRazonSocial.PreviewKeyDown
If e.Key = Key.F6 Then BiBuscarCliente_Click(Nothing, Nothing)
End Sub
End Class