📄 unit3.~pas
字号:
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBTables, ExtCtrls, ADODB, Grids, DBGrids;
type
Tfindreadertype = class(TForm)
Button2: TButton;
Panel1: TPanel;
Edit1: TEdit;
Edit2: TEdit;
DBGrid1: TDBGrid;
button3: TButton;
GroupBox1: TGroupBox;
Label5: TLabel;
Label6: TLabel;
Memo1: TMemo;
Edit5: TEdit;
Label4: TLabel;
Label3: TLabel;
Edit3: TEdit;
Edit4: TEdit;
Button4: TButton;
Button1: TButton;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
ADOTable1: TADOTable;
DataSource1: TDataSource;
procedure Button1Click(Sender: TObject);
procedure button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
findreadertype: Tfindreadertype;
implementation
{$R *.dfm}
procedure Tfindreadertype.Button1Click(Sender: TObject);
begin
edit1.color := clBtnFace;
edit2.color := clBtnFace;
edit1.ReadOnly:=true;
edit2.ReadOnly:=true;
edit3.ReadOnly:=false;
edit4.ReadOnly:=false;
edit5.ReadOnly:=false;
memo1.ReadOnly:=false;
edit3.color := clBtnHighlight;
edit4.color := clBtnHighlight;
edit5.color := clBtnHighlight;
memo1.color := clBtnHighlight;
edit2.Text:=adotable1.fieldbyname('rt_typename').asstring;
edit1.Text:=adotable1.fieldbyname('rt_typeno').asstring;
edit3.Text:=adotable1.fieldbyname('rt_booknumber').asstring;
edit4.Text:=adotable1.fieldbyname('rt_bookdays').asstring;
edit5.Text:=adotable1.fieldbyname('rt_userfullife').asstring;
memo1.Text:=adotable1.fieldbyname('rt_typememo').asstring;
end;
procedure Tfindreadertype.button3Click(Sender: TObject);
begin
if edit1.Text='' then showmessage('编号不可为空')
else if edit2.Text='' then showmessage('姓名不可为空')
else if edit3.Text ='' then showmessage('数量不可为空')
else if edit4.Text ='' then showmessage('借书期限不可为空')
else if edit5.Text ='' then showmessage('有效期限不可为空')
else begin
adotable1.Active:=true;
adotable1.Edit;
adotable1.fieldbyname('RT_booknumber').AsString:=edit3.Text;
adotable1.fieldbyname('RT_bookdays').AsString:=edit4.Text;
adotable1.fieldbyname('RT_userfullife').AsString:=edit5.Text;
adotable1.fieldbyname('RT_typememo').AsString:=memo1.Text;
adotable1.Post;
adotable1.active:=false;
adotable1.active:=true;
showmessage('ok');
edit3.color := clBtnFace;
edit4.color := clBtnFace;
edit5.color := clBtnFace;
memo1.Color:= clBtnFace;
edit1.color := clBtnHighlight;
edit2.color := clBtnHighlight;
edit3.ReadOnly:=true;
edit4.ReadOnly:=true;
edit5.ReadOnly:=true;
end;
end;
procedure Tfindreadertype.Button4Click(Sender: TObject);
begin
adotable1.Active:= false;
adotable1.Active:= true;
if RadioButton1.Checked then
if not adotable1.Locate('rt_typeno',edit1.Text,[]) then
begin
showmessage('没有该编号,请重新输入');
edit1.Text:='';
edit2.Text:='';
end
else
begin
edit2.Text:=adotable1.fieldbyname('rt_typename').asstring;
edit3.Text:=adotable1.fieldbyname('rt_booknumber').asstring;
edit4.Text:=adotable1.fieldbyname('rt_bookdays').asstring;
edit5.Text:=adotable1.fieldbyname('rt_userfullife').asstring;
memo1.Text:=adotable1.fieldbyname('rt_typememo').asstring;
end;
if RadioButton2.Checked then
if not adotable1.Locate('rt_typename',edit2.Text,[]) then
begin
showmessage('没有该名称,请重新输入');
edit1.Text:='';
edit2.Text:='';
end
else
begin
edit2.Text:=adotable1.fieldbyname('rt_typename').asstring;
edit3.Text:=adotable1.fieldbyname('rt_booknumber').asstring;
edit4.Text:=adotable1.fieldbyname('rt_bookdays').asstring;
edit5.Text:=adotable1.fieldbyname('rt_userfullife').asstring;
memo1.Text:=adotable1.fieldbyname('rt_typememo').asstring;
end;
end;
procedure Tfindreadertype.Button2Click(Sender: TObject);
begin
edit1.color := clBtnHighlight;
edit2.color := clBtnHighlight;
edit1.ReadOnly:=false;
edit2.ReadOnly:=false;
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
edit5.Text:='';
memo1.Text:='';
end;
procedure Tfindreadertype.FormShow(Sender: TObject);
begin
ADOTable1.Active :=false;
ADOTable1.Active :=true;
dbgrid1.Columns[0].Title.caption := '种类编号';
dbgrid1.Columns[1].Title.caption := '种类姓名';
dbgrid1.Columns[2].Title.caption := '读者限制借阅本数';
dbgrid1.Columns[3].Title.caption := '借阅有效日期(月)';
dbgrid1.Columns[4].Title.caption := '读者借阅年限(年)';
dbgrid1.Columns[5].Title.caption := '备注';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -