Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit UnitSearch;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls;
- type
- TFormSearch = class(TForm)
- SearchedList: TListView;
- LabelSearch: TLabel;
- ButtonFind: TButton;
- ComboBox: TComboBox;
- procedure ButtonFindClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- FormSearch: TFormSearch;
- implementation
- {$R *.dfm}
- uses UnitMain;
- procedure AddToList(Name: String; var List: TListView);
- begin
- List.Items.Add.Caption := Name;
- end;
- procedure FindDishes(Curr: TPElemBanquet);
- var
- IngrCode, I: Integer;
- IsFound: Boolean;
- Dish: TPElemDish;
- begin
- try
- IngrCode := StrToInt(FormSearch.ComboBox.Items[FormSearch.ComboBox.ItemIndex]);
- while (Curr <> nil) do
- begin
- if (Curr^.CanCook) then
- begin
- I := 0;
- IsFound := false;
- UnitMain.FormMenu.SearchDish(Dish, Curr^.Code);
- while (I < 5) and not(IsFound) do
- begin
- if Dish^.Ingr[I].Code = IngrCode then
- begin
- IsFound := true;
- AddToList(Dish^.Name, FormSearch.SearchedList);
- end;
- Inc(I);
- end;
- end;
- Curr := Curr^.Next;
- end;
- except
- FormSearch.ButtonFind.Enabled := false;
- end;
- end;
- procedure TFormSearch.ButtonFindClick(Sender: TObject);
- begin
- SearchedList.Clear;
- FindDishes(HeadBanquet^.Next);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement