📄 booktypefrm.pas
字号:
unit booktypefrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ButtonFrm, StdCtrls, Buttons, ExtCtrls, Menus;
type
TBooktypeForm = class(Tbuttonform)
GroupBox1: TGroupBox;
Splitter1: TSplitter;
GroupBox2: TGroupBox;
Label1: TLabel;
LBbigtype: TListBox;
Label2: TLabel;
Label3: TLabel;
edBigtypename: TEdit;
BtBAddbigtype: TBitBtn;
BtBbigcancel: TBitBtn;
BtBdelBigtype: TBitBtn;
Label4: TLabel;
CBbigtypelist: TComboBox;
Label5: TLabel;
LBsmalltype: TListBox;
Label6: TLabel;
Edsmalltype: TEdit;
Label7: TLabel;
Edsmalltypename: TEdit;
BtBaddSmalltype: TBitBtn;
BtBsmallcancel: TBitBtn;
BtBdelsmalltype: TBitBtn;
CBbigtype: TComboBox;
procedure FormDestroy(Sender: TObject);
procedure SBcommbtnClick(Sender: TObject);
procedure edBigtypenameKeyPress(Sender: TObject; var Key: Char);
procedure EdsmalltypenameKeyPress(Sender: TObject; var Key: Char);
procedure BtBAddbigtypeClick(Sender: TObject);
procedure BtBdelBigtypeClick(Sender: TObject);
procedure BtBaddSmalltypeClick(Sender: TObject);
procedure BtBdelsmalltypeClick(Sender: TObject);
procedure CBbigtypelistChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BtBsmallcancelClick(Sender: TObject);
procedure EdsmalltypeKeyPress(Sender: TObject; var Key: Char);
procedure BBtnCancelClick(Sender: TObject);
procedure BtBbigcancelClick(Sender: TObject);
procedure BBtnPrintClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
BooktypeForm: TBooktypeForm;
implementation
uses dmfrm, prtbooktypefrm;
{$R *.dfm}
procedure TBooktypeForm.FormDestroy(Sender: TObject);
begin
inherited;
BooktypeForm:=nil;
end;
procedure TBooktypeForm.SBcommbtnClick(Sender: TObject);
begin
inherited;
// showmessage(booktypeForm.SBcommbtn.Parent.ClassName);
end;
procedure TBooktypeForm.edBigtypenameKeyPress(Sender: TObject;
var Key: Char);
begin
inherited;
if key=#13 then BtBAddbigtype.SetFocus;
end;
procedure TBooktypeForm.EdsmalltypenameKeyPress(Sender: TObject;
var Key: Char);
begin
inherited;
if key=#13 then BtBaddSmalltype.SetFocus;
end;
procedure TBooktypeForm.BtBAddbigtypeClick(Sender: TObject);
begin
inherited;
if CBbigtype.Text=Emptystr then
begin
bookInformation('请选择新增的大类编号!');
CBbigtype.SetFocus;
exit;
end;
if edBigtypename.Text=Emptystr then
begin
bookInformation('请输入新增的大类名称!');
edBigtypename.SetFocus;
exit;
end;
//Add bigtype mothed
if not DMbook.addbigtype(CBbigtype.Text,edBigtypename.Text) then
begin
bookError('新增大类失败!');
edBigtypename.Clear;
CBbigtype.SetFocus;
exit;
end;
LBbigtype.Items.Add(CBbigtype.Text+'-'+edBigtypename.Text);
CBbigtypelist.Items.Add(CBbigtype.Text+'-'+edBigtypename.Text);
CBbigtype.DeleteSelected;
edBigtypename.Clear;
end;
procedure TBooktypeForm.BtBdelBigtypeClick(Sender: TObject);
var
delstring:string;
begin
inherited;
if LBbigtype.ItemIndex=-1 then
begin
bookInformation('请选择需要删除的大类!');
LBbigtype.SetFocus;
exit;
end;
delstring:=LBbigtype.Items.Strings[LBbigtype.itemindex];
delstring:=copy(delstring,1,pos('-',delstring)-1);
if bookWarning('如果你要删除该大类,蒋会导致数据库中属该大类'+#13
+'的图书信息都会丢失,你应检查该大类是否是空大类.'+#13+'真的要删除吗?')=mrYes then
begin
//delete bigtype modth
// showmessage(delstring);
if not DMbook.deletebigtype(delstring) then
begin
bookError('删除大类失败!');
exit;
end;
CBbigtypelist.Items.Delete(CBbigtypelist.Items.IndexOf(LBbigtype.Items.Strings[LBbigtype.ItemIndex]));
LBbigtype.DeleteSelected;
CBbigtype.Items.Add(delstring);
end;
end;
procedure TBooktypeForm.BtBaddSmalltypeClick(Sender: TObject);
var
Astring,Astring1:string;
i:integer;
begin
inherited;
if CBbigtypelist.Text=Emptystr then
begin
bookInformation('请选择大类!');
CBbigtypelist.SetFocus;
exit;
end;
if Edsmalltype.Text=Emptystr then
begin
bookInformation('请输入需新增的小类编号!');
Edsmalltype.SetFocus;
exit;
end;
if Edsmalltypename.Text=Emptystr then
begin
bookInformation('请输入需新增的小类名称!');
Edsmalltypename.SetFocus;
exit;
end;
Astring1:=copy(CBbigtypelist.Text,1,pos('-',CBbigtypelist.Text)-1);
Astring:=Astring1+Edsmalltype.Text;
for i:=0 to LBsmalltype.Count-1 do
begin
if copy(LBsmalltype.Items.Strings[i],1,pos('-',LBsmalltype.Items.Strings[i])-1)=Astring then
begin
bookInformation('新增的小类编号已存在!');
Edsmalltype.Clear;
Edsmalltypename.Clear;
Edsmalltype.SetFocus;
exit;
end;
end;
Astring:=Astring+'-'+Edsmalltypename.Text;
LBsmalltype.Items.Add(Astring);
//add smalltype modth
if not DMbook.addsmalltype(Astring1,Astring1+edsmalltype.Text,edsmalltypename.Text) then
begin
bookError('新增小类失败!');
edsmalltypename.Clear;
edsmalltype.Clear;
edsmalltype.SetFocus;
exit;
end;
Edsmalltype.Clear;
Edsmalltypename.Clear;
Edsmalltype.SetFocus;
end;
procedure TBooktypeForm.BtBdelsmalltypeClick(Sender: TObject);
var
delstring:string;
begin
inherited;
if LBsmalltype.ItemIndex=-1 then
begin
bookInformation('请选择需要删除的小类!');
LBsmalltype.SetFocus;
exit;
end;
delstring:=LBsmalltype.Items.Strings[LBsmalltype.itemindex];
delstring:=copy(delstring,1,pos('-',delstring)-1);
if bookWarning('如果你要删除该小类,蒋会导致数据库中属该小类'+#13
+'的图书信息都会丢失,你应检查该小类是否是空小类.'+#13+'真的要删除吗?')=mrYes then
begin
//delete smalltype modth
//showmessage(delstring);
if not DMbook.deletesmalltype(delstring) then
begin
bookError('删除小类失败!');
exit;
end;
LBsmalltype.DeleteSelected;
end;
end;
procedure TBooktypeForm.CBbigtypelistChange(Sender: TObject);
var
Astring:string;
begin
inherited;
BtBsmallcancel.Enabled:=false;
LBsmalltype.Items.Clear;
Astring:=copy(CBbigtypelist.Text,1,pos('-',CBbigtypelist.Text)-1);
LBsmalltype.Items.Text:=dmbook.getSmalltypelist(Astring);
end;
procedure TBooktypeForm.FormCreate(Sender: TObject);
var
i:integer;
Astring:string;
begin
inherited;
LBbigtype.Items.Text:=dmbook.getBigtypeList;
CBbigtypelist.Items.Text:=dmbook.getBigtypeList;
for i:=0 to LBbigtype.Count-1 do
begin
Astring:=copy(LBbigtype.Items.Strings[i],1,pos('-',LBbigtype.Items.Strings[i])-1);
if CBbigtype.Items.IndexOf(Astring)<>-1 then
CBbigtype.Items.Delete(CBbigtype.Items.IndexOf(Astring));
end;
end;
procedure TBooktypeForm.BtBsmallcancelClick(Sender: TObject);
begin
inherited;
Edsmalltype.Clear;
Edsmalltypename.Clear;
end;
procedure TBooktypeForm.EdsmalltypeKeyPress(Sender: TObject;
var Key: Char);
begin
inherited;
if key=#13 then edsmalltypename.SetFocus
else begin
if not (key in ['0'..'9',#8]) then
begin
key:=#0;
beep;
end;
end;
end;
procedure TBooktypeForm.BBtnCancelClick(Sender: TObject);
begin
inherited;
edBigtypename.Clear;
Edsmalltype.Clear;
Edsmalltypename.Clear;
end;
procedure TBooktypeForm.BtBbigcancelClick(Sender: TObject);
begin
inherited;
edBigtypename.Clear;
end;
procedure TBooktypeForm.BBtnPrintClick(Sender: TObject);
begin
inherited;
if not assigned(prtbooktypeForm) then
prtbooktypeForm:=TprtbooktypeForm.Create(Application);
try
prtbooktypeForm.ShowModal;
finally
prtbooktypeForm.Free;
prtbooktypeForm:=nil;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -