unit Unit7;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, ADODB, Grids, DBGrids, StdCtrls;

type
  TForm7 = class(TForm)
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    ADOTable1: TADOTable;
    ADOTable1_: TWideStringField;
    ADOTable1_2: TWideStringField;
    ADOTable1_3: TIntegerField;
    ADOTable1_4: TIntegerField;
    ADOTable1__1_: TIntegerField;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    GroupBox2: TGroupBox;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    GroupBox3: TGroupBox;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Edit1Change(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form7: TForm7;

implementation

uses Unit9;

{$R *.dfm}

procedure TForm7.Edit1Change(Sender: TObject);
begin
if Length(Edit1.Text) > 0 then
begin
ADOTable1.Filtered:=false;
ADOTable1.Filter:='Наименование_Поставищика LIKE ' + #39 + Edit1.Text + '%' + #39;
ADOTable1.Filtered:=true;
end
else ADOTable1.Filtered:=false;
end;

procedure TForm7.Edit2Change(Sender: TObject);
begin
if Length(Edit2.Text) > 0 then
begin
ADOTable1.Filtered:=false;
ADOTable1.Filter:='№_Заказа=' + #39 + Edit2.text + #39;
ADOTable1.Filtered:=true;
end
else ADOTable1.Filtered:=false;
end;

//Вкл-Выкл режим редактирования

procedure TForm7.Button3Click(Sender: TObject);
begin
if DBGrid1.ReadOnly = True then
  begin
  Button3.Caption:='Выключить режим редактирования';
  DBGrid1.ReadOnly:= False;
  end
else
  Begin
  DBGrid1.ReadOnly:=True;
  Button3.Caption:='Включить режим редактирования';
  end
end;



//Удаление

procedure TForm7.Button1Click(Sender: TObject);
begin
if MessageDlg('Вы действительно хотите удалить запись?', mtConfirmation, [mbOk, mbCancel], 0) = mrCancel
then
begin
Button1.SetFocus;
end
else
ADOTable1.Delete;
end;

procedure TForm7.Button2Click(Sender: TObject);
begin
Form9.ShowModal;
end;

end.
