1032 lines
36 KiB
C++
1032 lines
36 KiB
C++
//---------------------------------------------------------------------------
|
|
#include <io.h>
|
|
#include <stdio.h>
|
|
|
|
#include <vcl\vcl.h>
|
|
#pragma hdrstop
|
|
|
|
#include "TpvCFG.h"
|
|
#include "TpvCmp.h"
|
|
//#include "TpvGBDAT.h"
|
|
#include "TDlgBuscar.h"
|
|
|
|
//---------------------------------------------------------------------------
|
|
#pragma link "Grids"
|
|
#pragma link "ElastFrm"
|
|
#pragma resource "*.dfm"
|
|
TTpvCmp1 *TpvCmp1;
|
|
//---------------------------------------------------------------------------
|
|
__fastcall TTpvCmp1::TTpvCmp1(TComponent* Owner)
|
|
: TForm(Owner)
|
|
{
|
|
BusqManual = false;
|
|
// 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á corrupta" );
|
|
CambiandoFactura = false;
|
|
}
|
|
|
|
|
|
CambioCantidad5 = false;
|
|
CambiandoFactura = false;
|
|
|
|
// Mostramos el dialogo, buscar [Productos]
|
|
DlgBuscarProd = new TDlgBuscar(this);
|
|
|
|
TbProveedor -> Active = true;
|
|
DlgBuscarProd -> TbBusquedas -> TableName = "Tb_Ref";
|
|
DlgBuscarProd -> TbBusquedas -> Active = true;
|
|
|
|
// Selecciona la base de datos correcta (Tpv_Cm'####)
|
|
FechaFacturaA = FechaFacturaA.CurrentDate();
|
|
|
|
TbFacturasC -> Active = false;
|
|
TbFacturasD -> Active = false;
|
|
|
|
TbFacturasC -> TableName = "Compras (cabecera).db";
|
|
TbFacturasD -> TableName = "Compras (cuerpo).db";
|
|
|
|
TbFacturasD -> Active = true;
|
|
TbFacturasC -> Active = true;
|
|
|
|
// Inicializamos la fecha de compra ( Y el filtro, en base a esta... )
|
|
FechaFactura->Date = FechaFacturaA;
|
|
TbCartera -> Active = true;
|
|
|
|
// Activamos el filtro para el dia/mes/año actuales (FechaFactura)
|
|
ReajustaFiltro();
|
|
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::SpeedButton5Click(TObject *Sender)
|
|
{
|
|
Close();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::SpeedButton4Click(TObject *Sender)
|
|
{
|
|
TbFacturasD -> Insert();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::SpeedButton6Click(TObject *Sender)
|
|
{
|
|
TbFacturasD -> Delete();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::BusqAntClick(TObject *Sender)
|
|
{
|
|
/*
|
|
if ( DataModule1 -> TbFacturasC -> FindPrior() == true )
|
|
{
|
|
BusqSig -> Enabled = true;
|
|
} else {
|
|
BusqAnt -> Enabled = false;
|
|
MessageBox( 0, "Coincidencia no hayada", "¡ Buscar Anterior !", MB_OK );
|
|
}
|
|
*/
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::BuscarFichaClick(TObject *Sender)
|
|
{
|
|
MessageBox( 0, "¿Qué Pretendes BUSCAR?", "¡ No esta CLARO !", MB_OK );
|
|
/*
|
|
TDlgBuscProd *DlgBuscProd;
|
|
|
|
DlgBuscProd = new TDlgBuscProd(this);
|
|
|
|
DlgBuscProd -> ShowModal();
|
|
|
|
if ( DlgBuscProd -> ModalResult == mrOk )
|
|
{
|
|
BusqSig -> Enabled = true;
|
|
BusqAnt -> Enabled = true;
|
|
}
|
|
|
|
delete DlgBuscProd;
|
|
*/
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::BusqSigClick(TObject *Sender)
|
|
{
|
|
/*
|
|
if ( DataModule1 -> TbFacturasC -> FindNext() == true )
|
|
{
|
|
//DataModule1 -> TbProductos -> GotoCurrent(DataModule1 -> TbFacturasC);
|
|
BusqAnt -> Enabled = true;
|
|
} else {
|
|
BusqSig -> Enabled = false;
|
|
MessageBox( 0, "Coincidencia no hayada", "¡ Buscar Siguiente !", MB_OK );
|
|
}
|
|
*/
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::SpeedButton1Click(TObject *Sender)
|
|
{
|
|
TbFacturasC -> Insert();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::DsFacturasDDataChange(TObject *Sender, TField *Field)
|
|
{
|
|
char BarraEstado[80];
|
|
|
|
// Indicador de FichaActual / Num.Fichas
|
|
if ( TbFacturasD -> RecNo > 0 && TbFacturasD -> RecordCount > 0 )
|
|
{
|
|
sprintf( BarraEstado, "C: %d / %d", TbFacturasD -> RecNo, TbFacturasD -> RecordCount );
|
|
} else {
|
|
sprintf( BarraEstado, "C: ¿Nuevo? / %d", TbFacturasD -> RecordCount );
|
|
}
|
|
|
|
StatusBar1->Panels->Items[1]->Text = BarraEstado;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::DsFacturasCDataChange(TObject *Sender, TField *Field)
|
|
{
|
|
char BarraEstado[80];
|
|
Currency TParcial; int CantProd = 0;
|
|
|
|
// Indicador de FichaActual / Num.Fichas
|
|
if ( TbFacturasC -> RecNo > 0 && TbFacturasC -> RecordCount > 0 )
|
|
{
|
|
if ( !CambioCantidad5 )
|
|
{
|
|
SUMAcompraC = 0; IVAcompraC = 0;
|
|
|
|
sprintf( BarraEstado, "F: %d / %d", TbFacturasC -> RecNo, TbFacturasC -> RecordCount );
|
|
TbFacturasD -> DisableControls();
|
|
TbFacturasD -> First();
|
|
while ( ! TbFacturasD -> Eof )
|
|
{
|
|
StatusBar1->Panels->Items[2]->Text = "Sumando: " + TbFacturasD -> RecNo;
|
|
|
|
TParcial = TbFacturasD->FieldByName("PrecioC") -> AsCurrency * Currency( (int)( TbFacturasD->FieldByName("Cantidad") -> AsInteger ) );
|
|
SUMAcompraC += TParcial;
|
|
IVAcompraC += ( TParcial / 100 ) * Currency( (int)( TbFacturasD->FieldByName("IVA") -> AsInteger ) );
|
|
|
|
CantProd += TbFacturasD->FieldByName("Cantidad") -> AsInteger;
|
|
TbFacturasD -> Next();
|
|
}
|
|
|
|
TbFacturasD -> EnableControls();
|
|
}
|
|
} else {
|
|
sprintf( BarraEstado, "F: ¿Nuevo? / %d", TbFacturasC -> RecordCount );
|
|
CambiandoFactura = false;
|
|
return;
|
|
}
|
|
|
|
SUMAcompra -> Caption = FormatCurr("###,###,###.#0", SUMAcompraC );
|
|
IVAcompra -> Caption = FormatCurr("###,###,###.#0", IVAcompraC );
|
|
TotalCompra -> Caption = FormatCurr("###,###,###.#0", SUMAcompraC + IVAcompraC );
|
|
|
|
StatusBar1->Panels->Items[2]->Text = BarraEstado;
|
|
btFacturar->Enabled = ! TbFacturasC->FieldByName("Contabilizada")->AsBoolean;
|
|
DsFacturasC->AutoEdit = ! TbFacturasC->FieldByName("Contabilizada")->AsBoolean;
|
|
DsFacturasD->AutoEdit = ! TbFacturasC->FieldByName("Contabilizada")->AsBoolean;
|
|
|
|
if ( CambiandoFactura ) return;
|
|
CambiandoFactura = true;
|
|
cbFormaPago->ItemIndex = TbFacturasC->FieldByName("FormaPago")->AsInteger;
|
|
CambiandoFactura = false;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::TbFacturasCNewRecord(TDataSet *DataSet)
|
|
{
|
|
try {
|
|
TbFacturasC -> FieldByName("FormaPago")->AsInteger = 0;
|
|
TbFacturasC -> FieldByName( "FechaFactura" ) -> AsDateTime = FechaFacturaA;//TDateTime::CurrentDate();
|
|
TbFacturasC -> FieldByName( "CodProveedor" ) -> AsInteger = 1;
|
|
TbFacturasC -> FieldByName( "UltimoPago" ) -> AsDateTime = TDateTime::CurrentDate();
|
|
|
|
} catch(...) {
|
|
Abort();
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::Button1Click(TObject *Sender)
|
|
{
|
|
// Mostramos el dialogo, buscar Vendedores
|
|
TDlgBuscar *DlgBuscar;
|
|
|
|
DlgBuscar = new TDlgBuscar(this);
|
|
|
|
DlgBuscar->Filter = "Proveedor > 0";
|
|
DlgBuscar->TbBusquedas->Filter = DlgBuscar->Filter;
|
|
DlgBuscar->TbBusquedas->Filtered = true;
|
|
DlgBuscar->TbBusquedas->TableName = "personas";
|
|
DlgBuscar->TbBusquedas->Active = true;
|
|
DlgBuscar->ShowModal();
|
|
|
|
if ( DlgBuscar -> ModalResult == mrOk )
|
|
{
|
|
TbFacturasC -> Edit();
|
|
TbFacturasC -> FieldByName( "CodProveedor" ) -> AsInteger = DlgBuscar -> TbBusquedas -> FieldByName( "CodCliente1" ) -> AsInteger;
|
|
|
|
TbFacturasC->FieldByName("Banco_Entidad" )->Value = DlgBuscar->TbBusquedas->FieldByName("Banco_Entidad" )->Value;
|
|
TbFacturasC->FieldByName("Banco_Sucursal" )->Value = DlgBuscar->TbBusquedas->FieldByName("Banco_Sucursal" )->Value;
|
|
TbFacturasC->FieldByName("Banco_DC" )->Value = DlgBuscar->TbBusquedas->FieldByName("Banco_DC" )->Value;
|
|
TbFacturasC->FieldByName("Banco_NumCuenta" )->Value = DlgBuscar->TbBusquedas->FieldByName("Banco_NumCuenta" )->Value;
|
|
|
|
TbFacturasC -> Post();
|
|
}
|
|
|
|
delete DlgBuscar;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
/*
|
|
void __fastcall TTpvCmp1::SpeedButton2Click(TObject *Sender)
|
|
{
|
|
TDateTime FTest;
|
|
|
|
enum TDateTimeFlag {Date, Time, DateTime} DTFlag = Date;
|
|
|
|
unsigned short M, D, A, Aa;
|
|
|
|
try {
|
|
FTest = TDateTime( FechaFactura->Text, DTFlag );
|
|
FTest.DecodeDate( &A, &M, &D );
|
|
FechaFacturaA.CurrentDate();
|
|
FechaFacturaA.DecodeDate( &Aa, &M, &D );
|
|
// Se prohibe cambiar de año
|
|
if ( Aa != A )
|
|
{
|
|
MessageBox( 0, "Fecha de Factura fuera de rango.", "Atención", MB_OK );
|
|
return;
|
|
} else {
|
|
FechaFacturaA = FTest;
|
|
ReajustaFiltro();
|
|
}
|
|
} catch(...) {
|
|
MessageBox( 0, "Imposible aplicar filro.", "Atención", MB_OK );
|
|
}
|
|
}
|
|
*/
|
|
//---------------------------------------------------------------------------
|
|
void _fastcall TTpvCmp1::ReajustaFiltro(void)
|
|
{
|
|
|
|
SUMAcompra->Caption = 0; IVAcompra->Caption = 0; TotalCompra->Caption = 0;
|
|
|
|
TbFacturasC->FilterOptions = TbFacturasC->FilterOptions << foCaseInsensitive;
|
|
|
|
TbFacturasC->Filter = "([FechaFactura] = '" + FechaFacturaA + "')";
|
|
|
|
TbFacturasC->Filtered = true;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::DBEdit1KeyPress(TObject *Sender, char &Key)
|
|
{
|
|
if ( Key == VK_RETURN )
|
|
{
|
|
Key = 0;
|
|
TbFacturasC -> Post();
|
|
Button1 -> SetFocus();
|
|
}
|
|
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::TbFacturasCBeforeDelete(TDataSet *DataSet)
|
|
{
|
|
if ( TbFacturasC->FieldByName("Contabilizada")->AsBoolean == true )
|
|
{
|
|
ShowMessage( "No se pueden eliminar, facturas que hayan sido contabilizadas." );
|
|
Abort();
|
|
}
|
|
|
|
switch( MessageDlg( "Atención, está apunto de\neliminar la factura " + TbFacturasC -> FieldByName( "CodFactura" ) -> AsString + "...\ny todas sus compras asociadas.\n¿Realmente desea continuar?", mtWarning, TMsgDlgButtons() << mbNo << mbYes, 0 ) )
|
|
{
|
|
case mrNo:
|
|
Abort();
|
|
break;
|
|
default:
|
|
// Borramos y NO DESCONTAMOS DEL ¡¡¡STOCK!!!
|
|
while( TbFacturasD -> RecordCount != 0 )
|
|
{
|
|
TbFacturasD -> Delete();
|
|
}
|
|
break;
|
|
};
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::TbFacturasDBeforeInsert(TDataSet *DataSet)
|
|
{
|
|
if ( !( TbFacturasC -> RecNo > 0 && TbFacturasC -> RecordCount > 0 ) )
|
|
{
|
|
MessageBox( 0, "¿ No cree que debería crear,\no seleccionar una factura nueva,\nantes de agregar datos de compra?.", "¡ Atención !", MB_OK );
|
|
Abort();
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
//
|
|
// Muestra la ficha para elegir producto, y en caso de ser distinto al actual
|
|
// actualiza los Stock's correspondientes.
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::DBGrid1EditButtonClick(TObject *Sender)
|
|
{
|
|
if ( !( TbFacturasC -> RecNo > 0 && TbFacturasC -> RecordCount > 0 ) )
|
|
{
|
|
MessageBox( 0, "¿ No cree que debería crear,\no seleccionar una factura nueva,\nantes de agregar datos de compra?.", "¡ Atención !", MB_OK );
|
|
return;
|
|
}
|
|
|
|
// Mostramos el dialogo, buscar Productos
|
|
DlgBuscarProd -> ShowModal();
|
|
|
|
if ( DlgBuscarProd -> ModalResult == mrOk )
|
|
{
|
|
if ( TbFacturasD -> RecordCount <= 0 )
|
|
TbFacturasD -> Insert();
|
|
|
|
if ( TbFacturasD -> State != dsEdit )
|
|
TbFacturasD -> Edit();
|
|
|
|
BusqManual = true;
|
|
TbFacturasDCodProductoSetText(TbFacturasD -> FieldByName( "CodProducto" ),
|
|
DlgBuscarProd -> TbBusquedas -> FieldByName( "ID Producto" ) -> AsString);
|
|
BusqManual = false;
|
|
|
|
if ( TbFacturasD -> State != dsEdit )
|
|
TbFacturasD -> Edit();
|
|
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::ActualizaStock( AnsiString CodProducto, int Cantidad, int CodProveedor )
|
|
{
|
|
// Localizamos el CodProducto y actualizamos
|
|
Set<TLocateOption,0,1> flags;
|
|
flags << loCaseInsensitive;
|
|
|
|
DlgBuscarProd -> TbBusquedas -> Filtered = false;
|
|
if ( DlgBuscarProd -> TbBusquedas -> Locate( "ID Producto", CodProducto, flags ) )
|
|
{
|
|
DlgBuscarProd -> TbBusquedas -> Edit();
|
|
DlgBuscarProd -> TbBusquedas -> FieldByName( "Stock Actual" ) -> AsInteger += Cantidad;
|
|
if ( CodProveedor != -1 )
|
|
DlgBuscarProd -> TbBusquedas -> FieldByName( "ProveedorActual" ) -> AsInteger = CodProveedor;
|
|
DlgBuscarProd -> TbBusquedas -> Post();
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::TbFacturasDCalcFields(TDataSet *DataSet)
|
|
{
|
|
|
|
TbFacturasDTotal -> AsCurrency = TbFacturasD->FieldByName("PrecioC")->AsCurrency * TbFacturasD->FieldByName("Cantidad") -> AsCurrency;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::DBGrid1KeyPress(TObject *Sender, char &Key)
|
|
{
|
|
switch( Key )
|
|
{
|
|
case VK_RETURN:
|
|
if ( DBGrid1 -> EditorMode )
|
|
{
|
|
if ( TbFacturasD -> State == dsEdit )
|
|
TbFacturasD -> Post();
|
|
if ( DBGrid1 -> Fields[DBGrid1 -> SelectedIndex] -> FieldName == "IVA" )
|
|
{
|
|
DBGrid1 -> SelectedField = DBGrid1 -> Fields[0];
|
|
TbFacturasD -> Next();
|
|
if ( TbFacturasD -> Eof )
|
|
{
|
|
TbFacturasD -> Append();
|
|
}
|
|
} else
|
|
DBGrid1 -> SelectedIndex = DBGrid1 -> SelectedIndex + 1;
|
|
Key = 0;
|
|
}
|
|
break;
|
|
case '.':
|
|
Key = ',';
|
|
// FALTA 'BREAK' ARRIBA ¡¡¡¡¡¡¡¡ CORRECTO !!!!!!!!!
|
|
default:
|
|
// Solo si el campo seleccionado es el de NOMBRE DEL PRODUCTO
|
|
if ( DBGrid1 -> Fields[DBGrid1 -> SelectedIndex] -> FieldName == "NombreProducto" )
|
|
{
|
|
// TInplaceEdit *CellsEditor;
|
|
// TCustomEdit
|
|
// DBGrid1 -> InplaceEditor -> SelStart = 1;
|
|
// DBGrid1 -> InplaceEditor -> SelLength = 2;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
// Recalculamos los TOTALES
|
|
MessageBox ( 0, AnsiString ( "Antiguo: " +
|
|
Sender -> OldValue +
|
|
"\nNuevo: " +
|
|
Sender -> NewValue ).c_str() , "JEJE", MB_OK );
|
|
|
|
*/
|
|
void __fastcall TTpvCmp1::TbFacturasDCantidadSetText(TField *Sender,
|
|
const AnsiString Text)
|
|
{
|
|
Currency TParcial;
|
|
|
|
ActualizaStock( TbFacturasD->FieldByName("CodProducto") -> AsString,
|
|
-1 * TbFacturasD->FieldByName("Cantidad") -> AsInteger,
|
|
-1 );
|
|
//
|
|
|
|
TParcial = TbFacturasD->FieldByName("PrecioC") -> AsCurrency * Currency( (int)( Sender -> AsInteger ) );
|
|
SUMAcompraC -= TParcial;
|
|
IVAcompraC -= ( TParcial / 100 ) * Currency( (int)( TbFacturasD -> FieldByName( "IVA" ) -> AsInteger ) );
|
|
|
|
Sender -> AsString = Text;
|
|
|
|
TParcial = TbFacturasD->FieldByName("PrecioC") -> AsCurrency * Currency( (int)( Text.ToInt() ) );
|
|
SUMAcompraC += TParcial;
|
|
IVAcompraC += ( TParcial / 100 ) * Currency( (int)( TbFacturasD -> FieldByName( "IVA" ) -> AsInteger ) );
|
|
|
|
CambioCantidad5 = true;
|
|
TbFacturasC -> Edit();
|
|
TbFacturasC -> FieldByName( "TotalSin") -> AsCurrency = SUMAcompraC;
|
|
TbFacturasC -> FieldByName( "TotalIva") -> AsCurrency = IVAcompraC;
|
|
TbFacturasC -> Post();
|
|
CambioCantidad5 = false;
|
|
|
|
|
|
SUMAcompra -> Caption = AnsiString( SUMAcompraC );
|
|
IVAcompra -> Caption = AnsiString( IVAcompraC );
|
|
TotalCompra -> Caption = AnsiString::CurrToStr( SUMAcompraC + IVAcompraC );
|
|
|
|
//
|
|
ActualizaStock( TbFacturasD->FieldByName("CodProducto") -> AsString,
|
|
+1 * TbFacturasD->FieldByName("Cantidad") -> AsInteger,
|
|
TbFacturasC -> FieldByName( "CodProveedor" ) -> AsInteger );
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::TbFacturasDPrecioCSetText(TField *Sender,
|
|
const AnsiString Text)
|
|
{
|
|
Currency TParcial;
|
|
|
|
TParcial = Sender -> AsCurrency * Currency( (int)( TbFacturasDCantidad -> AsInteger ) );
|
|
SUMAcompraC -= TParcial;
|
|
IVAcompraC -= ( TParcial / 100 ) * Currency( (int)( TbFacturasD -> FieldByName( "IVA" ) -> AsInteger ) );
|
|
|
|
Sender -> AsString = Text;
|
|
|
|
TParcial = Currency( Text ) * Currency( (int)( TbFacturasDCantidad -> AsInteger ) );
|
|
SUMAcompraC += TParcial;
|
|
IVAcompraC += ( TParcial / 100 ) * Currency( (int)( TbFacturasD -> FieldByName( "IVA" ) -> AsInteger ) );
|
|
|
|
CambioCantidad5 = true;
|
|
TbFacturasC -> Edit();
|
|
TbFacturasC -> FieldByName( "TotalSin") -> AsCurrency = SUMAcompraC;
|
|
TbFacturasC -> FieldByName( "TotalIva") -> AsCurrency = IVAcompraC;
|
|
TbFacturasC -> Post();
|
|
CambioCantidad5 = false;
|
|
|
|
///////// ACTUALIZAMOS EL PrecioC en el LISTADO DE PRODUCTOS :---------
|
|
if ( CFG->CmpActualizaPCoste->Checked )
|
|
{
|
|
Set<TLocateOption,0,1> flags;
|
|
flags << loCaseInsensitive;
|
|
if ( DlgBuscarProd -> TbBusquedas -> Locate( "ID Producto", TbFacturasD->FieldByName( "CodProducto" )->AsString, flags ) )
|
|
{
|
|
DlgBuscarProd -> TbBusquedas -> Edit();
|
|
if ( CFG->CmpActualizaPVP->Checked )
|
|
{
|
|
/// CUIDADO QUE TAMBIEN ESTO ESTA LIGADO A TPVproductos.CPP y TPVcmp.CPP
|
|
Currency Ganancia = 0, PC;
|
|
if ( CFG->RecalcularPrecioVentaAlCambiarCoste->ItemIndex > 0 )
|
|
{
|
|
Ganancia = DlgBuscarProd->TbBusquedas->FieldByName("Precio Venta 1")->AsCurrency - Sender->AsCurrency;
|
|
PC = Sender->AsCurrency;
|
|
}
|
|
|
|
/// CUIDADO QUE TAMBIEN ESTO ESTA LIGADO A TPVproductos.CPP y TPVcmp.CPP
|
|
if ( CFG->RecalcularPrecioVentaAlCambiarCoste->ItemIndex == 1 )
|
|
DlgBuscarProd -> TbBusquedas->FieldByName("Precio Venta 1")->AsCurrency = Ganancia + Sender->AsCurrency;
|
|
if ( CFG->RecalcularPrecioVentaAlCambiarCoste->ItemIndex == 2 )
|
|
DlgBuscarProd -> TbBusquedas->FieldByName("Precio Venta 1")->AsCurrency = Sender->AsCurrency + ( (Ganancia * Sender->AsCurrency)/PC );
|
|
}
|
|
DlgBuscarProd -> TbBusquedas -> FieldByName( "Precio Costo" ) -> AsCurrency = Sender -> AsCurrency;
|
|
DlgBuscarProd -> TbBusquedas -> Post();
|
|
}
|
|
}
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
SUMAcompra -> Caption = AnsiString( SUMAcompraC );
|
|
IVAcompra -> Caption = AnsiString( IVAcompraC );
|
|
TotalCompra -> Caption = AnsiString::CurrToStr( SUMAcompraC + IVAcompraC );
|
|
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::TbFacturasDIVASetText(TField *Sender,
|
|
const AnsiString Text)
|
|
{
|
|
Currency TParcial;
|
|
|
|
TParcial = TbFacturasDPrecioC -> AsCurrency * Currency( (int)( TbFacturasDCantidad -> AsInteger ) );
|
|
SUMAcompraC -= TParcial;
|
|
IVAcompraC -= ( TParcial / 100 ) * Currency( (int)( Sender -> AsInteger ) );
|
|
|
|
Sender -> AsString = Text;
|
|
|
|
TParcial = TbFacturasDPrecioC -> AsCurrency * Currency( (int)( TbFacturasDCantidad -> AsInteger ) );
|
|
SUMAcompraC += TParcial;
|
|
IVAcompraC += ( TParcial / 100 ) * Currency( (int)( Text.ToInt() ) );
|
|
|
|
CambioCantidad5 = true;
|
|
TbFacturasC -> Edit();
|
|
TbFacturasC -> FieldByName( "TotalSin") -> AsCurrency = SUMAcompraC;
|
|
TbFacturasC -> FieldByName( "TotalIva") -> AsCurrency = IVAcompraC;
|
|
TbFacturasC -> Post();
|
|
CambioCantidad5 = false;
|
|
|
|
SUMAcompra -> Caption = AnsiString( SUMAcompraC );
|
|
IVAcompra -> Caption = AnsiString( IVAcompraC );
|
|
TotalCompra -> Caption = AnsiString::CurrToStr( SUMAcompraC + IVAcompraC );
|
|
|
|
// Localizacion del producto
|
|
Set<TLocateOption,0,1> flags;
|
|
flags << loCaseInsensitive;
|
|
DlgBuscarProd -> TbBusquedas -> Filtered = false;
|
|
if ( DlgBuscarProd -> TbBusquedas -> Locate( "ID Producto", Text, flags ) )
|
|
{
|
|
DlgBuscarProd -> TbBusquedas -> Edit();
|
|
DlgBuscarProd -> TbBusquedas -> FieldByName( "IVA Costo" ) -> AsInteger = TbFacturasD -> FieldByName( "IVA" ) -> AsInteger;
|
|
DlgBuscarProd -> TbBusquedas -> Post();
|
|
}
|
|
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::TbFacturasDCodProductoSetText(TField *Sender,
|
|
const AnsiString Text)
|
|
{
|
|
AnsiString oldCodProducto,SearchField;
|
|
Currency TParcial;
|
|
|
|
oldCodProducto = Sender -> AsString;
|
|
|
|
TParcial = TbFacturasDPrecioC -> AsCurrency * Currency( (int)( TbFacturasDCantidad -> AsInteger ) );
|
|
SUMAcompraC -= TParcial;
|
|
IVAcompraC -= ( TParcial / 100 ) * Currency( (int)( TbFacturasD -> FieldByName( "IVA" ) -> AsInteger ) );
|
|
|
|
Sender -> AsString = Text;
|
|
// Localizacion del producto
|
|
Set<TLocateOption,0,1> flags;
|
|
flags << loCaseInsensitive;
|
|
DlgBuscarProd -> TbBusquedas -> Filtered = false;
|
|
/*if ( BusqManual ) SearchField = "ForcedIndex"; else */
|
|
SearchField = "ID Producto";
|
|
if ( DlgBuscarProd -> TbBusquedas -> Locate( SearchField, Text, flags ) )
|
|
{
|
|
TbFacturasD->FieldByName( "NombreProducto" )->AsString = DlgBuscarProd->TbBusquedas->FieldByName( "Nombre del Producto" )->AsString;
|
|
TbFacturasDPrecioC -> AsCurrency = DlgBuscarProd->TbBusquedas->FieldByName( "Precio Costo" )->AsCurrency;
|
|
TbFacturasD->FieldByName( "IVA" )->AsInteger = DlgBuscarProd->TbBusquedas->FieldByName( "I.V.A" )->AsInteger;
|
|
|
|
if ( oldCodProducto != TbFacturasD->FieldByName( "CodProducto" )->AsString )
|
|
{
|
|
ActualizaStock( oldCodProducto,
|
|
-1 * TbFacturasD -> FieldByName( "Cantidad" ) -> AsInteger,
|
|
-1 );
|
|
|
|
ActualizaStock( Sender -> AsString,
|
|
+1 * TbFacturasD -> FieldByName( "Cantidad" ) -> AsInteger,
|
|
TbFacturasC -> FieldByName( "CodProveedor" ) -> AsInteger );
|
|
}
|
|
|
|
}
|
|
|
|
TParcial = TbFacturasDPrecioC -> AsCurrency * Currency( (int)( TbFacturasDCantidad -> AsInteger ) );
|
|
SUMAcompraC += TParcial;
|
|
IVAcompraC += ( TParcial / 100 ) * Currency( (int)( TbFacturasD -> FieldByName( "IVA" ) -> AsInteger ) );
|
|
|
|
CambioCantidad5 = true;
|
|
TbFacturasC -> Edit();
|
|
TbFacturasC -> FieldByName( "TotalSin") -> AsCurrency = SUMAcompraC;
|
|
TbFacturasC -> FieldByName( "TotalIva") -> AsCurrency = IVAcompraC;
|
|
TbFacturasC -> Post();
|
|
CambioCantidad5 = false;
|
|
|
|
SUMAcompra -> Caption = AnsiString( SUMAcompraC );
|
|
IVAcompra -> Caption = AnsiString( IVAcompraC );
|
|
TotalCompra -> Caption = AnsiString::CurrToStr( SUMAcompraC + IVAcompraC );
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::DBGrid1ColExit(TObject *Sender)
|
|
{
|
|
if ( TbFacturasD -> State == dsEdit )
|
|
try {
|
|
TbFacturasD -> Post();
|
|
}catch(...){
|
|
// Do nothing
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::TbFacturasDBeforeDelete(TDataSet *DataSet)
|
|
{
|
|
if ( TbFacturasC->FieldByName("Contabilizada")->AsBoolean == true )
|
|
{
|
|
ShowMessage( "No se pueden eliminar, lineas de facturas que hayan sido contabilizadas." );
|
|
Abort();
|
|
}
|
|
|
|
switch( MessageDlg( "Atención, está apunto de\neliminar la compra señalada actual...\n¿Realmente desea continuar?", mtConfirmation, TMsgDlgButtons() << mbNo << mbYes, 0 ) )
|
|
{
|
|
case mrNo:
|
|
Abort();
|
|
break;
|
|
default:
|
|
// No nos olvidemos de anular todo esto (Y del STOCK)
|
|
ActualizaStock( TbFacturasD -> FieldByName( "CodProducto" ) -> AsString,
|
|
-1 * TbFacturasD -> FieldByName( "Cantidad" ) -> AsInteger,
|
|
-1);
|
|
Currency TParcial;
|
|
TParcial = TbFacturasDPrecioC -> AsCurrency * Currency( (int)( TbFacturasDCantidad -> AsInteger ) );
|
|
SUMAcompraC -= TParcial;
|
|
IVAcompraC -= ( TParcial / 100 ) * Currency( (int)( TbFacturasD -> FieldByName( "IVA" ) -> AsInteger ) );
|
|
|
|
CambioCantidad5 = true;
|
|
TbFacturasC -> Edit();
|
|
TbFacturasC -> FieldByName( "TotalSin") -> AsCurrency = SUMAcompraC;
|
|
TbFacturasC -> FieldByName( "TotalIva") -> AsCurrency = IVAcompraC;
|
|
TbFacturasC -> Post();
|
|
CambioCantidad5 = false;
|
|
|
|
SUMAcompra -> Caption = AnsiString( SUMAcompraC );
|
|
IVAcompra -> Caption = AnsiString( IVAcompraC );
|
|
TotalCompra -> Caption = AnsiString::CurrToStr( SUMAcompraC + IVAcompraC );
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTpvCmp1::FormClose(TObject *Sender, TCloseAction &Action)
|
|
{
|
|
// Eliminamos el dialogo, buscar [Productos]
|
|
delete DlgBuscarProd;
|
|
// Destruimos la imagen de OK!
|
|
delete BtmOK;
|
|
delete BtmLockOpen;
|
|
delete BtmLockShut;
|
|
|
|
try
|
|
{
|
|
if ( TbFacturasD -> State == dsEdit || TbFacturasD -> State == dsInsert )
|
|
TbFacturasD -> Post();
|
|
if ( TbFacturasC -> State == dsEdit || TbFacturasC -> State == dsInsert )
|
|
TbFacturasC -> Post();
|
|
if ( TbCartera -> State == dsEdit || TbCartera -> State == dsInsert )
|
|
TbCartera -> Post();
|
|
} catch(...)
|
|
{
|
|
// Nothing
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::FechaFacturaChange(TObject *Sender)
|
|
{
|
|
#ifdef TB_DISCONTINUAS
|
|
// Si el año de la factura que pedimos ver, no concuerda con los años que
|
|
// estamos viendo, abrimos la base de datos que concuerde...
|
|
enum TDateTimeFlag {Date, Time, DateTime} DTFlag = Date;
|
|
unsigned short M, D, A, Aa;
|
|
|
|
try {
|
|
FechaFacturaA.DecodeDate( &Aa, &M, &D );
|
|
FechaFactura -> Date.DecodeDate( &A, &M, &D );
|
|
// Se prohibe cambiar de año
|
|
if ( Aa != A )
|
|
{
|
|
MessageBox( 0, "Fecha de Factura fuera de rango.", "Atención CAMBIAREMOS DE BD...", MB_OK );
|
|
// CAMBIAMOS DE BASE DE DATOS... (SOLO SI ES POSIBLE)
|
|
if ( access( AnsiString("Compras (cabecera) '"+ AnsiString(A)).c_str(), 0 ) != 0 )
|
|
{
|
|
MessageBox( 0, "Imposible aplicar filro.", "Atención", MB_OK );
|
|
return;
|
|
}
|
|
|
|
TbFacturasC -> Active = false;
|
|
TbFacturasD -> Active = false;
|
|
TbFacturasC -> TableName = "Compras (cabecera) '"+ AnsiString(A);
|
|
TbFacturasD -> TableName = "Compras (cuerpo) '"+ AnsiString(A);
|
|
TbFacturasD -> Active = true;
|
|
TbFacturasC -> Active = true;
|
|
}
|
|
} catch(...) {
|
|
MessageBox( 0, "Imposible aplicar filro.", "Atención", MB_OK );
|
|
}
|
|
#endif
|
|
|
|
// Reajustamos el filtro...
|
|
FechaFacturaA = FechaFactura -> Date;
|
|
ReajustaFiltro();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTpvCmp1::TbFacturasDNombreProductoSetText(TField *Sender,
|
|
const AnsiString Text)
|
|
{
|
|
// Si modifica el nombre del producto... ( El código debe ser "VACIO" )
|
|
if ( ( TbFacturasDCodProducto -> AsString ) . IsEmpty() )
|
|
Sender -> AsString = Text;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
void __fastcall TTpvCmp1::btFacturarClick(TObject *Sender)
|
|
{
|
|
// ¿ Actualizar factura ?
|
|
if (
|
|
TbFacturasC->FieldByName("Contabilizada")->AsBoolean!=true &&
|
|
Application->MessageBox("¿ Actualizar Factura ?", "Alerta contable", MB_OKCANCEL ) != IDCANCEL
|
|
)
|
|
{
|
|
int maxCONT;
|
|
|
|
TbFacturasC->Edit();
|
|
TbFacturasC->FieldByName("Contabilizada")->AsBoolean = true;
|
|
TbFacturasC->Post();
|
|
|
|
/*
|
|
TbAsientos->FilterOptions = TbAsientos->FilterOptions << foCaseInsensitive;
|
|
TbAsientos->Filter = "([nAsiento] = 40)";
|
|
TbAsientos-> Active = true;
|
|
|
|
maxCONT = 0;
|
|
TbAsientos->First();
|
|
while( ! TbAsientos-> Eof )
|
|
{
|
|
if ( TbAsientos-> FieldByName("nOrden")->AsInteger > maxCONT )
|
|
maxCONT = TbAsientos-> FieldByName("nOrden")->AsInteger;
|
|
TbAsientos->Next();
|
|
}
|
|
|
|
//##### BLOQUEAR BD ###############################
|
|
//####################################
|
|
double SumaTotal = TbFacturasC->FieldByName("TotalSin")->AsCurrency + TbFacturasC->FieldByName("TotalIva")->AsCurrency;
|
|
TbAsientos -> InsertRecord( ARRAYOFCONST( ( 40, (maxCONT+1), TbFacturasC->FieldByName("FechaFatura")->Value, (400000000+TbFacturasC->FieldByName("CodProveedor")->AsInteger), SumaTotal, false, AnsiString( "Su factura nº: " + TbFacturasC->FieldByName("CodFactura")->AsString ), TbFacturasC->FieldByName("EnlaceFactura")->AsInteger ) ) );
|
|
TbAsientos -> InsertRecord( ARRAYOFCONST( ( 40, (maxCONT+2), TbFacturasC->FieldByName("FechaFatura")->Value, 472000016, IVAcompraC, false, AnsiString( "Su factura nº: " + TbFacturasC->FieldByName("CodFactura")->AsString ), TbFacturasC->FieldByName("EnlaceFactura")->AsInteger ) ) );
|
|
#ifdef EXIST_CFG
|
|
if ( ! CFG->AsientoProductosIndividual )
|
|
{
|
|
TbFacturasD->Fisrt();
|
|
while( !TbFacturasD->Eof )
|
|
{
|
|
// SUMA PRODUCTOS INDIVIDUALES
|
|
TbFacturasD->Next();
|
|
}
|
|
} else
|
|
#endif
|
|
TbAsientos -> InsertRecord( ARRAYOFCONST( ( 40, (maxCONT+3), TbFacturasC->FieldByName("FechaFatura")->Value, "600000001", SUMAcompraC, false, AnsiString( "Su factura nº: " + TbFacturasC->FieldByName("CodFactura")->AsString ), TbFacturasC->FieldByName("EnlaceFactura")->AsInteger ) ) );
|
|
//####################################
|
|
*/
|
|
}
|
|
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTpvCmp1::SpeedButton2Click(TObject *Sender)
|
|
{
|
|
// Imprimir
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void __fastcall TTpvCmp1::DsCarteraDataChange(TObject *Sender,
|
|
TField *Field)
|
|
{
|
|
Edit2->Text = "";
|
|
Edit1->Text = "";
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTpvCmp1::Edit2Change(TObject *Sender)
|
|
{
|
|
bool pag; short int i; int npagos;
|
|
Currency Total = SUMAcompraC + IVAcompraC;
|
|
|
|
if ( Edit2->Text . IsEmpty() ) return;
|
|
|
|
try {
|
|
npagos = Edit2->Text.ToInt();
|
|
} catch(...) {
|
|
ShowMessage( "El número de veces a fraccionar el pago, no es correcto" );
|
|
return;
|
|
}
|
|
if ( npagos < 2 )
|
|
{
|
|
ShowMessage( "El número de veces a fraccionar el pago, no es correcto" );
|
|
return;
|
|
}
|
|
|
|
|
|
pag = false;
|
|
// Eliminamos todos los pagos acumulados (SOLO SI NO HAY NINGUN PAGO REALIZADO)
|
|
TbCartera->First();
|
|
while( !TbCartera->Eof )
|
|
if ( TbCartera->FieldByName("Pagado")->AsBoolean == true )
|
|
{
|
|
pag = true;
|
|
break;
|
|
}
|
|
|
|
if ( pag )
|
|
{
|
|
while( !TbCartera->Eof ) // Eliminamos los pagos actuales
|
|
TbCartera->Delete();
|
|
|
|
unsigned short year;
|
|
Total /= i;
|
|
TDateTime::CurrentDate().DecodeDate( &year, NULL, NULL);
|
|
// desde 1 para que inc. los meses
|
|
for ( i = 1; i <= npagos; i++ )
|
|
TbCartera->InsertRecord( ARRAYOFCONST( ( TbFacturasC->FieldByName("EnlaceFactura")->AsInteger, Variant( EncodeDate( year, i, 1 ) ), Total, 0, cbFormaPago->ItemIndex, false ) ) );
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTpvCmp1::Edit1Change(TObject *Sender)
|
|
{
|
|
bool pag; short int i; int npagos; int tpagos;
|
|
Currency Total = SUMAcompraC + IVAcompraC;
|
|
|
|
if ( Edit1->Text . IsEmpty() ) return;
|
|
|
|
try {
|
|
tpagos = Edit1->Text.ToInt();
|
|
} catch(...) {
|
|
ShowMessage( "La cantidad para fraccionar el pago, no es correcta" );
|
|
return;
|
|
}
|
|
if ( tpagos < 2000 )
|
|
{
|
|
ShowMessage( "La cantidad para fraccionar el pago, no es correcta" );
|
|
return;
|
|
}
|
|
|
|
|
|
pag = false;
|
|
// Eliminamos todos los pagos acumulados (SOLO SI NO HAY NINGUN PAGO REALIZADO)
|
|
TbCartera->First();
|
|
while( !TbCartera->Eof )
|
|
if ( TbCartera->FieldByName("Pagado")->AsBoolean == true )
|
|
{
|
|
pag = true;
|
|
break;
|
|
} else {
|
|
TbCartera->Next();
|
|
}
|
|
|
|
if ( pag )
|
|
{
|
|
while( !TbCartera->Eof ) // Eliminamos los pagos actuales
|
|
TbCartera->Delete();
|
|
|
|
unsigned short year;
|
|
npagos = Total / tpagos;
|
|
Total = tpagos;
|
|
TDateTime::CurrentDate().DecodeDate(&year, NULL, NULL);
|
|
// desde 1 para que inc. los meses
|
|
for ( i = 1; i <= npagos; i++ )
|
|
TbCartera->InsertRecord( ARRAYOFCONST( ( TbFacturasC->FieldByName("EnlaceFactura")->AsInteger, Variant( EncodeDate( year, i, 1 ) ), Total, 0, cbFormaPago->ItemIndex, false ) ) );
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTpvCmp1::cbFormaPagoChange(TObject *Sender)
|
|
{
|
|
if ( CambiandoFactura ) return;
|
|
|
|
/*
|
|
// Debemos cambiar todo lo fraccionado
|
|
if ( cbFormaPago->Items->Strings[cbFormaPago->ItemIndex] == "Contado" )
|
|
{
|
|
if ( Application->MessageBox("¿Eliminar todo el fraccionamiento de pagos?", "Alerta contable", MB_OKCANCEL ) != IDCANCEL )
|
|
{
|
|
while( !TbCartera->Eof ) // Eliminamos los pagos actuales
|
|
TbCartera->Delete();
|
|
dbgFraccion->Enabled = false;
|
|
Edit1->Enabled=false; Edit2->Enabled=false;
|
|
|
|
TbFacturasC->Edit();
|
|
TbFacturasC->FieldByName("UltimoPago")->AsDateTime = TDateTime::CurrentDate();
|
|
TbFacturasC->Post();
|
|
} else {
|
|
cbFormaPago->ItemIndex = TbCartera->FieldByName("FormaPago")->AsInteger;
|
|
}
|
|
} else {
|
|
dbgFraccion->Enabled = true;
|
|
Edit1->Enabled=true; Edit2->Enabled=true;
|
|
TbCartera->First();
|
|
while( !TbCartera->Eof )
|
|
{
|
|
TbCartera->Edit();
|
|
TbCartera->FieldByName("FormaPago")->AsInteger = cbFormaPago->ItemIndex;
|
|
TbCartera->Post();
|
|
TbCartera->Next();
|
|
}
|
|
}
|
|
*/
|
|
CambiandoFactura = true;
|
|
TbFacturasC->Edit();
|
|
TbFacturasC->FieldByName("FormaPago")->AsInteger = cbFormaPago->ItemIndex;
|
|
TbFacturasC->Post();
|
|
CambiandoFactura = false;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTpvCmp1::TbCarteraNewRecord(TDataSet *DataSet)
|
|
{
|
|
TbCartera->FieldByName("Fecha")->AsDateTime = TDateTime::CurrentDate();
|
|
TbCartera->FieldByName("FormaPago")->AsInteger = cbFormaPago->ItemIndex;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTpvCmp1::TbCarteraBeforeDelete(TDataSet *DataSet)
|
|
{
|
|
if ( TbCartera->FieldByName("Pagado")->AsBoolean == true )
|
|
{
|
|
ShowMessage( "No se pueden eliminar, fraccionamientos que ya han sido efectuados." );
|
|
Abort();
|
|
}
|
|
/*
|
|
TbFacturasC->Edit();
|
|
TbFacturasC->FieldByName("TotalFrac")->AsCurrency -= TbCartera->FieldByName("Importe")->AsCurrency * (( 100 + TbCartera->FieldByName("Incremento")->AsCurrency )/100);
|
|
TbFacturasC->Post();
|
|
*/
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTpvCmp1::TbCarteraCalcFields(TDataSet *DataSet)
|
|
{
|
|
TbCartera->FieldByName("Total")->AsCurrency = TbCartera->FieldByName("Importe")->AsCurrency * ( 0.01 * TbCartera->FieldByName("Incremento")->AsCurrency );
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTpvCmp1::dbgFraccionDrawColumnCell(TObject *Sender,
|
|
const TRect &Rect, int DataCol, TColumn *Column,
|
|
TGridDrawState State)
|
|
{
|
|
if ( Column -> ID == 0 )
|
|
{
|
|
if ( TbCartera->FieldByName("Pagado")->AsBoolean )
|
|
{
|
|
dbgFraccion->Canvas->StretchDraw( Rect, BtmOK );
|
|
} else {
|
|
dbgFraccion->Canvas->Brush->Color = clWindow;
|
|
dbgFraccion->Canvas->FillRect( Rect );
|
|
}
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTpvCmp1::DBGrid2DrawColumnCell(TObject *Sender,
|
|
const TRect &Rect, int DataCol, TColumn *Column,
|
|
TGridDrawState State)
|
|
{
|
|
if ( Column -> ID == 0 )
|
|
{
|
|
if ( TbFacturasC->FieldByName("Contabilizada")->AsBoolean )
|
|
DBGrid2->Canvas->StretchDraw( Rect, BtmLockShut );
|
|
else
|
|
DBGrid2->Canvas->StretchDraw( Rect, BtmLockOpen );
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTpvCmp1::TbCarteraBeforeInsert(TDataSet *DataSet)
|
|
{
|
|
if ( !( TbFacturasC -> RecNo > 0 && TbFacturasC -> RecordCount > 0 ) &&
|
|
!( TbFacturasD -> RecNo > 0 && TbFacturasD -> RecordCount > 0 ) )
|
|
{
|
|
MessageDlg("¿ No cree que debería crear,\no seleccionar una factura CON DATOS,\nantes de intentar fracionar su pago?.", mtWarning, TMsgDlgButtons() << mbOK, 0);
|
|
// MessageBox( 0, "¿ No cree que debería crear,\no seleccionar una factura CON DATOS,\nantes de intentar fracionar su pago?.", "¡ Atención !", MB_OK );
|
|
Abort();
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
void __fastcall TTpvCmp1::TbCarteraFechaChange(TField *Sender)
|
|
{
|
|
if ( (int)Sender->AsDateTime > (int)TbFacturasC->FieldByName("UltimoPago")->AsDateTime )
|
|
{
|
|
TbFacturasC->Edit();
|
|
TbFacturasC->FieldByName("UltimoPago")->AsDateTime = Sender->AsDateTime;
|
|
TbFacturasC->Post();
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|