145 lines
5.8 KiB
C++
145 lines
5.8 KiB
C++
//---------------------------------------------------------------------------
|
|
|
|
#include <vcl.h>
|
|
#include <inifiles.hpp>
|
|
#pragma hdrstop
|
|
|
|
#include "TpvCFG.h"
|
|
//---------------------------------------------------------------------------
|
|
#pragma package(smart_init)
|
|
#pragma resource "*.dfm"
|
|
TCFG *CFG;
|
|
//---------------------------------------------------------------------------
|
|
__fastcall TCFG::TCFG(TComponent* Owner)
|
|
: TForm(Owner)
|
|
{
|
|
TIniFile *ini;
|
|
ini = new TIniFile( ExtractFileDir( Application->ExeName ) + "\\TPV.INI" );
|
|
// General
|
|
initMax->Checked = ini->ReadBool( "Form", "InitMax", false );
|
|
// Ventas
|
|
alFacturar->ItemIndex = ini->ReadInteger( "Ventas", "alFacturar", 1 );
|
|
Codigo_y_Unidad->Checked = ini->ReadBool( "Ventas", "Codigo_y_Unidad", false );
|
|
CajonMonedasDonde->ItemIndex = ini->ReadInteger( "Ventas", "CajonMonedas-donde", 2 );
|
|
CajonMonedas->Checked = ini->ReadBool( "Ventas", "CajonMonedas", false );
|
|
CajonMonedasDonde->Visible = CajonMonedas->Checked;
|
|
ProbarCajon->Visible = CajonMonedas->Checked;
|
|
CambioPrecioProdExistente->Checked = ini->ReadBool( "Ventas", "CambioPrecioProdExistente", false );
|
|
// Almacen / Stock
|
|
RecalcularPrecioVentaAlCambiarCoste->ItemIndex = ini->ReadInteger( "Almacen", "RecalcularPrecioVentaAlCambiarCoste", 1 );
|
|
RefQR_LEDS->Checked = ini->ReadBool( "Almacen", "RefQR_LEDS", true );
|
|
ImprimirCabFam->Checked = ini->ReadBool( "Almacen", "ImprimirCabFam", true );
|
|
ImprimirCabFamVacia->Checked = ini->ReadBool( "Almacen", "ImprimirCabFamVacia", false );
|
|
StockQR_LEDS->Checked = ini->ReadBool( "Almacen", "StockQR_LEDS", true );
|
|
// Resumenes
|
|
VntProdCosteBeneficio->Checked = ini->ReadBool( "Resumenes", "VntProdCosteBeneficio", true );
|
|
// Compras
|
|
CmpActualizaPCoste->Checked = ini->ReadBool( "Compras", "CmpActualizaPCoste", true );
|
|
CmpActualizaPVP->Checked = ini->ReadBool( "Compras", "CmpActualizaPVP", true );
|
|
|
|
delete ini;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TCFG::AbrirCajon( void )
|
|
{
|
|
HANDLE hCom;
|
|
hCom = CreateFile( CajonMonedasDonde->Items->Strings[CajonMonedasDonde->ItemIndex].c_str(),
|
|
GENERIC_READ | GENERIC_WRITE,
|
|
0, // comm devices must be opened w/exclusive-access
|
|
NULL, // no security attributes
|
|
OPEN_EXISTING, // comm devices must use OPEN_EXISTING
|
|
0, // not overlapped I/O
|
|
NULL // hTemplate must be NULL for comm devices
|
|
);
|
|
|
|
if (hCom != INVALID_HANDLE_VALUE)
|
|
{
|
|
DCB dcb;
|
|
// We will build on the current configuration, and skip setting the size
|
|
// of the input and output buffers with SetupComm.
|
|
if ( GetCommState(hCom, &dcb) )
|
|
{
|
|
|
|
// Fill in the DCB: baud=57,600 bps, 8 data bits, no parity, and 1 stop bit.
|
|
dcb.BaudRate = CBR_9600; // set the baud rate
|
|
dcb.ByteSize = 8; // data size, xmit, and rcv
|
|
dcb.Parity = NOPARITY; // no parity bit
|
|
dcb.StopBits = ONESTOPBIT; // one stop bit
|
|
|
|
if ( SetCommState(hCom, &dcb) )
|
|
TransmitCommChar( hCom, 0xFF );
|
|
|
|
CloseHandle( hCom );
|
|
}
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TCFG::SpeedButton1Click(TObject *Sender)
|
|
{
|
|
Close();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TCFG::SpeedButton2Click(TObject *Sender)
|
|
{
|
|
// Meter datos en la base de datos...
|
|
if ( alFacturar->ItemIndex==-1 )
|
|
alFacturar->ItemIndex = 1;
|
|
/*
|
|
0 ...siempre
|
|
1 ...solo a clientes
|
|
2 ...a clientes y preguntar otros
|
|
3 ...preguntar siempre
|
|
4 ...nunca
|
|
*/
|
|
if ( RecalcularPrecioVentaAlCambiarCoste->ItemIndex==-1 )
|
|
RecalcularPrecioVentaAlCambiarCoste->ItemIndex = 1;
|
|
/*
|
|
0 ...nunca
|
|
1 ...absoluto
|
|
2 ...proporcional
|
|
*/
|
|
TIniFile *ini;
|
|
ini = new TIniFile( ExtractFileDir( Application->ExeName ) + "\\TPV.INI" );
|
|
// General
|
|
ini->WriteBool( "Form", "InitMax", initMax->Checked );
|
|
// Ventas
|
|
ini->WriteInteger( "Ventas", "alFacturar", alFacturar->ItemIndex );
|
|
ini->WriteBool( "Ventas", "Codigo_y_Unidad", Codigo_y_Unidad->Checked );
|
|
ini->WriteInteger( "Ventas", "CajonMonedas-donde", CajonMonedasDonde->ItemIndex );
|
|
ini->WriteBool( "Ventas", "CajonMonedas", CajonMonedas->Checked );
|
|
ini->WriteBool( "Ventas", "CambioPrecioProdExistente", CambioPrecioProdExistente->Checked );
|
|
// Almacen / Stock
|
|
ini->WriteInteger( "Almacen", "RecalcularPrecioVentaAlCambiarCoste", RecalcularPrecioVentaAlCambiarCoste->ItemIndex );
|
|
ini->WriteBool( "Almacen", "RefQR_LEDS", RefQR_LEDS->Checked );
|
|
ini->WriteBool( "Almacen", "ImprimirCabFam", ImprimirCabFam->Checked );
|
|
ini->WriteBool( "Almacen", "ImprimirCabFamVacia", ImprimirCabFamVacia->Checked );
|
|
ini->WriteBool( "Almacen", "StockQR_LEDS", StockQR_LEDS->Checked );
|
|
// Resumenes
|
|
ini->WriteBool( "Resumenes", "VntProdCosteBeneficio", VntProdCosteBeneficio->Checked );
|
|
// Compras
|
|
ini->WriteBool( "Compras", "CmpActualizaPCoste", CmpActualizaPCoste->Checked );
|
|
ini->WriteBool( "Compras", "CmpActualizaPVP", CmpActualizaPVP->Checked );
|
|
delete ini;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TCFG::SpeedButton3Click(TObject *Sender)
|
|
{
|
|
ShowMessage( "Especifique un valor, para hacer que la siguiente factura empiece a contar desde él." );
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TCFG::CajonMonedasClick(TObject *Sender)
|
|
{
|
|
CajonMonedasDonde->Visible = CajonMonedas->Checked;
|
|
ProbarCajon->Visible = CajonMonedas->Checked;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TCFG::ProbarCajonClick(TObject *Sender)
|
|
{
|
|
AbrirCajon();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
|