?? 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 + -