?? carddele.pas
字號:
unit CardDele;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls;
type
TFrm_CardDele = class(TForm)
Label5: TLabel;
Label6: TLabel;
Label8: TLabel;
Lb_kysj: TLabel;
Lb_ZS: TLabel;
Lb_X: TLabel;
Lb_Y: TLabel;
LB_CardType: TLabel;
Lb_Deposit: TLabel;
LB_Payment: TLabel;
Label10: TLabel;
Label9: TLabel;
LB_Gift: TLabel;
LB_JSSS: TLabel;
Label11: TLabel;
LB_SYJE: TLabel;
Label7: TLabel;
Label4: TLabel;
Bevel1: TBevel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Btn_Read: TButton;
Btn_Dele: TButton;
Btn_Close: TButton;
Bevel2: TBevel;
LB_CardDate: TLabel;
LB_CardTime: TLabel;
LB_Gname: TLabel;
LB_IdentityNo: TLabel;
LB_Tele: TLabel;
edt_HT: TEdit;
Label12: TLabel;
Label13: TLabel;
procedure FormShow(Sender: TObject);
procedure Btn_ReadClick(Sender: TObject);
procedure Btn_DeleClick(Sender: TObject);
private
procedure ValidCheck(Sender: TObject);
{ Private declarations }
public
{ Public declarations }
end;
var
Frm_CardDele: TFrm_CardDele;
implementation
uses sys_dm, sys_global, DllDef ;
{$R *.dfm}
var
checkFlag: char;
procedure TFrm_CardDele.FormShow(Sender: TObject);
begin
LB_CardType.Caption := '' ;
Lb_Deposit.Caption := '' ;
LB_Payment.Caption := '' ;
LB_Gift.Caption := '' ;
LB_JSSS.Caption := '' ;
LB_SYJE.Caption := '' ;
LB_CardDate.Caption := '' ;
LB_CardTime.Caption := '' ;
LB_Gname.Caption := '' ;
LB_IdentityNo.Caption := '';
LB_Tele.Caption := '' ;
if ChkCard(m_com) = 0 then Btn_Read.Click ; // 如果插入了卡,則讀卡
end;
procedure TFrm_CardDele.Btn_ReadClick(Sender: TObject);
var
p: array[0..32] of char;
I:INTEGER;
begin
if ChkCard(m_com) <> 0 then begin
messagebox(handle,' 請插入IC卡 ', '提示', mb_ok+MB_ICONWARNING);
exit ;
end;
// 檢查IC卡是否是新卡
I:=GETNO(m_com, p);
if I<>0 then begin
messagebox(handle,PCHAR(GETMSG(I)), '提示', mb_ok+MB_ICONWARNING);
exit;
end;
if CardInfo(m_ICtype, m_ICno, m_ICmoney, m_ICdate)= 0 then // 讀卡成功
begin
if m_ICtype='4' then begin // 計時卡
Lb_kysj.Visible := true ;
LB_JSSS.visible := true ; //顯示可用時間
Lb_X.Visible := true ;
Lb_ZS.Visible := false ;
LB_Gift.Visible := false ; //不顯示贈送
Lb_Y.Visible := false ;
end else begin
Lb_kysj.Visible := false ;
Lb_JSSS.visible := false ; //不顯示可用時間
Lb_X.Visible := false ;
Lb_ZS.Visible := true ;
LB_Gift.Visible := true ; //顯示贈送
Lb_Y.Visible := true ;
end;
end else begin
messagebox(handle,' 卡已損壞, 請再試幾次 ', '提示', mb_ok+MB_ICONWARNING);
exit ;
end;
if m_ICtype <> '4' then // 對非計時卡,四舍五入
m_ICmoney := round(m_ICmoney);
with frm_sys_dm.Qr_tmp1 do
begin
close;
sql.clear;
sql.text := 'select * from card where Icno='+intTostr(strToint(m_ICno)) ;
open;
LB_CardType.Caption := fieldbyname('icType').AsString ;
Lb_Deposit.Caption := floatTostr(fieldbyname('Deposit').AsFloat);
LB_Payment.Caption := floatTostr(fieldbyname('Payment').AsFloat);
LB_Gift.Caption := floatTostr(fieldbyname('Gift').AsFloat);
LB_JSSS.Caption := floatTostr(fieldbyname('JSSS').AsFloat /60) ;
if m_ICtype='4' then begin // 計時卡
LB_SYJE.caption := GetHourMinute(Trunc(m_ICmoney)) ;
edt_HT.Text := Lb_Deposit.Caption ;
edt_HT.Enabled := true ;
end else begin
LB_SYJE.caption := floatTostr(m_ICmoney)+' 元' ;
edt_HT.Text := floatTostr(m_ICmoney+strTofloat(Lb_Deposit.Caption)) ;
edt_HT.Enabled := false ;
end;
LB_CardDate.Caption := formatdatetime('yyyy"-"mm"-"dd', m_ICdate) ;
LB_CardTime.Caption := formatdatetime('hh":"nn":"ss', m_ICdate) ;
LB_Gname.caption := fieldbyname('Gname').AsString ;
LB_IdentityNo.caption := fieldbyname('IdentityNo').AsString ;
LB_Tele.caption := fieldbyname('Tele').AsString ;
end;
Btn_Read.Tag := 1 ;
end;
procedure TFrm_CardDele.ValidCheck(Sender: TObject);
var
p: array[0..32] of char;
IcCardNo: string ;
begin
// 檢查有無IC卡插入
if ChkCard(m_com) <> 0 then begin
messagebox(handle,' 請插入IC卡 ', '提示', mb_ok+MB_ICONWARNING);
checkFlag :='0' ;
exit ;
end;
// 檢查是否更換了其它的卡
if getno(m_com, p) = 7 then begin
messagebox(handle,pchar(' 這已是一張新卡.'+#13+#13+' 按確定鍵退出 ! '), '提示', mb_ok+MB_ICONWARNING);
checkFlag :='0' ;
exit ;
end else begin
IcCardNo := copy(p,2,5) ;
if IcCardNo <> m_ICno then begin
messagebox(handle,' 已換了另一張卡, 按確定鍵退出 ! ', '提示', mb_ok+MB_ICONWARNING);
checkFlag :='0' ;
exit ;
end;
end;
// 檢查網絡是否正常
m_Stop := '0' ;
ServerDateTime ;
if m_Stop = '9' then begin
messagebox(handle,' 網絡不通, 該卡暫時不能注銷! ', '提示', mb_ok+MB_ICONWARNING);
checkFlag :='0' ;
exit ;
end;
edt_HT.text := trim(edt_HT.text);
if Trim(edt_HT.text)='' then edt_HT.text := '0' ;
try
strTofloat(edt_HT.text)
except
MessageBox(handle, ' 退回的金額有錯!','提示', mb_ok+mb_iconstop);
edt_HT.SetFocus ;
checkFlag :='0' ;
exit;
end;
end;
procedure TFrm_CardDele.Btn_DeleClick(Sender: TObject);
begin
if Btn_Read.Tag = 0 then begin
messagebox(handle, '請先讀卡, 再注銷.', '提示', mb_ok+mb_iconstop);
exit ;
end;
checkFlag := '1' ; // 假定能通過有效性檢查
ValidCheck(sender); // 進行有效性檢查
if checkFlag='0' then exit; // 若檢查通不過, 則自動退出
if messagebox(handle,pchar('退回客人 '+edt_ht.Text+' 元'+#13+#13+' 您要注銷嗎? '), '提示',mb_okcancel+mb_iconquestion)=idcancel then
exit ;
// 注銷IC卡
if canc(m_com,pchar(m_ICtype+m_ICno))<>0 then begin
messagebox(handle, pchar(' 卡可能損壞, 請重新注銷.'+#13+' 按確定鍵退出! '), '提示', mb_ok+MB_ICONWARNING);
exit ;
end;
// 刪除CARD中相應的記錄, 在delcard 中插入一條記錄
with frm_sys_dm.Qr_tmp1 do
begin
close;
sql.clear;
sql.text := 'delete from card where Icno='+intTostr(strToint(m_ICno)) ;
try
execsql;
except
beep;
end;
close ;
sql.clear;
sql.text := 'insert into DelCard (CardNo, DelTime) values (:CardNo, :DelTime)' ;
Parameters.parambyname('CardNo').Value := strToint(m_ICno) ;
Parameters.parambyname('DelTime').value := now ;
try
execsql
except
beep;
end;
end;
// 向借貸表插入一條記錄
if strTofloat(edt_HT.text)>=0.5 then
with frm_sys_dm.Qr_tmp1 do
begin
close;
sql.clear;
sql.Text := 'insert into Pbill (icNo, Edate, itemName, DF, Operator) values (:icNo, :Edate, :itemName, :DF, :Operator)' ;
Parameters.parambyname('icNo').Value := strToint(m_ICno) ;
Parameters.parambyname('Edate').value := now ;
Parameters.parambyname('itemName').value := 'HT' ;
Parameters.parambyname('DF').value := strTofloat(edt_HT.text);
Parameters.parambyname('Operator').value := m_OpName ;
try
execsql;
except
beep;
end;
end;
beep;
messagebox(handle,'注銷成功!','提示信息',64);
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -