第一次機房收費系統——結賬
阿新 • • 發佈:2018-12-12
前言:談到結賬,大家都覺得挺難的,當然我也是這麼覺得的,但是通過一段時間的磨練,最終還是解決了,那麼就來分享一下把!
頁面
首先談到頁面,我將臨時收費金額改成了上網收費金額。
彙總的計算
售卡張數
就是你今天所出售的卡數 注意: 是今天售的卡數。
退卡張數
即你今天所退的的卡數
充值金額
我認為註冊基礎餘額也是一種充值,所以我的充值是充值的錢+註冊時候的錢。
上網收費金額
即是上機產生的消費。
退卡金額
即你今天退卡所返還給使用者的錢。
總售卡數
即售卡張數-退卡張數
應收金額
即充值金額(充值金額包括充值金額+註冊時所充值的金額)-退卡金額
程式碼
新增操作員使用者名稱
Private Sub Form_Load() '讓窗體居中 Me.Left = Screen.Width / 2 - Me.Width / 2 Me.Top = Screen.Height / 2 - Me.Height / 2 BorderStyle = 1 WindowState = 0 '新增操作員使用者名稱 txtSQL = "select *from user_info where level='" & "操作員" & "' or level='" & "管理員" & "'" Set mrc_User = ExecuteSQL(txtSQL, MsgText) If mrc_User.EOF Then Exit Sub End If mrc_User.MoveFirst While Not mrc_User.EOF ComboUserID.AddItem mrc_User.Fields(0) mrc_User.MoveNext Wend mrc_User.Close '呼叫過程,新增表名 Call AddName End Sub
新增操作員真實姓名和四個控制元件中的內容
Private Sub ComboUserID_click() '新增操作員姓名 txtSQL = "select *from user_info where userid='" & Trim(ComboUserID.Text) & "'" Set mrc_User = ExecuteSQL(txtSQL, MsgText) If mrc_User.EOF Then mrc_User.Close Exit Sub End If lblUsrName.Caption = mrc_User.Fields(3) mrc_User.Close '呼叫過程,新增表名 Call AddName '購卡 SellNum = 0 '售卡張數為0 SellMoney = 0 txtSQL = "select*from student_info where userid='" & ComboUserID.Text & "'" & "and " & _ "ischeck='" & "未結賬" & "'and date='" & Date & "'" Set mrc_Stu_Sum = ExecuteSQL(txtSQL, MsgText) If mrc_Stu_Sum.EOF = False Then mrc_Stu_Sum.MoveFirst End If While Not mrc_Stu_Sum.EOF With FlexGridSell .Rows = .Rows + 1 .CellAlignment = 4 .ColAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrc_Stu_Sum.Fields(1)) '學號 .TextMatrix(.Rows - 1, 1) = Trim(mrc_Stu_Sum.Fields(0)) ' "卡號" .TextMatrix(.Rows - 1, 2) = Trim(mrc_Stu_Sum.Fields(13)) '"日期" .TextMatrix(.Rows - 1, 3) = Trim(mrc_Stu_Sum.Fields(14)) '"時間" SellMoney = SellMoney + Val(mrc_Stu_Sum.Fields(7)) SellNum = SellNum + 1 mrc_Stu_Sum.MoveNext End With Wend '關閉資料庫 mrc_Stu_Sum.Close '充值 AddMoney = 0 txtSQL = "select*from recharge_info where userid='" & ComboUserID.Text & "'" & "and " & _ "status='" & "未結賬" & "' and date='" & Date & "'" Set mrc_RE = ExecuteSQL(txtSQL, MsgText) If mrc_RE.EOF = False Then mrc_RE.MoveFirst End If While Not mrc_RE.EOF With FlexGridRe .Rows = .Rows + 1 .CellAlignment = 4 .ColAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrc_RE.Fields(1)) '學號 .TextMatrix(.Rows - 1, 1) = Trim(mrc_RE.Fields(2)) ' "卡號" .TextMatrix(.Rows - 1, 2) = Trim(mrc_RE.Fields(3)) '"充值金額" .TextMatrix(.Rows - 1, 3) = Trim(mrc_RE.Fields(4)) '"日期" .TextMatrix(.Rows - 1, 4) = Trim(mrc_RE.Fields(5)) '"時間" AddMoney = AddMoney + Val(mrc_RE.Fields(3)) mrc_RE.MoveNext End With Wend mrc_RE.Close '退卡 BackCard = 0 txtSQL = "select*from cancelcard_info where userid='" & ComboUserID.Text & "'" & "and " & _ "status='" & "未結賬" & "' and date='" & Date & "'" Set mrc_Stu_Off = ExecuteSQL(txtSQL, MsgText) If mrc_Stu_Off.EOF = False Then mrc_Stu_Off.MoveFirst End If While Not mrc_Stu_Off.EOF With FlexGridOff .Rows = .Rows + 1 .CellAlignment = 4 .ColAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrc_Stu_Off.Fields(1)) '學號 .TextMatrix(.Rows - 1, 1) = Trim(mrc_Stu_Off.Fields(0)) ' "卡號" .TextMatrix(.Rows - 1, 2) = Trim(mrc_Stu_Off.Fields(3)) '"日期" .TextMatrix(.Rows - 1, 3) = Trim(mrc_Stu_Off.Fields(4)) '"時間" .TextMatrix(.Rows - 1, 4) = Trim(mrc_Stu_Off.Fields(2)) '"退卡金額" BackNum = BackNum + 1 BackMoney = BackMoney + Val(mrc_Stu_Off.Fields(2)) mrc_Stu_Off.MoveNext End With Wend mrc_Stu_Off.Close '臨時使用者 txtSQL = "select*from student_info where userid='" & ComboUserID.Text & "'" & "and " & _ "ischeck='" & "未結賬" & "'" & "and " & _ "type='" & "臨時使用者" & "' and date='" & Date & "'" Set mrc_Stu_Tem = ExecuteSQL(txtSQL, MsgText) If mrc_Stu_Tem.EOF = False Then mrc_Stu_Tem.MoveFirst End If While Not mrc_Stu_Tem.EOF With FlexGridTem .Rows = .Rows + 1 .CellAlignment = 4 .ColAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrc_Stu_Tem.Fields(1)) '學號 .TextMatrix(.Rows - 1, 1) = Trim(mrc_Stu_Tem.Fields(0)) ' "卡號" .TextMatrix(.Rows - 1, 2) = Trim(mrc_Stu_Tem.Fields(13)) '"日期" .TextMatrix(.Rows - 1, 3) = Trim(mrc_Stu_Tem.Fields(14)) '"時間" .TextMatrix(.Rows - 1, 4) = Trim(mrc_Stu_Tem.Fields(7)) '金額 mrc_Stu_Tem.MoveNext End With Wend mrc_Stu_Tem.Close End Sub
結賬按鈕
Private Sub lblOK_Click() '購卡 txtSQL = "select*from student_info where userid='" & ComboUserID.Text & "'" & "and " & _ "ischeck='" & "未結賬" & "' and date='" & Date & "'" Set mrc_Stu_Sum = ExecuteSQL(txtSQL, MsgText) If mrc_Stu_Sum.EOF = False Then mrc_Stu_Sum.MoveFirst End If While Not mrc_Stu_Sum.EOF mrc_Stu_Sum.Fields(11) = "結賬" mrc_Stu_Sum.Update mrc_Stu_Sum.MoveNext Wend '關閉資料庫 mrc_Stu_Sum.Close '充值 AddMoney = 0 txtSQL = "select*from recharge_info where userid='" & ComboUserID.Text & "'" & "and " & _ "status='" & "未結賬" & "' and date='" & Date & "'" Set mrc_RE = ExecuteSQL(txtSQL, MsgText) If mrc_RE.EOF = False Then mrc_RE.MoveFirst End If While Not mrc_RE.EOF AddMoney = AddMoney + Trim(mrc_RE.Fields(3)) mrc_RE.Fields(7) = "結賬" mrc_RE.Update mrc_RE.MoveNext Wend mrc_RE.Close '退卡 BackCard = 0 txtSQL = "select*from cancelcard_info where userid='" & ComboUserID.Text & "'" & "and " & _ "status='" & "未結賬" & "' and date='" & Date & "'" Set mrc_Stu_Off = ExecuteSQL(txtSQL, MsgText) If mrc_Stu_Off.EOF = False Then mrc_Stu_Off.MoveFirst End If While Not mrc_Stu_Off.EOF mrc_Stu_Off.Fields(6) = "結賬" mrc_Stu_Off.Update mrc_Stu_Off.MoveNext Wend mrc_Stu_Off.Close '臨時使用者 '' TemMoney = 0 '臨時收費金額 txtSQL = "select*from student_info where userid='" & ComboUserID.Text & "'" & "and " & _ "ischeck='" & "未結賬" & "'" & "and " & _ "type='" & "臨時使用者" & "' and date='" & Date & "'" Set mrc_Stu_Tem = ExecuteSQL(txtSQL, MsgText) If mrc_Stu_Tem.EOF = False Then mrc_Stu_Tem.MoveFirst End If While Not mrc_Stu_Tem.EOF With FlexGridTem .Rows = .Rows + 1 .CellAlignment = 4 .ColAlignment = 4 mrc_Stu_Tem.Fields(11) = "結賬" mrc_Stu_Tem.MoveNext End With Wend mrc_Stu_Tem.Close '下機 '' TemMoney = 0 '臨時收費金額 txtSQL = "select*from line_info where userid='" & ComboUserID.Text & "'" & "and " & _ "statu='" & "未結賬" & "' and offdate='" & Date & "'" Set mrc_Line = ExecuteSQL(txtSQL, MsgText) If mrc_Line.EOF = False Then mrc_Line.MoveFirst End If While Not mrc_Line.EOF mrc_Line.Fields(16) = "結賬" mrc_Line.MoveNext Wend mrc_Line.Close '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '呼叫過程,新增表名 Call AddName '臨時收費金額 txtSQL = "select * from line_info where offdate='" & Format(Date, "yyyy-MM-dd") & "'" & _ "and userid='" & ComboUserID.Text & "' and offdate='" & Date & "'" Set mrc_Line = ExecuteSQL(txtSQL, MsgText) If mrc_Line.EOF Then TemMoney = 0 Else While Not mrc_Line.EOF TemMoney = TemMoney + Val(Trim(mrc_Line.Fields(11))) mrc_Line.MoveNext Wend End If ' TemMoney = mrc_Line.Fields(10) '售卡張數 lblSellCardSum.Caption = SellNum '退卡張數 lblBackCardSum.Caption = BackNum '充值金額 lblRecharge.Caption = AddMoney '臨時收費金額 lblTemRecharge.Caption = TemMoney '退卡金額 lblBackCardMoney.Caption = BackMoney '總售卡數 SumCard = SellNum - BackNum lblSellCardActual.Caption = SumCard '所售金額 SunMoney = AddMoney - BackMoney lblCollectMoney.Caption = SunMoney '傳值去日結賬單 txtSQL = "select *from checkday_info " Set mrc_CheckDay = ExecuteSQL(txtSQL, MsgText) If mrc_CheckDay.EOF Then LastMoney = 0 Else mrc_CheckDay.MoveLast LastMoney = Trim(mrc_CheckDay.Fields(0)) End If mrc_CheckDay.AddNew mrc_CheckDay.Fields(0) = Trim(LastMoney) '上次餘額 mrc_CheckDay.Fields(1) = AddMoney '充值金額 mrc_CheckDay.Fields(2) = TemMoney '消費金額 mrc_CheckDay.Fields(3) = BackMoney '退卡金額 mrc_CheckDay.Fields(4) = SunMoney '所售金額 mrc_CheckDay.Fields(5) = Format(Date, "yyyy-MM-dd") '日期 mrc_CheckDay.Update mrc_CheckDay.Close End Sub
為了避免程式碼重複過大,所以寫的新增導航屬性的過程!
Public Sub AddName()
'購卡新增表頭
With FlexGridSell
.Rows = 1
.CellAlignment = 4
.ColAlignment = 4
.TextMatrix(0, 0) = "學號"
.TextMatrix(0, 1) = "卡號"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "時間"
End With
'充值新增表頭
With FlexGridRe
.Rows = 1
.CellAlignment = 4
.ColAlignment = 4
.TextMatrix(0, 0) = "學號"
.TextMatrix(0, 1) = "卡號"
.TextMatrix(0, 2) = "充值金額"
.TextMatrix(0, 3) = "日期"
.TextMatrix(0, 4) = "時間"
End With
'退卡新增表頭
With FlexGridOff
.Rows = 1
.CellAlignment = 4
.ColAlignment = 4
.TextMatrix(0, 0) = "學號"
.TextMatrix(0, 1) = "卡號"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "時間"
.TextMatrix(0, 4) = "退卡金額"
End With
'臨時使用者新增表頭
With FlexGridTem
.Rows = 1
.CellAlignment = 4
.ColAlignment = 4
.TextMatrix(0, 0) = "學號"
.TextMatrix(0, 1) = "卡號"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "時間"
.TextMatrix(0, 4) = "消費金額"
End With
End Sub
希望我的分享能你有所幫助! 感謝您的閱讀,如果您有更好的方法,歡迎分享給我,謝謝您!