關於結賬窗口 這個存在比較多的異議,因爲這個是自己設計的軟件 所以裏邊要有自己的邏輯 自己想要實現什麼功能,最後軟件功能做出來要能夠“自圓其說” 在我理解的結賬窗體上想要實現的是管理員對每個操作員的工作的審覈
這裏所針對的是操作員的業績 無論是購卡 充值 退卡 還是臨時用戶都要有一個點將這些關聯起來 而這個點就是你選擇的操作員。
結賬相當於前面所做的功能的一個綜合應用 之所以這裏會是一個難點 就是因爲如果你的邏輯如果不是很通 或者是和你前面的邏輯有出入 這裏所彙總的信息就會不全面 或者說有漏洞那麼這個功能就不是一個可用的功能
在結賬窗口分爲“顯示”和“結賬” 顯示比較簡答 前面大部分都已經做過一遍了
Private Sub Combo1_Click()
Dim txtsql1 As String
Dim msgtext1 As String
Dim mrc1 As ADODB.Recordset
txtsql1 = "SElect * from user_info where userid = '" & Combo1.Text & "'"
Set mrc1 = ExecuteSQL(txtsql1, msgtext1)
Label10.Caption = mrc1.Fields(3)
'根據用戶名查看被註冊的學生 購卡
Dim sTxtsql As String
Dim sMsgtext As String
Dim sMrc As ADODB.Recordset
sTxtsql = "select * from student_info where userid = '" & Trim(Combo1.Text) & "'"
Set sMrc = ExecuteSQL(sTxtsql, sMsgtext)
With MSFlexGrid1
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "學號"
.TextMatrix(0, 1) = "卡號"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "時間"
Do While Not sMrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = sMrc.Fields(1)
.TextMatrix(.Rows - 1, 1) = sMrc.Fields(0)
.TextMatrix(.Rows - 1, 2) = sMrc.Fields(12)
.TextMatrix(.Rows - 1, 3) = sMrc.Fields(13)
sMrc.MoveNext
Loop
End With
'售卡張數
Text1.Text = sMrc.RecordCount
'臨時用戶
Dim lTxtsql As String
Dim lMsgtext As String
Dim lMrc As ADODB.Recordset
lTxtsql = "select * from student_Info where UserID='" & Trim(Combo1.Text) & "'and type='" & "臨時用戶" & "'and Ischeck='" & "未結賬" & "'"
Set lMrc = ExecuteSQL(lTxtsql, lMsgtext)
With MSFlexGrid4
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "學號"
.TextMatrix(0, 1) = "卡號"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "時間"
Do While Not lMrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = lMrc.Fields(1)
.TextMatrix(.Rows - 1, 1) = lMrc.Fields(0)
.TextMatrix(.Rows - 1, 2) = lMrc.Fields(12)
.TextMatrix(.Rows - 1, 3) = lMrc.Fields(13)
lMrc.MoveNext
Loop
End With
'充值金額
Dim cTxtsql As String
Dim cMsgtext As String
Dim cMrc As ADODB.Recordset
cTxtsql = "select * from recharge_info where userid = '" & Trim(Combo1.Text) & "'and status='" & "未結賬" & "'"
Set cMrc = ExecuteSQL(cTxtsql, cMsgtext)
With MSFlexGrid2
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "學號"
.TextMatrix(0, 1) = "卡號"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "時間"
.TextMatrix(0, 4) = "充值金額"
Do While Not cMrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = cMrc.Fields(1)
.TextMatrix(.Rows - 1, 1) = cMrc.Fields(2)
.TextMatrix(.Rows - 1, 2) = cMrc.Fields(4)
.TextMatrix(.Rows - 1, 3) = cMrc.Fields(5)
.TextMatrix(.Rows - 1, 4) = cMrc.Fields(3)
cMrc.MoveNext
Loop
End With
'退卡
Dim tTxtsql As String
Dim tMsgtext As String
Dim tMrc As ADODB.Recordset
tTxtsql = "select * from cancelcard_info where userid = '" & Trim(Combo1.Text) & "' and status ='" & "未結賬" & "'"
Set tMrc = ExecuteSQL(tTxtsql, tMsgtext)
With MSFlexGrid3
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "學號"
.TextMatrix(0, 1) = "卡號"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "時間"
.TextMatrix(0, 4) = "退卡金額"
Do While Not tMrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = tMrc.Fields(0)
.TextMatrix(.Rows - 1, 1) = tMrc.Fields(1)
.TextMatrix(.Rows - 1, 2) = tMrc.Fields(3)
.TextMatrix(.Rows - 1, 3) = tMrc.Fields(4)
.TextMatrix(.Rows - 1, 4) = tMrc.Fields(2)
tMrc.MoveNext
Loop
End With
Text2.Text = tMrc.RecordCount
End Sub
接下來是實現結賬功能
Private Sub Command1_Click()
Dim tTxtsql As String
Dim tMsgtext As String
Dim tMrc As ADODB.Recordset
Dim lTxtsql As String
Dim lMsgtext As String
Dim lMrc As ADODB.Recordset
Dim cTxtsql As String
Dim cMsgtext As String
Dim cMrc As ADODB.Recordset
Dim mrc1 As ADODB.Recordset
Dim mrc2 As ADODB.Recordset
Dim mrc3 As ADODB.Recordset
Dim t As Integer
Dim j As Integer
Dim i As Integer
'充值金額
cTxtsql = "select * from Recharge_Info where UserID='" & Trim(Combo1.Text) & "'and status='" & "未結賬" & "'" '充值時的金額
Set cMrc = ExecuteSQL(cTxtsql, cMsgtext)
t = 0
For i = 1 To cMrc.RecordCount
t = t + Val(cMrc.Fields(3))
' Text3.Text = Val(Text3.Text) + Val(cMrc.Fields(3))
Text3 = Val(t)
cMrc.MoveNext
Next i
'退卡金額
tTxtsql = "select * from CancelCard_Info where UserID='" & Trim(Combo1.Text) & "'and status='" & "未結賬" & "'" '退卡金額等於該操作員操作的所有用戶退卡金額的總和
Set tMrc = ExecuteSQL(tTxtsql, tMsgtext)
For i = 1 To tMrc.RecordCount
Text5.Text = Val(Text5.Text) + Val(tMrc.Fields(2))
tMrc.MoveNext
Next i
lTxtsql = "select * from student_Info where UserID='" & Trim(Combo1.Text) & "'and type='" & "臨時用戶" & "'and Ischeck='" & "未結賬" & "'"
Set lMrc = ExecuteSQL(lTxtsql, lMsgtext)
j = 0
If Not lMrc.EOF Then
For i = 1 To lMrc.RecordCount
j = j + Val(lMrc.Fields(7))
Text4.Text = Val(j)
lMrc.MoveNext
Next i
End If
'總售卡數
Text6.Text = Val(Text1.Text) + Val(Text2.Text)
'應收金額
Text7.Text = Val(Text3.Text) + Val(Text4.Text) - Val(Text5.Text)
'更新student表 將未結賬改爲結賬
lTxtsql = "select * from student_info where userid = '" & Trim(Combo1.Text) & "' and ischeck = '" & "未結賬" & "'"
Set mrc1 = ExecuteSQL(lTxtsql, lMsgtext)
Do While Not mrc1.EOF
mrc1!ischeck = "已結賬"
mrc1.Update
mrc1.MoveNext
Loop
mrc1.Close
'更新Recharge表
cTxtsql = "select * from recharge_info where userid = '" & Trim(Combo1.Text) & "' and status = '" & "未結賬" & "' "
Set mrc2 = ExecuteSQL(cTxtsql, cMsgtext)
Do While Not mrc2.EOF
mrc2!Status = "已結賬"
mrc2.Update
mrc2.MoveNext
Loop
mrc2.Close
'更新Cancelcard表
tTxtsql = "select * from cancelcard_info where userid = '" & Trim(Combo1.Text) & "' and status = '" & "未結賬" & "'"
Set mrc3 = ExecuteSQL(tTxtsql, tMsgtext)
Do While Not mrc3.EOF
mrc3!Status = "已結賬"
mrc3.Update
mrc3.MoveNext
Loop
mrc3.Close
MsgBox "結賬成功", 48, "提示"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
End Sub