Changeset 22 for trunk/UCore.pas
- Timestamp:
- Mar 25, 2013, 11:47:38 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r20 r22 11 11 12 12 type 13 14 { TAccountOperation } 15 13 16 TAccountOperation = class 14 17 Id: string; 15 18 Time: TDateTime; 16 19 Value: Double; 20 Account: string; 17 21 VarSym: string; 18 22 SpecSym: string; 19 23 ConstSym: string; 24 procedure LoadFromRegistry(Context: TRegistryContext); 25 procedure SaveToRegistry(Context: TRegistryContext); 20 26 end; 21 27 … … 118 124 SDumpFormat = 'Dump %d %t.%f'; 119 125 126 { TAccountOperation } 127 128 procedure TAccountOperation.LoadFromRegistry(Context: TRegistryContext); 129 begin 130 with TRegistryEx.Create do 131 try 132 RootKey := Context.RootKey; 133 OpenKey(Context.Key, True); 134 Id := UTF8Encode(ReadStringWithDefault('Id', UTF8Decode(''))); 135 Time := ReadDateTimeWithDefault('Time', 0); 136 Value := ReadFloatWithDefault('Value', 0); 137 Account := UTF8Encode(ReadStringWithDefault('Account', UTF8Decode(''))); 138 VarSym := UTF8Encode(ReadStringWithDefault('VarSym', UTF8Decode(''))); 139 SpecSym := UTF8Encode(ReadStringWithDefault('SpecSym', UTF8Decode(''))); 140 ConstSym := UTF8Encode(ReadStringWithDefault('ConstSym', UTF8Decode(''))); 141 finally 142 Free; 143 end; 144 end; 145 146 procedure TAccountOperation.SaveToRegistry(Context: TRegistryContext); 147 begin 148 with TRegistryEx.Create do 149 try 150 RootKey := Context.RootKey; 151 OpenKey(Context.Key, True); 152 WriteString('Id', UTF8Decode(Id)); 153 WriteString('Account', UTF8Decode(Account)); 154 WriteDateTime('Time', Time); 155 WriteFloat('Value', Value); 156 WriteString('VarSym', UTF8Decode(VarSym)); 157 WriteString('SpecSym', UTF8Decode(SpecSym)); 158 WriteString('ConstSym', UTF8Decode(ConstSym)); 159 finally 160 Free; 161 end; 162 end; 163 120 164 { TAccount } 121 165 … … 127 171 Time := Source.Time; 128 172 Number := Source.Number; 173 BankCode := Source.BankCode; 174 //Operations.Assign(Source.Operations); 129 175 end; 130 176 131 177 procedure TAccount.LoadFromRegistry(Context: TRegistryContext); 178 var 179 I: Integer; 132 180 begin 133 181 with TRegistryEx.Create do … … 144 192 Free; 145 193 end; 194 with Operations do 195 for I := 0 to Count - 1 do begin 196 if not Assigned(Items[I]) then Items[I] := TAccountOperation.Create; 197 TAccountOperation(Items[I]).LoadFromRegistry(RegContext(Context.RootKey, Context.Key + '\' + IntToStr(I))); 198 end; 146 199 end; 147 200 148 201 procedure TAccount.SaveToRegistry(Context: TRegistryContext); 202 var 203 I: Integer; 149 204 begin 150 205 with TRegistryEx.Create do … … 161 216 Free; 162 217 end; 218 with Operations do 219 for I := 0 to Count - 1 do 220 TAccountOperation(Items[I]).SaveToRegistry(RegContext(Context.RootKey, Context.Key + '\' + IntToStr(I))); 163 221 end; 164 222 … … 219 277 Strings.Delete(Strings.Count - 1); 220 278 for I := 0 to Count - 1 do begin 221 Strings.Strings[I] := IntToStr(I ) + ': ' + TAccount(Items[I]).Name + ' (' +279 Strings.Strings[I] := IntToStr(I + 1) + ': ' + TAccount(Items[I]).Name + ' (' + 222 280 TAccount(Items[I]).Number + '/' + TAccount(Items[I]).BankCode + ')'; 223 281 Strings.Objects[I] := Items[I];
Note:
See TracChangeset
for help on using the changeset viewer.