第一次機房之結賬
阿新 • • 發佈:2018-11-27
結賬是做機房遇到的難點之一, 難在是第一次接觸結賬計算功能,所以很多情況考慮不夠全面,做之前一定要梳理關係,把結賬的關係梳理清楚,有一個自己的思路,那麼,做起來還是很簡單的,每一個功能都有它的套路,只要找到了關鍵的部分,剩下的就是去做了。
結賬分為五步:1、選擇操作員。2、查詢資訊。3、計算彙總資訊。4、進行結賬計算。5、退出
第一步,選擇操作員使用者名稱,在這需要考慮的是,操作員使用者名稱能否選擇管理員,在軟體的使用過程中,管理員也有操作員的全部功能,所以個人認為,操作員使用者名稱應選擇操作員和管理員。通過操作員使用者名稱獲取姓名,這個很簡單,就不在這裡說了
第二步,查詢購卡、充值、退卡、臨時使用者資訊,這些查詢功能使用sql查詢語句就可以做到,以下為查詢程式碼:
如:
'購卡 '連線資料庫 txtsql = "select * from student_Info where UserID='" & Trim(cbuser.Text) & "'and ischeck='未結賬'" Set mrc = ExecuteSQL(txtsql, msgtext) '充值 '連線資料庫 txtsql = "select * from ReCharge_Info where UserID='" & cbuser.Text & "'and status='未結賬'" Set mrc = ExecuteSQL(txtsql, msgtext) '退卡 '連線資料庫 txtsql = "select * from CancelCard_Info where UserID='" & Trim(cbuser.Text) & "'and status='未結賬'" Set mrc = ExecuteSQL(txtsql, msgtext) '臨時使用者 '連線資料庫 txtsql = "select * from student_Info where UserID='" & Trim(cbuser.Text) & "'and type='臨時使用者'and ischeck='未結賬'" Set mrc = ExecuteSQL(txtsql, msgtext)
第三步,彙總
彙總需要計算,該操作員售卡張數、退卡金額、退卡張數、總售卡數、充值金額、應收金額、臨時收費金額
售卡張數通過student_Info表查出,查詢程式碼為
'通過student表---查詢該操作員售卡數, txtsql = "select * from student_Info where UserID='" & Trim(cbuser.Text) & "'and ischeck='未結賬'" 'and date=date and status='使用'" Set mrc = ExecuteSQL(txtsql, msgtext)
退卡金額通過CancelCard_Info表查出,查詢程式碼為
'通過CandelCard表,檢視退卡金額
txtsql = "select SUM(CancelCash) AS SUM_Info from CancelCard_Info where userID = '" & Trim(cbuser.Text) & "' and status='未結賬'"
Set mrc = ExecuteSQL(txtsql, msgtext)
退卡張數通過CancelCard_Info表,查詢程式碼為
'查詢退卡張數
txtsql = "select * from CancelCard_Info where userID='" & Trim(cbuser.Text) & "'and status= '未結賬' "
Set mrc = ExecuteSQL(txtsql, msgtext)
總售卡數通過student_Info查詢,查詢程式碼為
'機房該操作員總售卡數
txtsql = "select * from student_Info where UserID='" & Trim(cbuser.Text) & "'"
Set mrc = ExecuteSQL(txtsql, msgtext)
充值金額利用臨時表查出,程式碼為
'充值金額
txtsql = "select SUM(addmoney) AS SUM_Info from ReCharge_Info where userID = '" & cbuser.Text & "' and status='未結賬'"
Set mrc = ExecuteSQL(txtsql, msgtext)
If IsNull(Trim(mrc.Fields(0))) Then '充值金額是否為空
txtcash.Text = 0
Else
txtcash.Text = mrc.Fields(0)
End If
本期應收金額(消費金額+餘額)=本期充值金額-本期退卡金額
第四步,結賬
結賬,就是計算日結賬單和周結賬單中的內容,然後儲存到對應的CheckDay_Info表和checkWeek_Info表中,日結賬單和周結賬單中的內容是一樣的
日結賬單中需要計算的資訊和表中對應關係如下
上期餘額---RemainCash
本期充值金額---RechargeCash
本期消費金額---ConsumeCash
本期退款金額---CancelCash
本期金額---AllCash
日期---date
上期餘額計算查詢程式碼
'計算上期餘額
txtsql = "select sum(cash) from student_Info where UserID='" & Trim(cbuser.Text) & "'and ischeck = '" & "未結賬" & "'"
Set mrc = ExecuteSQL(txtsql, msgtext)
本期消費金額計算查詢程式碼
'從line表計算當日消費金額
txtsql = "select sum(consume) from Line_Info "
Set mrcL = ExecuteSQL(txtsql, msgtext)
第五步,退出
Unload Me
有不當之處,請在下方評論指出