// назначение группы 1 по шаблону наименования

var Form :TForm;
    Lab :TLabel;
    Edit1 :TEdit;
    Lab2 :TLabel;
    Edit2 :TEdit;
    Bevel,Bevel1 :Tbevel;
    Button1 :Tbutton;
    Button2 :tButton;

begin


  Form := Tform.create(nil);
  try

    begin // создаем форму

      Form.Caption := 'Массовое изменение группы в справочнике товаров';
      Form.BorderStyle := bsDialog;
      Form.Width := 500;
      Form.Height := 200;
      Form.position := poScreenCenter;
      Form.Font.name := 'Tahoma';


      Bevel := tbevel.create(form);
      Bevel.Shape := bsTopLine;
      Bevel.Height := 4;
      Bevel.align := alTop;
      bevel.parent := Form;


      Lab := TLabel.create(form); // удалять не нужно, Form его owner, сам удалит
      Lab.caption := 'Укажите наименование:';
      Lab.font.size := 10;
      Lab.Top := 20;
      Lab.Left := 10;
      Lab.parent := Form;

      Edit1 := TEdit.create(Form);
      Edit1.Top := Lab.Top;
      Edit1.width := 300;
      Edit1.Left := Lab.left + lab.width + 10;
      Edit1.parent := Form;

      Lab2 := TLabel.create(form); // удалять не нужно, Form его owner, сам удалит
      Lab2.caption := 'Укажите код группы:';
      Lab2.font.size := 10;
      Lab2.Top := Lab.Top +Lab.Height + 10;;
      Lab2.Left := 10;
      Lab2.parent := Form;

      Edit2 := TEdit.create(Form);
      Edit2.Top := Lab2.Top;
      Edit2.width := 300;
      Edit2.Left := Edit1.left;
      Edit2.parent := Form;



      Bevel1 := TBevel.create(Form);
      Bevel1.shape := bsTopLine;
      Bevel1.Height := 4;
      Bevel1.Width := Form.clientWidth - 30;
      Bevel1.Left := (Form.ClientWidth - Bevel1.Width) div 2;
      Bevel1.Top := Edit2.Top + Edit2.Height + 20;
      Bevel1.parent := Form;

      Button1 := Tbutton.create(Form);
      Button1.Caption := 'Старт';
      Button1.Width := 70;
      Button1.ModalResult := mrOk;
      Button1.Top := Bevel1.Top + 13;
      button1.Default := true;
      Button1.Parent := Form;


      Button2 := Tbutton.create(Form);
      Button2.Caption := 'Отмена';
      Button2.Width := 70;
      Button2.ModalResult := mrCancel;
      Button2.Top := Button1.top;
      Button2.left := Form.ClientWidth - Button2.Width - 35;
      Button2.Cancel := true;
      Button2.Parent := Form;

      Button1.left := Button2.left - Button1.width - 5;


      Form.clientHeight := Button1.Top + Button1.height + 15;

    end;

    if Form.ShowModal = mrOk
    then begin
      try
        BDEExecSQL('update tovar set gr1 = '+edit2.text+' where upper(name) like :nm' ,[ansiuppercase('%'+edit1.text+'%')],'dbkassa');
        createHinti('Операция проведена успешно');
      except
        showmessage(ExceptMessage);
      end;
    end;
  finally
    Form.free;
  end;


end.
