本文主要是介绍机房收费系统总结之结帐,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
结账这个真的比较难,改了又改,改了又改。
因为这个窗口是在管理的权限范围之内的,所以我做了改动,把可以实现结账功能的人,也就是操作员和管理员都列在了这个里面。管理员和操作员都可以实现结账的权利。
因为combobox是能是下拉菜单来现实这个功能,不能往里面输入任何的字符,所以这时候就需要用一个键盘事件啦。
Private Sub Combo1_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
就这样,很轻松的就实现了这个功能啦。
接下来就是俩个combobox实现同步的功能啦,首先需要将combo1中的操作员和管理员的用户名添加进去,其实就是用到了一个通过循环经行增加。具体代码:
Private Sub Form_Load()
txtsql = "select * from User_Info where Level <>'一般用户'" '选择用户级别Set mrc = ExecuteSQL(txtsql, msgtext)Do While mrc.EOF = FalseCombo1.AddItem Trim(mrc.Fields(0)) '通过循环进行添加mrc.MoveNextLoopmrc.Close
End Sub
然后就是俩个combo的同步啦。也就是combo2随着combo1的变化而变化,这时候需要用combo1的单击事件啦
txtsql1 = "select * from User_Info where userID='" & Trim(Combo1.Text) & "'" '选择用户级别
Set mrc1 = ExecuteSQL(txtsql1, msgtext1)
Combo2.Text = Trim(mrc1.Fields(3))
那么,我们现在需要实现的就是在SSTab1这个控件里面显示各种信息啦,首先购卡充值退卡、临时用户的这些信息分别是从student、recharge、cancelcard和的数据库表中查询到的,现在我们以临时用户为例,来看看具体的额代码。
If SSTab1.Tab = 3 Then
txtsql = "select * from student_Info where UserID = '" & Combo1.Text & "'and type='临时用户'and status='未结账'"
Set mrc = ExecuteSQL(txtsql, msgtext)
With MSFlexGrid4.CellAlignment = 4.Rows = 1.TextMatrix(0, 0) = "学号".TextMatrix(0, 1) = "卡号".TextMatrix(0, 2) = "日期".TextMatrix(0, 3) = "时间"Do While mrc.EOF = False.Rows = .Rows + 1.TextMatrix(.Rows - 1, 0) = Trim(mrc!studentno).TextMatrix(.Rows - 1, 1) = Trim(mrc!cardno).TextMatrix(.Rows - 1, 2) = Trim(mrc!Date).TextMatrix(.Rows - 1, 3) = Trim(mrc!Time)mrc.MoveNextLoopmrc.CloseEnd With
End If
在汇总的目录下,我们可以看到里面有一些售卡张数和退卡张数等信息,这些数据可以直接在我们我们已经敲了代码的购卡、退卡等信息中经行查询,也就是售卡张数就是我们购卡中的行数,退卡张数就是我们的退卡的行数,当然需要减去表头的一行啦。当然啦,我们也可以用mrc.RecordCount来实现,但是这样我们还需要查询一次数据库,比较麻烦。
售卡张数-退卡张数=总售卡数 注册充值金额-退卡金额=应收金额
接下来就是结账的这个command按钮的代码啦!
首先我们知道,我们按下啦结账,软件的后台是怎样经行工作的。我们结账的界面将直接在报表中经行反应的,也就是报表中要得数据是从这里来的,所以需要更新报表中的数据,同时需要修改cancelcard和recharge中的数据,具体代码如下:Private Sub Command1_Click()
Dim d As String
Dim cash As String
Dim consume As Stringtxtsql1 = "select * from recharge_info where UserID='" & Combo1.Text & "'and status='未结账'"
Set mrc1 = ExecuteSQL(txtsql1, msgtext1)
If mrc1.EOF = False Thentxtsql = "select * from Line_Info where offdate='" & Trim(Format(Now, "yyyy-mm-dd")) & "'"
Set mrc = ExecuteSQL(txtsql, msgtext)
If mrc.RecordCount = 0 Thend = 0
Else
Do While mrc.EOF = False
d = Val(d) + Val(mrc!consume)
mrc.MoveNext
Loop
mrc.Close
End Iftxtsql = "select * from checkday_info"
Set mrc = ExecuteSQL(txtsql, msgtext)
If mrc.BOF And mrc.EOF Thenremaincash = 0
Elsemrc.MoveLastremaincash = mrc.Fields(4)mrc.MoveFirst
End Ifmrc.AddNewmrc.Fields(0) = remaincashmrc.Fields(1) = Text5.Textmrc.Fields(2) = dmrc.Fields(3) = Val(Text2.Text)mrc.Fields(4) = Val(Text5.Text - d - Text2.Text)mrc.Fields(5) = Datemrc.Update
mrc.Closetxtsql = "select * from recharge_info where UserID='" & Combo1.Text & "'and status='未结账'"
Set mrc = ExecuteSQL(txtsql, msgtext)
If mrc.RecordCount = 0 ThenText5.Text = 0Elsemrc!Status = "已结账"mrc.Updatemrc.Close
End If
txtsql1 = "select * from cancelcard_info where UserID='" & Combo1.Text & "'and status='未结账'"
Set mrc1 = ExecuteSQL(txtsql1, msgtext1)
If mrc1.RecordCount = 0 ThenText2.Text = 0
Elsemrc1!Status = "已结账"mrc1.Updatemrc1.Close
End IfMsgBox "结账成功!", vbOKOnly, "提示"Exit Sub
ElseMsgBox "已经结账成功啦,不能重复结账"Exit Sub
End IfEnd Sub
对于这段代码,我觉得最重要的就是把汇总的信息添加到日报表啦,这里面涉及到很多的算法,当然啦,这仅仅是我自己的理解。前些天师傅验收系统的时候提到了利用change事件来实现整个结账的功能,这样更方便用户。所以,我们用软件是让任何人来用的,也就是需要耐得住点啊!
Private Sub Command1_Click()
Dim d As String
Dim cash As String
Dim consume As Stringtxtsql1 = "select * from recharge_info where UserID='" & Combo1.Text & "'and status='未结账'"
Set mrc1 = ExecuteSQL(txtsql1, msgtext1)
If mrc1.EOF = False Thentxtsql = "select * from Line_Info where offdate='" & Trim(Format(Now, "yyyy-mm-dd")) & "'"
Set mrc = ExecuteSQL(txtsql, msgtext)
If mrc.RecordCount = 0 Thend = 0
Else
Do While mrc.EOF = False
d = Val(d) + Val(mrc!consume)
mrc.MoveNext
Loop
mrc.Close
End Iftxtsql = "select * from checkday_info"
Set mrc = ExecuteSQL(txtsql, msgtext)
If mrc.BOF And mrc.EOF Thenremaincash = 0
Elsemrc.MoveLastremaincash = mrc.Fields(4)mrc.MoveFirst
End Ifmrc.AddNewmrc.Fields(0) = remaincashmrc.Fields(1) = Text5.Textmrc.Fields(2) = dmrc.Fields(3) = Val(Text2.Text)mrc.Fields(4) = Val(Text5.Text - d - Text2.Text)mrc.Fields(5) = Datemrc.Update
mrc.Closetxtsql = "select * from recharge_info where UserID='" & Combo1.Text & "'and status='未结账'"
Set mrc = ExecuteSQL(txtsql, msgtext)
If mrc.RecordCount = 0 ThenText5.Text = 0Elsemrc!Status = "已结账"mrc.Updatemrc.Close
End If
txtsql1 = "select * from cancelcard_info where UserID='" & Combo1.Text & "'and status='未结账'"
Set mrc1 = ExecuteSQL(txtsql1, msgtext1)
If mrc1.RecordCount = 0 ThenText2.Text = 0
Elsemrc1!Status = "已结账"mrc1.Updatemrc1.Close
End IfMsgBox "结账成功!", vbOKOnly, "提示"Exit Sub
ElseMsgBox "已经结账成功啦,不能重复结账"Exit Sub
End IfEnd Sub
这篇关于机房收费系统总结之结帐的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!