1.结账,结谁的账?
在这里就要理清管理员、操作员和一般用户之间的关系了。
结账是管理员的权限,他结账的对象是操作员。其实就是操作员辛辛苦苦工作一天,把收的钱、退给用户的钱最后算一个总数交给拥有管理员权限的老板。
在理清了管理员和操作员的关系之后,对于窗体上为什么会出现那些内容以及相关的功能也就好理解多了。
2.结账中的各种费用是什么?
结账中涉及到购卡、充值、退卡、临时用户,这些还是比较容易理解的,就是该操作员今天完成的相关业务。
至于汇总中的总售卡数、售卡张数、退卡张数、退卡金额、充值金额、临时收费金额、应收金额可能会有些歧义。
总售卡数:开始我的理解是 总售卡数=售卡张数+退卡张数,现在我认为这样有些不妥,如果是老板在看这个账目汇总的时候,他会看这个操作员今天卖了多少张卡,退给用户多少张卡,以及退了多少钱,收了多少钱,但是他退卡+售卡的加和这个数据对他来说意义不是很大,因为它并表示什么
所以,目前我认为总售卡数指的是今天所有操作员一共售卡的总数(这个数据对老板还是有参考价值的)
售卡张数:该操作员今天售卡的张数,也代表今天赢得多少用户
退卡张数:该操作员今天退卡的张数,也代表今天损失多少用户
退卡金额:该操作员今天退给用户金额的总数,也代表今天损失的金额
充值金额:该操作员今天为注册用户充值的金额,一般说来也是今天大部分的实际现金收入
临时收费金额:该操作员今天对临时用户收取的实际消费金额
应收金额:充值金额+临时收费金额-退卡金额,其实就是该操作员今天实际应该上交给老板的金额
3.功能如何实现?
(1)应用SSTaB控件,在 工程→部件→控件 中勾选“Microsoft Tabbed Dialog Control”控件
(2)“购卡”“充值”“退卡”“临时用户”“汇总”功能点击时调取相应的数据库中的表就好了
(3)具体代码如下:
Private Sub SSTab_Click(PreviousTab As Integer)
'***************************操作员combobox不能为空****************************
If Not Testtxt(cmbUsername.Text) Then '测试文本框是否有文本输入
MsgBox "请选择操作员用户名!", vbOKOnly + vbExclamation, "警告"
cmbUsername.SetFocus
Exit Sub
End If
'*****************************************************************************
If SSTab.Caption = "购卡" Then
myflexgrid1.Clear
txtSQL = "select * from student_Info where userID='" & cmbUsername.Text & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
txtTotalAmount.Text = mrc.RecordCount
With myflexgrid1 '设置myflexgrid
.ColWidth(2) = 2000
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
.Rows = 1
Do While Not mrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrc.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrc.Fields(0))
.TextMatrix(.Rows - 1, 2) = Trim(mrc.Fields(12))
.TextMatrix(.Rows - 1, 3) = Trim(mrc.Fields(13))
mrc.MoveNext
Loop
End With
mrc.Close
End If
If SSTab.Caption = "充值" Then
myflexgrid2.Clear
txtSQL = "select * from Recharge_Info where userID='" & cmbUsername.Text & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
With myflexgrid2 '设置myflexgrid
.ColWidth(3) = 2000
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "充值金额"
.TextMatrix(0, 3) = "日期"
.TextMatrix(0, 4) = "时间"
.Rows = 1
Do While Not mrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrc.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrc.Fields(2))
.TextMatrix(.Rows - 1, 2) = Trim(mrc.Fields(3))
.TextMatrix(.Rows - 1, 3) = Trim(mrc.Fields(4))
.TextMatrix(.Rows - 1, 4) = Trim(mrc.Fields(5))
txtRecharge2.Text = Val(txtRecharge2.Text) + Val(Trim(mrc.Fields(3)))
mrc.MoveNext
Loop
End With
mrc.Close
End If
If SSTab.Caption = "退卡" Then
myflexgrid3.Clear
txtSQL = "select * from student_Info where userID='" & cmbUsername.Text & "'" & " and status='不使用'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
txtExitCardAmount.Text = mrc.RecordCount
With myflexgrid3 '设置myflexgrid
.ColWidth(3) = 2000
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "退卡金额"
.TextMatrix(0, 3) = "日期"
.TextMatrix(0, 4) = "时间"
.Rows = 1
Do While Not mrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrc.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrc.Fields(0))
.TextMatrix(.Rows - 1, 2) = Trim(mrc.Fields(7))
.TextMatrix(.Rows - 1, 3) = Trim(mrc.Fields(12))
.TextMatrix(.Rows - 1, 4) = Trim(mrc.Fields(13))
txtExitCash2.Text = Val(txtExitCash2.Text) + Val(Trim(mrc.Fields(7)))
mrc.MoveNext
Loop
End With
mrc.Close
End If
If SSTab.Caption = "临时用户" Then
myflexgrid4.Clear
txtSQL = "select * from student_Info where userID='" & cmbUsername.Text & "'" & " and type='临时用户'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
With myflexgrid4 '设置myflexgrid
.ColWidth(3) = 2000
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
.Rows = 1
Do While Not mrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrc.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrc.Fields(0))
.TextMatrix(.Rows - 1, 2) = Trim(mrc.Fields(12))
.TextMatrix(.Rows - 1, 3) = Trim(mrc.Fields(13))
mrc.MoveNext
Loop
End With
mrc.Close
End If
If SSTab.Caption = "汇总" Then
Dim i As Integer
If txtCash.Text = "0" Then '限制重复结账
txtCardAmount.Text = Val(txtTotalAmount.Text) - Val(txtExitCardAmount.Text)
txtExitCash.Text = txtExitCash2.Text
txtRecharge.Text = txtRecharge2.Text
txtSQL = "select * from student_Info where userID='" & cmbUsername.Text & "'" & " and type='临时用户'" & " and status='使用'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
For i = 1 To mrc.RecordCount
txtTemCash.Text = Val(txtTemCash.Text) + Val(Trim(mrc.Fields(7)))
Next i
mrc.Close
txtCash.Text = Val(txtTemCash.Text) + Val(txtRecharge.Text) - Val(txtExitCash.Text)
End If
End If
End Sub
总结:
这一块的内容难点就是在逻辑上,具体实现上问题应该不大。
逻辑方面弄清楚软件的使用对象,具体工作流程,以及相关业务需求其实也就容易理解多了,通过结合我们平时的日常生活,相信可以找到类似的模式。
软件中实现功能固然可贵,但是想到有这些功能更加可贵。
本文详细解析了操作员结算过程,包括结账对象、费用类型及汇总数据解释,并展示了如何通过SSTaB控件及数据库操作实现购卡、充值、退卡、临时用户等软件功能。
1684





