接踵而至的是结账,在这一部分中重要的清晰的思路,理清钱的来龙去脉。琢磨清楚结账的钱是哪个操作员结的,结的是哪个用户的帐。在这个系统中有着不同的权限,管理员、操作员、一般用户。在这里来个比喻:机房如思雨网吧,管理员就是思雨的大boss,而操作员就是平常在那里的干活的人,而对于一般用户就是那些在哪做兼职的网管,就是做一些最基本的操作,如查询余额、开个账号等。
清楚他们的具体操作权限,现在就晓得结账是谁在操作,给谁结账。只要有人上网柜台就会有操作员管理者上下机、充值、退卡等一系列的操作。管理员大boss就是查看是某某操作员值班时充了多少,退卡还了多少。检查柜台账面上的钱是否符合一天的结账金。
总售卡数=售卡张数-退卡张数
应收金额=充值金额-退卡金额
临时收费金额=临时用户充值金额-临时用户退卡金额
1.结账中临时收费金额到底是啥?
其实就是临时用户上机消费的金额,但是有的认为是所有用户上机的消费金额。只要你能清楚计算出每天的盈利就行,在此不纠结了,就按照我自己的思路往下写了。这是一个师姐在对待临时用户的几点问题,有则改之,无则加勉!
问题(1) 结账中的临时收费金额应该归到哪里呢?
临时收费金额应该是用户上机时的消费金额。所以我觉得这个应该换个名称叫做用户上机消费金额。所谓的上机消费金额也就相当于我们充在卡上的钱当我们上机后会被扣掉的部分,而这个临时收费金额也就是这个操作员所操作的用户所消费的金额总数。它是以一种电子的形式显示在计算机上,而不是我们实实在在拿到的钱。就像我们饭卡刷在机子上显示在刷卡机上的数字。所以结账的时候不应该把它算在其中。
问题(2) 临时收费中的临时到底指什么
其实这个问题基本上从上一个问题中也可以分析出来,我们需要明确的一点就是这里的“临时”一定不是临时用户中的临时,而是相对于收费状态来说的一种临时,所以当我们进行对临时收费金额结账的时候,一定是对所有的用户所消费的金额结账,而不是指对”临时“用户进行结账。
问题(3) 临时收费金额应该怎么结?
我们都知道了临时收费金额是所有用户的上机消费金额,那么应该怎么对于 某个操作员来说进行临时收费结账呢,可能有的人会说找到line表中这个操作员所操作的未结账的用户的消费金额,然后相加,但是line表中根本没有userid这个字段。而student表中的userid是在给学生注册卡时的操作员,而此学生上下机就不一定是这个操作员操作的了。那我们要怎么计算所有临时消费金额呢? 这个问题我始终绕不过来。。按照从第一个问题的思路这样下来下边这个临时收费金额根本没有办法去算,因为我们要算的是此操作员所操作的临时收费。。要不就是从第一个问题思路就错了???我始终想不通。后来,找了美红理了一下思路。。
原来,上边的问题错了!!
师姐告诉我说,其实这个临时收费金额你想让它是怎样就能是怎样,没有一个对与错的概念,只有优化的概念,只要你全心全意为人民考虑了,那这就是对的。上边的只是一种思路,其实还有很多方法去定义临时用户。我觉得从这个收费结账中,我发现了很多我们建表中的问题,也发现了其中的利与弊。只有经历过了,只有认真思考过了,我们才能找到更好的方法。才能更好的为人民服务。。。
现在知道了临时用户金额的概念了,下面就计算收费吧!
2.怎么给临时用户结账?我们就要追溯到临时用户的来源,找到其注册时的操作员,因此我们需要在student和line这两张表进行查询,但是line表中没有UseID,此时就要借助外键(给其注册的操作员也是管理它上下机的操作员)那么,结账时我们要在student表中先搜出此操作员并且未结账的在line表中的消费cash。
3.应收金额变成什么?
有人会说这里的应收金额会不会也改变,这个就在你查询充值时,只需要排除临时用户就行,也可以直接求总的充值金额,之后减去临时用户充值金额。
总结:
至于之前文中所说的对错,其实并不重要,由你自己的思想并坚持做下去才是重要的,在这个过程中不仅深思熟虑的考虑了各种可能的结果,就算最终结果错了也是有安慰的。说这些就是让你明白要有自己的想法,创造性的思维,不要拘泥于已有的模式。
'在 工程→部件→控件 中勾选“Microsoft Tabbed Dialog Control”控件
奉送个小知识点:
刚开始没有设置MDI窗体,是你之后改的,在设置的过程遇到这样的问题:在父窗体上无法添加label,text或者是commandbutton等这些控件。
原因:那是因为只有具有Align或者是不可见的控件(如timer)才可以直接放到mdi的主窗体上。因为mdi是其它子窗体的容器。如果能放置按钮的话,那么显示子窗体的时候按钮将会被盖住。可以先在mdi上放置一个具有Align属性的控件。例如PictureBox,再把按钮放到PictureBox上。这样才可以间接的把按钮放到mdi主窗体上。
结账部分代码:
Private Sub cmdCheckOut_Click()
Dim mrcc As New ADODB.Recordset, mraa As New ADODB.Recordset, mrbb As New ADODB.Recordset, mra As New ADODB.Recordset, mrb As New ADODB.Recordset, mrc As New ADODB.Recordset, mrd As New ADODB.Recordset
Dim i As Integer, Daycash As Integer, RemainCash2 As Integer, weeki As Integer, wekkn As Integer
Dim remaincash1
'空值验证
If comboUserId.Text = "" Then
MsgBox "请选择操作员!", , "温馨提示"
comboUserId.SetFocus
Exit Sub
End If
If Trim(txtScard.Text) = "" Or Trim(txtTuiKa.Text) = "" Or Trim(txtSallcard.Text) = "" Or Trim(txtAllmoney.Text) = "" Or Trim(txtKaJin.Text) = "" Or Trim(txtCharge.Text) = "" Or Trim(txtLinShi.Text) = "" Then
MsgBox "请完善结账信息然后结账!", , "温馨提示"
Exit Sub
End If
If Trim(txtScard.Text) = 0 Or Trim(txtTuiKa.Text) = 0 Or Trim(txtSallcard.Text) = 0 Or Trim(txtAllmoney.Text) = 0 Or Trim(txtKaJin.Text) = 0 Or Trim(txtCharge.Text) = 0 Or Trim(txtLinShi.Text) = 0 Then
IntR = MsgBox("结账信息均为零,是否依然结账?", vbYesNo, "温馨提示")
If IntR = vbNo Then
Exit Sub
End If
End If
'将结账结果添加到CheckDay_Info,方便做成日结账单
txtSQL = "select * from CheckDay_Info"
Set mraa = ExecuteSQL(txtSQL, MsgText)
'对于CheckDay_Info表剩余金额(RemainCash)的处理
'记录集如果为空
If mraa.RecordCount - 1 < 0 Then
remaincash1 = 0
Else
'记录最后一条记录的应收金额,作为新记录的剩余金额
mraa.MoveLast
remaincash1 = mraa!AllCash
End If
'做今日本操作员的日结账单,所以 ondate='" & Date & "'"
txtSQL = "select * from Line_Info where userID='" & Trim(comboUserId.Text) & "' and ondate='" & Date & "'"
Set mrbb = ExecuteSQL(txtSQL, MsgText)
'记录本操作员本日期间的总收入
For i = 0 To mrbb.RecordCount - 1
Daycash = Daycash + mrbb!consume
Next i
'CheckDay_Info表中添加记录
mraa.AddNew
'充值金额
mraa!RechargeCash = Trim(txtCharge.Text)
'退卡金额
mraa!cancelCash = Trim(txtKaJin.Text)
'应收金额
mraa!AllCash = Trim(txtAllmoney.Text)
'剩余金额
mraa!RemainCash = remaincash1
'今日收入总金额
mraa!ConsumeCash = Daycash
'日期
mraa!Date = Date
'时间
'mraa!Time = Time
'userID
'mraa!UserId = Trim(comboUserId.Text)
mraa.Update
mraa.Close
mrbb.Close
'**********************************************************************
'查找本操作员student表中未结账用户
txtSQL = "select Ischeck from student_Info where Ischeck='未结账' and UserID='" & Trim(comboUserId.Text) & "'"
Set mra = ExecuteSQL(txtSQL, MsgText)
'查找本操作员recharge表中未结账用户
txtSQL = "select status from ReCharge_Info where status='未结账' and UserID='" & Trim(comboUserId.Text) & "'"
Set mrb = ExecuteSQL(txtSQL, MsgText)
'查找本操作员canclecard表中未结账用户
txtSQL = "select status from CancelCard_Info where status='未结账' and UserID='" & Trim(comboUserId.Text) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
'将各自数据库中未结账修改为已结账
While mra.EOF = False
mra.Fields(0) = "已结账"
mra.Update
mra.MoveNext
Wend
mra.Close
While mrb.EOF = False
mrb.Fields(0) = "已结帐"
mrb.Update
mrb.MoveNext
Wend
mrb.Close
While mrc.EOF = False
mrc.Fields(0) = "已结帐"
mrc.Update
mrc.MoveNext
Wend
mrc.Close
'结账成功
MsgBox "结账成功!", vbInformation, "提示"
txtScard.Text = ""
txtSallcard.Text = ""
txtCharge.Text = ""
txtLinShi.Text = ""
txtTuiKa.Text = ""
txtAllmoney.Text = ""
txtKaJin.Text = ""
End Sub
'
查询对应操作员的所有操作:
Private Sub comboUserId_Click()
Dim mrc As ADODB.Recordset
Dim txtSQL As String
Dim MsgText As String
'判断是否为空
If Trim(comboUserId.Text = "") Then
MsgBox "请选择操作员用户名", vbOKOnly + vbExclamation, "警告"
comboUserId.SetFocus
Exit Sub
End If
txtSQL = "select * from User_Info where UserID='" & comboUserId.Text & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
comboUserName.Text = mrc.Fields(3)
mrc.Close
''''''''''''''购卡
txtSQL = "select * from student_info where userid = '" & Trim(comboUserId.Text) & "' And ischeck = '未结账'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = True Then
MsgBox "没有数据", , "警告"
Exit Sub
End If
With myFlexGrid1
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
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
''''''''''''
'''''''''''''充值 、、、、、
'''''''''''''
txtSQL = "select * from recharge_info where userid = '" & Trim(comboUserId.Text) & "' And status= '未结账'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
With myFlexGrid2
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "充值金额"
.TextMatrix(0, 3) = "日期"
.TextMatrix(0, 4) = "时间"
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))
mrc.MoveNext
Loop
End With
mrc.Close
'''''''''''''退卡
txtSQL = "select * from cancelcard_info where userid = '" & Trim(comboUserId.Text) & "' And status = '未结账'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
With myFlexGrid3
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
.TextMatrix(0, 4) = "退卡金额"
Do While Not mrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrc.Fields(0))
.TextMatrix(.Rows - 1, 1) = Trim(mrc.Fields(1))
.TextMatrix(.Rows - 1, 2) = Trim(mrc.Fields(3))
.TextMatrix(.Rows - 1, 3) = Trim(mrc.Fields(4))
.TextMatrix(.Rows - 1, 4) = Trim(mrc.Fields(2))
mrc.MoveNext
Loop
End With
mrc.Close ''''''''''
'''''''''''临时用户
txtSQL = "select * from student_info where userid = '" & Trim(comboUserId.Text) & "' And Ischeck = '未结账' and type='临时用户'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
With myFlexGrid4
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
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 Sub
选项卡需要显示的信息:Private Sub SSTab1_Click(PreviousTab As Integer)
Dim mrc As ADODB.Recordset
Dim txtSQL As String
Dim MsgText As String
Dim rcharge As String
Dim TuichargeMoney
'判断是否为空
If Trim(comboUserId.Text = "") Then
MsgBox "请选择操作员用户名", vbOKOnly + vbExclamation, "警告"
comboUserId.SetFocus
Exit Sub
End If
If SSTab1.Tab = 4 Then
'售卡张数
txtSQL = "select count(cardno) from student_Info where UserID='" & Trim(comboUserId.Text) & "' and ischeck = '未结账'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF And mrc.BOF Then
rcharge = 0
Else
rcharge = mrc.Fields(0)
End If
txtScard.Text = mrc.Fields(0)
'退卡张数
txtSQL = "select count(cardno) from student_Info where UserID='" & Trim(comboUserId.Text) & "' and status = '禁用'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF And mrc.BOF Then
Tuicharge = 0
Else
Tuicharge = mrc.Fields(0)
End If
txtTuiKa.Text = mrc.Fields(0)
'售卡总张数=售卡张数+退卡张数
txtSallcard = rcharge + Tuicharge
'充值金额
txtSQL = "select sum(addmoney) from Recharge_Info where UserID='" & Trim(comboUserId.Text) & "' and status = '未结账'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If IsNull(mrc.Fields(0).Value) Then
TRchargeMoney = 0
Else
RchargeMoney = mrc.Fields(0)
End If
txtCharge.Text = RchargeMoney
'
'退卡金额同充值金额
txtSQL = "select sum(cancelcash) from cancelcard_Info where UserID='" & Trim(comboUserId.Text) & "' and status = '未结账'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If IsNull(mrc.Fields(0).Value) Then
TuichargeMoney = 0
Else
TuichargeMoney = mrc.Fields(0)
End If
'
txtKaJin.Text = TuichargeMoney
'应收总金额=充值金额-退卡金额
txtAllmoney.Text = RchargeMoney - TuichargeMoney
End If
'临时收费
txtSQL = "select sum(addmoney) from recharge_Info where UserID='" & Trim(comboUserId.Text) & "' and type = '临时用户' and status = '未结账' "
Set mrc = ExecuteSQL(txtSQL, MsgText)
If IsNull(mrc.Fields(0).Value) Then
txtLinShi.Text = 0
Else
txtLinShi.Text = mrc.Fields(0)
End If
End Sub