?? kehu.~pas
字號:
unit kehu;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, Grids, DBGrids, Menus, StdCtrls, ExtCtrls,
DB, ADODB;
type
TFormkehu = class(TForm)
PageControl1: TPageControl;
MainMenu1: TMainMenu;
Q1: TMenuItem;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
ToolButton7: TToolButton;
ToolButton9: TToolButton;
DBGrid1: TDBGrid;
StringGrid1: TStringGrid;
Panel1: TPanel;
GroupBox1: TGroupBox;
Edit1: TEdit;
Button1: TButton;
Edit2: TEdit;
Button2: TButton;
Edit3: TEdit;
Button3: TButton;
Edit4: TEdit;
Button4: TButton;
DataSource1: TDataSource;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
procedure Q1Click(Sender: TObject);
procedure ToolButton9Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Formkehu: TFormkehu;
implementation
uses datamodel;
{$R *.dfm}
procedure TFormkehu.Q1Click(Sender: TObject);
begin
close;
end;
procedure TFormkehu.ToolButton9Click(Sender: TObject);
begin
ADOQuery2.Close;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select * from 客戶');
ADOQuery2.Open;
end;
procedure TFormkehu.ToolButton1Click(Sender: TObject);
begin
DataSource1.DataSet.First;
end;
procedure TFormkehu.ToolButton2Click(Sender: TObject);
begin
DataSource1.DataSet.Prior;
end;
procedure TFormkehu.ToolButton3Click(Sender: TObject);
begin
DataSource1.DataSet.Next;
end;
procedure TFormkehu.ToolButton4Click(Sender: TObject);
begin
DataSource1.DataSet.Last;
end;
procedure TFormkehu.ToolButton5Click(Sender: TObject);
begin
DataSource1.DataSet.Insert;
end;
procedure TFormkehu.ToolButton6Click(Sender: TObject);
begin
DataSource1.DataSet.Delete;
end;
procedure TFormkehu.Button1Click(Sender: TObject);
var
i,j:integer;
begin
if edit1.Text<>'' then
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from 客戶 where 公司名稱 like ''%'+edit1.Text+'%''');
ADOQuery1.Open;
for i:=1 to 100 do
for j:=0 to 100 do
stringgrid1.Cells[i,j]:='';
i:=1;
// recordnum:=0;
while not ADOQuery1.Eof do
begin
//設置列寬
stringgrid1.ColWidths[0]:=32;
stringgrid1.ColWidths[2]:=128;
stringgrid1.ColWidths[4]:=128;
stringgrid1.ColWidths[7]:=128;
stringgrid1.ColWidths[9]:=128;
//----顯示查詢-------////
stringgrid1.Cells[0,0]:='客戶ID';
stringgrid1.Cells[1,0]:='客戶類別';
stringgrid1.Cells[2,0]:='公司名稱';
stringgrid1.Cells[3,0]:='聯系人';
stringgrid1.Cells[4,0]:='地址';
stringgrid1.Cells[5,0]:='電話號碼';
stringgrid1.Cells[6,0]:='傳真號碼';
stringgrid1.Cells[7,0]:='電子郵件地址';
stringgrid1.Cells[8,0]:='開戶行';
stringgrid1.Cells[9,0]:='銀行賬號';
stringgrid1.Cells[10,0]:='客戶信譽統計';
stringgrid1.Cells[11,0]:='客戶等級管理';
stringgrid1.Cells[0,i]:=ADOQuery1.Fieldbyname('客戶ID').AsString;
stringgrid1.Cells[2,i]:=ADOQuery1.Fieldbyname('公司名稱').AsString;
stringgrid1.Cells[3,i]:=ADOQuery1.Fieldbyname('聯系人名字').AsString;
stringgrid1.Cells[4,i]:=ADOQuery1.Fieldbyname('地址').AsString;
stringgrid1.Cells[5,i]:=ADOQuery1.Fieldbyname('電話號碼').AsString;
stringgrid1.Cells[6,i]:=ADOQuery1.Fieldbyname('傳真號碼').AsString;
stringgrid1.Cells[7,i]:=ADOQuery1.Fieldbyname('電子郵件地址').AsString;
stringgrid1.Cells[8,i]:=ADOQuery1.Fieldbyname('開戶行').AsString;
stringgrid1.Cells[9,i]:=ADOQuery1.Fieldbyname('銀行賬號').AsString;
stringgrid1.Cells[10,i]:=ADOQuery1.Fieldbyname('客戶信譽統計').AsString;
stringgrid1.Cells[11,i]:=ADOQuery1.Fieldbyname('客戶等級管理').AsString;
i:=i+1;
// recordnum:=recordnum+1;
ADOQuery1.Next;
end;
if edit1.Text='' then
showmessage('你輸入的信息為空');
end;
procedure TFormkehu.Button3Click(Sender: TObject);
var
i,j:integer;
begin
if edit3.Text<>'' then
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from 客戶 where 客戶等級 like ''%'+edit3.Text+'%''');
ADOQuery1.Open;
for i:=1 to 100 do
for j:=0 to 100 do
stringgrid1.Cells[i,j]:='';
i:=1;
// recordnum:=0;
while not ADOQuery1.Eof do
begin
//設置列寬
stringgrid1.ColWidths[0]:=32;
stringgrid1.ColWidths[2]:=128;
stringgrid1.ColWidths[4]:=128;
stringgrid1.ColWidths[7]:=128;
stringgrid1.ColWidths[9]:=128;
//----顯示查詢-------////
stringgrid1.Cells[0,0]:='客戶ID';
stringgrid1.Cells[1,0]:='客戶類別';
stringgrid1.Cells[2,0]:='公司名稱';
stringgrid1.Cells[3,0]:='聯系人';
stringgrid1.Cells[4,0]:='地址';
stringgrid1.Cells[5,0]:='電話號碼';
stringgrid1.Cells[6,0]:='傳真號碼';
stringgrid1.Cells[7,0]:='電子郵件地址';
stringgrid1.Cells[8,0]:='開戶行';
stringgrid1.Cells[9,0]:='銀行賬號';
stringgrid1.Cells[10,0]:='客戶信譽統計';
stringgrid1.Cells[11,0]:='客戶等級管理';
stringgrid1.Cells[0,i]:=ADOQuery1.Fieldbyname('客戶ID').AsString;
stringgrid1.Cells[2,i]:=ADOQuery1.Fieldbyname('公司名稱').AsString;
stringgrid1.Cells[3,i]:=ADOQuery1.Fieldbyname('聯系人名字').AsString;
stringgrid1.Cells[4,i]:=ADOQuery1.Fieldbyname('地址').AsString;
stringgrid1.Cells[5,i]:=ADOQuery1.Fieldbyname('電話號碼').AsString;
stringgrid1.Cells[6,i]:=ADOQuery1.Fieldbyname('傳真號碼').AsString;
stringgrid1.Cells[7,i]:=ADOQuery1.Fieldbyname('電子郵件地址').AsString;
stringgrid1.Cells[8,i]:=ADOQuery1.Fieldbyname('開戶行').AsString;
stringgrid1.Cells[9,i]:=ADOQuery1.Fieldbyname('銀行賬號').AsString;
stringgrid1.Cells[10,i]:=ADOQuery1.Fieldbyname('客戶信譽統計').AsString;
stringgrid1.Cells[11,i]:=ADOQuery1.Fieldbyname('客戶等級管理').AsString;
i:=i+1;
// recordnum:=recordnum+1;
ADOQuery1.Next;
end;
if edit1.Text='' then
showmessage('你輸入的信息為空');
end;
procedure TFormkehu.Button2Click(Sender: TObject);
var
i,j:integer;
begin
if edit2.Text<>'' then
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from 客戶 where 地址 like ''%'+edit2.Text+'%''');
ADOQuery1.Open;
for i:=1 to 100 do
for j:=0 to 100 do
stringgrid1.Cells[i,j]:='';
i:=1;
// recordnum:=0;
while not ADOQuery1.Eof do
begin
//設置列寬
stringgrid1.ColWidths[0]:=32;
stringgrid1.ColWidths[2]:=128;
stringgrid1.ColWidths[4]:=128;
stringgrid1.ColWidths[7]:=128;
stringgrid1.ColWidths[9]:=128;
//----顯示查詢-------////
stringgrid1.Cells[0,0]:='客戶ID';
stringgrid1.Cells[1,0]:='客戶類別';
stringgrid1.Cells[2,0]:='公司名稱';
stringgrid1.Cells[3,0]:='聯系人';
stringgrid1.Cells[4,0]:='地址';
stringgrid1.Cells[5,0]:='電話號碼';
stringgrid1.Cells[6,0]:='傳真號碼';
stringgrid1.Cells[7,0]:='電子郵件地址';
stringgrid1.Cells[8,0]:='開戶行';
stringgrid1.Cells[9,0]:='銀行賬號';
stringgrid1.Cells[10,0]:='客戶信譽統計';
stringgrid1.Cells[11,0]:='客戶等級管理';
stringgrid1.Cells[0,i]:=ADOQuery1.Fieldbyname('客戶ID').AsString;
stringgrid1.Cells[2,i]:=ADOQuery1.Fieldbyname('公司名稱').AsString;
stringgrid1.Cells[3,i]:=ADOQuery1.Fieldbyname('聯系人名字').AsString;
stringgrid1.Cells[4,i]:=ADOQuery1.Fieldbyname('地址').AsString;
stringgrid1.Cells[5,i]:=ADOQuery1.Fieldbyname('電話號碼').AsString;
stringgrid1.Cells[6,i]:=ADOQuery1.Fieldbyname('傳真號碼').AsString;
stringgrid1.Cells[7,i]:=ADOQuery1.Fieldbyname('電子郵件地址').AsString;
stringgrid1.Cells[8,i]:=ADOQuery1.Fieldbyname('開戶行').AsString;
stringgrid1.Cells[9,i]:=ADOQuery1.Fieldbyname('銀行賬號').AsString;
stringgrid1.Cells[10,i]:=ADOQuery1.Fieldbyname('客戶信譽統計').AsString;
stringgrid1.Cells[11,i]:=ADOQuery1.Fieldbyname('客戶等級管理').AsString;
i:=i+1;
// recordnum:=recordnum+1;
ADOQuery1.Next;
end;
if edit1.Text='' then
showmessage('你輸入的信息為空');
end;
procedure TFormkehu.Button4Click(Sender: TObject);
var
i,j:integer;
begin
if edit4.Text<>'' then
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from 客戶 where 聯系人名字 like ''%'+edit4.Text+'%''');
ADOQuery1.Open;
for i:=1 to 100 do
for j:=0 to 100 do
stringgrid1.Cells[i,j]:='';
i:=1;
// recordnum:=0;
while not ADOQuery1.Eof do
begin
//設置列寬
stringgrid1.ColWidths[0]:=32;
stringgrid1.ColWidths[2]:=128;
stringgrid1.ColWidths[4]:=128;
stringgrid1.ColWidths[7]:=128;
stringgrid1.ColWidths[9]:=128;
//----顯示查詢-------////
stringgrid1.Cells[0,0]:='客戶ID';
stringgrid1.Cells[1,0]:='客戶類別';
stringgrid1.Cells[2,0]:='公司名稱';
stringgrid1.Cells[3,0]:='聯系人';
stringgrid1.Cells[4,0]:='地址';
stringgrid1.Cells[5,0]:='電話號碼';
stringgrid1.Cells[6,0]:='傳真號碼';
stringgrid1.Cells[7,0]:='電子郵件地址';
stringgrid1.Cells[8,0]:='開戶行';
stringgrid1.Cells[9,0]:='銀行賬號';
stringgrid1.Cells[10,0]:='客戶信譽統計';
stringgrid1.Cells[11,0]:='客戶等級管理';
stringgrid1.Cells[0,i]:=ADOQuery1.Fieldbyname('客戶ID').AsString;
stringgrid1.Cells[2,i]:=ADOQuery1.Fieldbyname('公司名稱').AsString;
stringgrid1.Cells[3,i]:=ADOQuery1.Fieldbyname('聯系人名字').AsString;
stringgrid1.Cells[4,i]:=ADOQuery1.Fieldbyname('地址').AsString;
stringgrid1.Cells[5,i]:=ADOQuery1.Fieldbyname('電話號碼').AsString;
stringgrid1.Cells[6,i]:=ADOQuery1.Fieldbyname('傳真號碼').AsString;
stringgrid1.Cells[7,i]:=ADOQuery1.Fieldbyname('電子郵件地址').AsString;
stringgrid1.Cells[8,i]:=ADOQuery1.Fieldbyname('開戶行').AsString;
stringgrid1.Cells[9,i]:=ADOQuery1.Fieldbyname('銀行賬號').AsString;
stringgrid1.Cells[10,i]:=ADOQuery1.Fieldbyname('客戶信譽統計').AsString;
stringgrid1.Cells[11,i]:=ADOQuery1.Fieldbyname('客戶等級管理').AsString;
i:=i+1;
// recordnum:=recordnum+1;
ADOQuery1.Next;
end;
if edit1.Text='' then
showmessage('你輸入的信息為空');
end;
procedure TFormkehu.FormCreate(Sender: TObject);
begin
stringgrid1.Cells[0,0]:='客戶ID';
stringgrid1.Cells[1,0]:='客戶類別';
stringgrid1.Cells[2,0]:='公司名稱';
stringgrid1.Cells[3,0]:='聯系人';
stringgrid1.Cells[4,0]:='地址';
stringgrid1.Cells[5,0]:='電話號碼';
stringgrid1.Cells[6,0]:='傳真號碼';
stringgrid1.Cells[7,0]:='電子郵件地址';
stringgrid1.Cells[8,0]:='開戶行';
stringgrid1.Cells[9,0]:='銀行賬號';
stringgrid1.Cells[10,0]:='客戶信譽統計';
stringgrid1.Cells[11,0]:='客戶等級管理';
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -