-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOwnerView.pas
183 lines (160 loc) · 5.94 KB
/
OwnerView.pas
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
unit OwnerView;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, pngimage, Owner, ServiceClass, Grids,
DBGrids, mainDB, MakePayment, Globals;
type
TfrmOwnerView = class(TForm)
pnlHeading: TPanel;
btnMakePay: TButton;
grpMonthlyDue: TGroupBox;
lblTitle: TLabel;
pnlWater: TPanel;
pnlElectricity: TPanel;
pnlRefuse: TPanel;
Image1: TImage;
Image2: TImage;
Image3: TImage;
lblOptions: TLabel;
btnPaymentHistory: TButton;
imgLine: TImage;
imgLine2: TImage;
btnViewTotalDue: TButton;
btnViewMonthlyInstallments: TButton;
dbgrdPaymenHistory: TDBGrid;
lblTotal: TLabel;
lblBreakdown: TLabel;
grpStillToPay: TGroupBox;
img1: TImage;
img2: TImage;
img3: TImage;
lblTotal1: TLabel;
lblBreakdown1: TLabel;
pnlWater1: TPanel;
pnlElectricity1: TPanel;
pnlRefuse1: TPanel;
procedure btnMakePayClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btnPaymentHistoryClick(Sender: TObject);
procedure btnViewMonthlyInstallmentsClick(Sender: TObject);
procedure btnViewTotalDueClick(Sender: TObject);
procedure lblTitleClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure createOwner(OwnerID: string);
end;
var
frmOwnerView: TfrmOwnerView;
objOwner: TOwner;
objGlobals: TGlobals;
implementation
{$R *.dfm}
{ TfrmOwnerView }
procedure TfrmOwnerView.btnMakePayClick(Sender: TObject);
begin
// Show the payment form and set the current owner for it
frmMakePayment.Show;
frmMakePayment.setOwner(objOwner.getOwnerID);
end;
procedure TfrmOwnerView.btnPaymentHistoryClick(Sender: TObject);
begin
// Update the UI to display payment history
lblTitle.Caption := 'Displaying Payment History'; // Set the title for the payment history
dbgrdPaymenHistory.Show; // Show the payment history grid
grpMonthlyDue.Hide; // Hide the monthly due group
grpStillToPay.Hide; // Hide the still to pay group
end;
procedure TfrmOwnerView.btnViewMonthlyInstallmentsClick(Sender: TObject);
begin
// Update the UI to display monthly installment rates
lblTitle.Caption := 'Displaying the monthly installment rates'; // Set the title for monthly installments
grpMonthlyDue.Show; // Show the monthly due group
grpStillToPay.Hide; // Hide the still to pay group
dbgrdPaymenHistory.Hide; // Hide the payment history grid
end;
procedure TfrmOwnerView.btnViewTotalDueClick(Sender: TObject);
begin
// Update the UI to display the total amount still due
lblTitle.Caption := 'Displaying what still needs to be paid'; // Set the title for total due
grpMonthlyDue.Hide; // Hide the monthly due group
grpStillToPay.Show; // Show the still to pay group
dbgrdPaymenHistory.Hide; // Hide the payment history grid
end;
procedure TfrmOwnerView.createOwner(OwnerID: string);
var
lablle : TLabel; // Temporary label for displaying property addresses and bills
panle : TPanel; // Temporary panel for displaying bill amounts
i, j : Integer; // Loop counters
adresses : TBuildingsArray; // Array of property addresses and bills
begin
// Initialize the owner object with the given OwnerID
objOwner := TOwner.Create(OwnerID);
// Update the UI with the owner's utility bills
pnlWater.Caption := 'R' + FloatToStr(objOwner.getWaterBill);
pnlRefuse.Caption := 'R' + FloatToStr(objOwner.getRefuseBill);
pnlElectricity.Caption := 'R' + FloatToStr(objOwner.getElecBill);
// Set SQL query to retrieve payment history for the owner
objGlobals.setSQL('SELECT PropertyAddress, Type, PayedDate, AmountPaid FROM Services WHERE OwnerID = "' + objOwner.getOwnerID + '" ORDER BY PayedDate');
// Hide the groups that are not relevant initially
grpStillToPay.Hide;
grpMonthlyDue.Hide;
// Get the list of property addresses for the owner
adresses := objOwner.getPropertyAddressList;
// Loop through each property address and create labels and panels for monthly due bills
for i := 0 to High(adresses) do
begin
// Create a label for the property address
lablle := TLabel.Create(grpMonthlyDue);
lablle.Parent := grpMonthlyDue;
lablle.Font := lblTotal.Font;
lablle.Top := lblBreakdown.Top + 50 + (i * 80);
lablle.Left := lblTotal.Left;
lablle.Caption := adresses[i].Address + ': ';
// Create panels for each type of bill (assuming 4 types of bills)
for j := 0 to 3 do
begin
panle := TPanel.Create(grpMonthlyDue);
panle.Parent := grpMonthlyDue;
panle.Font := pnlWater.Font;
panle.Top := lblBreakdown.Top + 50 + (i * 80);
panle.Left := pnlWater.Left + (j * 123);
panle.Width := pnlWater.Width;
panle.Caption := 'R' + FloatToStr(adresses[i].Bills[j]); // Display the bill amount
end;
end;
// Generate the 'still to pay' group box with the remaining amounts
for i := 0 to High(adresses) do
begin
// Create a label for the property address
lablle := TLabel.Create(grpStillToPay);
lablle.Parent := grpStillToPay;
lablle.Font := lblTotal.Font;
lablle.Top := lblBreakdown.Top + 50 + (i * 80);
lablle.Left := lblTotal.Left;
lablle.Caption := adresses[i].Address + ': ';
// Create panels for the remaining amounts of each bill (total - paid)
for j := 0 to 3 do
begin
panle := TPanel.Create(grpStillToPay);
panle.Parent := grpStillToPay;
panle.Font := pnlWater.Font;
panle.Top := lblBreakdown.Top + 50 + (i * 80);
panle.Left := pnlWater.Left + (j * 123);
panle.Width := pnlWater.Width;
panle.Caption := 'R' + FloatToStr(adresses[i].Bills[j] - adresses[i].Paid[j]); // Display remaining amount
end;
end;
end;
procedure TfrmOwnerView.FormCreate(Sender: TObject);
begin
// Initialize global variables when the form is created
objGlobals := TGlobals.Create;
end;
procedure TfrmOwnerView.lblTitleClick(Sender: TObject);
begin
lblTitle.Caption := 'You clicked the wrong thing :/'
end;
end.