Changeset 12
- Timestamp:
- Mar 15, 2013, 11:42:38 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FioInfo.lpi
r9 r12 99 99 </Item5> 100 100 </RequiredPackages> 101 <Units Count=" 6">101 <Units Count="7"> 102 102 <Unit0> 103 103 <Filename Value="FioInfo.lpr"/> … … 142 142 <UnitName Value="UCore"/> 143 143 </Unit5> 144 <Unit6> 145 <Filename Value="Forms/UFormAccounts.pas"/> 146 <IsPartOfProject Value="True"/> 147 <ComponentName Value="FormAccounts"/> 148 <HasResources Value="True"/> 149 <ResourceBaseClass Value="Form"/> 150 <UnitName Value="UFormAccounts"/> 151 </Unit6> 144 152 </Units> 145 153 </ProjectOptions> -
trunk/FioInfo.lpr
r9 r12 9 9 Interfaces, // this includes the LCL widgetset 10 10 Forms, laz_synapse, UFioAPI, Common, TemplateGenerics, 11 UFormSettings, UFormMain, UFormAbout, U Core, CoolTranslator;11 UFormSettings, UFormMain, UFormAbout, UFormAccounts, UCore, CoolTranslator; 12 12 13 13 {$R *.res} … … 20 20 Application.CreateForm(TFormSettings, FormSettings); 21 21 Application.CreateForm(TFormAbout, FormAbout); 22 Application.CreateForm(TFormAccounts, FormAccounts); 22 23 Application.Run; 23 24 end. -
trunk/Forms/UFormMain.lfm
r10 r12 22 22 end 23 23 object GroupBox1: TGroupBox 24 Left = 824 Left = 16 25 25 Height = 57 26 Top = 826 Top = 120 27 27 Width = 498 28 28 Anchors = [akTop, akLeft, akRight] … … 42 42 end 43 43 object GroupBox2: TGroupBox 44 Left = 844 Left = 17 45 45 Height = 72 46 Top = 8046 Top = 184 47 47 Width = 498 48 48 Anchors = [akTop, akLeft, akRight] … … 108 108 end 109 109 object GroupBox3: TGroupBox 110 Left = 8110 Left = 16 111 111 Height = 65 112 Top = 168112 Top = 280 113 113 Width = 499 114 114 Anchors = [akTop, akLeft, akRight] … … 181 181 TabOrder = 5 182 182 end 183 object Label5: TLabel 184 Left = 16 185 Height = 17 186 Top = 12 187 Width = 56 188 Caption = 'Account:' 189 ParentColor = False 190 end 191 object ComboBoxAccounts: TComboBox 192 Left = 96 193 Height = 29 194 Top = 8 195 Width = 312 196 Anchors = [akTop, akLeft, akRight] 197 ItemHeight = 0 198 OnChange = ComboBoxAccountsChange 199 Style = csDropDownList 200 TabOrder = 6 201 end 202 object ButtonNew1: TButton 203 Left = 416 204 Height = 25 205 Top = 8 206 Width = 88 207 Anchors = [akTop, akRight] 208 Caption = 'Edit' 209 OnClick = ButtonNew1Click 210 TabOrder = 7 211 end 212 object GroupBox4: TGroupBox 213 Left = 16 214 Height = 65 215 Top = 48 216 Width = 498 217 Anchors = [akTop, akLeft, akRight] 218 Caption = 'Account state' 219 ClientHeight = 46 220 ClientWidth = 494 221 TabOrder = 8 222 object Label6: TLabel 223 Left = 14 224 Height = 17 225 Top = 7 226 Width = 56 227 Caption = 'Balance:' 228 ParentColor = False 229 end 230 object LabelBalance: TLabel 231 Left = 110 232 Height = 17 233 Top = 7 234 Width = 12 235 Caption = ' ' 236 ParentColor = False 237 end 238 end 183 239 end -
trunk/Forms/UFormMain.lrt
r9 r12 14 14 TFORMMAIN.LABEL2.CAPTION=Year: 15 15 TFORMMAIN.LABEL3.CAPTION=Number: 16 TFORMMAIN.LABEL5.CAPTION=Account: 17 TFORMMAIN.BUTTONNEW1.CAPTION=Edit 18 TFORMMAIN.GROUPBOX4.CAPTION=Account state 19 TFORMMAIN.LABEL6.CAPTION=Balance: 20 TFORMMAIN.LABELBALANCE.CAPTION= -
trunk/Forms/UFormMain.pas
r9 r12 16 16 TFormMain = class(TForm) 17 17 ButtonNew: TButton; 18 ButtonNew1: TButton; 18 19 ButtonSettings: TButton; 19 20 ButtonInterval: TButton; … … 21 22 ButtonExit: TButton; 22 23 ButtonAbout: TButton; 24 ComboBoxAccounts: TComboBox; 23 25 DateEditStart: TDateEdit; 24 26 DateEditTo: TDateEdit; … … 26 28 GroupBox2: TGroupBox; 27 29 GroupBox3: TGroupBox; 30 GroupBox4: TGroupBox; 28 31 Label1: TLabel; 29 32 Label2: TLabel; 30 33 Label3: TLabel; 31 34 Label4: TLabel; 35 Label5: TLabel; 36 Label6: TLabel; 37 LabelBalance: TLabel; 32 38 SpinEditYear: TSpinEdit; 33 39 SpinEditId: TSpinEdit; 34 40 procedure ButtonIntervalClick(Sender: TObject); 35 41 procedure ButtonMonthlyClick(Sender: TObject); 42 procedure ButtonNew1Click(Sender: TObject); 36 43 procedure ButtonNewClick(Sender: TObject); 44 procedure ComboBoxAccountsChange(Sender: TObject); 37 45 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 38 46 procedure FormCreate(Sender: TObject); … … 68 76 end; 69 77 78 procedure TFormMain.ComboBoxAccountsChange(Sender: TObject); 79 begin 80 if ComboBoxAccounts.ItemIndex <> -1 then 81 Core.CurrentAccount := TAccount(Core.Accounts[ComboBoxAccounts.ItemIndex]) 82 else Core.CurrentAccount := nil; 83 end; 84 70 85 procedure TFormMain.ButtonIntervalClick(Sender: TObject); 71 86 begin … … 78 93 SaveInterface; 79 94 Core.ADownloadMonthly.Execute; 95 end; 96 97 procedure TFormMain.ButtonNew1Click(Sender: TObject); 98 begin 99 Core.AAccounts.Execute; 100 LoadInterface; 80 101 end; 81 102 … … 92 113 procedure TFormMain.LoadInterface; 93 114 begin 115 Core.Accounts.LoadToStrings(ComboBoxAccounts.Items); 94 116 DateEditStart.Date := Core.ReportTimeFrom; 95 117 DateEditTo.Date := Core.ReportTimeTo; 96 118 SpinEditYear.Value := Core.ReportYear; 97 119 SpinEditId.Value := Core.ReportId; 120 ButtonInterval.Enabled := Assigned(Core.CurrentAccount); 121 ButtonMonthly.Enabled := Assigned(Core.CurrentAccount); 122 ButtonNew.Enabled := Assigned(Core.CurrentAccount); 98 123 end; 99 124 -
trunk/Forms/UFormSettings.lfm
r9 r12 10 10 Position = poScreenCenter 11 11 LCLVersion = '1.1' 12 object LabeledEditToken: TLabeledEdit13 Left = 814 Height = 2715 Top = 2516 Width = 52817 Anchors = [akTop, akLeft, akRight]18 EditLabel.AnchorSideLeft.Control = LabeledEditToken19 EditLabel.AnchorSideRight.Control = LabeledEditToken20 EditLabel.AnchorSideRight.Side = asrBottom21 EditLabel.AnchorSideBottom.Control = LabeledEditToken22 EditLabel.Left = 823 EditLabel.Height = 1724 EditLabel.Top = 525 EditLabel.Width = 52826 EditLabel.Caption = 'Token'27 EditLabel.ParentColor = False28 TabOrder = 029 end30 12 object ButtonCancel: TButton 31 13 Left = 376 … … 36 18 Caption = 'Cancel' 37 19 ModalResult = 2 38 TabOrder = 120 TabOrder = 0 39 21 end 40 22 object ButtonOk: TButton … … 47 29 Default = True 48 30 ModalResult = 1 49 TabOrder = 231 TabOrder = 1 50 32 end 51 33 object ComboBox1: TComboBox 52 Left = 834 Left = 11 53 35 Height = 29 54 Top = 8036 Top = 32 55 37 Width = 236 56 38 ItemHeight = 0 57 39 Style = csDropDownList 58 TabOrder = 340 TabOrder = 2 59 41 end 60 42 object Label1: TLabel 61 Left = 843 Left = 11 62 44 Height = 17 63 Top = 6445 Top = 16 64 46 Width = 83 65 47 Caption = 'Data format:' … … 67 49 end 68 50 object LabeledEditFolder: TLabeledEdit 69 Left = 851 Left = 11 70 52 Height = 27 71 Top = 13653 Top = 88 72 54 Width = 440 73 55 Anchors = [akTop, akLeft, akRight] … … 76 58 EditLabel.AnchorSideRight.Side = asrBottom 77 59 EditLabel.AnchorSideBottom.Control = LabeledEditFolder 78 EditLabel.Left = 860 EditLabel.Left = 11 79 61 EditLabel.Height = 17 80 EditLabel.Top = 11662 EditLabel.Top = 68 81 63 EditLabel.Width = 440 82 64 EditLabel.Caption = 'Destination folder:' 83 65 EditLabel.ParentColor = False 84 TabOrder = 466 TabOrder = 3 85 67 end 86 68 object Button1: TButton 87 Left = 46 169 Left = 464 88 70 Height = 25 89 Top = 13671 Top = 88 90 72 Width = 75 91 73 Anchors = [akTop, akRight] 92 74 Caption = 'Select' 93 75 OnClick = Button1Click 94 TabOrder = 576 TabOrder = 4 95 77 end 96 78 end -
trunk/Forms/UFormSettings.lrt
r9 r12 1 1 TFORMSETTINGS.CAPTION=Settings 2 TFORMSETTINGS.LABELEDEDITTOKEN.EDITLABEL.CAPTION=Token3 2 TFORMSETTINGS.BUTTONCANCEL.CAPTION=Cancel 4 3 TFORMSETTINGS.BUTTONOK.CAPTION=Ok -
trunk/Forms/UFormSettings.pas
r10 r12 19 19 ComboBox1: TComboBox; 20 20 Label1: TLabel; 21 LabeledEditToken: TLabeledEdit;22 21 LabeledEditFolder: TLabeledEdit; 23 22 procedure Button1Click(Sender: TObject); … … 67 66 procedure TFormSettings.Load; 68 67 begin 69 LabeledEditToken.Text := Core.Token;70 68 ComboBox1.ItemIndex := Integer(Core.DataFormat); 71 69 LabeledEditFolder.Text := Core.TargetDirectory; … … 74 72 procedure TFormSettings.Save; 75 73 begin 76 Core.Token := LabeledEditToken.Text;77 74 Core.DataFormat := TFioDataFormat(ComboBox1.ItemIndex); 78 75 Core.TargetDirectory := LabeledEditFolder.Text; -
trunk/Languages/FioInfo.cs.po
r11 r12 15 15 msgstr "O aplikaci" 16 16 17 #: tcore.aaccounts.caption 18 msgctxt "tcore.aaccounts.caption" 19 msgid "Accounts" 20 msgstr "ÃÄty" 21 17 22 #: tcore.adownloadinterval.caption 18 23 msgid "Download defined time interval" … … 56 61 msgstr "O aplikaci" 57 62 63 #: tformaccounts.buttonadd.caption 64 msgid "Add" 65 msgstr "PÅidat" 66 67 #: tformaccounts.buttoncancel.caption 68 msgctxt "tformaccounts.buttoncancel.caption" 69 msgid "Cancel" 70 msgstr "ZruÅ¡it" 71 72 #: tformaccounts.buttonok.caption 73 msgctxt "tformaccounts.buttonok.caption" 74 msgid "Ok" 75 msgstr "Ok" 76 77 #: tformaccounts.buttonremove.caption 78 msgid "Remove" 79 msgstr "Odebrat" 80 81 #: tformaccounts.caption 82 msgctxt "tformaccounts.caption" 83 msgid "Accounts" 84 msgstr "ÃÄty" 85 86 #: tformaccounts.labelededitname.editlabel.caption 87 msgctxt "tformaccounts.labelededitname.editlabel.caption" 88 msgid "Name" 89 msgstr "Jméno" 90 91 #: tformaccounts.labelededittoken.editlabel.caption 92 msgctxt "tformaccounts.labelededittoken.editlabel.caption" 93 msgid "Token" 94 msgstr "Token" 95 96 #: tformaccounts.listview1.columns[0].caption 97 msgctxt "tformaccounts.listview1.columns[0].caption" 98 msgid "Name" 99 msgstr "Jméno" 100 101 #: tformaccounts.listview1.columns[1].caption 102 msgid "Number" 103 msgstr "ÄÃslo" 104 105 #: tformaccounts.listview1.columns[2].caption 106 msgid "Balance" 107 msgstr "Zůstatek" 108 109 #: tformaccounts.listview1.columns[3].caption 110 #| msgid "Token" 111 msgctxt "tformaccounts.listview1.columns[3].caption" 112 msgid "Date" 113 msgstr "Datum" 114 115 #: tformaccounts.listview1.columns[4].caption 116 msgctxt "tformaccounts.listview1.columns[4].caption" 117 msgid "Token" 118 msgstr "Token" 119 58 120 #: tformmain.buttoninterval.caption 59 121 msgctxt "TFORMMAIN.BUTTONINTERVAL.CAPTION" … … 71 133 msgstr "Stáhnout" 72 134 135 #: tformmain.buttonnew1.caption 136 msgid "Edit" 137 msgstr "Upravit" 138 73 139 #: tformmain.caption 74 140 msgid "FioInfo" … … 96 162 97 163 #: tformmain.groupbox1.caption 164 msgctxt "tformmain.groupbox1.caption" 98 165 msgid "New transaction from last check" 99 166 msgstr "Nové transakce od poslednà kontroly" … … 107 174 msgstr "VybranÃœ mÄsÃÄnà vÃœpis" 108 175 176 #: tformmain.groupbox4.caption 177 #| msgid "New transaction from last check" 178 msgctxt "tformmain.groupbox4.caption" 179 msgid "Account state" 180 msgstr "Stav úÄtu" 181 109 182 #: tformmain.label1.caption 110 183 msgid "From:" … … 123 196 msgstr "Do:" 124 197 198 #: tformmain.label5.caption 199 msgid "Account:" 200 msgstr "ÃÄet:" 201 202 #: tformmain.label6.caption 203 msgid "Balance:" 204 msgstr "Zůstatek:" 205 206 #: tformmain.labelbalance.caption 207 msgid " " 208 msgstr "" 209 125 210 #: tformsettings.button1.caption 126 211 msgid "Select" … … 133 218 134 219 #: tformsettings.buttonok.caption 220 msgctxt "tformsettings.buttonok.caption" 135 221 msgid "Ok" 136 222 msgstr "Ok" … … 149 235 msgstr "CÃlová sloÅŸka:" 150 236 151 #: tformsettings.labelededittoken.editlabel.caption152 msgid "Token"153 msgstr "Token"154 155 237 #: ucore.sdownloadnotsuccess 156 238 msgctxt "ucore.sdownloadnotsuccess" … … 185 267 #: uformabout.shomepage 186 268 msgid "Web" 187 msgstr " "269 msgstr "Web" 188 270 189 271 #: uformabout.smanufacturer … … 199 281 msgstr "Verze" 200 282 201 #: uformmain.sdownloadnotsuccess202 msgid "StaÅŸenà nebylo úspÄÅ¡né"203 msgstr ""204 205 283 #: uformsettings.sselectfolder 206 284 msgid "Select destination folder" -
trunk/Languages/FioInfo.po
r11 r12 7 7 msgstr "" 8 8 9 #: tcore.aaccounts.caption 10 msgctxt "TCORE.AACCOUNTS.CAPTION" 11 msgid "Accounts" 12 msgstr "" 13 9 14 #: tcore.adownloadinterval.caption 10 15 msgid "Download defined time interval" … … 48 53 msgstr "" 49 54 55 #: tformaccounts.buttonadd.caption 56 msgid "Add" 57 msgstr "" 58 59 #: tformaccounts.buttoncancel.caption 60 msgctxt "TFORMACCOUNTS.BUTTONCANCEL.CAPTION" 61 msgid "Cancel" 62 msgstr "" 63 64 #: tformaccounts.buttonok.caption 65 msgctxt "TFORMACCOUNTS.BUTTONOK.CAPTION" 66 msgid "Ok" 67 msgstr "" 68 69 #: tformaccounts.buttonremove.caption 70 msgid "Remove" 71 msgstr "" 72 73 #: tformaccounts.caption 74 msgctxt "tformaccounts.caption" 75 msgid "Accounts" 76 msgstr "" 77 78 #: tformaccounts.labelededitname.editlabel.caption 79 msgctxt "TFORMACCOUNTS.LABELEDEDITNAME.EDITLABEL.CAPTION" 80 msgid "Name" 81 msgstr "" 82 83 #: tformaccounts.labelededittoken.editlabel.caption 84 msgctxt "TFORMACCOUNTS.LABELEDEDITTOKEN.EDITLABEL.CAPTION" 85 msgid "Token" 86 msgstr "" 87 88 #: tformaccounts.listview1.columns[0].caption 89 msgctxt "tformaccounts.listview1.columns[0].caption" 90 msgid "Name" 91 msgstr "" 92 93 #: tformaccounts.listview1.columns[1].caption 94 msgid "Number" 95 msgstr "" 96 97 #: tformaccounts.listview1.columns[2].caption 98 msgid "Balance" 99 msgstr "" 100 101 #: tformaccounts.listview1.columns[3].caption 102 msgctxt "TFORMACCOUNTS.LISTVIEW1.COLUMNS[3].CAPTION" 103 msgid "Date" 104 msgstr "" 105 106 #: tformaccounts.listview1.columns[4].caption 107 msgctxt "TFORMACCOUNTS.LISTVIEW1.COLUMNS[4].CAPTION" 108 msgid "Token" 109 msgstr "" 110 50 111 #: tformmain.buttoninterval.caption 51 112 msgctxt "TFORMMAIN.BUTTONINTERVAL.CAPTION" … … 63 124 msgstr "" 64 125 126 #: tformmain.buttonnew1.caption 127 msgid "Edit" 128 msgstr "" 129 65 130 #: tformmain.caption 66 131 msgid "FioInfo" … … 88 153 89 154 #: tformmain.groupbox1.caption 155 msgctxt "tformmain.groupbox1.caption" 90 156 msgid "New transaction from last check" 91 157 msgstr "" … … 99 165 msgstr "" 100 166 167 #: tformmain.groupbox4.caption 168 msgctxt "TFORMMAIN.GROUPBOX4.CAPTION" 169 msgid "Account state" 170 msgstr "" 171 101 172 #: tformmain.label1.caption 102 173 msgid "From:" … … 115 186 msgstr "" 116 187 188 #: tformmain.label5.caption 189 msgid "Account:" 190 msgstr "" 191 192 #: tformmain.label6.caption 193 msgid "Balance:" 194 msgstr "" 195 196 #: tformmain.labelbalance.caption 197 msgid " " 198 msgstr "" 199 117 200 #: tformsettings.button1.caption 118 201 msgid "Select" … … 125 208 126 209 #: tformsettings.buttonok.caption 210 msgctxt "tformsettings.buttonok.caption" 127 211 msgid "Ok" 128 212 msgstr "" … … 141 225 msgstr "" 142 226 143 #: tformsettings.labelededittoken.editlabel.caption144 msgid "Token"145 msgstr ""146 147 227 #: ucore.sdownloadnotsuccess 148 228 msgctxt "ucore.sdownloadnotsuccess" … … 190 270 msgstr "" 191 271 192 #: uformmain.sdownloadnotsuccess193 msgctxt "uformmain.sdownloadnotsuccess"194 msgid "StaÅŸenà nebylo úspÄÅ¡né"195 msgstr ""196 197 272 #: uformsettings.sselectfolder 198 273 msgid "Select destination folder" -
trunk/UCore.lfm
r10 r12 355 355 OnExecute = AAboutExecute 356 356 end 357 object AAccounts: TAction 358 Caption = 'Accounts' 359 OnExecute = AAccountsExecute 360 end 357 361 end 358 362 object PopupMenuTray: TPopupMenu … … 398 402 EmailContact = 'robie@centrum.cz' 399 403 AppName = 'FioInfo' 400 ReleaseDate = 4134 7404 ReleaseDate = 41348 401 405 RegistryKey = '\Software\Chronosoft\FioInfo' 402 406 RegistryRoot = rrKeyCurrentUser -
trunk/UCore.lrt
r9 r12 6 6 TCORE.ADOWNLOADMONTHLY.CAPTION=Download monthly report 7 7 TCORE.AABOUT.CAPTION=About 8 TCORE.AACCOUNTS.CAPTION=Accounts 8 9 TCORE.MENUITEM3.CAPTION=- -
trunk/UCore.pas
r11 r12 8 8 Classes, SysUtils, FileUtil, ExtCtrls, Controls, ActnList, Menus, UFioAPI, 9 9 URegistry, UApplicationInfo, UCoolTranslator, Registry, DateUtils, Forms, 10 Dialogs ;10 Dialogs, SpecializedList, dom, XMLRead, XMLWrite; 11 11 12 12 type 13 14 { TAccount } 15 16 TAccount = class 17 Token: string; 18 Name: string; 19 Number: string; 20 Balance: Double; 21 Time: TDateTime; 22 procedure Assign(Source: TAccount); 23 procedure LoadFromRegistry(Context: TRegistryContext); 24 procedure SaveToRegistry(Context: TRegistryContext); 25 end; 26 27 { TAccountList } 28 29 TAccountList = class(TListObject) 30 procedure LoadFromRegistry(Context: TRegistryContext); 31 procedure SaveToRegistry(Context: TRegistryContext); 32 procedure LoadToStrings(Strings: TStrings); 33 procedure Assign(Source: TAccountList); 34 end; 13 35 14 36 { TCore } … … 16 38 TCore = class(TDataModule) 17 39 AAbout: TAction; 40 AAccounts: TAction; 18 41 ActionList1: TActionList; 19 42 ADownloadInterval: TAction; … … 36 59 PopupMenuTray: TPopupMenu; 37 60 TrayIcon1: TTrayIcon; 61 procedure AAccountsExecute(Sender: TObject); 38 62 procedure ADownloadIntervalExecute(Sender: TObject); 39 63 procedure ADownloadMonthlyExecute(Sender: TObject); … … 49 73 public 50 74 RegistryContext: TRegistryContext; 51 Token: string; 75 Accounts: TAccountList; 76 CurrentAccount: TAccount; 52 77 DataFormat: TFioDataFormat; 53 78 TargetDirectory: string; … … 56 81 ReportTimeFrom: TDateTime; 57 82 ReportTimeTo: TDateTime; 83 procedure LoadAccount(Account: TAccount); 84 procedure LoadAccounts; 58 85 procedure SaveToRegistry(Context: TRegistryContext); 59 86 procedure LoadFromRegistry(Context: TRegistryContext); … … 68 95 69 96 uses 70 UFormAbout, UFormMain, UFormSettings ;97 UFormAbout, UFormMain, UFormSettings, UFormAccounts; 71 98 72 99 resourcestring … … 75 102 SSavedToFile = 'Dump saved to file %s'; 76 103 104 { TAccount } 105 106 procedure TAccount.Assign(Source: TAccount); 107 begin 108 Token := Source.Token; 109 Name := Source.Name; 110 Balance := Source.Balance; 111 Time := Source.Time; 112 Number := Source.Number; 113 end; 114 115 procedure TAccount.LoadFromRegistry(Context: TRegistryContext); 116 begin 117 with TRegistryEx.Create do 118 try 119 RootKey := Context.RootKey; 120 OpenKey(Context.Key, True); 121 Name := ReadStringWithDefault('Name', ''); 122 Time := ReadDateTimeWithDefault('Time', 0); 123 Token := ReadStringWithDefault('Token', ''); 124 Balance := ReadFloatWithDefault('Balance', 0); 125 Number := ReadStringWithDefault('Number', ''); 126 finally 127 Free; 128 end; 129 end; 130 131 procedure TAccount.SaveToRegistry(Context: TRegistryContext); 132 begin 133 with TRegistryEx.Create do 134 try 135 RootKey := Context.RootKey; 136 OpenKey(Context.Key, True); 137 WriteString('Number', Number); 138 WriteString('Name', Name); 139 WriteDateTime('Time', Time); 140 WriteString('Token', Token); 141 WriteFloat('Balance', Balance); 142 finally 143 Free; 144 end; 145 end; 146 147 { TAccountList } 148 149 procedure TAccountList.LoadFromRegistry(Context: TRegistryContext); 150 var 151 I: Integer; 152 begin 153 with TRegistryEx.Create do 154 try 155 RootKey := Context.RootKey; 156 OpenKey(Context.Key, True); 157 Count := ReadIntegerWithDefault('Count', 0); 158 finally 159 Free; 160 end; 161 for I := 0 to Count - 1 do begin 162 if not Assigned(Items[I]) then Items[I] := TAccount.Create; 163 TAccount(Items[I]).LoadFromRegistry(RegContext(Context.RootKey, Context.Key + '\' + IntToStr(I))); 164 end; 165 end; 166 167 procedure TAccountList.SaveToRegistry(Context: TRegistryContext); 168 var 169 I: Integer; 170 begin 171 with TRegistryEx.Create do 172 try 173 RootKey := Context.RootKey; 174 OpenKey(Context.Key, True); 175 WriteInteger('Count', Count); 176 finally 177 Free; 178 end; 179 for I := 0 to Count - 1 do 180 TAccount(Items[I]).SaveToRegistry(RegContext(Context.RootKey, Context.Key + '\' + IntToStr(I))); 181 end; 182 183 procedure TAccountList.LoadToStrings(Strings: TStrings); 184 var 185 I: Integer; 186 begin 187 while Strings.Count < Count do 188 Strings.Add(''); 189 while Strings.Count > Count do 190 Strings.Delete(Strings.Count - 1); 191 for I := 0 to Count - 1 do 192 Strings.Strings[I] := TAccount(Items[I]).Name; 193 end; 194 195 procedure TAccountList.Assign(Source: TAccountList); 196 var 197 I: Integer; 198 begin 199 //inherited Assign(Source); 200 Count := Source.Count; 201 for I := 0 to Count - 1 do begin 202 if not Assigned(Items[I]) then Items[I] := TAccount.Create; 203 TAccount(Items[I]).Assign(TAccount(Source.Items[I])); 204 end; 205 end; 206 77 207 { TCore } 78 208 … … 84 214 procedure TCore.DataModuleCreate(Sender: TObject); 85 215 begin 216 Accounts := TAccountList.Create; 86 217 RegistryContext := RegContext(HKEY(ApplicationInfo1.RegistryRoot), 87 218 ApplicationInfo1.RegistryKey); 88 219 LoadFromRegistry(RegistryContext); 220 //LoadAccounts; 89 221 end; 90 222 … … 92 224 begin 93 225 SaveToRegistry(RegistryContext); 226 FreeAndNil(Accounts); 227 end; 228 229 procedure TCore.LoadAccount(Account: TAccount); 230 var 231 FioAPI: TFioAPI; 232 List: TStringList; 233 FileName: string; 234 XMLDocument: TXMLDocument; 235 Mem: TMemoryStream; 236 RootNode: TDOMNode; 237 begin 238 FioAPI := TFioAPI.Create; 239 List := TStringList.Create; 240 XMLDocument := TXMLDocument.Create; 241 Mem := TMemoryStream.Create; 242 try 243 FioAPI.Format := DataFormat; 244 FioAPI.Token := Account.Token; 245 Account.Time := Now; 246 if FioAPI.DownloadInterval(Now, Now, List) then begin 247 List.SaveToStream(Mem); 248 ReadXMLFile(XMLDocument, Mem); 249 RootNode := XMLDocument.DocumentElement; 250 ShowMessage(RootNode.NodeName); 251 end else begin 252 Account.Number := ''; 253 Account.Balance := 0; 254 end; 255 finally 256 Mem.Free; 257 XMLDocument.Free; 258 FioAPI.Free; 259 List.Free; 260 end; 261 end; 262 263 procedure TCore.LoadAccounts; 264 var 265 I: Integer; 266 begin 267 for I := 0 to Accounts.Count - 1 do 268 LoadAccount(TAccount(Accounts[I])); 94 269 end; 95 270 … … 108 283 WriteString('TargetDir', TargetDirectory); 109 284 WriteInteger('DataFormat', Integer(DataFormat)); 110 WriteString('Token', Token);111 285 WriteDate('ReportTimeFrom', ReportTimeFrom); 112 286 WriteDateTime('ReportTimeTo', ReportTimeTo); … … 117 291 Free; 118 292 end; 293 Accounts.SaveToRegistry(RegContext(Context.RootKey, Context.Key + '\Account')); 119 294 end; 120 295 … … 127 302 TargetDirectory := ReadStringWithDefault('TargetDir', ExtractFileDir(Application.ExeName)); 128 303 DataFormat := TFioDataFormat(ReadIntegerWithDefault('DataFormat', Integer(dfXML))); 129 Token := ReadStringWithDefault('Token', '');130 304 ReportTimeFrom := ReadDateTimeWithDefault('ReportTimeFrom', Now); 131 305 ReportTimeTo := ReadDateTimeWithDefault('ReportTimeTo', Now); … … 136 310 Free; 137 311 end; 312 Accounts.LoadFromRegistry(RegContext(Context.RootKey, Context.Key + '\Account')); 138 313 end; 139 314 … … 162 337 try 163 338 FioAPI.Format := DataFormat; 164 FioAPI.Token := Token;339 FioAPI.Token := CurrentAccount.Token; 165 340 if FioAPI.DownloadLast(List) then begin 166 341 FileName := TargetDirectory + DirectorySeparator + Format(SReport, [FormatDateTime('yyyy-mm-dd hh-nn-ss', Now) + … … 185 360 try 186 361 FioAPI.Format := DataFormat; 187 FioAPI.Token := Token;362 FioAPI.Token := CurrentAccount.Token; 188 363 if FioAPI.DownloadMonthly(ReportYear, ReportId, List) then begin 189 364 FileName := TargetDirectory + DirectorySeparator + Format(SReport, [IntToStr(ReportYear) + … … 209 384 try 210 385 FioAPI.Format := DataFormat; 211 FioAPI.Token := Token;386 FioAPI.Token := CurrentAccount.Token; 212 387 if FioAPI.DownloadInterval(ReportTimeFrom, ReportTimeTo, List) then begin 213 388 FileName := TargetDirectory + DirectorySeparator + Format(SReport, [FormatDateTime('yyyy-mm-dd', ReportTimeFrom) + … … 223 398 end; 224 399 400 procedure TCore.AAccountsExecute(Sender: TObject); 401 begin 402 TAccountList(FormAccounts.Accounts).Assign(Accounts); 403 if FormAccounts.ShowModal = mrOk then begin 404 Accounts.Assign(TAccountList(FormAccounts.Accounts)); 405 end; 406 end; 407 225 408 end. 226 409
Note:
See TracChangeset
for help on using the changeset viewer.