Changeset 5
- Timestamp:
- Jul 8, 2024, 11:31:59 PM (5 months ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Car.pas
r4 r5 98 98 destructor Destroy; override; 99 99 procedure LoadFromFile(FileName: string); 100 procedure LoadFromStrings(Lines: TStrings); 100 101 function Print: string; 101 102 property OnLog: TLogEvent read FOnLog write FOnLog; … … 388 389 procedure TSummary.LoadFromFile(FileName: string); 389 390 var 390 I: Integer;391 391 Lines: TStringList; 392 begin 393 Lines := TStringList.Create; 394 try 395 Lines.LoadFromFile(FileName); 396 LoadFromStrings(Lines); 397 finally 398 Lines.Free; 399 end; 400 end; 401 402 procedure TSummary.LoadFromStrings(Lines: TStrings); 403 var 404 I: Integer; 392 405 Line: string; 393 406 CarComparer: TCarComparer; … … 426 439 TableLineCellSeparator = '||'; 427 440 begin 428 Lines := TStringList.Create;429 Lines.LoadFromFile(FileName);430 441 for I := 0 to Lines.Count - 1 do begin 431 442 Line := Lines[I]; … … 539 550 SaveAndFreeCar(CarName, EngineType, CompanyName, Distance, Odometer, Price, 540 551 PriceWithFuel, RentTime, Consumption); 541 Lines.Free;542 552 CarComparer := TCarComparer.Create; 543 553 Cars.Sort(CarComparer); -
trunk/FormMain.lfm
r3 r5 1 1 object FormMain: TFormMain 2 Left = 4 842 Left = 456 3 3 Height = 869 4 Top = 2 534 Top = 228 5 5 Width = 1128 6 6 Caption = 'Car rental summary' … … 8 8 ClientWidth = 1128 9 9 DesignTimePPI = 144 10 OnClose = FormClose 10 11 OnCreate = FormCreate 11 12 OnDestroy = FormDestroy 12 13 OnShow = FormShow 13 LCLVersion = ' 2.2.6.0'14 LCLVersion = '3.4.0.0' 14 15 WindowState = wsMaximized 15 16 object LabelSummary: TLabel … … 43 44 Top = 104 44 45 Width = 1099 45 ActivePage = TabSheet 146 ActivePage = TabSheetSource 46 47 Anchors = [akTop, akLeft, akRight, akBottom] 47 48 TabIndex = 0 48 49 TabOrder = 1 49 object TabSheet1: TTabSheet 50 object TabSheetSource: TTabSheet 51 Caption = 'Source' 52 ClientHeight = 724 53 ClientWidth = 1089 54 object MemoSource: TMemo 55 Left = 8 56 Height = 708 57 Top = 8 58 Width = 1073 59 Align = alClient 60 BorderSpacing.Around = 8 61 ScrollBars = ssAutoBoth 62 TabOrder = 0 63 end 64 end 65 object TabSheetSummary: TTabSheet 50 66 Caption = 'Summary' 51 67 ClientHeight = 724 -
trunk/FormMain.pas
r3 r5 17 17 MemoSummary: TMemo; 18 18 MemoLog: TMemo; 19 MemoSource: TMemo; 19 20 PageControlSummary: TPageControl; 20 TabSheet1: TTabSheet; 21 TabSheetSummary: TTabSheet; 22 TabSheetSource: TTabSheet; 21 23 TabSheetLog: TTabSheet; 24 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 22 25 procedure FormCreate(Sender: TObject); 23 26 procedure FormDestroy(Sender: TObject); … … 40 43 procedure TFormMain.FormShow(Sender: TObject); 41 44 begin 45 if FileExists(EditSource.Text) then 46 MemoSource.Lines.LoadFromFile(EditSource.Text); 42 47 Summary.OnLog := Log; 43 Summary.LoadFrom File(EditSource.Text);48 Summary.LoadFromStrings(MemoSource.Lines); 44 49 MemoSummary.Text := Summary.Print; 50 //PageControlSummary.TabIndex := 1; 45 51 end; 46 52 … … 55 61 end; 56 62 63 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction); 64 begin 65 MemoSource.Lines.SaveToFile(EditSource.Text); 66 end; 67 57 68 procedure TFormMain.FormDestroy(Sender: TObject); 58 69 begin
Note:
See TracChangeset
for help on using the changeset viewer.