Advertisement
ksyshshot

упозн 3

Jun 1st, 2023
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.73 KB | Source Code | 0 0
  1. unit UnitSearch;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls;
  8.  
  9. type
  10.   TFormSearch = class(TForm)
  11.     SearchedList: TListView;
  12.     LabelSearch: TLabel;
  13.     ButtonFind: TButton;
  14.     ComboBox: TComboBox;
  15.     procedure ButtonFindClick(Sender: TObject);
  16.   private
  17.     { Private declarations }
  18.   public
  19.     { Public declarations }
  20.   end;
  21.  
  22. var
  23.   FormSearch: TFormSearch;
  24.  
  25. implementation
  26.  
  27. {$R *.dfm}
  28.  
  29. uses UnitMain;
  30.  
  31. procedure AddToList(Name: String; var List: TListView);
  32. begin
  33.     List.Items.Add.Caption := Name;
  34. end;
  35.  
  36. procedure FindDishes(Curr: TPElemBanquet);
  37. var
  38.     IngrCode, I: Integer;
  39.     IsFound: Boolean;
  40.     Dish: TPElemDish;
  41. begin
  42.     try
  43.         IngrCode := StrToInt(FormSearch.ComboBox.Items[FormSearch.ComboBox.ItemIndex]);
  44.         while (Curr <> nil) do
  45.         begin
  46.             if (Curr^.CanCook) then
  47.             begin
  48.                 I := 0;
  49.                 IsFound := false;
  50.                 UnitMain.FormMenu.SearchDish(Dish, Curr^.Code);
  51.                 while (I < 5) and not(IsFound) do
  52.                 begin
  53.                     if Dish^.Ingr[I].Code = IngrCode then
  54.                     begin
  55.                         IsFound := true;
  56.                         AddToList(Dish^.Name, FormSearch.SearchedList);
  57.                     end;
  58.                     Inc(I);
  59.                 end;
  60.             end;
  61.             Curr := Curr^.Next;
  62.         end;
  63.     except
  64.         FormSearch.ButtonFind.Enabled := false;
  65.     end;
  66. end;
  67.  
  68. procedure TFormSearch.ButtonFindClick(Sender: TObject);
  69. begin
  70.     SearchedList.Clear;
  71.     FindDishes(HeadBanquet^.Next);
  72. end;
  73.  
  74. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement