1 | unit UFormMain;
|
---|
2 |
|
---|
3 | {$mode delphi{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
---|
9 | ExtCtrls, Menus, ActnList, Spin, EditBtn, ComCtrls, UFioAPI, URegistry,
|
---|
10 | Registry, DateUtils;
|
---|
11 |
|
---|
12 | type
|
---|
13 |
|
---|
14 | { TFormMain }
|
---|
15 |
|
---|
16 | TFormMain = class(TForm)
|
---|
17 | ButtonNew: TButton;
|
---|
18 | ButtonNew1: TButton;
|
---|
19 | ButtonGetState: TButton;
|
---|
20 | ButtonSettings: TButton;
|
---|
21 | ButtonInterval: TButton;
|
---|
22 | ButtonMonthly: TButton;
|
---|
23 | ButtonExit: TButton;
|
---|
24 | ButtonAbout: TButton;
|
---|
25 | ComboBoxAccounts: TComboBox;
|
---|
26 | DateEditStart: TDateEdit;
|
---|
27 | DateEditTo: TDateEdit;
|
---|
28 | GroupBox1: TGroupBox;
|
---|
29 | GroupBox2: TGroupBox;
|
---|
30 | GroupBox3: TGroupBox;
|
---|
31 | GroupBox4: TGroupBox;
|
---|
32 | Label1: TLabel;
|
---|
33 | Label2: TLabel;
|
---|
34 | Label3: TLabel;
|
---|
35 | Label4: TLabel;
|
---|
36 | Label5: TLabel;
|
---|
37 | Label6: TLabel;
|
---|
38 | Label7: TLabel;
|
---|
39 | LabelBalance: TLabel;
|
---|
40 | ListViewOperation: TListView;
|
---|
41 | SpinEditYear: TSpinEdit;
|
---|
42 | SpinEditId: TSpinEdit;
|
---|
43 | SpinEditLastId: TSpinEdit;
|
---|
44 | procedure ButtonGetStateClick(Sender: TObject);
|
---|
45 | procedure ButtonIntervalClick(Sender: TObject);
|
---|
46 | procedure ButtonMonthlyClick(Sender: TObject);
|
---|
47 | procedure ButtonNew1Click(Sender: TObject);
|
---|
48 | procedure ButtonNewClick(Sender: TObject);
|
---|
49 | procedure ComboBoxAccountsChange(Sender: TObject);
|
---|
50 | procedure DateEditStartAcceptDate(Sender: TObject; var ADate: TDateTime;
|
---|
51 | var AcceptDate: Boolean);
|
---|
52 | procedure DateEditToAcceptDate(Sender: TObject; var ADate: TDateTime;
|
---|
53 | var AcceptDate: Boolean);
|
---|
54 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
55 | procedure FormCreate(Sender: TObject);
|
---|
56 | procedure FormShow(Sender: TObject);
|
---|
57 | procedure ListViewOperationData(Sender: TObject; Item: TListItem);
|
---|
58 | private
|
---|
59 | { private declarations }
|
---|
60 | public
|
---|
61 | procedure ReloadList;
|
---|
62 | procedure LoadInterface;
|
---|
63 | procedure SaveInterface;
|
---|
64 | end;
|
---|
65 |
|
---|
66 | var
|
---|
67 | FormMain: TFormMain;
|
---|
68 |
|
---|
69 | implementation
|
---|
70 |
|
---|
71 | {$R *.lfm}
|
---|
72 |
|
---|
73 | uses
|
---|
74 | UCore;
|
---|
75 |
|
---|
76 | { TFormMain }
|
---|
77 |
|
---|
78 | procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
79 | begin
|
---|
80 | SaveInterface;
|
---|
81 | end;
|
---|
82 |
|
---|
83 | procedure TFormMain.ButtonNewClick(Sender: TObject);
|
---|
84 | begin
|
---|
85 | SaveInterface;
|
---|
86 | Core.ADownloadNew.Execute;
|
---|
87 | end;
|
---|
88 |
|
---|
89 | procedure TFormMain.ComboBoxAccountsChange(Sender: TObject);
|
---|
90 | begin
|
---|
91 | Core.SelectedAccountIndex := ComboBoxAccounts.ItemIndex;
|
---|
92 | LoadInterface;
|
---|
93 | end;
|
---|
94 |
|
---|
95 | procedure TFormMain.DateEditStartAcceptDate(Sender: TObject;
|
---|
96 | var ADate: TDateTime; var AcceptDate: Boolean);
|
---|
97 | begin
|
---|
98 | AcceptDate := (ADate <= Now) and (ADate <= DateEditTo.Date);
|
---|
99 | end;
|
---|
100 |
|
---|
101 | procedure TFormMain.DateEditToAcceptDate(Sender: TObject; var ADate: TDateTime;
|
---|
102 | var AcceptDate: Boolean);
|
---|
103 | begin
|
---|
104 | AcceptDate := (ADate <= Now) and (ADate >= DateEditStart.Date);
|
---|
105 | end;
|
---|
106 |
|
---|
107 | procedure TFormMain.ButtonIntervalClick(Sender: TObject);
|
---|
108 | begin
|
---|
109 | SaveInterface;
|
---|
110 | Core.ADownloadInterval.Execute;
|
---|
111 | end;
|
---|
112 |
|
---|
113 | procedure TFormMain.ButtonGetStateClick(Sender: TObject);
|
---|
114 | begin
|
---|
115 | if Assigned(Core.CurrentAccount) then begin
|
---|
116 | Core.LoadAccount(Core.CurrentAccount);
|
---|
117 | LoadInterface;
|
---|
118 | ReloadList;
|
---|
119 | end;
|
---|
120 | end;
|
---|
121 |
|
---|
122 | procedure TFormMain.ButtonMonthlyClick(Sender: TObject);
|
---|
123 | begin
|
---|
124 | SaveInterface;
|
---|
125 | Core.ADownloadMonthly.Execute;
|
---|
126 | end;
|
---|
127 |
|
---|
128 | procedure TFormMain.ButtonNew1Click(Sender: TObject);
|
---|
129 | begin
|
---|
130 | Core.AAccounts.Execute;
|
---|
131 | LoadInterface;
|
---|
132 | end;
|
---|
133 |
|
---|
134 | procedure TFormMain.FormCreate(Sender: TObject);
|
---|
135 | begin
|
---|
136 | end;
|
---|
137 |
|
---|
138 | procedure TFormMain.FormShow(Sender: TObject);
|
---|
139 | begin
|
---|
140 | LoadInterface;
|
---|
141 | Core.CoolTranslator1.Translate;
|
---|
142 | end;
|
---|
143 |
|
---|
144 | procedure TFormMain.ListViewOperationData(Sender: TObject; Item: TListItem);
|
---|
145 | begin
|
---|
146 | if Assigned(Core.CurrentAccount) then
|
---|
147 | with Core.CurrentAccount do begin
|
---|
148 | if (Item.Index >= 0) and (Item.Index < Operations.Count) then
|
---|
149 | with TAccountOperation(Operations[Item.Index]) do begin
|
---|
150 | Item.Caption := IntToStr(Item.Index + 1);
|
---|
151 | Item.Data := Operations[Item.Index];
|
---|
152 | Item.SubItems.Add(DateToStr(Time));
|
---|
153 | Item.SubItems.Add(Account);
|
---|
154 | Item.SubItems.Add(FloatToStr(Value));
|
---|
155 | Item.SubItems.Add(VarSym);
|
---|
156 | Item.SubItems.Add(SpecSym);
|
---|
157 | Item.SubItems.Add(ConstSym);
|
---|
158 | end;
|
---|
159 | end;
|
---|
160 | end;
|
---|
161 |
|
---|
162 | procedure TFormMain.ReloadList;
|
---|
163 | begin
|
---|
164 | if Assigned(Core.CurrentAccount) then
|
---|
165 | ListViewOperation.Items.Count := Core.CurrentAccount.Operations.Count
|
---|
166 | else ListViewOperation.Items.Count;
|
---|
167 | ListViewOperation.Refresh;
|
---|
168 | end;
|
---|
169 |
|
---|
170 | procedure TFormMain.LoadInterface;
|
---|
171 | begin
|
---|
172 | Core.Accounts.LoadToStrings(ComboBoxAccounts.Items);
|
---|
173 | if (Core.SelectedAccountIndex >= 0) and
|
---|
174 | (Core.SelectedAccountIndex < ComboBoxAccounts.Items.Count) then begin
|
---|
175 | ComboBoxAccounts.ItemIndex := Core.SelectedAccountIndex;
|
---|
176 | end;
|
---|
177 | if (ComboBoxAccounts.Items.Count > 0) and (ComboBoxAccounts.ItemIndex = -1) then
|
---|
178 | ComboBoxAccounts.ItemIndex := 0;
|
---|
179 | if ComboBoxAccounts.ItemIndex <> -1 then
|
---|
180 | Core.CurrentAccount := TAccount(Core.Accounts[ComboBoxAccounts.ItemIndex])
|
---|
181 | else Core.CurrentAccount := nil;
|
---|
182 | DateEditStart.Date := Core.ReportTimeFrom;
|
---|
183 | DateEditTo.Date := Core.ReportTimeTo;
|
---|
184 | SpinEditYear.Value := Core.ReportYear;
|
---|
185 | SpinEditYear.MaxValue := YearOf(Now);
|
---|
186 | SpinEditId.Value := Core.ReportId;
|
---|
187 | ButtonInterval.Enabled := Assigned(Core.CurrentAccount);
|
---|
188 | ButtonMonthly.Enabled := Assigned(Core.CurrentAccount);
|
---|
189 | ButtonNew.Enabled := Assigned(Core.CurrentAccount);
|
---|
190 | ButtonGetState.Enabled := Assigned(Core.CurrentAccount);
|
---|
191 | Core.ADownloadInterval.Enabled := Assigned(Core.CurrentAccount);
|
---|
192 | Core.ADownloadMonthly.Enabled := Assigned(Core.CurrentAccount);
|
---|
193 | Core.ADownloadNew.Enabled := Assigned(Core.CurrentAccount);
|
---|
194 | if ComboBoxAccounts.ItemIndex <> -1 then begin
|
---|
195 | LabelBalance.Caption := FloatToStr(TAccount(ComboBoxAccounts.Items.Objects[
|
---|
196 | ComboBoxAccounts.ItemIndex]).Balance) + ' KÄ';
|
---|
197 | end else begin
|
---|
198 | LabelBalance.Caption := '? KÄ';
|
---|
199 | end;
|
---|
200 | end;
|
---|
201 |
|
---|
202 | procedure TFormMain.SaveInterface;
|
---|
203 | begin
|
---|
204 | Core.ReportTimeFrom := DateEditStart.Date;
|
---|
205 | Core.ReportTimeTo := DateEditTo.Date;
|
---|
206 | Core.ReportYear := SpinEditYear.Value;
|
---|
207 | Core.ReportId := SpinEditId.Value;
|
---|
208 | end;
|
---|
209 |
|
---|
210 | end.
|
---|
211 |
|
---|