TPVwin/BuscarEntreLineas.cpp
2021-09-12 22:19:30 +02:00

77 lines
3.0 KiB
C++

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "BuscarEntreLineas.h"
#include "TDlgBuscar.h"
#include "TpvVntAlbPrint.h"
#include "TpvVntFctPrint.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int CodFactura;
// Mostramos la zona de busqueda de clientes...
// Mostramos el dialogo, buscar Vendedores
TDlgBuscar *DlgBuscar;
DlgBuscar = new TDlgBuscar(this);
DlgBuscar -> DefaultField = "NombreProducto";
DlgBuscar -> TbBusquedas -> TableName = "Ventas (cuerpo).db";
DlgBuscar -> TbBusquedas -> Active = true;
DlgBuscar -> ShowModal();
if ( DlgBuscar -> ModalResult == mrOk )
{
CodFactura = DlgBuscar -> TbBusquedas -> FieldByName( "EnlaceFactura" ) -> AsInteger;
TbVentasC -> Active = true;
if ( ( TbVentasC -> Locate( "EnlaceFactura", CodFactura, TLocateOptions() << loCaseInsensitive ) ) )
{
if ( TbVentasC->FieldByName("CodFactura")->AsInteger <= 0 )
{
// Imprime Ticket
TQRMDFacturaVnt1 *QRMDFacturaVnt;
// Creamos una ficha del tipo TProductos
// Guardando la referencia en la variable TProductos
QRMDFacturaVnt = new TQRMDFacturaVnt1(this);
// Mostrarla como modal y según el valor devuelto
QRMDFacturaVnt -> TbVntCabecera -> GotoCurrent( TbVentasC );
QRMDFacturaVnt -> Preview();
// Destruimos la ficha
delete QRMDFacturaVnt;
} else {
// Imprime factura
TQRMDFacturaVnt *QRMDFacturaVnt;
// Creamos una ficha del tipo TProductos
// Guardando la referencia en la variable TProductos
QRMDFacturaVnt = new TQRMDFacturaVnt(this);
// Mostrarla como modal y según el valor devuelto
QRMDFacturaVnt -> TbVntCabecera -> GotoCurrent( TbVentasC );
QRMDFacturaVnt -> Preview();
// Destruimos la ficha
delete QRMDFacturaVnt;
}
TbVentasC -> Active = false;
}
}
delete DlgBuscar;
}
//---------------------------------------------------------------------------