表hv_cardrecord说明
主键
c_ncardno numeric(10) 卡号(key)
c_nxlh numeric(6) 流水号 (key)
c_cxfsj char(16) 消费时间 格式“2000-12-31 18:20”
c_noper char(10) 收银员
c_nje numeric(15,2) 金额 消费100元则为100
c_cxsd char(16) 消费点 “大商场”
c_ctrnid
c_cmenuid
c_ctype char(10) 类型 值为“商场消费”
说明:
1、流水号要不断递增
2、插入记录前要检测是否超支。
表hv_card说明
c_ncardno卡号
c_cendtime 到期时间 //卡到期后不能继续消费
读卡说明:(以下为pb代码)
每次窗体创建后,运行以下代码
if gi_useiccard=0 then
close(this)
return
end if
if gi_initcom<>1 then//没有初始过
if init_com(gi_com)=0 then
gi_initcom=1
else
f_mberr("串口错误")
close(this)
return
end if
end if
if sele_card(42)<> 0 then
f_mberr("选择卡错误")
close(this)
return
end if
以下代码为插入记录做准备
在通过以下代码后,即刻往数据库中插入一行消费记录
string ls_passbuff
long ll_cardno,ll_row
setpointer(hourglass!)
if power_on()<> 0 then
messagebox("提示","上电错误")
return
end if
string ls_ss
ls_ss=" "
rd_asc(0,0,4,ref ls_ss)
if trim(ls_ss)<>"A2131091" then
Power_off()
Messagebox('提示','卡错误')
return
end if
string buffer
int i
buffer=" "
i=rd_str(1,100,30,ref buffer)
if i<>0 then
power_off()
MessageBox('提示','读卡出错!!')
return
end if
ll_cardno=long(buffer)
if ll_cardno=0 then
MessageBox('提示',"IC卡没有卡号,请先制卡!!")
Power_off()
return
end if
//说明:如果密码检测三次都不对,ic卡永远失效。
string ls_passold
ls_passbuff="7F86"
if Chk_sc(0,3,ref ls_passbuff)<>0 then
ls_passold="FFFFFF"
if Chk_sc(0,3,ref ls_passold)<>0 then
Power_off()
MessageBox('提示','密码错误!')
return
else
wr_sc(ls_passbuff)
end if
end if
power_off()
double lr_ye
ll_row=dw_card.retrieve(ll_cardno)
if ll_row=0 then
f_mberr("数据库中没有该卡的记录,该卡可能已经被作废!!")
return
end if
string ls_endtime,ls_time
ls_endtime=dw_card.getitemstring(1,"c_cendtime")
ls_time=string(f_getservertime(),"yyyy-mm-dd")
if ls_endtime<ls_time then
f_mberr("该卡已经到期,不能使用!!")
return
end if
ll_row=dw_cardrecord.retrieve(ll_cardno)
if ll_row>0 then
lr_ye=dw_cardrecord.getitemnumber(1,"c_sumje")
if ir_amt -lr_ye>0 then
f_mbtish("卡上金额不够买单,最少要付款:"+string(ir_amt -lr_ye,"¥0.00"))
//cb_pay.enabled=true
return
end if
else
f_mbtish("请先付款!!")
//cb_pay.enabled=true
return
end if
外部函数声明
function int init_com(int comport) library "sure32wc.dll"
function int close_com() library "sure32wc.dll"
function int power_on() library "sure32wc.dll"
function int power_off() library "sure32wc.dll"
function int sele_card(int card_type) library "sure32wc.dll"
function int inquire(ref string buff) library "sure32wc.dll"
function int rd_str(int zone,int pos,int length,ref string buff) library "sure32wc.dll"
function int wr_str(int zone,int pos,int length,ref string buff) library "sure32wc.dll"
function int rd_asc(int zone,int pos,int length,ref string buff) library "sure32wc.dll"
function int wr_asc(int zone,int pos,int length,ref string buff) library "sure32wc.dll"
function int chk_sc(int zone,int pos,ref string buff) library "sure32wc.dll"
function int rd_pm(int apz,int pos,int length, ref string buff) library "sure32wc.dll"
function int rd_sm( ref string buff) library "sure32wc.dll"
function int wr_sc(ref string buff) library "sure32wc.dll"
- 1
- 2
前往页