Форма выполнения запросов и жесткого поиска
unit Unit6;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Buttons, StdCtrls, jpeg, ExtCtrls, DBCtrls, Grids, DBGrids, ShellAPI, comobj;
type TForm6 = class(TForm) DBGrid1: TDBGrid; DBGrid2: TDBGrid; DBNavigator1: TDBNavigator; DBNavigator2: TDBNavigator; GroupBox1: TGroupBox; RadioButton1: TRadioButton; RadioButton2: TRadioButton; RadioButton3: TRadioButton; Edit1: TEdit; ComboBox1: TComboBox; Label1: TLabel; RadioButton4: TRadioButton; Button1: TButton; Image1: TImage; Button2: TButton; procedure SpeedButton1Click(Sender: TObject); procedure FormActivate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Edit1Change(Sender: TObject); procedure ComboBox1Change(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form6: TForm6;
implementation
uses Unit1, Unit3, Unit5, Unit2;
{$R *.dfm}
procedure TForm6.Button1Click(Sender: TObject); var x,c,s:variant; i,index: integer; j: Integer; begin x:=createOleObject('Excel.Application'); x.Visible:=true; x.WorkBooks.Add(-4167); x.WorkBooks[1].WorkSheets[1].Name:='Beautymania'; c:=x.WorkBooks[1].WorkSheets['Beautymania'].Columns; c.columns[1].ColumnWidth:=5; c.columns[2].ColumnWidth:=20; c.columns[3].ColumnWidth:=20; c.columns[4].ColumnWidth:=20; c.columns[5].ColumnWidth:=8; c.columns[6].ColumnWidth:=7; c.columns[7].ColumnWidth:=250; s:=x.WorkBooks[1].WorkSheets['Beautymania']; s.cells[2,1]:='Код'; s.cells[2,2]:='Название'; s.cells[2,3]:='Фирма'; s.cells[2,4]:='Адрес'; s.cells[2,5]:='Телефон'; s.cells[2,6]:='Цена'; s.cells[2,7]:='Примечание'; c:=x.WorkBooks[1].WorkSheets['Beautymania'].Rows; c.Rows[2].Font.Size:=12; c.Rows[2].Font.Color:=clblue; c.Rows[2].Font.Bold:=true; c.Rows[2].Font.Italic:=true; index:=3; Data.ADOQuery1.First; for i:= 0 to Data.AdoQuery1.RecordCount - 1 do begin for j:= 1 to 7 do s.cells[index,j]:=Data.AdoQuery1.Fields.Fields[j-1].AsString; inc(index); Data.AdoQuery1.Next;
end;
end;
procedure TForm6.Button2Click(Sender: TObject); begin ShellExecute(0,nil,pchar(ExtractFilePath(Application.ExeName)+'NewProject.chm'),nil,nil,sw_shownormal); end;
procedure TForm6.ComboBox1Change(Sender: TObject); begin case Combobox1.ItemIndex of 0: begin DBGrid2.DataSource:=Data.DataSource10; DBNavigator2.DataSource:=Data.DataSource10; end; 1: begin DBGrid2.DataSource:=Data.DataSource9; DBNavigator2.DataSource:=Data.DataSource9; end; 2: begin DBGrid2.DataSource:=Data.DataSource12; DBNavigator2.DataSource:=Data.DataSource12; end; end;
end;
procedure TForm6.Edit1Change(Sender: TObject); begin DBGrid2.DataSource:=Data.DataSource11; DBNavigator2.DataSource:=Data.DataSource11; begin if RadioButton1.Checked then begin Data.ADOQuery1.Active:=false; Data.ADOQuery1.SQL.Clear; Data.ADOQuery1.SQL.ADD('Select *'); Data.ADOQuery1.SQL.ADD('FROM Общая'); Data.ADOQuery1.SQL.ADD('where Адрес Like('+#39+Edit1.Text+'%'+#39+')'); Data.ADOQuery1.Active:=true; end; if RadioButton2.Checked then begin Data.ADOQuery1.Active:=false; Data.ADOQuery1.SQL.Clear; Data.ADOQuery1.SQL.ADD('Select *'); Data.ADOQuery1.SQL.ADD('FROM Общая'); Data.ADOQuery1.SQL.ADD('where Название Like('+#39+Edit1.Text+'%'+#39+')'); Data.ADOQuery1.Active:=true; end; if RadioButton3.Checked then begin Data.ADOQuery1.Active:=false; Data.ADOQuery1.SQL.Clear; Data.ADOQuery1.SQL.ADD('Select *'); Data.ADOQuery1.SQL.ADD('FROM Общая'); Data.ADOQuery1.SQL.ADD('where Фирма Like('+#39+Edit1.Text+'%'+#39+')'); Data.ADOQuery1.Active:=true; end; if RadioButton4.Checked then begin Data.ADOQuery1.Active:=false; Data.ADOQuery1.SQL.Clear; Data.ADOQuery1.SQL.ADD('Select *'); Data.ADOQuery1.SQL.ADD('FROM Общая'); Data.ADOQuery1.SQL.ADD('where Телефон Like('+#39+Edit1.Text+'%'+#39+')'); Data.ADOQuery1.Active:=true; end; end;
end;
procedure TForm6.FormActivate(Sender: TObject); begin Form2.Visible:=False; end;
procedure TForm6.FormClose(Sender: TObject; var Action: TCloseAction); begin Form2.Visible:=True; end;
procedure TForm6.SpeedButton1Click(Sender: TObject); begin Form1.visible:=True; Form1.Show; Form6.Visible:=False; end;
end.
|