unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    N4: TMenuItem;
    N5: TMenuItem;
    N6: TMenuItem;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Label2: TLabel;
    ADOTable1: TADOTable;
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    Label1: TLabel;
    GroupBox2: TGroupBox;
    Button1: TButton;
    Label3: TLabel;
    Label4: TLabel;
    N9: TMenuItem;
    XPManifest1: TXPManifest;
    GroupBox3: TGroupBox;
    Label5: TLabel;
    Button2: TButton;
    ADOTable1_: TIntegerField;
    ADOTable1_2: TIntegerField;
    ADOTable1DSDesigner2: TWideStringField;
    ADOTable1DSDesigner3: TIntegerField;
    Edit2: TMenuItem;
    N11: TMenuItem;
    Repeatcommand1: TMenuItem;
    Undo1: TMenuItem;
    N7: TMenuItem;
    N8: TMenuItem;
    N12: TMenuItem;
    N13: TMenuItem;
    N14: TMenuItem;
    N15: TMenuItem;
    procedure N2Click(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure N6Click(Sender: TObject);
    procedure DBGrid1CellClick(Column: TColumn);
    procedure FormActivate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Undo1Click(Sender: TObject);
    procedure Repeatcommand1Click(Sender: TObject);
    procedure N5Click(Sender: TObject);
    procedure N7Click(Sender: TObject);
    procedure N8Click(Sender: TObject);
    procedure N13Click(Sender: TObject);
    procedure N12Click(Sender: TObject);
  
     


  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2, Unit3, Unit4, Unit6, Unit7, Unit8;

{$R *.dfm}


// Выход

procedure TForm1.N2Click(Sender: TObject);
begin
Form1.close;
end;

//Поиск- Сортировка

procedure TForm1.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 TForm1.Button1Click(Sender: TObject);
begin
if DBGrid1.ReadOnly = True then
  begin
  Button1.Caption:='Выключить режим редактирования';
  Label4.Visible:=True;
  Label4.Caption:='ВКЛЮЧЕНО!!!';
  Label4.Font.Color:= clRed;
  DBGrid1.ReadOnly:= False;
  end
else
  Begin
  DBGrid1.ReadOnly:=True;
  Button1.Caption:='Включить режим редактирования';
  Label4.Visible:=False;

  end
end;


//Добавление

procedure TForm1.N6Click(Sender: TObject);
begin
Form2.ShowModal;
end;

//хз что

procedure TForm1.DBGrid1CellClick(Column: TColumn);
begin
Form1.SetFocus;
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
ADOTable1.First;
end;

//Удаление

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

//Сортировка

procedure TForm1.Undo1Click(Sender: TObject);
begin
ADOTable1.IndexFieldNames:='Наименование';
end;

procedure TForm1.Repeatcommand1Click(Sender: TObject);
begin
ADOTable1.IndexFieldNames:='№_Товара';
end;

//О программе
procedure TForm1.N5Click(Sender: TObject);
begin
Form3.ShowModal;
end;

// Покупатели
procedure TForm1.N7Click(Sender: TObject);
begin
Form4.ShowModal;
end;

procedure TForm1.N8Click(Sender: TObject);
begin
Form6.ShowModal;
end;

procedure TForm1.N13Click(Sender: TObject);
begin
Form7.ShowModal;
end;

procedure TForm1.N12Click(Sender: TObject);
begin
Form8.ShowModal;
end;

end.
