-
Notifications
You must be signed in to change notification settings - Fork 2
/
saldos.cpp
122 lines (102 loc) · 3.94 KB
/
saldos.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "saldos.h"
#include "basedatos.h"
#include "auxiliar.h"
#include "impresion.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFormSaldos *FormSaldos;
//---------------------------------------------------------------------------
__fastcall TFormSaldos::TFormSaldos(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void TFormSaldos::Mostrar()
{
ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TFormSaldos::DBGridDrawColumnCell(TObject *Sender,
const TRect &Rect, int DataCol, TColumn *Column,
TGridDrawState State)
{
if (BD->TableClientes->IsEmpty()) return;
TDBGrid *grid = static_cast<TDBGrid*>(Sender);
if(BD->TableClientes->FieldValues["SaldoCC"] < -0.001)
{
grid->Canvas->Font->Color = clRed;
}
grid->DefaultDrawColumnCell(Rect, DataCol, Column, State);
}
//---------------------------------------------------------------------------
void __fastcall TFormSaldos::FormCreate(TObject *Sender)
{
ListaMenuOrdenar lista;
lista["ISNumeroCliente"] = "Número cliente";
lista["ISNombreCliente"] = "Nombre cliente";
lista["ISNombreNegocio"] = "Nombre negocio";
lista["ISSaldoCC"] = "Saldo";
CrearMenuOrdenar(lista, "ISNombreCliente", BD->TableClientes,
MenuItemOrdenar, MenuItemOrdCol);
}
//---------------------------------------------------------------------------
void __fastcall TFormSaldos::MenuItemOrdCol(TObject *Sender)
{
SetearMenuOrdenar(BD->TableClientes, static_cast< TMenuItem * >(Sender));
}
//---------------------------------------------------------------------------
void __fastcall TFormSaldos::FormShow(TObject *Sender)
{
/* Seteo el index por defecto y muevo a la primera fila */
DefectoMenuOrdenar(BD->TableClientes, MenuItemOrdenar);
CalcularSaldoTotal();
BD->TableClientes->First();
}
//---------------------------------------------------------------------------
void __fastcall TFormSaldos::MenuItemCerrarClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TFormSaldos::MenuItemImprimirClick(TObject *Sender)
{
if (BD->TableClientes->IsEmpty()) return;
Impresion imp;
imp.ImprimirSaldos(false);
}
//---------------------------------------------------------------------------
void __fastcall TFormSaldos::ToolButtonImprimirDesdeClick(TObject *Sender)
{
MenuItemImprimir->Click();
}
//---------------------------------------------------------------------------
void TFormSaldos::CalcularSaldoTotal()
{
double saldototal = 0;
if (BD->TableClientes->IsEmpty())
{
StaticTextSaldoTotal->Caption = "";
return;
}
BD->TableClientes->DisableControls();
BD->TableClientes->First();
while (! BD->TableClientes->Eof)
{
saldototal += BD->TableClientes->FieldByName("SaldoCC")->AsFloat;
BD->TableClientes->Next();
}
StaticTextSaldoTotal->Caption = FormatFloat("0.00", saldototal);
BD->TableClientes->EnableControls();
}
//---------------------------------------------------------------------------
void __fastcall TFormSaldos::MenuItemVisualizarClick(TObject *Sender)
{
if (BD->TableClientes->IsEmpty()) return;
Impresion imp;
imp.ImprimirSaldos(true);
}
//---------------------------------------------------------------------------