unit_info_search.~pas

来自「美汇美容网网站管理系统」· ~PAS 代码 · 共 90 行

~PAS
90
字号
unit Unit_info_Search;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, 
  Buttons, ExtCtrls, CheckLst, XPMenu,unit_dm;

type
  TForm_info_Search = class(TForm)
    OKBtn: TButton;
    CancelBtn: TButton;
    Bevel1: TBevel;
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    CheckListBox1: TCheckListBox;
    XPMenu1: TXPMenu;
    procedure OKBtnClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form_info_Search: TForm_info_Search;

implementation

{$R *.dfm}

procedure TForm_info_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 news_info';
  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:='vCaption';
      if checklistbox1.Items.Strings[i]='内容' then fieldstr:='tContent';
      if checklistbox1.Items.Strings[i]='日期' then fieldstr:='dDate';
      if checklistbox1.Items.Strings[i]='类型' then fieldstr:='vType';
      if checklistbox1.Items.Strings[i]='链接' then fieldstr:='vLink';

      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.adsInfo do
  begin
    close;
    commandtext:=sql+' where '+wherestr;
    open;
  end;

  close;

end;

procedure TForm_info_Search.FormCreate(Sender: TObject);
begin
  Self.Left:= Round(Screen.Width/2-Width/2);
  Self.Top :=Round(Screen.Height/2-Height/2);
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?