📄 infoquery.pas
字号:
unit InfoQuery;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids;
type
TInfoQueryForm = class(TForm)
GroupBox1: TGroupBox;
DBGrid1: TDBGrid;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Button1: TButton;
Label5: TLabel;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Label3: TLabel;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ComboBox2Change(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
InfoQueryForm: TInfoQueryForm;
DStoCheck ,CheckType : String;
WhatChoosed, count: smallint;
implementation
uses Login, Main, Data, Borrow;
{$R *.dfm}
procedure TInfoQueryForm.FormShow(Sender: TObject);
begin
count := 1;
ComboBox2.Visible := false;
Label3.Visible := false;
Button2.Visible := false;
Button3.Visible := false;
if Main.Choose=12 then //查找图书
begin
DStoCheck := '在库图书';
ComboBox1.Items.Add('图书编号');
ComboBox1.Items.Add('作者');
ComboBox1.Items.Add('书名');
ComboBox1.Items.Add('分类');
ComboBox1.Items.Add('ISBN');
ComboBox1.Items.Add('出版社');
ComboBox1.ItemIndex := 0;
with Data.DataModule.InfoQuery do
begin
Close;
SQL.Clear;
SQL.Add('select * from 在库图书');
Open;
end;
end
else if Main.Choose=13 then //查询人员
begin
ComboBox2.Visible := true;
Label3.Visible := true;
with Data.DataModule.InfoQuery do
begin
Close;
SQL.Clear;
//不能查询超级管理员
if Login.Types='管理员' then
begin
SQL.Add('select * from 管理员 where 工作编号!=');
SQL.Add('9999');
end
else
SQL.Add('select * from 读者');
Open;
end;
end
else if Main.Choose=14 then //本人信息
begin
GroupBox1.Enabled := false;
Button1.Enabled := false;
Button2.Visible := true;
if Login.Types='管理员' then
begin
DStoCheck := '管理员';
CheckType := '工作编号';
end
else
begin
DStoCheck := '读者';
CheckType := '读者证号';
Button3.Visible := true;
end;
with Data.DataModule.InfoQuery do
begin
Close;
SQL.Clear;
SQL.Add('select * from ');
SQL.Add(DStoCheck);
SQL.Add('where ');
SQL.Add(CheckType);
SQL.Add('=');
SQL.Add('''' + Login.UseId + '''');
Open;
end
end;
end;
procedure TInfoQueryForm.Button1Click(Sender: TObject);
begin
//查询显示
with Data.DataModule.InfoQuery do
begin
Close;
SQL.Clear;
SQL.Add('select * from ');
SQL.Add(DStoCheck);
SQL.Add('where ');
SQL.Add(ComboBox1.Text);
SQL.Add('like');
SQL.Add('''' + Edit1.Text + '''');
Open;
end
end;
procedure TInfoQueryForm.ComboBox2Change(Sender: TObject);
begin
//设置组合框选项
if ComboBox2.Text='管理员' then
begin
ComboBox1.Items.Clear;
DStoCheck := '管理员';
ComboBox1.Items.Add('工作编号');
ComboBox1.Items.Add('管理员类型');
ComboBox1.Items.Add('姓名');
ComboBox1.Items.Add('所在单位');
ComboBox1.ItemIndex := 0;
end
else
begin
ComboBox1.Items.Clear;
DStoCheck := '读者';
ComboBox1.Items.Add('读者证号');
ComboBox1.Items.Add('读者类型');
ComboBox1.Items.Add('姓名');
ComboBox1.Items.Add('所在单位');
ComboBox1.ItemIndex := 0;
end
end;
procedure TInfoQueryForm.Button2Click(Sender: TObject);
begin
if count=1 then
begin
Data.DataModule.InforQueryDS.Edit;
Button2.Caption := '提交修改';
count := 2;
end
else
begin
Data.DataModule.InfoQuery.Post;
Button2.Caption := '修改';
count := 1;
end
end;
procedure TInfoQueryForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Edit1.Text := '';
ComboBox1.Items.Clear;
GroupBox1.Enabled := true;
Button1.Enabled := true;
Button2.Visible := false;
ComboBox2.Visible := false;
Label3.Visible := false;
Button2.Visible := false;
end;
procedure TInfoQueryForm.Button3Click(Sender: TObject);
begin
BorrowForm.Show;
InfoQueryForm.Hide;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -