机房收费系统之结账
2010-08-23 03:57
330 查看
该窗体的作用:管理员对每个操作员的工作情况进行查看(查看她卖了几张卡,充值了多少钱,退了多少钱等等)。
该窗体的主要思路:
1,遍历学生信息表(单击购卡选项时),充值信息表(单击充值选项时),退卡信息表(单击退卡选项时)中的该操作员和结账状态为“未结账”的金额。
2,单击结账选项时写入结账表,并将前面三个表中的结账状态标记为“已结账”,然后在将这些文本框清除。
SSTab控件的缺点和优点:
1,缺点:你写入到每个选项卡的事件只能在该选项再次变为当前活动选项时显示出来。(对于该缺点我觉得TabScrip控件比较好,它是一触发就会显示出来)
2,优点:SSTab的每个选项都是一个容器,而TabScrip控件只有一个容器。
该窗体的代码(单击SSTab选项卡时):
Private Sub SSTab1_Click(PreviousTab As Integer)
Dim strSQL As String
Dim MsgString As String
Dim mrs As ADODB.Recordset
Dim Registermoney As Single
Dim Rechargemoney As Single
Dim Backmoney As Single
'先判断真实名是否正确
strSQL = "select * from Userinfo where Username='" & Trim(cboUsername.Text) & "'"
Set mrs = ExecuteSQL(strSQL, MsgString)
If mrs.EOF Then
MsgBox "请选择操作员!", vbExclamation + vbOKOnly, "警告"
Exit Sub
End If
Select Case PreviousTab
Case 0 '选择购卡选项
BuyCardFlexGrid.Visible = True
strSQL = "select * from Studentinfo where Teacher='" & Trim(cboUsername.Text) & "' and CheckState='未结账'"
Set mrs = ExecuteSQL(strSQL, MsgString)
If mrs.EOF Then
With BuyCardFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "卡号"
.TextMatrix(0, 1) = "学号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
End With
Exit Sub
End If
With BuyCardFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "卡号"
.TextMatrix(0, 1) = "学号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
Do While Not (mrs.EOF)
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrs.Fields(0))
.TextMatrix(.Rows - 1, 1) = Trim(mrs.Fields(1))
.ColWidth(2) = 1600
.TextMatrix(.Rows - 1, 2) = Trim(mrs.Fields(12))
.TextMatrix(.Rows - 1, 3) = Trim(mrs.Fields(13))
Registermoney = Registermoney + Val(Trim(mrs.Fields(8)))
mrs.MoveNext
Loop
txtBuyCard.Text = mrs.RecordCount
txtRegister.Text = Trim(Registermoney)
mrs.Close
End With
txtSum.Text = Val(txtRegister.Text) + Val(txtRecharge.Text) - Val(txtBackMoney.Text)
Case 1 '选择充值选项
strSQL = "select * from Recharge where Teacher='" & Trim(cboUsername.Text) & "' and CheckState='未结账'"
Set mrs = ExecuteSQL(strSQL, MsgString)
If mrs.EOF Then
With RechargeFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "卡号"
.TextMatrix(0, 1) = "学号"
.TextMatrix(0, 2) = "充值金额"
.TextMatrix(0, 3) = "日期"
.TextMatrix(0, 4) = "时间"
End With
Exit Sub
End If
With RechargeFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "卡号"
.TextMatrix(0, 1) = "学号"
.TextMatrix(0, 2) = "充值金额"
.TextMatrix(0, 3) = "日期"
.TextMatrix(0, 4) = "时间"
Do While Not (mrs.EOF)
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrs.Fields(0))
.TextMatrix(.Rows - 1, 1) = Trim(mrs.Fields(8))
.TextMatrix(.Rows - 1, 2) = Trim(mrs.Fields(1))
Rechargemoney = Rechargemoney + Val(Trim(mrs.Fields(1)))
.ColWidth(3) = 1600
.TextMatrix(.Rows - 1, 3) = Trim(mrs.Fields(5))
.TextMatrix(.Rows - 1, 4) = Trim(mrs.Fields(4))
mrs.MoveNext
Loop
txtRecharge.Text = Trim(Rechargemoney)
mrs.Close
End With
txtSum.Text = Val(txtRegister.Text) + Val(txtRecharge.Text) - Val(txtBackMoney.Text)
Case 2 '选择退卡选项
strSQL = "select * from BackCard where Teacher='" & Trim(cboUsername.Text) & "' and CheckState='未结账'"
Set mrs = ExecuteSQL(strSQL, MsgString)
If mrs.EOF Then
With BackCardFlexGrid
.Cols = 5
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "卡号"
.TextMatrix(0, 1) = "学号"
.TextMatrix(0, 2) = "退卡金额"
.TextMatrix(0, 3) = "日期"
.TextMatrix(0, 4) = "时间"
End With
Exit Sub
End If
With BackCardFlexGrid
.Cols = 5
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "卡号"
.TextMatrix(0, 1) = "学号"
.TextMatrix(0, 2) = "退卡金额"
.TextMatrix(0, 3) = "日期"
.TextMatrix(0, 4) = "时间"
Do While Not (mrs.EOF)
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrs.Fields(0))
.TextMatrix(.Rows - 1, 1) = Trim(mrs.Fields(6))
.TextMatrix(.Rows - 1, 2) = Trim(mrs.Fields(1))
Backmoney = Backmoney + Val(Trim(mrs.Fields(1)))
.ColWidth(3) = 1600
.TextMatrix(.Rows - 1, 3) = Trim(mrs.Fields(2))
.TextMatrix(.Rows - 1, 4) = Trim(mrs.Fields(3))
mrs.MoveNext
Loop
txtBackCard.Text = mrs.RecordCount
txtBackMoney.Text = Trim(Backmoney)
mrs.Close
End With
txtSum.Text = Val(txtRegister.Text) + Val(txtRecharge.Text) - Val(txtBackMoney.Text)
Case 3 '选择汇总选项
txtSum.Text = Val(txtRegister.Text) + Val(txtRecharge.Text) - Val(txtBackMoney.Text)
'标记结账
' bCheckOut = True
'向结账表中添加数据,每个操作员一天只有一条记录
strSQL = "select * from Checkout where Operatername='" & Trim(cboUsername.Text) & "'"
Set mrs = ExecuteSQL(strSQL, MsgString)
'若没有新的记录则退出
If Trim(txtBuyCard.Text) = "0" And Trim(txtRecharge.Text) = "0" And Trim(txtBackCard.Text) = "0" And _
Trim(txtRegister.Text) = "0" And Trim(txtBackMoney.Text) = "0" And Trim(txtSum.Text) = "0" Then
Exit Sub
End If
mrs.AddNew
mrs.Fields(0) = Trim(cboUsername.Text)
mrs.Fields(1) = Trim(cboName.Text)
mrs.Fields(2) = Trim(txtBuyCard.Text)
mrs.Fields(3) = Trim(txtRecharge.Text)
mrs.Fields(4) = Trim(txtBackCard.Text)
mrs.Fields(5) = Trim(txtRegister.Text)
mrs.Fields(6) = Trim(txtBackMoney.Text)
mrs.Fields(7) = Trim(txtSum.Text)
mrs.Fields(8) = Date
mrs.Fields(9) = Time
mrs.Fields(10) = IIf(bCheckOut, "已结账", "未结账")
mrs.Fields(11) = Trim(strName)
mrs.Update
mrs.Close
End Select
End Sub
该窗体的主要思路:
1,遍历学生信息表(单击购卡选项时),充值信息表(单击充值选项时),退卡信息表(单击退卡选项时)中的该操作员和结账状态为“未结账”的金额。
2,单击结账选项时写入结账表,并将前面三个表中的结账状态标记为“已结账”,然后在将这些文本框清除。
SSTab控件的缺点和优点:
1,缺点:你写入到每个选项卡的事件只能在该选项再次变为当前活动选项时显示出来。(对于该缺点我觉得TabScrip控件比较好,它是一触发就会显示出来)
2,优点:SSTab的每个选项都是一个容器,而TabScrip控件只有一个容器。
该窗体的代码(单击SSTab选项卡时):
Private Sub SSTab1_Click(PreviousTab As Integer)
Dim strSQL As String
Dim MsgString As String
Dim mrs As ADODB.Recordset
Dim Registermoney As Single
Dim Rechargemoney As Single
Dim Backmoney As Single
'先判断真实名是否正确
strSQL = "select * from Userinfo where Username='" & Trim(cboUsername.Text) & "'"
Set mrs = ExecuteSQL(strSQL, MsgString)
If mrs.EOF Then
MsgBox "请选择操作员!", vbExclamation + vbOKOnly, "警告"
Exit Sub
End If
Select Case PreviousTab
Case 0 '选择购卡选项
BuyCardFlexGrid.Visible = True
strSQL = "select * from Studentinfo where Teacher='" & Trim(cboUsername.Text) & "' and CheckState='未结账'"
Set mrs = ExecuteSQL(strSQL, MsgString)
If mrs.EOF Then
With BuyCardFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "卡号"
.TextMatrix(0, 1) = "学号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
End With
Exit Sub
End If
With BuyCardFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "卡号"
.TextMatrix(0, 1) = "学号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
Do While Not (mrs.EOF)
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrs.Fields(0))
.TextMatrix(.Rows - 1, 1) = Trim(mrs.Fields(1))
.ColWidth(2) = 1600
.TextMatrix(.Rows - 1, 2) = Trim(mrs.Fields(12))
.TextMatrix(.Rows - 1, 3) = Trim(mrs.Fields(13))
Registermoney = Registermoney + Val(Trim(mrs.Fields(8)))
mrs.MoveNext
Loop
txtBuyCard.Text = mrs.RecordCount
txtRegister.Text = Trim(Registermoney)
mrs.Close
End With
txtSum.Text = Val(txtRegister.Text) + Val(txtRecharge.Text) - Val(txtBackMoney.Text)
Case 1 '选择充值选项
strSQL = "select * from Recharge where Teacher='" & Trim(cboUsername.Text) & "' and CheckState='未结账'"
Set mrs = ExecuteSQL(strSQL, MsgString)
If mrs.EOF Then
With RechargeFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "卡号"
.TextMatrix(0, 1) = "学号"
.TextMatrix(0, 2) = "充值金额"
.TextMatrix(0, 3) = "日期"
.TextMatrix(0, 4) = "时间"
End With
Exit Sub
End If
With RechargeFlexGrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "卡号"
.TextMatrix(0, 1) = "学号"
.TextMatrix(0, 2) = "充值金额"
.TextMatrix(0, 3) = "日期"
.TextMatrix(0, 4) = "时间"
Do While Not (mrs.EOF)
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrs.Fields(0))
.TextMatrix(.Rows - 1, 1) = Trim(mrs.Fields(8))
.TextMatrix(.Rows - 1, 2) = Trim(mrs.Fields(1))
Rechargemoney = Rechargemoney + Val(Trim(mrs.Fields(1)))
.ColWidth(3) = 1600
.TextMatrix(.Rows - 1, 3) = Trim(mrs.Fields(5))
.TextMatrix(.Rows - 1, 4) = Trim(mrs.Fields(4))
mrs.MoveNext
Loop
txtRecharge.Text = Trim(Rechargemoney)
mrs.Close
End With
txtSum.Text = Val(txtRegister.Text) + Val(txtRecharge.Text) - Val(txtBackMoney.Text)
Case 2 '选择退卡选项
strSQL = "select * from BackCard where Teacher='" & Trim(cboUsername.Text) & "' and CheckState='未结账'"
Set mrs = ExecuteSQL(strSQL, MsgString)
If mrs.EOF Then
With BackCardFlexGrid
.Cols = 5
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "卡号"
.TextMatrix(0, 1) = "学号"
.TextMatrix(0, 2) = "退卡金额"
.TextMatrix(0, 3) = "日期"
.TextMatrix(0, 4) = "时间"
End With
Exit Sub
End If
With BackCardFlexGrid
.Cols = 5
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "卡号"
.TextMatrix(0, 1) = "学号"
.TextMatrix(0, 2) = "退卡金额"
.TextMatrix(0, 3) = "日期"
.TextMatrix(0, 4) = "时间"
Do While Not (mrs.EOF)
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = Trim(mrs.Fields(0))
.TextMatrix(.Rows - 1, 1) = Trim(mrs.Fields(6))
.TextMatrix(.Rows - 1, 2) = Trim(mrs.Fields(1))
Backmoney = Backmoney + Val(Trim(mrs.Fields(1)))
.ColWidth(3) = 1600
.TextMatrix(.Rows - 1, 3) = Trim(mrs.Fields(2))
.TextMatrix(.Rows - 1, 4) = Trim(mrs.Fields(3))
mrs.MoveNext
Loop
txtBackCard.Text = mrs.RecordCount
txtBackMoney.Text = Trim(Backmoney)
mrs.Close
End With
txtSum.Text = Val(txtRegister.Text) + Val(txtRecharge.Text) - Val(txtBackMoney.Text)
Case 3 '选择汇总选项
txtSum.Text = Val(txtRegister.Text) + Val(txtRecharge.Text) - Val(txtBackMoney.Text)
'标记结账
' bCheckOut = True
'向结账表中添加数据,每个操作员一天只有一条记录
strSQL = "select * from Checkout where Operatername='" & Trim(cboUsername.Text) & "'"
Set mrs = ExecuteSQL(strSQL, MsgString)
'若没有新的记录则退出
If Trim(txtBuyCard.Text) = "0" And Trim(txtRecharge.Text) = "0" And Trim(txtBackCard.Text) = "0" And _
Trim(txtRegister.Text) = "0" And Trim(txtBackMoney.Text) = "0" And Trim(txtSum.Text) = "0" Then
Exit Sub
End If
mrs.AddNew
mrs.Fields(0) = Trim(cboUsername.Text)
mrs.Fields(1) = Trim(cboName.Text)
mrs.Fields(2) = Trim(txtBuyCard.Text)
mrs.Fields(3) = Trim(txtRecharge.Text)
mrs.Fields(4) = Trim(txtBackCard.Text)
mrs.Fields(5) = Trim(txtRegister.Text)
mrs.Fields(6) = Trim(txtBackMoney.Text)
mrs.Fields(7) = Trim(txtSum.Text)
mrs.Fields(8) = Date
mrs.Fields(9) = Time
mrs.Fields(10) = IIf(bCheckOut, "已结账", "未结账")
mrs.Fields(11) = Trim(strName)
mrs.Update
mrs.Close
End Select
End Sub