下機找好邏輯然後慢慢來,平靜下心來,其實也不難。
主要邏輯和上機還是挺像的。
如圖:
部分**如下:
一、判斷卡號是否為空:
if trim(txtcardno.text) = "" then
msgbox "請輸入卡號,卡號不能為空!", 48, "提示"
exit sub '防止錯誤 3021
二、判斷此卡是否存在
else
txtsql = "select * from student_info where cardno='" & txtcardno.text & "'"
set mrc = executesql(txtsql, msgtext)
if mrc.eof = true then
msgbox "此卡不存在,請重新輸入", 48, "提示"
三、檢查此卡是否登出
else
txtsql = "select * from student_info where cardno='" & txtcardno.text & "'and status='不使用'"
set mrc = executesql(txtsql, msgtext)
if mrc.eof = false then
msgbox "此卡已經被登出,請重新輸入卡號", 48, "提示"
txtcardno.text = ""
mrc.close
四、檢查此卡是否上機
else
txtsql = "select * from online_info where cardno='" & txtcardno.text & "'"
set mrc = executesql(txtsql, msgtext)
if mrc.eof = true then
msgbox "此卡未上機,請輸入其他卡號!", 48, "提示"
exit sub '防止出現錯誤 3021
五、計算消費金額,這裡只有小於兩分鐘的,大於兩分鐘的和計算消費餘額寫在了一起。
else
txtofftime.text = time
txtoffdate.text = date
txtlinetime.text = datediff("n", txtontime.text, txtofftime.text) '注意datediff函式的使用 n代表計算的單位,這裡是分鐘,後面依次是開始時間和結束時間。
'計算消費金額
'先判斷消費時間是否小於兩分鐘,如果小於兩分鐘,則不收費的
txtsql = "select * from basicdata_info"
set mrc1 = executesql(txtsql, msgtext)
txtsql = "select* from student_info where cardno='" & txtcardno.text & "'"
set mrc = executesql(txtsql, msgtext)
if txtlinetime.text <= 2 then
txtconsume.text = 0
txtbalance.text = mrc.fields(7)
六、計算消費餘額,用已有的錢減去消費的金額。這裡分為固定使用者和臨時使用者,臨時使用者是一小時三元錢,固定使用者是一小時兩元錢,這在basicbase表中有顯示。
if mrc.fields(14) = "固定使用者" then
txtconsume.text = (txtlinetime.text / mrc1.fields(2)) * mrc1.fields(0)
'計算消費餘額
txtbalance.text = format(val(mrc.fields(7)) - val(txtconsume.text), "0.00")
else'如果不是固定使用者的話
txtconsume.text = (txtlinetime.text / mrc1.fields(2)) * mrc1.fields(1)
'計算消費餘額
txtbalance.text = trim(format(val(mrc.fields(7)) - val(txtconsume.text), "0.00"))
end if
然後將資訊同步line表,將資訊從online表中刪除
'將下機的資訊寫到line表當中
txtsqlline = "select * from line_info"
set mrcline = executesql(txtsqlline, msgtext)
mrcline.fields(8) = trim(txtoffdate.text)
mrcline.fields(9) = txtofftime.text
mrcline.fields(10) = txtlinetime.text
mrcline.fields(11) = val(txtconsume.text)
mrcline.fields(12) = val(txtbalance.text)
'將資訊從online表中刪除
txtsql = "select * from online_info"
set mrc = executesql(txtsql, msgtext)
label15.caption = mrc.recordcount - 1
mrc.delete
mrc.update
mrc.close
現在明白了,但當時弄了差不多乙個上午,回過來看也不難。 機房收費系統之下機
收費了,開始收費了,機房終於要做到收費的階段了。本目前為止,終於扣題了。關於收費的難點就是時間差的計算,時間差算出來錢就可以隨便算 只要你不怕被打 不過前提是合理。下面就說說怎麼計算這個時間差。1 在就算時間差的時候,用到了 datediff 函式,關於函式的使用規則,這裡給出簡單介紹 datedi...
機房收費系統(二)之下機退卡
今天我又回顧了一下 機房管理系統,看見了我熟悉的花費了我三天才敲好的窗體 當然想了兩天 然後今天我就來總結一下下機退卡吧!第一句話是讓子窗體在父窗體中的框裡顯示!其他的然後就是定義函式名稱 然後接下來就是 呼叫函式,並計算上機時間的消費金額 接下來就是將 寫上資料庫中 寫完之後就關閉掉資料庫 整理思...
機房收費系統 下機
有了上機的思路,下機當然也就很簡單了,不過總是要比別人多想一步,這樣你就能夠比別人更加的優秀。下機的流程圖 下機的注意事項 txtontime.text trim mrc3.fields 7 txtdowndate.text format now yyyy mm dd txtdowntime.tex...