First commit 14/02/1999
This commit is contained in:
851
TpvBlcDVnt.cpp
Normal file
851
TpvBlcDVnt.cpp
Normal file
@ -0,0 +1,851 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <stdio.h>
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "TpvBlcDVnt.h"
|
||||
#include "TpvVntClt.h"
|
||||
#include "TpvVntEmpl.h"
|
||||
#include "TpvVntProd.h"
|
||||
#include "TpvBlcD_Print.h"
|
||||
#include "Inicio1.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma link "ElastFrm"
|
||||
#pragma resource "*.dfm"
|
||||
TTpvBlDVnt *TpvBlDVnt;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TTpvBlDVnt::TTpvBlDVnt(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
// Inicializamos la fecha de compra ( Y el filtro, en base a esta... )
|
||||
unsigned short year, mes, dia;
|
||||
( TDateTime::CurrentDate() ).DecodeDate( &year, &mes, &dia );
|
||||
|
||||
TbVentasI -> TableName = "Ventas (caja).db";
|
||||
TbVentasC -> TableName = "Ventas (cabecera).db";
|
||||
TbFacturasC -> TableName = "Compras (cabecera).db";
|
||||
|
||||
TbVentasI -> Active = true;
|
||||
TbVentasC -> Active = true;
|
||||
TbFacturasC -> Active = true;
|
||||
TbVentasI->Last();
|
||||
|
||||
StatusBar1->Panels->Items[1]->Text = "Recopilando datos del d<>a...";
|
||||
|
||||
FechaCaja -> Date = TDateTime::CurrentDate();
|
||||
FechaCajaChange( 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TTpvBlDVnt::SpeedButton1Click(TObject *Sender)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasICantidadx1SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasITotalx1 -> Value = TbVentasICantidadx1 -> Value * 1;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasICantidadx5SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasITotalx5 -> Value = TbVentasICantidadx5 -> Value * 5;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasICantidadx10SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasITotalx10 -> Value = TbVentasICantidadx10 -> Value * 10;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasICantidadx25SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasITotalx25 -> Value = TbVentasICantidadx25 -> Value * 25;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasICantidadx50SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasITotalx50 -> Value = TbVentasICantidadx50 -> Value * 50;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasICantidadx100SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasITotalx100 -> Value = TbVentasICantidadx100 -> Value * 100;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasICantidadx200SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasITotalx200 -> Value = TbVentasICantidadx200 -> Value * 200;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasICantidadx500SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasITotalx500 -> Value = TbVentasICantidadx500 -> Value * 500;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasICantidadx1000SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasITotalx1000 -> Value = TbVentasICantidadx1000 -> Value * 1000;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasICantidadx2000SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasITotalx2000 -> Value = TbVentasICantidadx2000 -> Value * 2000;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasICantidadx5000SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasITotalx5000 -> Value = TbVentasICantidadx5000 -> Value * 5000;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasICantidadx10000SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasITotalx10000 -> Value = TbVentasICantidadx10000 -> Value * 10000;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasITotalx1SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasICantidadx1 -> Value = TbVentasITotalx1 -> Value / 1;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasITotalx5SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasICantidadx5 -> Value = TbVentasITotalx5 -> Value / 5;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasITotalx10SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasICantidadx10 -> Value = TbVentasITotalx10 -> Value / 10;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasITotalx25SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasICantidadx25 -> Value = TbVentasITotalx25 -> Value / 25;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasITotalx50SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasICantidadx50 -> Value = TbVentasITotalx50 -> Value / 50;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasITotalx100SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasICantidadx100 -> Value = TbVentasITotalx100 -> Value / 100;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasITotalx200SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasICantidadx200 -> Value = TbVentasITotalx200 -> Value / 200;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasITotalx500SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasICantidadx500 -> Value = TbVentasITotalx500 -> Value / 500;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasITotalx1000SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasICantidadx1000 -> Value = TbVentasITotalx1000 -> Value / 1000;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasITotalx2000SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasICantidadx2000 -> Value = TbVentasITotalx2000 -> Value / 2000;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasITotalx5000SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasICantidadx5000 -> Value = TbVentasITotalx5000 -> Value / 5000;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::TbVentasITotalx10000SetText(TField *Sender,
|
||||
const AnsiString Text)
|
||||
{
|
||||
Sender -> AsInteger = Text.ToInt();
|
||||
TbVentasICantidadx10000 -> Value = TbVentasITotalx10000 -> Value / 10000;
|
||||
DsVentasIDataChange( 0, 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit1KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit2 -> SetFocus();
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit2KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit3 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit3KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit4 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit4KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit5 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit5KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit6 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit6KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit7 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit7KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit8 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit8KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit9 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit9KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit10 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit10KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit11 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit11KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit12 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit12KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit25 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit25KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit1 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit13KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit14 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit14KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit15 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit15KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit16 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit16KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit17 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit17KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit18 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit18KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit19 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit19KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit20 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit20KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit21 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit21KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit22 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit22KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit23 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit23KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit24 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit24KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit26 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::DBEdit26KeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
Key = 0;
|
||||
DBEdit13 -> SetFocus();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::FechaCajaChange(TObject *Sender)
|
||||
{
|
||||
// Vamos al registro indicado por el DateTimePicker
|
||||
if ( !( TbVentasI -> Locate( "FechaCaja", FechaCaja->DateTime, TLocateOptions() << loCaseInsensitive ) ) )
|
||||
{
|
||||
// Si el caso es que no existen ventas...
|
||||
if ( TbVentasI->Eof == true && TbVentasI->Eof == TbVentasI->Bof )
|
||||
{
|
||||
ShowMessage( "ATENCION: El registro de ventas esta VACIO\nSi esto NO es CORRECTO, pongase en contacto\nINMEDIATAMENTE con su distibuidor." );
|
||||
FechaCaja->Enabled = false;
|
||||
DBMemo1->Enabled = false;
|
||||
Clientes->Enabled = false; Empleados->Enabled = false; Productos->Enabled = false;
|
||||
|
||||
for ( int i=1; i<=26; i++ )
|
||||
( (TDBEdit *)FindComponent("DBEdit"+AnsiString(i)) )->Enabled = false;
|
||||
|
||||
Close(); // ...mejor salimos.
|
||||
return;
|
||||
}
|
||||
|
||||
ShowMessage( "El d<>a actual/seleccionado, no tiene datos de venta..." );
|
||||
// La fecha del Picker ha de cambiar (Sin provocar este evento, otra vez).
|
||||
TDateTime NuevaFecha = BuscaFecha( FechaCaja->DateTime );
|
||||
if ( NuevaFecha == FechaCaja->DateTime ) return;
|
||||
FechaCaja -> DateTime = NuevaFecha;
|
||||
FechaCajaChange(0);
|
||||
} else {
|
||||
DineroEnCajaAyer();
|
||||
CalculaVentaGasto();
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
TDateTime __fastcall TTpvBlDVnt::BuscaFecha( TDateTime FechaInicio )
|
||||
{
|
||||
bool Found;
|
||||
unsigned short year, mes, dia;
|
||||
FechaInicio.DecodeDate( &year, &mes, &dia );
|
||||
|
||||
Found = false;
|
||||
while ( dia > 1 && !Found )
|
||||
{
|
||||
Found = ( TbVentasI -> Locate( "FechaCaja", EncodeDate( year, mes, dia ), TLocateOptions() << loCaseInsensitive ) );
|
||||
dia--;
|
||||
}
|
||||
|
||||
if ( Found )
|
||||
FechaInicio = TbVentasI -> FieldByName("FechaCaja") -> AsDateTime;
|
||||
|
||||
return FechaInicio;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TTpvBlDVnt::DineroEnCajaAyer(void)
|
||||
{
|
||||
Currency TotalM;
|
||||
TBookmark SavePlace;
|
||||
// Marcamos el registro en el cual nos encontramos
|
||||
SavePlace = TbVentasI->GetBookmark();
|
||||
|
||||
// Calculamos el Dinero En Caja (del <20>ltimo d<>a) Ayer
|
||||
TotalM = 0;
|
||||
do
|
||||
{
|
||||
TbVentasI -> Prior();
|
||||
TotalM =
|
||||
TbVentasI -> FieldByName("Total x1" ) -> AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x5" ) -> AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x10" ) -> AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x25" ) -> AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x50" ) -> AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x100" ) -> AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x200" ) -> AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x500" ) -> AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x1000" ) -> AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x2000" ) -> AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x5000" ) -> AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x10000" ) -> AsCurrency +
|
||||
TbVentasI -> FieldByName("Total xvarios" ) -> AsCurrency ;
|
||||
} while( TotalM == 0 && !TbVentasI->Bof );
|
||||
|
||||
|
||||
EnCajaAyer = TotalM;
|
||||
Label27 -> Caption = TbVentasI -> FieldByName("FechaCaja") -> AsString + " ---> " + FormatCurr("###,###,###.#0", TotalM ) + " Ptas.";
|
||||
|
||||
// Regresamos al registro previo a esta llamada
|
||||
TbVentasI->GotoBookmark(SavePlace);
|
||||
TbVentasI->FreeBookmark(SavePlace);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TTpvBlDVnt::ClientesClick(TObject *Sender)
|
||||
{
|
||||
if ( !MenuInicio->TablaDeAcceso[3][8] )
|
||||
return;
|
||||
TVntEmpl *VentasEmpl;
|
||||
Visible = false;
|
||||
VentasEmpl = new TVntEmpl(this);
|
||||
VentasEmpl -> MinFechaFact = FechaCaja -> DateTime;
|
||||
VentasEmpl -> MaxFechaFact = FechaCaja -> DateTime;
|
||||
VentasEmpl -> MinFecha -> DateTime = FechaCaja -> DateTime;
|
||||
VentasEmpl -> MaxFecha -> DateTime = FechaCaja -> DateTime;
|
||||
VentasEmpl -> MinFecha -> Enabled = false;
|
||||
VentasEmpl -> MaxFecha -> Enabled = false;
|
||||
VentasEmpl -> ShowModal();
|
||||
Visible = true;
|
||||
delete VentasEmpl;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TTpvBlDVnt::EmpleadosClick(TObject *Sender)
|
||||
{
|
||||
if ( !MenuInicio->TablaDeAcceso[3][8] )
|
||||
return;
|
||||
|
||||
TVntClt *TpvVntClt;
|
||||
Visible = false;
|
||||
TpvVntClt = new TVntClt(this);
|
||||
TpvVntClt -> MinFechaFact = FechaCaja -> DateTime;
|
||||
TpvVntClt -> MaxFechaFact = FechaCaja -> DateTime;
|
||||
TpvVntClt -> MinFecha -> DateTime = FechaCaja -> DateTime;
|
||||
TpvVntClt -> MaxFecha -> DateTime = FechaCaja -> DateTime;
|
||||
TpvVntClt -> MinFecha -> Enabled = false;
|
||||
TpvVntClt -> MaxFecha -> Enabled = false;
|
||||
TpvVntClt -> ShowModal();
|
||||
Visible = true;
|
||||
delete TpvVntClt;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TTpvBlDVnt::ProductosClick(TObject *Sender)
|
||||
{
|
||||
if ( !MenuInicio->TablaDeAcceso[1][8] )
|
||||
return;
|
||||
|
||||
TVntProd *TpvVntProd;
|
||||
Visible = false;
|
||||
TpvVntProd = new TVntProd(this);
|
||||
TpvVntProd -> MinFechaFact = FechaCaja -> DateTime;
|
||||
TpvVntProd -> MaxFechaFact = FechaCaja -> DateTime;
|
||||
TpvVntProd -> MinFecha -> DateTime = FechaCaja -> DateTime;
|
||||
TpvVntProd -> MaxFecha -> DateTime = FechaCaja -> DateTime;
|
||||
TpvVntProd -> MinFecha -> Enabled = false;
|
||||
TpvVntProd -> MaxFecha -> Enabled = false;
|
||||
TpvVntProd -> FiltrarFacturas();
|
||||
TpvVntProd -> ShowModal();
|
||||
Visible = true;
|
||||
delete TpvVntProd;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TTpvBlDVnt::CalculaVentaGasto(void)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// VENTAS C (AFTERopen)
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
unsigned short H, M, S, mS, i;
|
||||
char buffer[80];
|
||||
TDateTime AjusteMinimo = FechaCaja->DateTime;
|
||||
Currency Parcial;
|
||||
// TDateTime AjusteMaximo = FechaCaja->DateTime + 1;
|
||||
|
||||
for ( i = 0; i<25; i++ )
|
||||
VentasHora[ i ] = 0;
|
||||
|
||||
|
||||
TbVentasC->FilterOptions = TbVentasC->FilterOptions << foCaseInsensitive;
|
||||
// TbVentasC->Filter = "([FechaFactura] >= '" + AjusteMinimo + "' AND [FechaFactura] < '" + AjusteMaximo + "')";
|
||||
TbVentasC->Filter = "([FechaFactura] = '" + AjusteMinimo + "')";
|
||||
TbVentasC->Filtered = true;
|
||||
|
||||
StatusBar1->Panels->Items[1]->Text = "Discriminando ventas";
|
||||
|
||||
// Reccorremos la tabla hasta obtener los gastos...
|
||||
Gastos = 0;
|
||||
VentasE = 0;
|
||||
TbVentasC -> First();
|
||||
while ( ! TbVentasC -> Eof )
|
||||
{
|
||||
TbVentasC -> FieldByName( "HoraFactura" ) -> AsDateTime.DecodeTime( &H, &M, &S, &mS );
|
||||
// VentasHora[ H ] += TbVentasC -> FieldByName( "Cantidad5" ) -> AsCurrency;
|
||||
Parcial = TbVentasC -> FieldByName( "TotalSin" ) -> AsCurrency + TbVentasC -> FieldByName( "TotalIva" ) -> AsCurrency;
|
||||
VentasHora[ H ] += Parcial;
|
||||
if ( TbVentasC->FieldByName("FormaPago")->AsInteger == 0 ) VentasE += Parcial;
|
||||
TbVentasC -> Next();
|
||||
}
|
||||
|
||||
StatusBar1->Panels->Items[1]->Text = "Colocando datos en el panel";
|
||||
VentasHora[25] = 0;
|
||||
MDatos -> Lines -> Clear();
|
||||
MDatos -> Lines -> Add( "Venta seg<65>n Horas" );
|
||||
Chart1 -> Series[0] -> Clear();
|
||||
for ( i = 0; i < 24; i++ )
|
||||
{
|
||||
sprintf( buffer, "[%02i:00 -> %02i:00] #", i, (i+1)%24 );
|
||||
MDatos -> Lines -> Add( AnsiString( buffer ) + FormatCurr("###,###,###.#0", VentasHora[i] ) );
|
||||
VentasHora[25] += VentasHora[i];
|
||||
|
||||
// Metemos los datos en la gr<67>fica...
|
||||
Chart1 -> Series[0] -> AddXY(i, VentasHora[i], i, clTeeColor);
|
||||
}
|
||||
LVentasT -> Caption = FormatCurr("###,###,###.#0", VentasHora[25]);
|
||||
LVentasE -> Caption = FormatCurr("###,###,###.#0", VentasE);
|
||||
StatusBar1->Panels->Items[1]->Text = "";
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// FACTURAS C (AFTERopen)
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
TbFacturasC->FilterOptions = TbFacturasC->FilterOptions << foCaseInsensitive;
|
||||
TbFacturasC->Filter = "([FechaFactura] = '" + FechaCaja->DateTime + "')";
|
||||
TbFacturasC->Filtered = true;
|
||||
|
||||
StatusBar1->Panels->Items[1]->Text = "Obteniendo gastos";
|
||||
|
||||
// Reccorremos la tabla hasta obtener los gastos...
|
||||
Currency GastosE = 0;
|
||||
Gastos = 0;
|
||||
TbFacturasC -> First();
|
||||
while ( ! TbFacturasC -> Eof )
|
||||
{
|
||||
Parcial = TbFacturasC -> FieldByName( "TotalSin") -> AsCurrency +
|
||||
TbFacturasC -> FieldByName( "TotalIva") -> AsCurrency ;
|
||||
Gastos += Parcial;
|
||||
|
||||
if ( TbFacturasC->FieldByName( "FormaPago" )->AsInteger == 0 )
|
||||
GastosE += Parcial;
|
||||
|
||||
|
||||
//TbFacturasC -> FieldByName( "Cantidad5" ) -> AsCurrency;
|
||||
TbFacturasC -> Next();
|
||||
}
|
||||
|
||||
StatusBar1->Panels->Items[1]->Text = "";
|
||||
|
||||
LGastos -> Caption = FormatCurr("###,###,###.#0", Gastos );
|
||||
LGastosE -> Caption = FormatCurr("###,###,###.#0", GastosE );
|
||||
Currency Beneficio = (VentasHora[25] - Gastos );
|
||||
LBeneficio->Caption = FormatCurr("###,###,###.#0", Beneficio );
|
||||
if ( Beneficio < 0 ) LBeneficio->Font->Color = clRed; else LBeneficio->Font->Color = clGreen;
|
||||
|
||||
Beneficio = (VentasE - GastosE );
|
||||
LBeneficioE->Caption = FormatCurr("###,###,###.#0", Beneficio );
|
||||
if ( Beneficio < 0 ) LBeneficioE->Font->Color = clRed; else LBeneficioE->Font->Color = clGreen;
|
||||
EnCaja->Caption = FormatCurr("###,###,###.#0", Beneficio + EnCajaAyer );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
void __fastcall TTpvBlDVnt::FormClose(TObject *Sender,
|
||||
TCloseAction &Action)
|
||||
{
|
||||
if ( TbVentasI -> State == dsEdit ||TbVentasI -> State == dsInsert )
|
||||
TbVentasI -> Post();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TTpvBlDVnt::DsVentasIDataChange(TObject *Sender,
|
||||
TField *Field)
|
||||
{
|
||||
SpeedButton4->Enabled = !TbVentasI->Bof;
|
||||
SpeedButton6->Enabled = !TbVentasI->Eof;
|
||||
|
||||
Currency TotalC, TotalM;
|
||||
|
||||
// Sumamos los totales monetarios...
|
||||
TotalC =
|
||||
TbVentasI -> FieldByName("Cantidad x1" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Cantidad x5" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Cantidad x10" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Cantidad x25" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Cantidad x50" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Cantidad x100" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Cantidad x200" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Cantidad x500" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Cantidad x1000" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Cantidad x2000" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Cantidad x5000" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Cantidad x10000" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Cantidad xvarios" )->AsCurrency;
|
||||
TotalM =
|
||||
TbVentasI -> FieldByName("Total x1" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x5" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x10" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x25" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x50" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x100" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x200" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x500" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x1000" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x2000" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x5000" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Total x10000" )->AsCurrency +
|
||||
TbVentasI -> FieldByName("Total xvarios" )->AsCurrency;
|
||||
|
||||
Label15->Caption = TotalC;
|
||||
Label16->Caption = TotalM;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TTpvBlDVnt::SpeedButton7Click(TObject *Sender)
|
||||
{
|
||||
TQRBlcD_Print *QRResumenFact;
|
||||
QRResumenFact = new TQRBlcD_Print(this);
|
||||
QRResumenFact->Preview();
|
||||
delete QRResumenFact;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user