<P>这样呀,太简单了用ID卡就可以了。发一个定餐+混饭的源代码,B/S结构</P><P><!--#include file="conn.asp"-->
<%
'http://192.168.200.100/kaoq/kcardsea.asp?cardid=0000999999&jihao=10261
'这条是表示卡钟向服务器IP地址为192.168.200.100发送为卡号为0000999999和发送这台卡钟的机器编号10261</P><P>
if request("CardId")="" or request("jihao")="" then
Response.Write "Ricom Systemswww.ricom.com.hk"&"count=0&"&"gzbh=&"&"xm="&"TransErr"&"&bmbh=&"&"ksbh=1"&"&"&"ly="
'卡钟自动上传卡号,和机器编号,如果上传为空值,就发一条数据告诉卡钟没有接收成功。
else
'定义时间变量。
dim jobb,dtime,ddate,skkhtemp
dim jobb1,nowtime,beforetime,aftertime
ddate=year(now)&"-"&month(now)&"-"&day(now)
if hour(now)<10 then
dtime="0"&hour(now)
else
dtime=hour(now)
end if
if minute(now)<10 then
dtime=dtime&":"&"0"&minute(now)
else
dtime=dtime&":"&minute(now)
end if
if second(now)<10 then
dtime=dtime&":"&"0"&second(now)
else
dtime=dtime&":"&second(now)
end if
nowtime=cdate(ddate&" "&dtime)
nowtime1=ddate&" "&dtime
'nowtime='2003-05-01 10:00'
skkhtemp=Right("0000000"&trim(request("CardId")),7)
'定义卡号不足7位地自动在前补0
end if
set jobb0=server.CreateObject("adodb.recordset")
set jobb0.activeconnection=conn
jobb0.open "select beforetime from ST_CS_SYSTEM ",,1,3
if jobb0.eof then
Response.Write "Ricom Systemswww.ricom.com.hkcount=0&gzbh=&"&"xm=参数没有设置&"&"bmbh=&"&"ksbh=1"&"&"&"ly="
response.end
else
beforetime=dateadd("s",- jobb0("beforetime"),nowtime)
aftertime=dateadd("s",jobb0("beforetime"),nowtime)
end if
set jobb1=server.CreateObject("adodb.recordset")
set jobb1.activeconnection=conn
'查找数据库里是否有这张卡的人事资料,如果没有就在卡钟显示非法卡,并且可以外接报警灯,提示工作人员
jobb1.open "select xm,gzbh,poskh,mustpre from ST_CS_GZB where gzbh ='"&skkhtemp&"' and (outf is null or outf>'"&ddate&"')",,1,3
if jobb1.eof then
Response.Write "Ricom Systemswww.ricom.com.hkcount=0&gzbh=&"&"xm=非法卡&"&"bmbh=&"&"ksbh=1"&"&"&"ly="
response.end</P><P>
else
'这里判是就餐还是定餐
set jobb2=server.CreateObject("adodb.recordset")
set jobb2.activeconnection=conn
jobb2.open "select machine_fun from parameter where coding ="&clng(trim(request("jihao"))),,1,3
if jobb2.eof then
'在数据库查找,这台卡钟是否设置了
Response.Write "Ricom Systemswww.ricom.com.hkcount=0&gzbh=&"&"xm=卡钟未设置&"&"bmbh=&"&"ksbh=1"&"&"&"ly="
response.end
else
if jobb2("machine_fun")=1 then '订餐
'response.write trim(request("CardId"))&"abc"
'response.write ddate&"abc"
'response.write ddate&" "&dtime&"abc"
'response.write dtime&"abc"
'response.write clng(trim(request("jihao")))&"abc"
'response.write jobb2("machine_fun")&"abc"
'response.write jobb1("gzbh")
'response.end
set jobb21=server.CreateObject("adodb.recordset")
set jobb21.activeconnection=conn
'判断卡钟是否是在订餐时间内
jobb21.Open "select xh from ST_CS_CC_DC where jhfw like '%"&trim(request("jihao"))&"%' and dcdate1<='"&nowtime1&"' and dcdate2>='"&nowtime1&"'",,1,3
if jobb21.eof then
Response.Write "Ricom Systemswww.ricom.com.hkcount=0&gzbh=&"&"xm=未在定餐时间内&"&"bmbh=&"&"ksbh=1"&"&"&"ly="
else
conn.execute "insert into ST_RECORD_DC(poskh,fdate,skrq,sksj,DevID,machine_fun,gzbh)values('"&trim(request("CardId"))&"','"&ddate&"','"&ddate&" "&left(dtime,5)&"','"&left(dtime,5)&"',"&clng(trim(request("jihao")))&","&jobb2("machine_fun")&",'"&jobb1("gzbh")&"')"
Response.Write "Ricom Systemswww.ricom.com.hk"&"count=1&gzbh="&jobb1("gzbh")&"&"&"xm="&jobb1("xm")&skkhtemp&"订餐成功"&"&"&"bmbh=&"&"ksbh=1"&"&"&"ly="
end if </P><P>
response.end
else '就餐
'machine_fun=2
set jobb3=server.CreateObject("adodb.recordset")
set jobb3.activeconnection=conn
'判断卡钟的就餐时间
jobb3.Open "select xh,defaultmoney,defaultmoney1,ghfw from ST_CS_CC where ghfw like '%"&left(skkhtemp,1)&"%' and jhfw like '%"&trim(request("jihao"))&"%' and qssjc<='"&dtime&"' and zzsjc>='"&dtime&"'",,1,3
if jobb3.eof then
Response.Write "Ricom Systemswww.ricom.com.hkcount=0&gzbh=&"&"xm=未在就餐时间&"&"bmbh=&"&"ksbh=1"&"&"&"ly="
response.end
end if
'每餐只能就餐一次
set jobb5=server.CreateObject("adodb.recordset")
set jobb5.activeconnection=conn
'response.write "Select gzbh from ST_RECORD Where gzbh='"&jobb1("gzbh")&"' and fdate='"&ddate&"' and skrq>='"&(beforetime)&"' and cc="&jobb3("xh")
jobb5.Open "Select gzbh from ST_RECORD Where gzbh='"&jobb1("gzbh")&"' and fdate='"&ddate&"' and (skrq<'"&beforetime&"' or skrq>'"&aftertime&"') and cc="&jobb3("xh")
if jobb5.Eof then
set jobb52=server.CreateObject("adodb.recordset")
set jobb52.activeconnection=conn
jobb52.Open "Select gzbh from ST_RECORD Where gzbh='"&jobb1("gzbh")&"' and fdate='"&ddate&"' and (skrq>='"&beforetime&"' and skrq<='"&aftertime&"') and cc="&jobb3("xh")
if jobb52.eof then '已就餐,但是还在定义的时间范围内,不报警
else
Response.Write "Ricom Systemswww.ricom.com.hk"&"count=1&gzbh="&jobb1("gzbh")&"&"&"xm="&jobb1("xm")&"&"&"bmbh=&"&"ksbh=1"&"&"&"ly="
response.end
end if
else
'重复就餐,并且报警
Response.Write "Ricom Systemswww.ricom.com.hkcount=0&gzbh=&"&"xm=重复就餐&"&"bmbh=&"&"ksbh=1"&"&"&"ly="
response.end
end if
'自己特别设置的就餐卡,不用定餐也可以就餐
if left(skkhtemp,1)<>"1" and left(skkhtemp,1)<>"2" then
set jobb4=server.CreateObject("adodb.recordset")
set jobb4.activeconnection=conn
'判断是否已经定餐了,如果没有定餐就餐,报警
jobb4.Open "Select gzbh from ST_RECORD_DC_RESULT Where gzbh='"&jobb1("gzbh")&"' and fdate='"&ddate&"' and cc="&jobb3("xh")&" and flag='T'"
if jobb4.eof then
Response.Write "Ricom Systemswww.ricom.com.hkcount=0&gzbh=&"&"xm=未定餐&"&"bmbh=&"&"ksbh=1"&"&"&"ly="
response.end
end if
end if
'判断不同人员就餐的金额
if mid(skkhtemp,2,1)="1"then
conn.execute "insert into ST_RECORD(atttime,gzbh,poskh,skrq,fdate,jcje,cc,oper,posid) Values('"&dtime&"','"&jobb1("gzbh")&"','"&trim(request("CardId"))&"','"&ddate&" "&dtime&"','"&ddate&"',"&jobb3("defaultmoney1")&","&jobb3("xh")&",0,"&clng(trim(request("jihao")))&")"
else
conn.execute "insert into ST_RECORD(atttime,gzbh,poskh,skrq,fdate,jcje,cc,oper,posid) Values('"&dtime&"','"&jobb1("gzbh")&"','"&trim(request("CardId"))&"','"&ddate&" "&dtime&"','"&ddate&"',"&jobb3("defaultmoney")&","&jobb3("xh")&",0,"&clng(trim(request("jihao")))&")"
end if
Response.Write "Ricom Systemswww.ricom.com.hk"&"count=1&gzbh="&jobb1("gzbh")&"&"&"xm="&jobb1("xm")&skkhtemp&"&"&"bmbh=&"&"ksbh=1"&"&"&"ly="
'消费成功,并且在卡钟上显示姓名和工号,(这里可以自己随便定义显示的内容如:可以显示剩于金额和次数)
response.end
end if
end if
end if
conn.close
response.end
</P><P> %></P><P>
国海实时一卡通
曹望君 QQ:17571611
TEL:0769-2062459 13713313384 FAX:0769-2314127
EMAIL:CWJJACK@163.COM
实时TCP/IP考勤、门禁、消费机
只做TCP/IP实时系列一卡通,和OEM产品。
</P> |