Changeset 22 for trunk/UCore.pas


Ignore:
Timestamp:
Mar 25, 2013, 11:47:38 PM (11 years ago)
Author:
chronos
Message:
  • Upraveno: Příprava pro zobrazování seznamu operací.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r20 r22  
    1111
    1212type
     13
     14  { TAccountOperation }
     15
    1316  TAccountOperation = class
    1417    Id: string;
    1518    Time: TDateTime;
    1619    Value: Double;
     20    Account: string;
    1721    VarSym: string;
    1822    SpecSym: string;
    1923    ConstSym: string;
     24    procedure LoadFromRegistry(Context: TRegistryContext);
     25    procedure SaveToRegistry(Context: TRegistryContext);
    2026  end;
    2127
     
    118124  SDumpFormat = 'Dump %d %t.%f';
    119125
     126{ TAccountOperation }
     127
     128procedure TAccountOperation.LoadFromRegistry(Context: TRegistryContext);
     129begin
     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;
     144end;
     145
     146procedure TAccountOperation.SaveToRegistry(Context: TRegistryContext);
     147begin
     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;
     162end;
     163
    120164{ TAccount }
    121165
     
    127171  Time := Source.Time;
    128172  Number := Source.Number;
     173  BankCode := Source.BankCode;
     174  //Operations.Assign(Source.Operations);
    129175end;
    130176
    131177procedure TAccount.LoadFromRegistry(Context: TRegistryContext);
     178var
     179  I: Integer;
    132180begin
    133181  with TRegistryEx.Create do
     
    144192    Free;
    145193  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;
    146199end;
    147200
    148201procedure TAccount.SaveToRegistry(Context: TRegistryContext);
     202var
     203  I: Integer;
    149204begin
    150205  with TRegistryEx.Create do
     
    161216    Free;
    162217  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)));
    163221end;
    164222
     
    219277    Strings.Delete(Strings.Count - 1);
    220278  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 + ' (' +
    222280      TAccount(Items[I]).Number + '/' + TAccount(Items[I]).BankCode + ')';
    223281    Strings.Objects[I] := Items[I];
Note: See TracChangeset for help on using the changeset viewer.