unit3.~pas

来自「是用DELPHI编写的图书管理系统」· ~PAS 代码 · 共 144 行

~PAS
144
字号
unit Unit3;

interface

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

type
  TFormdzcx = class(TForm)
    DBGriddzcx: TDBGrid;
    Panel1: TPanel;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    ComboBoxgjz: TComboBox;
    Label2: TLabel;
    Editgjz: TEdit;
    btncx: TButton;
    btnfh: TButton;
    Querydzcx: TQuery;
    DataSourcedzcx: TDataSource;
    procedure btncxClick(Sender: TObject);
    procedure btnfhClick(Sender: TObject);
    procedure ComboBoxgjzChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Formdzcx: TFormdzcx;

implementation

{$R *.dfm}

procedure TFormdzcx.btncxClick(Sender: TObject);

  var gjz,gjzsz:string;
begin
gjz:=comboboxgjz.Text ;
gjzsz:=editgjz.Text ;
if(gjz=' ')and(gjzsz=' ') then
  with querydzcx do
     begin
     close;
     sql.Clear ;
     sql.Add('select *');
     sql.Add('from dzmc');
     sql.Add('order by 借书证号');
     prepare;
     open;
     end
  else if(gjz<>'')and(gjzsz='') then
     showmessage('请输入“查询关键字设置”信息!!!' )
  else if(gjz='')and(gjzsz<>'') then
     showmessage('请输入“查询关键字选择”信息!!!' )
 else
  begin
   gjzsz:=gjzsz+'%';
   if gjz='借书证号' then
     with querydzcx do
     begin
     close;
     sql.Clear ;
     sql.Add('select *');
     sql.Add('from dzmc');
     sql.Add('where 借书证号 like:gjzszname')  ;
     sql.Add('order by 借书证号');
     parambyname('gjzszname').AsString :=gjzsz;
     prepare;
     open;
     end
  else if gjz='读者姓名' then
     with querydzcx do
     begin
     close;
     sql.Clear ;
     sql.Add('select *');
     sql.Add('from dzmc');
     sql.Add('where 读者姓名 like:gjzszname')  ;
     sql.Add('order by 借书证号');
     parambyname('gjzszname').AsString :=gjzsz;
     prepare;
     open;
     end

  else if gjz='读者性别' then
     with querydzcx do
     begin
     close;
     sql.Clear ;
     sql.Add('select *');
     sql.Add('from dzmc');
     sql.Add('where 读者性别 like:gjzszname')  ;
     sql.Add('order by 借书证号');
     parambyname('gjzszname').AsString :=gjzsz;
     prepare;
     open;
     end
 else if gjz='读者职业' then
     with querydzcx do
     begin
     close;
     sql.Clear ;
     sql.Add('select *');
     sql.Add('from dzmc');
     sql.Add('where 读者职业 like:gjzszname')  ;
     sql.Add('order by 借书证号');
     parambyname('gjzszname').AsString :=gjzsz;
     prepare;
     open;
     end
 else if gjz='读者单位' then
     with querydzcx do
     begin
     close;
     sql.Clear ;
     sql.Add('select *');
     sql.Add('from dzmc');
     sql.Add('where 读者单位 like:gjzszname')  ;
     sql.Add('order by 借书证号');
     parambyname('gjzszname').AsString :=gjzsz;
     prepare;
     open;
     end ;
     end;


end;

procedure TFormdzcx.btnfhClick(Sender: TObject);
begin
close;
end;

procedure TFormdzcx.ComboBoxgjzChange(Sender: TObject);
begin
editgjz.Text :='';
end;

end.

⌨️ 快捷键说明

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