⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fmmain.pas

📁 多数代码可以直接在Delphi6和Delphi7环境下运行。部分涉及.NET技术内容的代码
💻 PAS
字号:
unit fmMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    ListBox2: TListBox;
    ListBox3: TListBox;
    btnFirst: TButton;
    btnSecond: TButton;
    LabeledEdit1: TLabeledEdit;
    procedure btnFirstClick(Sender: TObject);
    procedure btnSecondClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses uclasses;

{$R *.dfm}

procedure TForm1.btnFirstClick(Sender: TObject);
var
  aPortfolio : TPortfolio;
  aASL : TStringList;
  aCSL : TStringList;
  aBSL : TStringList;
  FAuthor : TAuthor;
  FCategory : TCategory;
  FBook : TBook;
  iCount : Integer;
  iCount1 : Integer;
begin
  aPortfolio := TPortfolio.Create;
  try
    aASL := aPortfolio.GetAuthors;
    FAuthor := TAuthor(aASL.Objects[0]);
    aCSL := FAuthor.GetCategories;
    for iCount :=  0 to aCSL.Count - 1 do
    begin
      FCategory := TCategory(aCSL.Objects[iCount]);
      aBSL := FCategory.GetBooks;

      for iCount1 := 0 to aBSL.Count - 1 do
      begin
        FBook := TBook(aBSL.Objects[iCount1]);
        ListBox2.Items.Add(FBook.GetName);
        ListBox3.Items.Add(IntToStr(FBook.GetPrice));
      end;
    end;
  finally
    FreeAndNil(aPortfolio);
  end;
end;

procedure TForm1.btnSecondClick(Sender: TObject);
var
  aPortfolio : TPortfolio;
  rSL : TStringList;
  FBook : TBook;
  iCount : Integer;
begin
  aPortfolio := TPortfolio.Create;
  try
    rSL := aPortfolio.GetBooks(Self.LabeledEdit1.Text);
    if Assigned(rSL) then
    begin
      for iCount := 0 to rSL.Count - 1 do
      begin
        FBook := TBook(rSL.Objects[iCount]);
        ListBox2.Items.Add(FBook.GetName);
        ListBox3.Items.Add(IntToStr(FBook.GetPrice));
      end;
      FreeAndNil(rSL);
    end;
  finally
    FreeAndNil(aPortfolio);
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -