First commit 14/02/1999
This commit is contained in:
341
TpvBlcMVnt.cpp
Normal file
341
TpvBlcMVnt.cpp
Normal file
@ -0,0 +1,341 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "TpvBlcMVnt.h"
|
||||
#include "TpvVntClt.h"
|
||||
#include "TpvVntEmpl.h"
|
||||
#include "TpvVntProd.h"
|
||||
#include "TpvVntFctPrint.h"
|
||||
#include "TpvBlcM_PrintFact.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma link "ElastFrm"
|
||||
#pragma resource "*.dfm"
|
||||
TBlMVnt *BlMVnt;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TBlMVnt::TBlMVnt(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
// Cargamos la imagen OK!
|
||||
try {
|
||||
BtmOK = new Graphics::TBitmap();
|
||||
BtmOK -> LoadFromFile( "Systm\\ok.bmp" );
|
||||
|
||||
BtmLockOpen = new Graphics::TBitmap();
|
||||
BtmLockOpen -> LoadFromFile( "Systm\\lockopen.bmp" );
|
||||
|
||||
BtmLockShut = new Graphics::TBitmap();
|
||||
BtmLockShut -> LoadFromFile( "Systm\\lockshut.bmp" );
|
||||
|
||||
} catch (...) {
|
||||
ShowMessage( "Error: La imagen OK! est<73> corrupta" );
|
||||
}
|
||||
|
||||
|
||||
Word Year, Month, Day;
|
||||
TDateTime dtPresent = Now();
|
||||
DecodeDate(dtPresent, Year, Month, Day);
|
||||
FechaCajaMin -> Date = EncodeDate( Year, Month, 1);
|
||||
FechaCaja -> Date = dtPresent;
|
||||
FechaCajaChange( 0 );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TBlMVnt::ProductosClick(TObject *Sender)
|
||||
{
|
||||
TVntProd *TpvVntProd;
|
||||
Visible = false;
|
||||
TpvVntProd = new TVntProd(this);
|
||||
TpvVntProd -> MinFechaFact = FechaCajaMin -> DateTime;
|
||||
TpvVntProd -> MaxFechaFact = FechaCaja -> DateTime;
|
||||
TpvVntProd -> MinFecha -> DateTime = FechaCajaMin -> DateTime;
|
||||
TpvVntProd -> MaxFecha -> DateTime = FechaCaja -> DateTime;
|
||||
TpvVntProd -> MinFecha -> Enabled = false;
|
||||
TpvVntProd -> MaxFecha -> Enabled = false;
|
||||
TpvVntProd -> FiltrarFacturas();
|
||||
TpvVntProd -> ShowModal();
|
||||
Visible = true;
|
||||
delete TpvVntProd;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TBlMVnt::EmpleadosClick(TObject *Sender)
|
||||
{
|
||||
TVntClt *TpvVntClt;
|
||||
Visible = false;
|
||||
TpvVntClt = new TVntClt(this);
|
||||
TpvVntClt -> MinFechaFact = FechaCajaMin -> DateTime;
|
||||
TpvVntClt -> MinFechaFact = FechaCaja -> DateTime;
|
||||
TpvVntClt -> MaxFechaFact = FechaCaja -> DateTime;
|
||||
TpvVntClt -> MinFecha -> DateTime = FechaCajaMin -> 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 TBlMVnt::ClientesClick(TObject *Sender)
|
||||
{
|
||||
TVntEmpl *VentasEmpl;
|
||||
Visible = false;
|
||||
VentasEmpl = new TVntEmpl(this);
|
||||
VentasEmpl -> MinFechaFact = FechaCajaMin -> DateTime;
|
||||
VentasEmpl -> MinFechaFact = FechaCaja -> DateTime;
|
||||
VentasEmpl -> MaxFechaFact = FechaCaja -> DateTime;
|
||||
VentasEmpl -> MinFecha -> DateTime = FechaCajaMin -> 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 TBlMVnt::FechaCajaChange(TObject *Sender)
|
||||
{
|
||||
QVentasC->Close();
|
||||
QVentasR->Close();
|
||||
QComprasC->Close();
|
||||
QComprasR->Close();
|
||||
QVentasEmpleados->Close();
|
||||
|
||||
QVentasC->Active = true;
|
||||
QVentasR->Active = true;
|
||||
QComprasC->Active = true;
|
||||
QComprasR->Active = true;
|
||||
QVentasEmpleados->Active = true;
|
||||
|
||||
|
||||
Currency Ventas, Compras;
|
||||
ProgressBar1->Position = 0;
|
||||
ProgressBar1->Max = QVentasR->RecordCount + QComprasR->RecordCount;
|
||||
ProgressBar1->Visible = true;
|
||||
// Recorremos las ventas
|
||||
Ventas = 0;
|
||||
QVentasR->First();
|
||||
while ( ! QVentasR -> Eof )
|
||||
{
|
||||
ProgressBar1->Position++;
|
||||
Ventas += QVentasR->FieldByName("Total")->AsCurrency;
|
||||
QVentasR ->Next();
|
||||
}
|
||||
|
||||
// Recorremos las compras
|
||||
Compras = 0;
|
||||
QComprasR->First();
|
||||
while ( ! QComprasR -> Eof )
|
||||
{
|
||||
ProgressBar1->Position++;
|
||||
Compras += QComprasR->FieldByName("Total")->AsCurrency;
|
||||
QComprasR ->Next();
|
||||
}
|
||||
TotalVentas->Caption = FormatCurr("###,###,###.#0", Ventas );
|
||||
TotalCompras->Caption = FormatCurr("###,###,###.#0", Compras );
|
||||
Beneficio->Caption = FormatCurr("###,###,###.#0", (Ventas - Compras) );
|
||||
ProgressBar1->Visible = false;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TBlMVnt::DBGridVentasDrawColumnCell(TObject *Sender,
|
||||
const TRect &Rect, int DataCol, TColumn *Column,
|
||||
TGridDrawState State)
|
||||
{
|
||||
// Verde ] si el albaran/factura esta abiert@
|
||||
// Rojo ] los abonos o albaranes con perdidas
|
||||
if ( ! State.Contains(gdSelected) )
|
||||
{
|
||||
if ( QVentasC->FieldByName("FacturaAbierta")-> AsInteger > 0 )
|
||||
{
|
||||
DBGridVentas -> Canvas -> Font -> Color = clGreen;
|
||||
} else {
|
||||
if ( QVentasC->FieldByName("Base")->AsCurrency < 0 )
|
||||
DBGridVentas -> Canvas -> Font -> Color = clRed;
|
||||
}
|
||||
DBGridVentas -> DefaultDrawColumnCell( Rect, DataCol, Column, State );
|
||||
}
|
||||
if ( Column->DisplayName == "C" )
|
||||
{
|
||||
if ( QVentasC->FieldByName("C")->AsBoolean )
|
||||
DBGridVentas->Canvas->StretchDraw( Rect, BtmLockShut );
|
||||
else
|
||||
DBGridVentas->Canvas->StretchDraw( Rect, BtmLockOpen );
|
||||
} else if ( Column->DisplayName == "Fecha" ) {
|
||||
if ( ! State.Contains(gdSelected) )
|
||||
{
|
||||
DBGridVentas -> Canvas -> Brush -> Color = clMenu;
|
||||
DBGridVentas -> DefaultDrawColumnCell( Rect, DataCol, Column, State );
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TBlMVnt::SpeedButton1Click(TObject *Sender)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TBlMVnt::DBGridComprasDrawColumnCell(TObject *Sender,
|
||||
const TRect &Rect, int DataCol, TColumn *Column,
|
||||
TGridDrawState State)
|
||||
{
|
||||
// Rojo ] los abonos o albaranes con perdidas
|
||||
if ( ! State.Contains(gdSelected) )
|
||||
{
|
||||
if ( QComprasC->FieldByName("Base")->AsCurrency < 0 )
|
||||
DBGridCompras -> Canvas -> Font -> Color = clRed;
|
||||
|
||||
DBGridCompras -> DefaultDrawColumnCell( Rect, DataCol, Column, State );
|
||||
}
|
||||
if ( Column->DisplayName == "C" )
|
||||
{
|
||||
if ( QComprasC->FieldByName("C")->AsBoolean )
|
||||
DBGridCompras->Canvas->StretchDraw( Rect, BtmLockShut );
|
||||
else
|
||||
DBGridCompras->Canvas->StretchDraw( Rect, BtmLockOpen );
|
||||
} else if ( Column->DisplayName == "Fecha" ) {
|
||||
if ( ! State.Contains(gdSelected) )
|
||||
{
|
||||
DBGridCompras -> Canvas -> Brush -> Color = clMenu;
|
||||
DBGridCompras -> DefaultDrawColumnCell( Rect, DataCol, Column, State );
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TBlMVnt::QVentasCAfterOpen(TDataSet *DataSet)
|
||||
{
|
||||
DBGridVentas->Columns->Items[0]->Width = 16;
|
||||
|
||||
// Recalculamos la gr<67>fica...
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TBlMVnt::QComprasCAfterOpen(TDataSet *DataSet)
|
||||
{
|
||||
DBGridCompras->Columns->Items[0]->Width = 16;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TBlMVnt::QVentasCBeforeOpen(TDataSet *DataSet)
|
||||
{
|
||||
QVentasC->SQL->Clear();
|
||||
|
||||
QVentasC->SQL->Add( "SELECT VentasCabecera.Contabilizada C, VentasCabecera.FechaFactura Fecha, VentasCabecera.CodFactura, (VentasCabecera.TotalSin + VentasCabecera.TotalIVA) Importe, VentasCabecera.CodCliente, ((Personas.Nombre+', ')+Personas.Apellidos) Nombre, Personas.Empresa, VentasCabecera.FacturaAbierta, VentasCabecera.TotalSin Base, VentasCabecera.TotalIVA IVA" );
|
||||
QVentasC->SQL->Add( "FROM \"Ventas (cabecera).db\" VentasCabecera, \"personas.DB\" Personas" );
|
||||
QVentasC->SQL->Add( "WHERE (VentasCabecera.FechaFactura BETWEEN '"+FechaCajaMin->Date.FormatString("mm/dd/yyyy")+"' AND '"+FechaCaja->Date.FormatString("mm/dd/yyyy")+"') \
|
||||
AND (VentasCabecera.CodCliente = Personas.CodCliente1) ");
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TBlMVnt::QVentasRBeforeOpen(TDataSet *DataSet)
|
||||
{
|
||||
QVentasR->SQL->Clear();
|
||||
|
||||
QVentasR->SQL->Add( "SELECT FechaFactura Fecha, SUM( TotalSin ) Base, SUM( TotalIVA ) IVA, SUM( TotalIva + TotalSin ) Total");
|
||||
QVentasR->SQL->Add( "FROM \"Ventas (cabecera).DB\" VentasCabecera");
|
||||
QVentasR->SQL->Add( "WHERE (VentasCabecera.FechaFactura BETWEEN '"+FechaCajaMin->Date.FormatString("mm/dd/yyyy")+"' AND '"+FechaCaja->Date.FormatString("mm/dd/yyyy")+"')");
|
||||
QVentasR->SQL->Add( "GROUP BY FechaFactura");
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TBlMVnt::QComprasCBeforeOpen(TDataSet *DataSet)
|
||||
{
|
||||
QComprasC->SQL->Clear();
|
||||
|
||||
QComprasC->SQL->Add( "SELECT VentasCabecera.Contabilizada C, VentasCabecera.FechaFactura Fecha, VentasCabecera.CodFactura, (VentasCabecera.TotalSin + VentasCabecera.TotalIVA) Importe, VentasCabecera.CodProveedor, ((Personas.Nombre+', ')+Personas.Apellidos) Nombre, Personas.Empresa, VentasCabecera.TotalSin Base, VentasCabecera.TotalIVA IVA" );
|
||||
QComprasC->SQL->Add( "FROM \"Compras (cabecera).db\" VentasCabecera, \"personas.DB\" Personas" );
|
||||
QComprasC->SQL->Add( "WHERE (VentasCabecera.FechaFactura BETWEEN '"+FechaCajaMin->Date.FormatString("mm/dd/yyyy")+"' AND '"+FechaCaja->Date.FormatString("mm/dd/yyyy")+"') \
|
||||
AND (VentasCabecera.CodProveedor = Personas.CodCliente1) ");
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TBlMVnt::QComprasRBeforeOpen(TDataSet *DataSet)
|
||||
{
|
||||
QComprasR->SQL->Clear();
|
||||
|
||||
QComprasR->SQL->Add( "SELECT FechaFactura Fecha, SUM( TotalSin ) Base, SUM( TotalIVA ) IVA, SUM( TotalIva + TotalSin ) Total");
|
||||
QComprasR->SQL->Add( "FROM \"Compras (cabecera).DB\" ComprasCabecera");
|
||||
QComprasR->SQL->Add( "WHERE (ComprasCabecera.FechaFactura BETWEEN '"+FechaCajaMin->Date.FormatString("mm/dd/yyyy")+"' AND '"+FechaCaja->Date.FormatString("mm/dd/yyyy")+"')");
|
||||
QComprasR->SQL->Add( "GROUP BY FechaFactura");
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TBlMVnt::QVentasEmpleadosBeforeOpen(TDataSet *DataSet)
|
||||
{
|
||||
QVentasEmpleados->SQL->Clear();
|
||||
|
||||
QVentasEmpleados->SQL->Add( "SELECT Personas.Apellidos, Personas.Nombre, SUM( Ventas.TotalSin ) Base, SUM( Ventas.TotalIva ) IVA, SUM( Ventas.TotalSin + Ventas.TotalIva ) Total");
|
||||
QVentasEmpleados->SQL->Add( "FROM \"Ventas (cabecera).DB\" Ventas, \"personas.DB\" Personas");
|
||||
QVentasEmpleados->SQL->Add( "WHERE ( Ventas.FechaFactura BETWEEN '"+FechaCajaMin->Date.FormatString("mm/dd/yyyy")+"' AND '"+FechaCaja->Date.FormatString("mm/dd/yyyy")+"' ) \
|
||||
AND (Ventas.CodEmpleado = Personas.CodCliente1) \
|
||||
GROUP BY Personas.Apellidos, Personas.Nombre");
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TBlMVnt::bGraficasClick(TObject *Sender)
|
||||
{
|
||||
POINT MousePos;
|
||||
if ( GetCursorPos(&MousePos) )
|
||||
{
|
||||
mGraficas->PopupComponent = bGraficas;
|
||||
mGraficas->Popup( bGraficas->Left + Left,
|
||||
bGraficas->Height * 2 + Top);
|
||||
mGraficas->PopupComponent = 0;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TBlMVnt::MostrarVentasClick(TObject *Sender)
|
||||
{
|
||||
MostrarVentas->Checked = !MostrarVentas->Checked;
|
||||
// Ajustamos la grafica de totales...
|
||||
DBChart1 -> Series[0] -> Active = MostrarVentas->Checked;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TBlMVnt::MostrarComprasClik(TObject *Sender)
|
||||
{
|
||||
MostrarCompras->Checked = !MostrarCompras->Checked;
|
||||
// Ajustamos la grafica de totales...
|
||||
DBChart1 -> Series[1] -> Active = MostrarCompras->Checked;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void __fastcall TBlMVnt::bImpresionClick(TObject *Sender)
|
||||
{
|
||||
POINT MousePos;
|
||||
if ( GetCursorPos(&MousePos) )
|
||||
{
|
||||
mImpresion->PopupComponent = bImpresion;
|
||||
mImpresion->Popup( bImpresion->Left + Left,
|
||||
bImpresion->Height * 2 + Top);
|
||||
mImpresion->PopupComponent = 0;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TBlMVnt::VentasResumen1Click(TObject *Sender)
|
||||
{
|
||||
TQRListadoFacturas *QRResumenFact;
|
||||
QRResumenFact = new TQRListadoFacturas(this);
|
||||
QRResumenFact->DataSet = QVentasR;
|
||||
QRResumenFact->QRLabel1->Caption = "Resumen Facturas Ventas";
|
||||
QRResumenFact->Preview();
|
||||
delete QRResumenFact;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TBlMVnt::ComprasResumen1Click(TObject *Sender)
|
||||
{
|
||||
TQRListadoFacturas *QRResumenFact;
|
||||
QRResumenFact = new TQRListadoFacturas(this);
|
||||
QRResumenFact->Preview();
|
||||
delete QRResumenFact;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
Reference in New Issue
Block a user