unit_goods_search.pas
来自「美汇美容网网站管理系统」· PAS 代码 · 共 98 行
PAS
98 行
unit Unit_Goods_Search;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, XPMenu, StdCtrls, CheckLst, ExtCtrls;
type
TForm_Goods_Search = class(TForm)
Bevel1: TBevel;
Label1: TLabel;
Label2: TLabel;
OKBtn: TButton;
CancelBtn: TButton;
Edit1: TEdit;
CheckListBox1: TCheckListBox;
XPMenu1: TXPMenu;
procedure CancelBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure OKBtnClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form_Goods_Search: TForm_Goods_Search;
implementation
uses Unit_DM;
{$R *.dfm}
procedure TForm_Goods_Search.CancelBtnClick(Sender: TObject);
begin
close;
end;
procedure TForm_Goods_Search.FormCreate(Sender: TObject);
begin
Self.Left:= Round(Screen.Width/2-Width/2);
Self.Top :=Round(Screen.Height/2-Height/2);
end;
procedure TForm_Goods_Search.OKBtnClick(Sender: TObject);
var
sql,whereStr,fieldstr:String;
i:integer;
begin
if length(edit1.Text)<1 then
begin
application.MessageBox('请输入搜索内容.','提示',MB_OK);
edit1.SetFocus;
exit;
end;
sql:='select * from goods';
whereStr:='';
fieldstr:='';
for i:=0 to checklistbox1.Items.Count-1 do
begin
if checklistbox1.Checked[i] then
begin
if checklistbox1.Items.Strings[i]='商品编号' then fieldstr:='vSN';
if checklistbox1.Items.Strings[i]='商品名称' then fieldstr:='vName';
if checklistbox1.Items.Strings[i]='生产厂家' then fieldstr:='vProducer';
if checklistbox1.Items.Strings[i]='商品介绍' then fieldstr:='vIntro';
if length(whereStr)<1 then
whereStr:=fieldstr+' like ''%'+edit1.text+'%'''
else
whereStr:=whereStr+' or '+fieldstr+' like ''%'+edit1.text+'%''';
end;
end;
if length(whereStr)<1 then
begin
application.MessageBox('请输入搜索范围.','提示',MB_OK);
checklistbox1.SetFocus;
exit;
end;
with dm.adsComm do
begin
close;
commandtext:=sql+' where '+wherestr;
open;
end;
close;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?