机房收费系统——上机状态查询之下机
来源:互联网 发布:500px知乎什么意思 编辑:程序博客网 时间:2024/06/06 05:41
前言:
这部分内容整整花费了四天的时间,不过细细想来,自已想要的结果全都实现了!心里还是蛮骄傲的,接下来给大家展示一下这部分的成果
1、简单说明
这部分的内容分为查询、显示全部、上机管理、退出四个部分,查询与退出都不给予说明,这里面其实最难的就是上机管理中的选择下机了!既然是选择下机那么就可以实现一次性选择多条语句,并且可以同时下机!这样才符合实际需求,接下来给大家看一张图!这就实现了要达到的效果!
2、代码思想
全部下机相信大家都能实现了,可是选择下机就没那么好实现了,因为有的需要下机,有的不需要下机,这时候你就需要把所有带“√”的记录都放进一个容器,这个容器就是存储都需要下机的机器,因为这个容器里的内容全都是需要下机的机器,所以这样接下来就和全部下机的思想一样了!
3、代码展示
这里只展示选择下机的代码了,全部下机的代码大同小异
Dim Bob As Boolean '用来标记是否点击显示全部按钮的状态,最开始默认的是false,点击显示全部按钮后,值为true Dim txtsql As String Dim MsgText As String Dim mrc As ADODB.Recordset '代表online_info表 Dim mrc1 As ADODB.Recordset '代表Online_Info中有时间限制 Dim mrc2 As ADODB.Recordset '代表line表 Dim mrc3 As ADODB.Recordset '代表basicdate Dim mrc4 As ADODB.Recordset ' 代表学生 student_info表'选择下机Private Sub mnu1selectStuOutline_Click() Dim sz(9999) As String '这是一个数组,用来存储带“√”的学号 Dim xh(9999) As String '用来存储带“√”的msflexgrid1的行号 Dim txtCash As String Dim consumetime As String Dim consume As String Dim z As Integer '存带“√”的学号用到的变量 Dim i As Integer '改变颜色时候调用的变量 Dim s As Integer '存带“√”的msflexgrid1的行号用到的变量 With MSFlexGrid1'记录选中下机的卡号,在最后一行加了一个勾,将这些记录的所有的卡号信息全部存到数组sz中! i = 0 For j = 1 To .Rows - 1 If .TextMatrix(j, 5) = "√" Then sz(i) = .TextMatrix(j, 0) '存的是卡号 xh(i) = Val(j) i = i + 1 End If Next j For Z = 0 To i - 1 '数组是从0开始的 '更新了表online_info与表line info中的信息 txtsql = "select * from basicdata_info" Set mrc3 = ExecuteSQL(txtsql, MsgText) txtsql = "select * from student_Info where cardno='" & sz(Z) & "'" & "and status='使用" & "'" Set mrc4 = ExecuteSQL(txtsql, MsgText) txtsql = "select * from Online_Info where cardno='" & sz(Z) & "'" Set mrc1 = ExecuteSQL(txtsql, MsgText) '计算消费时间 consumetime = DateDiff("n", Trim(mrc1!Date), Now) '计算消费金额 '如果消费时间小于准备时间则不收钱,如果大于准备时间小于最短上机时间则半价,如果大于最短上机时间则正常收费 If Val(consumetime) <= Val(mrc3!prepareTime) Then consume = "0" Else If Val(consumetime) < Val(mrc3!leastTime) Then If Trim(mrc4!Type) = Trim("固定用户") Then consume = 0.5 * mrc3!Rate Else consume = 0.5 * mrc3!tmprate End If Else If Val(consumetime) Mod Val(mrc3!unitTime) = 0 Then t = Int(consumetime / mrc3!unitTime) Else t = Int(consumetime / mrc3!unitTime) + 1 End If If Trim(mrc4!Type) = Trim("固定用户") Then consume = t * mrc3.Fields(0) Else consume = t * mrc3.Fields(1) End If End If End If '计算余额(上机时候的余额显示减去消费金额) txtCash = Val(mrc4!cash) - Val(consume) '更新数据到line_info表 txtsql = "update Line_info set offdate='" & Date & "'" & ", offtime='" & Time & "'" & " ,consumetime='" & consumetime & "'" & ",consume='" & consume & "'" & ",cash='" & txtCash & "'" & " ,status='" & "正常下机" & "'" & " where cardno='" & sz(Z) & "'" Set mrc1 = ExecuteSQL(txtsql, MsgText) '更新表online_info txtsql1 = "delete online_info where cardno='" & sz(Z) & "'" Set mrc = ExecuteSQL(txtsql1, MsgText) Next Z '更新msflexgrid1的界面! For s = 0 To i - 1 .RemoveItem xh(s) Next s End WithEnd Sub'msflexgrid1的设计Private Sub msflexgrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)‘如何选中不连续的行 Dim col As Integer If MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 5) = "√" Then MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 5) = "" '改变行颜色(变为没选中之前的) For col = 0 To MSFlexGrid1.Cols - 1 MSFlexGrid1.col = col MSFlexGrid1.CellBackColor = vbWhite Next col Else MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 5) = "√" '改变行颜色(选中后的颜色) For col = 0 To MSFlexGrid1.Cols - 1 MSFlexGrid1.col = col MSFlexGrid1.CellBackColor = &HFFFF00 Next col End If'判断是否选中数据,如果选中数据那么就会让你的修改按钮为激活装态 If (MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 5) = "√") Then mnu1selectStuOutline.Enabled = True Else mnu1selectStuOutline.Enabled = False End If End Sub
后记:
这些东西真的是太痛苦了,想了好多天,期中也多亏了靖凡同志和赵雷同志的帮忙!现在总结了出来,希望对大家有所帮助!
阅读全文
1 0
- 机房收费系统——上机状态查询之下机
- 【机房收费系统】——上机下机
- 机房收费系统之上机状态查询
- 机房收费系统之上机、下机
- 机房收费系统之上机、下机
- 机房收费系统——上机和下机
- 机房收费系统之下机
- 机房收费系统之下机
- 机房收费系统——上下机
- 机房收费系统——上下机
- 机房收费系统——上下机
- 机房收费系统——上下机
- 机房收费系统——上下机
- 【机房收费系统】——上下机
- 【机房收费系统】——上下机
- 机房收费系统——上下机
- 机房收费系统——下机
- 机房收费系统——上下机
- Linux 基础
- Centos下PHP5升级PHP7
- 21号
- 11. java.util.Iterator
- shiro实例 缓存之Realm篇
- 机房收费系统——上机状态查询之下机
- AHB总线和axi总线的联系和区别
- SDR# (SDRSharp)代码讲解
- 插入数据时,保存的date类型时间字段的数据只有年月日,没有时分秒的问题
- cinder流程图
- JS函数前面的感叹号是什么意思?
- opencv3.0 + VS2010中FindContours()函数崩溃问题
- 自定义游戏手柄方向键
- Linux设备驱动之中断---tasklet使用示例