VB機房收費系統08——結賬
阿新 • • 發佈:2019-02-16
Private Sub comboid_Click() '購卡 Dim txtsql As String Dim msgtext As String Dim mrc As ADODB.Recordset '查詢管理員 txtsql = "select * from User_Info where userID='" & comboid.Text & "'" Set mrc = ExecuteSQL(txtsql, msgtext) comboname.Text = mrc.Fields(3) mrc.Close txtsql = "select * from student_Info where UserID='" & comboid.Text & "'" Set mrc1 = ExecuteSQL(txtsql, msgtext) '顯示購卡資訊 With MSFlexGrid1 .Rows = 1 .CellAlignment = 4 .TextMatrix(0, 0) = "學號" .TextMatrix(0, 1) = "卡號" .TextMatrix(0, 2) = "日期" .TextMatrix(0, 3) = "時間" Do While Not mrc1.EOF .Rows = .Rows + 1 .CellAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrc1.Fields(1)) .TextMatrix(.Rows - 1, 1) = Trim(mrc1.Fields(0)) .TextMatrix(.Rows - 1, 2) = Trim(mrc1.Fields(12)) .TextMatrix(.Rows - 1, 3) = Trim(mrc1.Fields(13)) mrc1.MoveNext Loop .Rows = .Rows - 1 Text1.Text = Int(.Rows - 1) '彙總:售卡張數 End With mrc1.Close '充值 Dim mrcrecharge As ADODB.Recordset '查詢管理員 txtsql = "select * from ReCharge_Info where userID='" & comboid.Text & "'" Set mrcrecharge = ExecuteSQL(txtsql, msgtext) '顯示購卡資訊 With MSFlexGrid2 .Rows = 1 .CellAlignment = 4 .TextMatrix(0, 0) = "學號" .TextMatrix(0, 1) = "卡號" .TextMatrix(0, 2) = "充值金額" .TextMatrix(0, 3) = "日期" .TextMatrix(0, 4) = "時間" Do While Not mrcrecharge.EOF .Rows = .Rows + 1 .CellAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrcrecharge.Fields(1)) .TextMatrix(.Rows - 1, 1) = Trim(mrcrecharge.Fields(2)) .TextMatrix(.Rows - 1, 2) = Trim(mrcrecharge.Fields(3)) .TextMatrix(.Rows - 1, 3) = Trim(mrcrecharge.Fields(4)) .TextMatrix(.Rows - 1, 4) = Trim(mrcrecharge.Fields(5)) Text3.Text = Val(.TextMatrix(.Rows - 1, 2)) + Val(Text3.Text) '彙總:充值金額 mrcrecharge.MoveNext Loop End With mrcrecharge.Close '退卡 Dim mrccancelcard As ADODB.Recordset '查詢管理員 txtsql = "select * from CancelCard_Info where userID='" & comboid.Text & "'" Set mrccancelcard = ExecuteSQL(txtsql, msgtext) '顯示購卡資訊 With MSFlexGrid3 .Rows = 1 .CellAlignment = 4 .TextMatrix(0, 0) = "學號" .TextMatrix(0, 1) = "卡號" .TextMatrix(0, 2) = "日期" .TextMatrix(0, 3) = "時間" .TextMatrix(0, 4) = "退卡金額" Do While Not mrccancelcard.EOF .Rows = .Rows + 1 .CellAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrccancelcard.Fields(0)) .TextMatrix(.Rows - 1, 1) = Trim(mrccancelcard.Fields(1)) .TextMatrix(.Rows - 1, 2) = Trim(mrccancelcard.Fields(3)) .TextMatrix(.Rows - 1, 3) = Trim(mrccancelcard.Fields(4)) .TextMatrix(.Rows - 1, 4) = Trim(mrccancelcard.Fields(2)) Text5.Text = Val(mrccancelcard.Fields(2)) + Val(Text5.Text) '彙總:退卡金額 mrccancelcard.MoveNext Loop .Rows = .Rows - 1 Text2.Text = Int(.Rows - 1) '彙總:退卡張數 End With mrccancelcard.Close '臨時使用者 txtsql = "select * from student_Info where UserID='" & comboid.Text & "'" & " " & "and type ='" & "臨時使用者" & "'" Set mrc1 = ExecuteSQL(txtsql, msgtext) '顯示購卡資訊 With MSFlexGrid4 .Rows = 1 .CellAlignment = 4 .TextMatrix(0, 0) = "學號" .TextMatrix(0, 1) = "卡號" .TextMatrix(0, 2) = "日期" .TextMatrix(0, 3) = "時間" Do While Not mrc1.EOF .Rows = .Rows + 1 .CellAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrc1.Fields(1)) .TextMatrix(.Rows - 1, 1) = Trim(mrc1.Fields(0)) .TextMatrix(.Rows - 1, 2) = Trim(mrc1.Fields(12)) .TextMatrix(.Rows - 1, 3) = Trim(mrc1.Fields(13)) Text4.Text = Val(mrc1.Fields(7)) + Val(Text4.Text) '彙總:臨時收費金額 mrc1.MoveNext Loop End With mrc1.Close Text6.Text = Val(Text1.Text) - Val(Text2.Text) '彙總:總售卡數 Text7.Text = Val(Text3.Text) - Val(Text5.Text) '彙總: 應收金額 End Sub Private Sub Command1_Click() '結賬 Dim txtsql As String Dim msgtext As String Dim mrc As ADODB.Recordset txtsql = "select * from student_Info where UserID='" & comboid.Text & "'" & " " & "and Ischeck ='" & "未結賬" & "'" Set mrc = ExecuteSQL(txtsql, msgtext) mrc.Fields(11) = "結賬" mrc.Update mrc.Close MsgBox "結賬成功!", vbonly + vbExclamation, "提示" Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" Text6.Text = "" Text7.Text = "" End Sub Private Sub Form_Load() comboid.AddItem "12" End Sub '退出 Private Sub SSTab1_Click(PreviousTab As Integer) Select Case SSTab1.Tab Case 5 Unload Me End Select End Sub