关于POS的各种外设处理(包括打印机、钱箱等)
现把POS的各种外设处理整理如下,可能还有许多不全或者代码不正确的地方,望大家补充且指证
POS的外设包括打印机、钱箱、顾显、卡、扫码枪和扫码平台。
一般的外设编程可以通过PB通过的串口编程,也有部分特殊的,可由厂家直接提供技术支持。
各种外设如果接的是COM,必须在打开的时候,让其初始化,一般卡可在刷卡的时候再初始化,刷卡结束后,再把COM口关闭。因为如果COM已被某一外设打开,另一外设将不可用,即COM口是独占的。
一、打印机
POS的外设包括打印机、钱箱、顾显、卡、扫码枪和扫码平台。
一般的外设编程可以通过PB通过的串口编程,也有部分特殊的,可由厂家直接提供技术支持。
各种外设如果接的是COM,必须在打开的时候,让其初始化,一般卡可在刷卡的时候再初始化,刷卡结束后,再把COM口关闭。因为如果COM已被某一外设打开,另一外设将不可用,即COM口是独占的。
一、打印机
申明
/*210D´串口打印*/
Function boolean OpenSerPort(int iPt) LIBRARY "prndll.dll" //打开串口
Function boolean ClosePort() LIBRARY "prndll.dll" //关闭串口
Function boolean SendPData(string pData,int iDataLen) LIBRARY "prndll.dll" //发送打印命令
Function boolean OpenPrnDrawer() LIBRARY "prndll.dll" //开钱箱
Function boolean TM210D_Init() LIBRARY "prndll.dll" //打印初始化串口
Function boolean TM210D_PrnCnEn(int iColor,string pData,int iDataLen) LIBRARY "prndll.dll" //向打印机从软字库(串口)
Function boolean OpenPalPort(int iPt) LIBRARY "prndll.dll" //´打开并口
Function boolean TM210PD_PrnCnEn(int iColor,string pData,int iDataLen) LIBRARY "prndll.dll" //向打印机从软字库(并口)
1、打印机初始化(可在OPEN事件中写)
gs_system_qt.ls_printtype:为打印机型号
OLE_print:为Microsoft Communication control控件(装VB6后,此控件可见)
gs_system_qt.ls_pagewidth:打印纸的宽度
ls_printstr:送入打印机的字符
//初始化串口打印机
choose case gs_system_qt.ls_printtype
case 'IBM Sure one 4614'
w_main.OLE_print.Object.RTSenable = true
w_main.OLE_print.Object.handshaking = 2
w_main.OLE_print.Object.CommPort = 3
w_main.OLE_print.Object.PortOpen = True
case 'TP POS2000'
choose case gs_system_qt.ls_printport
case 'COM1'
li_printport = 1
case 'COM2'
li_printport = 2
case 'COM3'
li_printport = 3
case 'COM4'
li_printport = 4
case 'COM5'
li_printport = 5
case 'COM6'
li_printport = 6
case else
li_printport = 1
end choose
if li_printport >=1 and li_printport <=6 then
w_main.OLE_print.Object.RTSenable = true
w_main.OLE_print.Object.handshaking = 2
w_main.OLE_print.Object.CommPort = li_printport
w_main.OLE_print.Object.PortOpen = True
end if
end choose
end if
//此处判断如果打印机不是“IBM Sure one 4614”,但是钱箱是“IBM Sure one 4614”的
if gs_system_qt.ls_printtype <> 'IBM Sure one 4614' then
if gs_system_qt.ls_moneyboxport = 'IBM Sure one 4614' then
w_main.OLE_print.Object.RTSenable = true
w_main.OLE_print.Object.handshaking = 2
w_main.OLE_print.Object.CommPort = 3
w_main.OLE_print.Object.PortOpen = True
end if
end if
问题点数:100、回复次数:24Top
2、打印小票(各个变量是要打印出来的数据,主要提供各种打印回车、换行、空格应该送那些字符)
choose case gs_system_qt.ls_printtype
case 'Epson 210AM'
choose case gs_system_qt.ls_pagewidth
case '75mm'
//判断一个商品打印几行
if gs_system_qt.li_GoodsPrintrow = 1 then
ls_printstr = ls_printstr + left(ls_GoodsNameS+space(18),18) + Space(7 - Len(String(ldec_num,"###0.000"))) + String(ldec_num,"###0.000") + Space(7-Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice* ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_printstr = ls_printstr + left(ls_goodscode+space(18),18) + Space(7 - Len(String(ldec_num,"###0.000"))) + String(ldec_num,"###0.000")+ Space(7 -Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00") + Space(7 - Len(String(ldec_disretailprice * ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
case '57mm'
if gs_system_qt.li_GoodsPrintrow = 1 then
ls_PrintStr = ls_PrintStr + left(ls_GoodsNames+space(14),14) + Space(4 - Len(String(ldec_num,"###0"))) + String(ldec_num,"###0") + Space(7 - Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7 - Len(String(ldec_disretailprice * ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_PrintStr = ls_PrintStr + left(ls_goodscode+space(14),14) + Space(4 - Len(String(ldec_num,"###0")))+String(ldec_num,"###0")+Space(7-Len(String(ldec_disretailprice,"###0.00"))) + String(ldec_disretailprice,"###0.00") + Space(7 - Len(String(ldec_disretailprice * ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
end choose
case 'Partner ADP 300'
choose case gs_system_qt.ls_pagewidth
case '75mm'
if gs_system_qt.li_GoodsPrintrow = 1 then
ls_printstr = ls_printstr + left(ls_GoodsNameS+space(18),18) + Space(7 - Len(String(ldec_num,"###0.000")))+String(ldec_num,"###0.000")+Space(7-Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_printstr = ls_printstr + left(ls_goodscode+space(18),18) + Space(7 - Len(String(ldec_num,"###0.000")))+String(ldec_num,"###0.000")+Space(7-Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00")))+String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
case '57mm'
if gs_system_qt.li_GoodsPrintrow = 1 then
ls_PrintStr = ls_PrintStr + left(ls_GoodsNames+space(14),14) + Space(4 -Len(String(ldec_num,"###0")))+String(ldec_num,"###0")+Space(7-Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00")))+String(ldec_disretailprice*ldec_num,"####0.00") + Char(13) + Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_PrintStr = ls_PrintStr + left(ls_goodscode+space(14),14) + Space(4 - Len(String(ldec_num,"###0"))) + String(ldec_num,"###0") + Space(7 - Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
end choose
case 'TX-210K'
choose case gs_system_qt.ls_pagewidth
case '75mm'
if gs_system_qt.li_GoodsPrintrow = 1 then
ls_printstr = ls_printstr + left(ls_GoodsNameS+space(18),18) + Space(7 - Len(String(ldec_num,"###0.000")))+String(ldec_num,"###0.000") + Space(7 -Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00") + Space(7 - Len(String(ldec_disretailprice * ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_printstr = ls_printstr + left(ls_goodscode+space(18),18) + Space(7 - Len(String(ldec_num,"###0.000"))) +String(ldec_num,"###0.000") + Space(7 -Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00") + Space(7 - Len(String(ldec_disretailprice * ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
case '57mm'
if gs_system_qt.li_GoodsPrintrow = 1 then
ls_PrintStr = ls_PrintStr + left(ls_GoodsNames+space(14),14) + Space(4 - Len(String(ldec_num,"###0")))+String(ldec_num,"###0")+Space(7-Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00")))+String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
else
ls_printstr=ls_printstr+left(string(li_id)+space(4),4)+ls_goodsname + Char(13) + Char(10)
ls_PrintStr=ls_PrintStr+left(ls_goodscode+space(14),14)+Space(4-Len(String(ldec_num,"###0")))+String(ldec_num,"###0")+Space(7-Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00")))+String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
end choose
case 'DIY POS58'
if gs_system_qt.li_GoodsPrintrow = 1 then
ls_PrintStr = ls_PrintStr + left(ls_GoodsNames+space(10),10) + Space(8 - Len(String(ldec_num,"###0.00"))) + String(ldec_num,"###0.00") + Space(7 - Len(String(ldec_disretailprice,"###0.00"))) + String(ldec_disretailprice,"###0.00") + Space(7 - Len(String(ldec_disretailprice * ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_PrintStr = ls_PrintStr + left(ls_goodscode+space(10),10) + Space(8 - Len(String(ldec_num,"###0.00"))) + String(ldec_num,"###0.00") + Space(7 - Len(String(ldec_disretailprice,"###0.00"))) + String(ldec_disretailprice,"###0.00") + Space(7 - Len(String(ldec_disretailprice * ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
case 'IBM Sure one 4614'
choose case gs_system_qt.ls_pagewidth
case '75mm'
if gs_system_qt.li_GoodsPrintrow = 1 then //
ls_printstr = ls_printstr + left(ls_GoodsNameS+space(18),18) + Space(7 - Len(String(ldec_num,"###0.000"))) + String(ldec_num,"###0.000") + Space(7-Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00")))+ String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_printstr = ls_printstr + left(ls_goodscode+space(18),18) + Space(7 - Len(String(ldec_num,"###0.000"))) + String(ldec_num,"###0.000") + Space(7-Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
case '57mm'
if gs_system_qt.li_GoodsPrintrow = 1 then
ls_PrintStr = ls_PrintStr + left(ls_GoodsNames+space(14),14) + Space(4 - Len(String(ldec_num,"###0"))) + String(ldec_num,"###0") + Space(7 - Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00")))+String(ldec_disretailprice*ldec_num,"####0.00")+Char(13)+Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_PrintStr = ls_PrintStr + left(ls_goodscode+space(14),14) + Space(4 - Len(String(ldec_num,"###0"))) + String(ldec_num,"###0") + Space(7 - Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
end choose
w_main.OLE_print.Object.Output = ls_printstr
do While w_main.OLE_print.Object.OutBufferCount() > 0
Yield()
Loop
ls_printstr= ''
case '海信P110DM'
choose case gs_system_qt.ls_pagewidth
case '75mm'
if gs_system_qt.li_GoodsPrintrow = 1 then //
ls_printstr = ls_printstr + left(ls_GoodsNameS+space(18),18) + Space(7-Len(String(ldec_num,"###0.000")))+String(ldec_num,"###0.000")+Space(7-Len(String(ldec_disretailprice,"###0.00"))) + String(ldec_disretailprice,"###0.00") + Space(7 - Len(String(ldec_disretailprice * ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_printstr = ls_printstr + left(ls_goodscode+space(18),18) + Space(7-Len(String(ldec_num,"###0.000")))+String(ldec_num,"###0.000")+Space(7-Len(String(ldec_disretailprice,"###0.00"))) + String(ldec_disretailprice,"###0.00") + Space(7 - Len(String(ldec_disretailprice * ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
case '57mm'
if gs_system_qt.li_GoodsPrintrow = 1 then
ls_PrintStr = ls_PrintStr + left(ls_GoodsNames+space(14),14) +Space(4-Len(String(ldec_num,"###0")))+String(ldec_num,"###0") + Space(7 - Len(String(ldec_disretailprice,"###0.00"))) + String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00")))+String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_PrintStr = ls_PrintStr + left(ls_goodscode+space(14),14) + Space(4-Len(String(ldec_num,"###0")))+String(ldec_num,"###0") + Space(7 - Len(String(ldec_disretailprice,"###0.00"))) + String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00")))+String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
end choose
case '桑达PT2000'
choose case gs_system_qt.ls_pagewidth
case '75mm'
if gs_system_qt.li_GoodsPrintrow = 1 then
ls_printstr = ls_printstr + left(ls_GoodsNameS+space(18),18) + Space(7-Len(String(ldec_num,"###0.000")))+String(ldec_num,"###0.000")+Space(7-Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00")))+String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_printstr = ls_printstr + left(ls_goodscode+space(18),18) + Space(7-Len(String(ldec_num,"###0.000")))+String(ldec_num,"###0.000")+Space(7-Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00")))+String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
case '57mm'
if gs_system_qt.li_GoodsPrintrow = 1 then
ls_PrintStr = ls_PrintStr + left(ls_GoodsNames+space(14),14) +Space(4-Len(String(ldec_num,"###0")))+String(ldec_num,"###0")+ Space(7 - Len(String(ldec_disretailprice,"###0.00"))) + String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00")))+String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_PrintStr = ls_PrintStr + left(ls_goodscode+space(14),14) + Space(4-Len(String(ldec_num,"###0")))+String(ldec_num,"###0") + Space(7 - Len(String(ldec_disretailprice,"###0.00"))) + String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00")))+String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
end choose
case 'TP POS2000'
choose case gs_system_qt.ls_pagewidth
case '75mm'
if gs_system_qt.li_GoodsPrintrow = 1 then
ls_printstr = ls_printstr + left(ls_GoodsNameS+space(18),18) + Space(7 - Len(String(ldec_num,"###0.000")))+String(ldec_num,"###0.000")+Space(7-Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_printstr = ls_printstr + left(ls_goodscode+space(18),18) + Space(7 - Len(String(ldec_num,"###0.000")))+String(ldec_num,"###0.000")+Space(7-Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
case '57mm'
if gs_system_qt.li_GoodsPrintrow = 1 then
ls_PrintStr = ls_PrintStr + left(ls_GoodsNames+space(14),14) + Space(4 - Len(String(ldec_num,"###0"))) + String(ldec_num,"###0") + Space(7 - Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_PrintStr = ls_PrintStr + left(ls_goodscode+space(14),14) + Space(4 - Len(String(ldec_num,"###0"))) + String(ldec_num,"###0") + Space(7 - Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
end choose
w_main.OLE_print.Object.Output = ls_printstr
do While w_main.OLE_print.Object.OutBufferCount() > 0
Yield()
Loop
ls_printstr= ''
case else //75mm
choose case gs_system_qt.ls_pagewidth
case '75mm'
if gs_system_qt.li_GoodsPrintrow = 1 then
ls_printstr=ls_printstr+left(ls_GoodsNameS+space(18),18)+Space(7-Len(String(ldec_num,"###0.000")))+String(ldec_num,"###0.000")+ Space(7 -Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00")))+String(ldec_disretailprice*ldec_num,"####0.00")+Char(13)+Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_printstr = ls_printstr + left(ls_goodscode+space(18),18) + Space(7- Len(String(ldec_num,"###0.000")))+String(ldec_num,"###0.000")+Space(7-Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
case '57mm'
if gs_system_qt.li_GoodsPrintrow = 1 then
ls_PrintStr = ls_PrintStr + left(ls_GoodsNames+space(14),14) + Space(4 -Len(String(ldec_num,"###0"))) + String(ldec_num,"###0") + Space(7 - Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00")))+String(ldec_disretailprice*ldec_num,"####0.00")+Char(13)+Char(10)
else
ls_printstr = ls_printstr + left(string(li_id)+space(4),4) + ls_goodsname + Char(13) + Char(10)
ls_PrintStr = ls_PrintStr + left(ls_goodscode+space(14),14) + Space(4 - Len(String(ldec_num,"###0"))) + String(ldec_num,"###0") + Space(7 - Len(String(ldec_disretailprice,"###0.00")))+String(ldec_disretailprice,"###0.00")+Space(7-Len(String(ldec_disretailprice*ldec_num,"####0.00"))) + String(ldec_disretailprice * ldec_num,"####0.00") + Char(13) + Char(10)
end if
end choose
end choose
Top
//添加回车换行
ls_printstr = ls_printstr + char(13) + char(10)
//判断打印机型号
choose case gs_system_qt.ls_printtype
case 'IBM Sure one 4614'
w_main.OLE_print.Object.Output = ls_printstr
do While w_main.OLE_print.Object.OutBufferCount() > 0
Yield()
Loop
ls_printstr= ''
case else
//
end choose
end if
//打印口
int li_printport
choose case gs_system_qt.ls_printport
case 'COM1'
li_printport = 1
case 'COM2'
li_printport = 2
case 'COM3'
li_printport = 3
case 'COM4'
li_printport = 4
case 'COM5'
li_printport = 5
case 'COM6'
li_printport = 6
case 'LPT1'
li_printport = 7
case 'LPT2'
li_printport = 8
case else
li_printport = 1
end choose
//发送打印命令
choose case gs_system_qt.ls_printtype
case 'Epson 210PD'
choose case gs_system_qt.li_windrive
case 1 //使用打印驱动
job = PrintOpen()
Print(job,ls_PrintStr)
PrintClose(job)
case -1 //不使用打印驱动
//打开端口
if li_printport = 7 or li_printport = 8 then //²¢¿Ú
choose case li_printport
case 7
li_printport = 1
case 8
li_printport = 2
end choose
OpenPalPort(li_printport) //打开并口
else //打开串口
OpenSerPort(li_printport) //´ò¿ª´®¿Ú
end if
TM210D_PrnCnEn(1,ls_printstr,len(ls_printstr))//Ïò´òÓ¡»ú´ÓÈí×Ö¿â²¢´òÓ¡
ClosePort() //关闭串口
end choose
case 'Epson 210AM'
//退一行
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
choose case gs_system_qt.li_windrive
case 1
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
job = PrintOpen()
PrintSend(job,ls_PrintStr)
PrintClose(job)
case -1
li_FileNum=FileOpen(gs_system_qt.ls_printport,LineMode!,Write!, LockWrite!, Append!)
FileWrite(li_FileNum,ls_printstr)
FileClose(li_FileNum)
end choose
case 'Partner ADP 300'
choose case gs_system_qt.li_windrive
case 1
job = PrintOpen()
PrintSend(job,ls_PrintStr)
PrintClose(job)
case -1
li_FileNum = FileOpen(gs_system_qt.ls_printport,LineMode!, Write!, LockWrite!, Append!)
FileWrite(li_FileNum,ls_printstr)
FileClose(li_FileNum)
end choose
case 'TX-210K'
//退一行
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
choose case gs_system_qt.li_windrive
case 1
job = PrintOpen()
PrintSend(job,ls_PrintStr)
PrintClose(job)
case -1
li_FileNum = FileOpen(gs_system_qt.ls_printport,LineMode!, Write!, LockWrite!, Append!)
FileWrite(li_FileNum,ls_printstr)
FileClose(li_FileNum)
end choose
case 'IBM Sure one 4614'
w_main.OLE_print.Object.Output = ls_printstr
do While w_main.OLE_print.Object.OutBufferCount() > 0
Yield()
Loop
case 'º海信P110DM'
//退一行
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
choose case gs_system_qt.li_windrive
case 1¯
job = PrintOpen()
PrintSend(job,ls_PrintStr)
PrintClose(job)
case -1
li_FileNum = FileOpen(gs_system_qt.ls_printport,LineMode!, Write!, LockWrite!, Append!)
FileWrite(li_FileNum,ls_printstr)
FileClose(li_FileNum)
end choose
case ‘桑达PT2000'
//退一行
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
choose case gs_system_qt.li_windrive
case 1
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
job = PrintOpen()
PrintSend(job,ls_PrintStr)
PrintClose(job)
case -1
li_FileNum = FileOpen(gs_system_qt.ls_printport,LineMode!, Write!, LockWrite!, Append!)
FileWrite(li_FileNum,ls_printstr)
FileClose(li_FileNum)
end choose
case 'TP POS2000'
if li_printport >=1 and li_printport <=6 then /
w_main.OLE_print.Object.Output = ls_printstr
do While w_main.OLE_print.Object.OutBufferCount() > 0
Yield()
Loop
end if
case else
choose case gs_system_qt.li_windrive
case 1
job = PrintOpen()
PrintSend(job,ls_PrintStr)
PrintClose(job)
case -1
li_FileNum = FileOpen(gs_system_qt.ls_printport,LineMode!, Write!, LockWrite!, Append!)
FileWrite(li_FileNum,ls_printstr)
FileClose(li_FileNum)
end choose
end choose
Top
二、钱箱
与打印机密切关联的就是钱箱,在软件里面,我们关字符到打印机,由打印机打开钱箱
申明
//桑达CR-3000A(并口)钱箱使用
Function int opend( long t1,long t2,long port ) LIBRARY "qxdll.dll" //开钱箱opend(500,500,LPT2的十进制地址•)
Function int posi (long port ) LIBRARY "qxdll.dll" //钱箱状态
/*海信HK588系列钱箱使用*/
Function int InitMBDrawer(int iType) library 'adrawerdll.dll' //初始化钱箱
Function int OpenMBDrawer(int iType) library 'adrawerdll.dll' //开钱箱
//打印口
choose case gs_system_qt.ls_printport
case 'COM1'
li_printport = 1
case 'COM2'
li_printport = 2
case 'COM3'
li_printport = 3
case 'COM4'
li_printport = 4
case 'COM5'
li_printport = 5
case 'COM6'
li_printport = 6
case 'LPT1'
li_printport = 7
case 'LPT2'
li_printport = 8
case else
li_printport = 1
end choose
choose case gs_system_qt.ls_moneyboxport
case '打印口'
choose case gs_system_qt.ls_printtype
Case "Epson 210PD"
choose case gs_system_qt.li_windrive
case 1 //使用WINDOW驱动
job = PrintOpen()
Print(job,ls_PrintStr)
PrintClose(job)
case -1 //不使用WINDOW驱动
if li_printport = 7 or li_printport = 8 then //并口
choose case li_printport
case 7
li_printport = 1
case 8
li_printport = 2
end choose
OpenPalPort(li_printport)
else //串口
OpenSerPort(li_printport)
end if
OpenPrnDrawer()//开钱箱
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
TM210D_PrnCnEn(1,ls_printstr,len(ls_printstr))
ClosePort()
end choose
Case "Epson 210AM"
if gs_system_qt.li_windrive = 1 then
ls_printstr = ls_printstr + Char(27)+Char(64)
end if
ls_printstr = ls_printstr + Char(27)+Char(112)+Char(0)+Char(48)
case 'Partner ADP 300'
if gs_system_qt.li_windrive = 1 then
ls_printstr = ls_printstr + Char(27)+Char(64)
end if
ls_printstr = ls_printstr + Char(27)+Char(112)+Char(0)+Char(48)
Case "TX-210K"
if gs_system_qt.li_windrive = 1 then
ls_printstr=ls_printstr+char(27)+"p"+char(254)+char(60)+char(255)
ls_printstr = ls_printstr + char(27) + 'e' + char(2)
else
ls_printstr=ls_printstr+Char(27)+Char(112)+Char(1)+Char(60)+char(255) end if
Case 'DIY POS58'
ls_printstr = ls_printstr + char(27) + 'e' + char(1)
ls_printstr=ls_printstr+Char(27)+Char(112)+Char(1)+Char(60)+char(255)
Case "桑达PT2000"
if gs_system_qt.li_windrive = 1 then
ls_printstr = ls_printstr + Char(27)+Char(64)
end if
ls_printstr = ls_printstr + Char(27)+Char(112)+Char(0)+Char(48) //Ç®Ïä
case 'TP POS2000'
ls_printstr = ls_printstr + Char(27)+Char(64) //´òÓ¡»ú³õʼ»¯
ls_printstr = ls_printstr + Char(27)+Char(112)+Char(0)+Char(48)
Case Else //Epson 210AM
if gs_system_qt.li_windrive = 1 then
ls_printstr = ls_printstr + Char(27)+Char(64)
end if
ls_printstr = ls_printstr + Char(27)+Char(112)+Char(0)+Char(48)
end choose
//发送打印命令
choose case gs_system_qt.ls_printtype
case 'Epson 210AM'
choose case gs_system_qt.li_windrive
case 1
job = PrintOpen()
PrintSend(job,ls_PrintStr)
PrintClose(job)
case -1
li_FileNum=FileOpen(gs_system_qt.ls_printport,LineMode!, Write!, LockWrite!, Append!)
FileWrite(li_FileNum,ls_printstr)
FileClose(li_FileNum)
end choose
case 'Partner ADP 300'
choose case gs_system_qt.li_windrive
case 1
job = PrintOpen()
PrintSend(job,ls_PrintStr)
PrintClose(job)
case -1 li_FileNum=FileOpen(gs_system_qt.ls_printport,LineMode!, Write!, LockWrite!, Append!)
FileWrite(li_FileNum,ls_printstr)
FileClose(li_FileNum)
end choose
case 'TX-210K'
choose case gs_system_qt.li_windrive
case 1
job = PrintOpen()
PrintSend(job,ls_PrintStr,254)
PrintClose(job)
case -1
li_FileNum=FileOpen(gs_system_qt.ls_printport,LineMode!, Write!, LockWrite!, Append!)
FileWrite(li_FileNum,ls_printstr)
FileClose(li_FileNum)
end choose
case 'IBM Sure one 4614'
w_main.OLE_print.Object.Output = ls_printstr
do While w_main.OLE_print.Object.OutBufferCount() > 0
Yield()
Loop
case 'TP POS2000'
if li_printport >=1 and li_printport <=6 then //±íÃ÷ʱ´®¿Ú
w_main.OLE_print.Object.Output = ls_printstr
do While w_main.OLE_print.Object.OutBufferCount() > 0
Yield()
Loop
end if
case else
choose case gs_system_qt.li_windrive
case 1 //使用WINDOW打印驱动
job = PrintOpen()
PrintSend(job,ls_PrintStr)
PrintClose(job)
case -1
li_FileNum=FileOpen(gs_system_qt.ls_printport,LineMode!, Write!, LockWrite!, Append!)
FileWrite(li_FileNum,ls_printstr)
FileClose(li_FileNum)
end choose
end choose
case 'IBM Sure one 4614'
isnull(ls_printstr)
ls_printstr = char(7)// + char(28)
w_main.OLE_print.Object.Output = ls_printstr
case '海信FWD-1-T'
openmbdrawer(4)
case '桑达'
opend(500,500,gs_system_qt.ll_moneyboxorder)
case else
end choose
end if
三、顾显
1、顾显初始化
function Boolean com_init(Int com,int baud)library "api_com.dll"
function Boolean com_rest() library "api_com.dll"
function Boolean com_send(string buf,int len)library "api_com.dll"
OLE_gx:为Microsoft Communication control控件
int li_gxport
choose case gs_system_qt.ls_gxport
case 'COM1'
li_gxport = 1
case 'COM2'
li_gxport = 2
case 'COM3'
li_gxport = 3
case 'COM4'
li_gxport = 4
case 'COM5'
li_gxport = 5
case 'COM6'
li_gxport = 6
case else
li_gxport = 1
end choose
gs_System_qt.ls_GxType:顾显型号
choose case gs_System_qt.ls_GxType
case '双向数字顾显'
ls_display=char(12)+char(27)+'.'+char(9)+char(1)
OLE_gx.Object.CommPort=li_gxport
OLE_gx.Object.PortOpen=True
OLE_gx.Object.Output=ls_display
case '双象中文顾显'
ls_display=String(real(2),"########0.00")
ls_display=char(27) + 'QA'+ "欢迎" + Space(9 - Len(ls_display)) + ls_display +char(13)
OLE_gx.Object.CommPort=li_gxport
OLE_gx.Object.PortOpen=True
OLE_gx.Object.Output=ls_display
OLE_gx.Object.PortOpen=False
case 'DIY PD-LED8'
if not com_init(li_Gxport,2400) then
messagebox("错误","顾显端口打开错误!",exclamation!)
end if
case 'IBM Sure one 4614'
OLE_gx.Object.CommPort = 4
OLE_gx.Object.PortOpen = True
case '海信VC108'
ls_display = char(27) + char(64)
OLE_gx.Object.CommPort = li_gxport
OLE_gx.Object.PortOpen = True
OLE_gx.Object.Output = ls_display
// OLE_gx.Object.PortOpen=False
case 'LANPOS IC-851'
if not com_init(li_Gxport,9600) then
messagebox("错误","顾显端口打开错误!",exclamation!)
end if
case '桑达顾显'
if not OpenCom(li_Gxport) then
messagebox("错误","顾显端口打开错误!",exclamation!)
end if
end choose
2、收银时候顾显显示数据
//顾显端口
choose case gs_system_qt.ls_gxport
case 'COM1'
li_gxport = 1
case 'COM2'
li_gxport = 2
case 'COM3'
li_gxport = 3
case 'COM4'
li_gxport = 4
case 'COM5'
li_gxport = 5
case 'COM6'
li_gxport = 6
case else
li_gxport = 1
end choose
//顾显型号
Choose Case gs_System_qt.ls_GxType
Case "DIY PD-LED8"
if ls_strnum = '.00' then
ls_strnum = '0.00'
end if
ls_display=Char(27)+Char(81)+Char(65)+ ls_strnum + Char(13);
choose case gs_zwgx
case '应收'
ls_display = ls_display + Char(27)+Char(115)+"2"
case '找零'
ls_display = ls_display + Char(27)+Char(115)+"4"
end choose
com_send(ls_display,Len(ls_display))
case '双象数字顾显'
ls_display=String(real(ls_strnum)*100,"########000")
ls_display=Space(11 - Len(ls_display)) + ls_display
OLE_gx.Object.Output = ls_display
case '双象中文顾显'
ls_display=String(real(ls_strnum),"########0.00")
ls_display=char(27) + 'QA'+ gs_zwgx + Space(9 - Len(ls_display)) + ls_display +char(13)
OLE_gx.Object.Output=ls_display
case 'IBM Sure one 4614'
ls_display = char(31)
choose case gs_zwgx
case 'Total'
ls_display = ls_display + char(84) + char(111) + char(116) + char(97) + char(108) + char(58)
ls_display = ls_display + ' ' + ls_strnum
case 'Change'
ls_display = ls_display + char(67) + char(104) + char(97) + char(110) + char(103) + char(101) + char(58)
ls_display = ls_display + ' ' + ls_strnum
end choose
case '海信VC108'
//清屏
ls_display = char(12)
/*多谢惠顾:char(31) + char(80) + n
n= 0 暗
n= 1 亮
n= 2 闪烁
*/
ls_display = ls_display + char(31) + char(80) + char(1) // 显示’多谢惠顾‘
/*币种:char(31) + char(115) + n
n= 0 全暗
n= 1 人民币
n= 2 美元
n= 3 港元
n= 4 全亮
n= 5 转动
*/
ls_display = ls_display + char(31) + char(115) + char(1) // 显示’人民币‘
/*顾显状态:char(27) + char(115) + n
n= 0 全暗
n= 1 单价
n= 2 合计
n= 3 收款
n= 4 找零
*/
choose case gs_zwgx
case '合计'
ls_display = ls_display + char(27) + char(115) + char(2) //合计
ls_display = ls_display + char(27) + char(81) + char(65) + ls_strnum + char(13)
case '找零'
ls_display = ls_display + char(27) + char(115) + char(4) //找零
ls_display = ls_display + char(27) + char(81) + char(65) + ls_strnum + char(13)
end choose
case 'LANPOS IC-851'
//指定汉字格式:
// [027][012]
// [027][115],N,M
// 1<=N<=5
// 0<=M<=1
// N=1:小计
// N=2:合计
// N=3:单价
// N=4:收款
// N=5:找回
// M=0:灭
// M=1:亮
//
//必须先送中文再送数字×××××××××××××××××××××××××
//显示中文
choose case gs_zwgx
case '合计'
//亮合计
ls_display = ls_display + char(27) + char(12) + Char(27)+Char(115)+char(2) + char(1)
//灭找回
ls_display = ls_display + char(27) + char(12) + Char(27)+Char(115)+char(5) + char(0)
case '找回'
//亮找回
ls_display = ls_display + char(27) + char(12) + Char(27)+Char(115)+char(5) + char(1)
//灭合计
ls_display = ls_display + char(27) + char(12) + Char(27)+Char(115)+char(2) + char(0)
end choose
if ls_strnum = '.00' then
ls_strnum = '0.00'
end if
ls_display = ls_display + Char(27)+Char(81)+Char(65)+ ls_strnum + Char(13);
com_send(ls_display,Len(ls_display))
case '桑达顾显'
SendByte(char(31),1)
SendByte(char(17),1)
choose case gs_zwgx
case '合计'
ls_display = ls_display + '合计' +char(10)
case '找回'
ls_display = ls_display + '找回' +char(10)
end choose
if ls_strnum = '.00' then
ls_strnum = '0.00'
end if
ls_display = ls_display + Char(27)+'QA'+ ls_strnum + Char(13);
SendByte(ls_display,Len(ls_display))
case else
//
end choose
五、卡(包括IC卡和磁卡)
申明
//IC卡使用
Function long chk_baud(int port) library "MWIC_32.dll"
Function long ic_init(int port,long baud) library "MWIC_32.dll"
Function long auto_init(int port,long baud) library "MWIC_32.dll"
Function int get_status(long icdev, ref int card_S) library "MWIC_32.dll"
Function long ic_exit(Long icdev) library "MWIC_32.dll"
Function int set_baud(long icdev,long baud) library "MWIC_32.dll"
Function int cmp_dvsc(Long icdev, int length,ref string data_buffer) library "MWIC_32.dll"
Function int srd_dvsc(Long icdev, int length,ref string data_buffer) library "MWIC_32.dll"
Function int swr_dvsc(Long icdev, int length,ref string data_buffer) library "MWIC_32.dll"
Function int setsc_md(Long icdev, int mode) library "MWIC_32.dll"
Function int turn_on(Long icdev) library "MWIC_32.dll"
Function int turn_off(Long icdev) library "MWIC_32.dll"
Function int srd_ver(Long icdev,int le,ref string data_buffer) library "MWIC_32.dll"
Function int auto_pull(Long icdev) library "MWIC_32.dll"
Function int dv_beep(Long icdev,int time) library "MWIC_32.dll"
Function int asc_hex(ref string asc,ref string hex,long le) library "MWIC_32.dll"
Function int hex_asc(ref string hex,ref string asc,long le) library "MWIC_32.dll"
Function int ic_encrypt(string key, ref string ptrsource ,integer le,ref string ptrdest) library "MWIC_32.dll"
Function int ic_decrypt(string key, ref string ptrdest,integer le,ref string ptrsource) library"MWIC_32.dll"
Function int srd_4442(long icdev,int Offset,int length,ref string ata_buffer) library "MWIC_32.dll"
Function int swr_4442(long icdev,int Offset,int length,ref string ata_buffer) library "MWIC_32.dll"
Function int prd_4442(long icdev,int length,ref string ata_buffer) library "MWIC_32.dll"
Function int pwr_4442(long icdev,int Offset,int length,ref string ata_buffer) library "MWIC_32.dll"
Function int chk_4442(long icdev) library "MWIC_32.dll"
Function int csc_4442(long icdev,int length,ref string ata_buffer) library "MWIC_32.dll"
Function int wsc_4442(long icdev,int length,ref string ata_buffer) library "MWIC_32.dll"
Function int rsc_4442(long icdev,int length,ref string ata_buffer) library "MWIC_32.dll"
Function int rsct_4442(long icdev,ref int counter) library "MWIC_32.dll"
磁卡是只读卡号,所有的数据保存在数据库,根据上面的ole_input中的代码就可以读出卡号,然后根据卡号自己处理。
IC卡是金额和卡号都存储在机器里面,相对来说复杂一些
用卡支付
1、 初始化
choose case gs_system_qt.ls_icport
case 'COM1'
li_iccom = 1
case 'COM2'
li_iccom = 2
case 'COM3'
li_iccom = 3
case 'COM4'
li_iccom = 4
case 'COM5'
li_iccom = 5
case 'COM6'
li_iccom = 6
case 'LPT1'
li_iccom = 7
case 'LPT2'
li_iccom = 8
case else
gf_messagebox(2,'IC卡设备的端口设置错误,请到系统设置中设置!')
close(this)
return
end choose
choose case gs_system_qt.ls_ictype
case 'MW RD-EB' //明华
icdev= auto_init(li_iccom - 1 ,9600) //初始化端口1,波特率是9600
if icdev<0 then
messagebox("提示信息","串口初始化错误!请检查IC卡设备是否接上正确的串口或电源是否已经打开!")
closewithreturn(this,"close")
end if
case 'DIY键盘IC卡'
icdev = diy95_ic.ic_init(li_iccom - 1 ,9600) //初始化端口1,波特率是9600
if icdev<0 then
messagebox("提示信息","串口初始化错误!请检查IC卡设备是否接上正确的串口或电源是否已经打开!")
closewithreturn(this,"close")
end if
end choose
Top
2、 支付
//划卡后进行相应地处理
//再次判断网络状态,
choose case gs_system_qt.ls_ictype
case 'MW RD-EB' //明华
//从IC卡中读取数据
if chk_4442(icdev) < 0 then
st_2.text="未检测到IC卡,请插入IC卡后按『确定』进行支付操作..."
gf_icbeep(icdev,-1)
return
end if
//验证密码
password=gf_geticpwd(gs_system_qt.ls_userid)
asc_hex(password,password1,3)
if csc_4442(icdev, 3,ref password1) < 0 then
rsct_4442(icdev,ref counter) //读出密码错误计数器
st_2.text="密码校验失败!该卡密码错误计数还剩"+String(counter)+"次!"
gf_icbeep(icdev,-1)
return
end if
rsct_4442(icdev,ref counter) //读出密码错误计数器
if counter<1 then
st_2.text="此卡由于三次密码错误,已经锁定!"
gf_icbeep(icdev,-1)
return
End If
//从IC卡中读取信息
offset=32
length=174
ls_readdata=space(174)
if srd_4442(icdev, Offset, length,ref ls_readdata) = 0 then
ls_readdata = space(31) + ls_readdata
//判断是不是新卡
if mid(ls_readdata,32,1)<>"s" then
gf_icbeep(icdev,-1)
gf_messagebox(1,"此卡尚未发行,请重新插入卡片...")
return
end if
ls_cardcode = trim(mid(ls_readdata,33,50))
//读出卡中的余额
ldec_money_card = dec(mid(ls_readdata,83,20))
//卡的可用金额 = 卡余额 - 储值卡消费下限
ldec_money_card = ldec_money_card - gs_system_qt.ldec_cardminmoney
//读取卡本次发行操作次数
ll_operatorid=long(mid(ls_readdata,201,5)) + 1
ls_operatorid = string(ll_operatorid)
//计算写到卡里的余额
ldec_money_card_now = ldec_money_card - ldec_money_now + gs_system_qt.ldec_cardminmoney
//给要写入的数据赋值:金额,卡片ID,本次发行操作次数
//第83-第102: 金额(20位),
ls_alldata = string(ldec_money_card_now) + space(20 - len(string(ldec_money_card_now)))
//第103-第112: 卡片ID(10位),
ls_alldata = ls_alldata + mid(ls_readdata,103,10)
//第113: 卡片状态(1位)
ls_alldata = ls_alldata + mid(ls_readdata,113,1)
//第114-第200: 服装软件使用(87位),
ls_alldata = ls_alldata + mid(ls_readdata,114,87)
//第201-第205: 本次发行使用次数(5位),
ls_alldata = ls_alldata + space(5 - len(ls_operatorid)) + ls_operatorid
//写入卡片
li_Offset = 83
li_length = 205 - 82
if swr_4442(icdev, li_Offset, li_length,ref ls_allData) <> 0 then
gf_icbeep(icdev,-1)
gf_messagebox(1,"写入卡片时发生错误!")
return
End If
//校验
ls_checkdata=space(205 - 82)
if srd_4442(icdev, 83, 205 - 82,ref ls_checkdata) = 0 then
if ls_checkdata <> ls_alldata then
gf_icbeep(icdev,-1)
messagebox("info","校验错误!")
return
end if
else
gf_icbeep(icdev,-1)
messagebox("info","读取校验错误!")
return
End If
gf_icbeep(icdev,1)
case 'DIY键盘IC卡'
if diy95_ic.is_card_on(icdev) <> 0 then
st_2.text="未检测到IC卡,请插入IC卡后按『确定』进行查询操作..."
gf_icbeep(icdev,-1)
return
end if
//卡上电
if diy95_ic.turnon_sle44xx(icdev,ls_datalen,ls_databuff) <> 0 then
st_2.text="IC卡上电失败..."
gf_icbeep(icdev,-1)
return
end if
//验证密码
password=gf_geticpwd(gs_system_qt.ls_userid)
asc_hex(password,password1,3) //该函数使用的时明华IC卡的函数
if diy95_ic.csc_sle44x2(icdev,3,password1) <> 0 then //密码校验失败
if diy95_ic.rsct_sle44x2(icdev,counter) = 0 then //读出密码错误计数器
gf_icbeep(icdev,-1)
st_2.text = "密码校验错误!此卡密码错误计数为:"+String(counter)+",请小心使用!"
return
end if
end if
//判断该卡是否已经被锁定
if diy95_ic.rsct_sle44x2(icdev,counter) = 0 then //读出密码错误计数器
if counter < 1 then
st_2.text="此卡由于三次密码错误,已经锁定!"
gf_icbeep(icdev,-1)
return
end if
end if
//从IC卡中读取信息
offset=32
length=120
ls_readdata=space(120)
if diy95_ic.srd_sle44x2(icdev,0,offset,length,ls_datalen,ls_readdata) = 0 then ls_readdata = space(31) + ls_readdata
//判断是不是新卡
if mid(ls_readdata,32,1)<>"s" then
gf_icbeep(icdev,-1)
gf_messagebox(1,"此卡尚未发行,请重新插入卡片...")
return
end if
//卡号
ls_cardcode = trim(mid(ls_readdata,33,50))
//读出卡中的余额
ldec_money_card = dec(mid(ls_readdata,83,20))
ls_operatorid = space(5)
if diy95_ic.srd_sle44x2(icdev,0,201,5,ls_datalen,ls_operatorid) = 0 then
ll_operatorid=long(ls_operatorid) + 1
ls_operatorid = string(ll_operatorid)
else
gf_icbeep(icdev,-1)
gf_messagebox(1,"读取卡片错误!")
return
end if
//给要写入的数据赋值:金额,卡片ID,卡片状态,服装部分,本次发行操作次数
//第83-第102: 金额(20位), ls_alldata=string(ldec_money_card_now)+space(20-len(string(ldec_money_card_now)))
//第103-第112: 卡片ID(10位),
ls_alldata = ls_alldata + mid(ls_readdata,103,10)
//第113: 卡片状态(1位)
ls_alldata = ls_alldata + mid(ls_readdata,113,1)
//第114-第200: 服装软件使用(87位),
ls_alldata = ls_alldata + space(87)// + mid(ls_readdata,114,87)
//第201-第205: 本次发行使用次数(5位),
ls_alldata = ls_alldata + space(5 - len(ls_operatorid)) + ls_operatorid
//写入卡片
li_Offset = 83
li_length = 205 - 82
if diy95_ic.swr_sle44x2(icdev,0,li_Offset,li_length,ref ls_allData) <> 0 then gf_icbeep(icdev,-1)
gf_messagebox(1,"写入卡片时发生错误!")
return
End If
//校验
ls_checkdata=space(205 - 82)
if diy95_ic.srd_sle44x2(icdev,0,83, 205 - 82,ls_datalen,ref ls_checkdata) = 0 then if ls_checkdata <> ls_alldata then
gf_icbeep(icdev,-1)
messagebox("info","校验错误!")
return
end if
else
gf_icbeep(icdev,-1)
messagebox("info","读取校验错误!")
return
End If
//下电
if diy95_ic.turnoff_sle44xx(icdev) <> 0 then
gf_icbeep(icdev,-1)
messagebox("info","下电失败!")
return
end if
gf_icbeep(icdev,1)
函数gf_icbeep
参数 类型
Icdev long
i_type Integer
choose case i_type
case 1
choose case gs_system_qt.ls_ictype
case 'MW RD-EB' //明华
dv_beep(icdev,10)
dv_beep(icdev,10)
case 'DIY键盘IC卡'
diy95_ic.dv_beep(icdev,1) //两声
end choose
case -1
choose case gs_system_qt.ls_ictype
case 'MW RD-EB' //明华
dv_beep(icdev,50)
case 'DIY键盘IC卡'//一共响4声
diy95_ic.dv_beep(icdev,0) //1声
diy95_ic.dv_beep(icdev,0) //1声
diy95_ic.dv_beep(icdev,0) //1声
diy95_ic.dv_beep(icdev,0) //1声
end choose
case else
choose case gs_system_qt.ls_ictype
case 'MW RD-EB' //明华
dv_beep(icdev,50)
dv_beep(icdev,50)
case 'DIY键盘IC卡'
diy95_ic.dv_beep(icdev,0) //1声
diy95_ic.dv_beep(icdev,0) //1声
diy95_ic.dv_beep(icdev,0) //1声
diy95_ic.dv_beep(icdev,0) //1声
diy95_ic.dv_beep(icdev,0) //1声
diy95_ic.dv_beep(icdev,0) //1声
diy95_ic.dv_beep(icdev,0) //1声
diy95_ic.dv_beep(icdev,0) //1声
end choose
end choose
Top