Advertisement
ksyshshot

упозн 4

Jun 1st, 2023
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 3.70 KB | Source Code | 0 0
  1. unit UnitIngredient;
  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;
  8.  
  9. type
  10.   TFormIngredient = class(TForm)
  11.     Edit1: TEdit;
  12.     Edit2: TEdit;
  13.     Edit3: TEdit;
  14.     Edit4: TEdit;
  15.     Edit5: TEdit;
  16.     Code: TLabel;
  17.     Name: TLabel;
  18.     Protein: TLabel;
  19.     Fat: TLabel;
  20.     Hydro: TLabel;
  21.     ChangeCode: TLabel;
  22.     ButtonAdd: TButton;
  23.     ComboBox: TComboBox;
  24.     procedure Edit1KeyPress(Sender: TObject; var Key: Char);
  25.     procedure Edit3KeyPress(Sender: TObject; var Key: Char);
  26.     procedure Edit4KeyPress(Sender: TObject; var Key: Char);
  27.     procedure Edit6KeyPress(Sender: TObject; var Key: Char);
  28.     procedure Edit5KeyPress(Sender: TObject; var Key: Char);
  29.     procedure Edit1Change(Sender: TObject);
  30.     procedure Edit2Change(Sender: TObject);
  31.     procedure Edit3Change(Sender: TObject);
  32.     procedure Edit4Change(Sender: TObject);
  33.     procedure Edit5Change(Sender: TObject);
  34.     procedure ButtonAddClick(Sender: TObject);
  35.   private
  36.     { Private declarations }
  37.   public
  38.     { Public declarations }
  39.   end;
  40.  
  41. var
  42.   FormIngredient: TFormIngredient;
  43.  
  44. implementation
  45.  
  46. {$R *.dfm}
  47.  
  48. procedure TFormIngredient.ButtonAddClick(Sender: TObject);
  49. begin
  50.     ModalResult := mrOk;
  51. end;
  52.  
  53. procedure TFormIngredient.Edit1Change(Sender: TObject);
  54. begin
  55.     if (Edit2.Text <> '') and (length(Edit1.Text) = 3)
  56.     and (Edit3.Text <> '') and (Edit4.Text <> '') and
  57.     (Edit5.Text <> '') then
  58.     begin
  59.         ButtonAdd.Enabled := true;
  60.     end
  61.     else
  62.     begin
  63.         ButtonAdd.Enabled := false;
  64.     end;
  65.  
  66. end;
  67.  
  68. procedure TFormIngredient.Edit1KeyPress(Sender: TObject; var Key: Char);
  69. begin
  70.     if not(Key in ['0'..'9', #8]) then
  71.         Key := #0;
  72. end;
  73.  
  74. procedure TFormIngredient.Edit2Change(Sender: TObject);
  75. begin
  76.     if (Edit2.Text <> '') and (length(Edit1.Text) = 3)
  77.     and (Edit3.Text <> '') and (Edit4.Text <> '') and
  78.     (Edit5.Text <> '') then
  79.     begin
  80.         ButtonAdd.Enabled := true;
  81.     end
  82.     else
  83.     begin
  84.         ButtonAdd.Enabled := false;
  85.     end;
  86. end;
  87.  
  88. procedure TFormIngredient.Edit3Change(Sender: TObject);
  89. begin
  90.     if (Edit2.Text <> '') and (length(Edit1.Text) = 3)
  91.     and (Edit3.Text <> '') and (Edit4.Text <> '') and
  92.     (Edit5.Text <> '') then
  93.     begin
  94.         ButtonAdd.Enabled := true;
  95.     end
  96.     else
  97.     begin
  98.         ButtonAdd.Enabled := false;
  99.     end;
  100. end;
  101.  
  102. procedure TFormIngredient.Edit3KeyPress(Sender: TObject; var Key: Char);
  103. begin
  104.     if not(Key in ['0'..'9', #8]) then
  105.         Key := #0;
  106. end;
  107.  
  108. procedure TFormIngredient.Edit4Change(Sender: TObject);
  109. begin
  110.     if (Edit2.Text <> '') and (length(Edit1.Text) = 3)
  111.     and (Edit3.Text <> '') and (Edit4.Text <> '') and
  112.     (Edit5.Text <> '') then
  113.     begin
  114.         ButtonAdd.Enabled := true;
  115.     end
  116.     else
  117.     begin
  118.         ButtonAdd.Enabled := false;
  119.     end;
  120. end;
  121.  
  122. procedure TFormIngredient.Edit4KeyPress(Sender: TObject; var Key: Char);
  123. begin
  124.     if not(Key in ['0'..'9', #8]) then
  125.         Key := #0;
  126. end;
  127.  
  128. procedure TFormIngredient.Edit5Change(Sender: TObject);
  129. begin
  130.     if (Edit2.Text <> '') and (length(Edit1.Text) = 3)
  131.     and (Edit3.Text <> '') and (Edit4.Text <> '') and
  132.     (Edit5.Text <> '') then
  133.     begin
  134.         ButtonAdd.Enabled := true;
  135.     end
  136.     else
  137.     begin
  138.         ButtonAdd.Enabled := false;
  139.     end;
  140. end;
  141.  
  142. procedure TFormIngredient.Edit5KeyPress(Sender: TObject; var Key: Char);
  143. begin
  144.     if not(Key in ['0'..'9', #8]) then
  145.         Key := #0;
  146. end;
  147.  
  148. procedure TFormIngredient.Edit6KeyPress(Sender: TObject; var Key: Char);
  149. begin
  150.     if not(Key in ['0'..'9', #8]) then
  151.         Key := #0;
  152. end;
  153.  
  154. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement