?? bljsk_form.pas
字號:
unit BLJSK_Form;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TFlatButtonUnit, StdCtrls, TFlatComboBoxUnit, TFlatEditUnit,
TFlatGroupBoxUnit,DB,DBTables;
type
TBLJSK_F = class(TForm)
FlatGroupBox1: TFlatGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
BH_FE: TFlatEdit;
XM_FE: TFlatEdit;
ZJH_FE: TFlatEdit;
ZM_FCB: TFlatComboBox;
Label8: TLabel;
XB_FCB: TFlatComboBox;
FlatButton1: TFlatButton;
FlatButton2: TFlatButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FlatButton2Click(Sender: TObject);
procedure FlatButton1Click(Sender: TObject);
private
function CheckError:boolean;
{ Private declarations }
public
{ Public declarations }
end;
var
BLJSK_F: TBLJSK_F;
implementation
uses
Common_Unit;
{$R *.dfm}
var
YHZ_T:TTable;
YHDA_T:TTable;
function IsNum(str:string):boolean;
var
i:integer;
begin
Result:= true;
for i:=1 to length(str) do
if not (ord(str[i]) in[48..57]) then
begin
result:=false;
exit;
end;
end;
//***********************************************************************************
procedure TBLJSK_F.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
end;
//***********************************************************************************
procedure TBLJSK_F.FormDestroy(Sender: TObject);
begin
YHZ_T.Close;
FreeAndNil(YHZ_T);
YHDA_T.Close;
FreeAndNil(YHDA_T);
BLJSK_F:=nil;
end;
//***********************************************************************************
procedure TBLJSK_F.FormCreate(Sender: TObject);
begin
YHZ_T:=TTable.Create(nil);
YHZ_T.DatabaseName:=DataPath;
YHZ_T.TableName:='GroupUser.db';
YHDA_T:=TTable.Create(nil);
YHDA_T.DatabaseName:=DataPath;
YHDA_T.TableName:='YH.db';
end;
//***********************************************************************************
procedure TBLJSK_F.FormShow(Sender: TObject);
begin
YHZ_T.Open;
YHDA_T.Open;
while not YHZ_T.Eof do
begin
ZM_FCB.Items.Add(YHZ_T.FieldValues['GroupName']);
YHZ_T.Next;
end;
ZM_FCB.ItemIndex:=0;
end;
//***********************************************************************************
procedure TBLJSK_F.FlatButton2Click(Sender: TObject);
begin
close;
end;
//***********************************************************************************
function TBLJSK_F.CheckError:boolean; //檢查輸入的數據是否有錯誤
begin
result:=false;
if (length(BH_FE.Text)<>10)or (not IsNum(BH_FE.Text)) then //圖書編號是否合法
begin
MessageBox(handle,'借書卡編號為10位數字!','編號錯誤',MB_OK or MB_ICONERROR);
result:=true;
exit;
end
else begin
if YHDA_T.Locate('UserID',BH_FE.Text,[]) then
begin
MessageBox(handle,'借書卡編號已經存在!','編號重復',MB_OK or MB_ICONERROR);
result:=true;
exit;
end;
end;
if XM_FE.Text='' then
begin
MessageBox(handle,'姓名不能為空!','姓名有誤',MB_OK or MB_ICONERROR);
result:=true;
exit;
end;
if ZJH_FE.Text='' then
begin
MessageBox(handle,'證件號不能為空!','證件號有誤',MB_OK or MB_ICONERROR);
result:=true;
exit;
end
else if not IsNum(ZJH_FE.Text) then
begin
MessageBox(handle,'證件號為數字,最好是身份證號!','證件號有誤',MB_OK or MB_ICONERROR);
result:=true;
exit;
end;
end;
//***********************************************************************************
procedure TBLJSK_F.FlatButton1Click(Sender: TObject); //辦理借書卡
begin
if CheckError then exit;
YHDA_T.Append;
YHDA_T.FieldByName('UserID').AsString:=BH_FE.Text;
YHDA_T.FieldByName('Name').AsString:=XM_FE.Text;
YHDA_T.FieldByName('Sex').AsString:=XB_FCB.Text;
YHDA_T.FieldByName('ZJID').AsString:=ZJH_FE.Text;
YHZ_T.Locate('GroupName',ZM_FCB.Text,[]);
YHDA_T.FieldByName('GroupID').AsString:=YHZ_T.FieldValues['GroupID'];
YHDA_T.Post;
MessageBox(handle,'借書卡信息添加成功!','添加成功',MB_OK or MB_ICONINFORMATION);
BH_FE.Text:='';
XM_FE.Text:='';
XB_FCB.ItemIndex:=0;
ZM_FCB.ItemIndex:=0;
ZJH_FE.Text:='';
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -