第一次机房收费系统之上下机

2024-02-22 20:48

本文主要是介绍第一次机房收费系统之上下机,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

前言: 首先,学生上机需要在主界面上显示学生的信息,然后在online表和line表中添加记录,下机需要计算好上机时间和消费金额,更新line表和student表,删除online表中对应的记录。
流程图如下:
在这里插入图片描述
学生下机
上机:

Dim txtsql As StringDim msgtext As StringDim mrc As ADODB.RecordsetDim mrc1 As ADODB.Recordsettxtdowntime.Text = ""txtdowndate.Text = ""txtpaytime.Text = ""txtpay.Text = ""'判断是否输入卡号If Not Testtxt(txtcardid.Text) ThenLabel1.Visible = TrueLabel1.Caption = "请输入卡号!"Exit SubEnd IfIf Not IsNumeric(txtcardid.Text) ThenLabel1.Visible = Truetxtcardid.Text = ""txtcardid.SetFocusLabel1.Caption = "卡号请输入数字!"Exit SubEnd If'查询卡号txtsql = "select * from student_info where cardno='" & Trim(txtcardid.Text) & "'"Set mrc = ExecuteSQL(txtsql, msgtext)If mrc.RecordCount = 0 ThenLabel1.Visible = Truetxtcardid.Text = ""txtcardid.SetFocusLabel1.Caption = "卡号不存在!"Exit SubElseIf Trim(mrc!Status) = "不使用" Then             '查询是否注册Label1.Visible = TrueLabel1.Caption = "此卡尚未注册!"Exit SubEnd IfEnd Ifmrc.Close'查询是否上机txtsql = "select * from online_info where cardno='" & Trim(txtcardid.Text) & "'"Set mrc = ExecuteSQL(txtsql, msgtext)If mrc.RecordCount = 1 ThenLabel1.Visible = TrueLabel1.Caption = "此卡正在上机!"txttype.Text = Trim(mrc.Fields(1))txtsid.Text = Trim(mrc.Fields(2))txtname.Text = Trim(mrc.Fields(3))txtdepartment.Text = Trim(mrc.Fields(4))txtsex.Text = Trim(mrc.Fields(5))txtupdate.Text = Trim(mrc.Fields(6))txtuptime.Text = Trim(mrc.Fields(7))Exit SubEnd Ifmrc.Close'查询余额txtsql = "select * from student_info where cardno='" & Trim(txtcardid.Text) & "'"Set mrc = ExecuteSQL(txtsql, msgtext)txtsql = "select * from basicdata_info"Set mrc1 = ExecuteSQL(txtsql, msgtext)If Val(Trim(mrc!cash)) < Val(Trim(mrc1!limitcash)) ThenLabel1.Visible = TrueLabel1.Caption = "余额不足,请充值!"Exit SubEnd Ifmrc.Closemrc1.Close'显示学生信息txtsql = "select * from student_info where cardno='" & Trim(txtcardid.Text) & "'"Set mrc = ExecuteSQL(txtsql, msgtext)txtname.Text = Trim(mrc.Fields(2))txtsex.Text = Trim(mrc.Fields(3))txtsid.Text = Trim(mrc.Fields(1))txtdepartment.Text = Trim(mrc.Fields(4))txttype.Text = Trim(mrc.Fields(14))txtcash.Text = Trim(mrc.Fields(7))txtuptime.Text = timetxtupdate.Text = Datemrc.Close'向online表中添加数据txtsql = "select * from online_info "Set mrc = ExecuteSQL(txtsql, msgtext)mrc.AddNewmrc.Fields(0) = txtcardid.Textmrc.Fields(1) = txttype.Textmrc.Fields(2) = txtsid.Textmrc.Fields(3) = txtname.Textmrc.Fields(4) = txtdepartment.Textmrc.Fields(5) = txtsex.Textmrc.Fields(6) = txtupdate.Textmrc.Fields(7) = txtuptime.Textmrc.Fields(8) = GetThisComputerNamemrc.Fields(9) = Nowmrc.Updatelblshangji.Caption = mrc.RecordCountmrc.Close'向line表中添加数据txtsql = "select * from line_info"Set mrc = ExecuteSQL(txtsql, msgtext)mrc.AddNewmrc.Fields(1) = txtcardid.Textmrc.Fields(2) = txtsid.Textmrc.Fields(3) = txtname.Textmrc.Fields(4) = txtdepartment.Textmrc.Fields(5) = txtsex.Textmrc.Fields(6) = txtupdate.Textmrc.Fields(7) = txtuptime.Textmrc.Fields(14) = GetThisComputerNamemrc.Fields(13) = "正常上机"mrc.Fields(12) = txtcash.Textmrc.Updatemrc.CloseMsgBox "成功上机", vbOKOnly + vbExclamation, "提示"Label1.Visible = False

下机:

Dim txtsql As StringDim msgtext As StringDim mrc As ADODB.RecordsetDim mrc1 As ADODB.RecordsetDim umrc As ADODB.Recordset'判断是否输入卡号If Not Testtxt(txtcardid.Text) ThenLabel1.Visible = TrueLabel1.Caption = "请输入卡号!"Exit SubEnd IfIf Not IsNumeric(txtcardid.Text) ThenLabel1.Visible = TrueLabel1.Caption = "卡号请输入数字!"txtcardid.Text = ""txtcardid.SetFocusExit SubEnd If'查询卡号txtsql = "select * from student_info where cardno='" & Trim(txtcardid.Text) & "'"Set mrc = ExecuteSQL(txtsql, msgtext)If mrc.RecordCount = 0 ThenLabel1.Visible = TrueLabel1.Caption = "卡号不存在!"txtcardid.Text = ""txtcardid.SetFocusExit SubElseIf Trim(mrc!Status) = "不使用" Then             '查询是否注册Label1.Visible = TrueLabel1.Caption = "此卡尚未注册!"Exit SubEnd IfEnd Ifmrc.Close'查询是否上机txtsql = "select * from online_info where cardno='" & Trim(txtcardid.Text) & "'"Set mrc = ExecuteSQL(txtsql, msgtext)If mrc.RecordCount = 0 ThenLabel1.Visible = TrueLabel1.Caption = "此卡没有上机!"Exit SubEnd Ifmrc.Close'显示数据txtdowntime.Text = timetxtdowndate.Text = Datetxtsql = "select * from online_info where cardno='" & txtcardid.Text & "'"Set mrc = ExecuteSQL(txtsql, msgtext)txtcardid.Text = Trim(mrc.Fields(0))txttype.Text = Trim(mrc.Fields(1))txtsid.Text = Trim(mrc.Fields(2))txtname.Text = Trim(mrc.Fields(3))txtdepartment.Text = Trim(mrc.Fields(4))txtsex.Text = Trim(mrc.Fields(5))txtupdate.Text = Trim(mrc.Fields(6))txtuptime.Text = Trim(mrc.Fields(7))'计算上机时间txtpaytime.Text = DateDiff("n", txtupdate, txtdowndate) + DateDiff("n", txtuptime, txtdowntime)mrc.Close'计算消费金额txtsql = "select * from student_info where cardno='" & Trim(txtcardid.Text) & "'"Set mrc = ExecuteSQL(txtsql, msgtext)txtsql = "select * from basicdata_info "Set mrc1 = ExecuteSQL(txtsql, msgtext)If Val(txtpaytime.Text) < Trim(mrc1!LeastTime) Thentxtpay.Text = 0txtcash.Text = Trim(mrc.Fields(7))ElseIf Trim(mrc!Type) = "固定用户" Thentxtpay.Text = Round(Val(txtpaytime.Text) / Trim(mrc1!unittime) * Trim(mrc1!Rate))txtcash.Text = Trim(mrc!cash - txtpay.Text)Elsetxtpay.Text = Round(Val(txtpaytime.Text) / Trim(mrc1!unittime) * Trim(mrc1!TmpRate))txtcash.Text = Trim(mrc!cash - txtpay.Text)End IfEnd Ifmrc.Closemrc1.Close'更新两个表txtsql = "select * from online_info where cardno='" & txtcardid.Text & "'"Set mrc = ExecuteSQL(txtsql, msgtext)txtsql = "select * from line_info where cardno='" & txtcardid.Text & "'and ondate='" & Trim(mrc!ondate) & "'and ontime='" & Trim(mrc!OnTime) & "'"Set mrc1 = ExecuteSQL(txtsql, msgtext)mrc1.Fields(8) = Datemrc1.Fields(9) = timemrc1.Fields(10) = Trim(txtpaytime.Text)mrc1.Fields(11) = Trim(txtpay.Text)mrc1.Fields(12) = Trim(txtcash.Text)mrc1.Fields(13) = "正常下机"mrc1.Updatemrc.Deletemrc.Closemrc1.Closetxtsql = "select * from online_info "Set mrc = ExecuteSQL(txtsql, msgtext)lblshangji.Caption = mrc.RecordCountmrc.Closetxtsql = "select * from student_info where cardno='" & txtcardid.Text & "'"Set mrc = ExecuteSQL(txtsql, msgtext)mrc.Fields(7) = Trim(txtcash.Text)mrc.Updatemrc.Close

这篇关于第一次机房收费系统之上下机的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/736451

相关文章

Python FastAPI+Celery+RabbitMQ实现分布式图片水印处理系统

《PythonFastAPI+Celery+RabbitMQ实现分布式图片水印处理系统》这篇文章主要为大家详细介绍了PythonFastAPI如何结合Celery以及RabbitMQ实现简单的分布式... 实现思路FastAPI 服务器Celery 任务队列RabbitMQ 作为消息代理定时任务处理完整

Linux系统中卸载与安装JDK的详细教程

《Linux系统中卸载与安装JDK的详细教程》本文详细介绍了如何在Linux系统中通过Xshell和Xftp工具连接与传输文件,然后进行JDK的安装与卸载,安装步骤包括连接Linux、传输JDK安装包... 目录1、卸载1.1 linux删除自带的JDK1.2 Linux上卸载自己安装的JDK2、安装2.1

Linux系统之主机网络配置方式

《Linux系统之主机网络配置方式》:本文主要介绍Linux系统之主机网络配置方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、查看主机的网络参数1、查看主机名2、查看IP地址3、查看网关4、查看DNS二、配置网卡1、修改网卡配置文件2、nmcli工具【通用

Linux系统之dns域名解析全过程

《Linux系统之dns域名解析全过程》:本文主要介绍Linux系统之dns域名解析全过程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、dns域名解析介绍1、DNS核心概念1.1 区域 zone1.2 记录 record二、DNS服务的配置1、正向解析的配置

Linux系统中配置静态IP地址的详细步骤

《Linux系统中配置静态IP地址的详细步骤》本文详细介绍了在Linux系统中配置静态IP地址的五个步骤,包括打开终端、编辑网络配置文件、配置IP地址、保存并重启网络服务,这对于系统管理员和新手都极具... 目录步骤一:打开终端步骤二:编辑网络配置文件步骤三:配置静态IP地址步骤四:保存并关闭文件步骤五:重

Windows系统下如何查找JDK的安装路径

《Windows系统下如何查找JDK的安装路径》:本文主要介绍Windows系统下如何查找JDK的安装路径,文中介绍了三种方法,分别是通过命令行检查、使用verbose选项查找jre目录、以及查看... 目录一、确认是否安装了JDK二、查找路径三、另外一种方式如果很久之前安装了JDK,或者在别人的电脑上,想

Linux系统之authconfig命令的使用解读

《Linux系统之authconfig命令的使用解读》authconfig是一个用于配置Linux系统身份验证和账户管理设置的命令行工具,主要用于RedHat系列的Linux发行版,它提供了一系列选项... 目录linux authconfig命令的使用基本语法常用选项示例总结Linux authconfi

Nginx配置系统服务&设置环境变量方式

《Nginx配置系统服务&设置环境变量方式》本文介绍了如何将Nginx配置为系统服务并设置环境变量,以便更方便地对Nginx进行操作,通过配置系统服务,可以使用系统命令来启动、停止或重新加载Nginx... 目录1.Nginx操作问题2.配置系统服android务3.设置环境变量总结1.Nginx操作问题

CSS3 最强二维布局系统之Grid 网格布局

《CSS3最强二维布局系统之Grid网格布局》CS3的Grid网格布局是目前最强的二维布局系统,可以同时对列和行进行处理,将网页划分成一个个网格,可以任意组合不同的网格,做出各种各样的布局,本文介... 深入学习 css3 目前最强大的布局系统 Grid 网格布局Grid 网格布局的基本认识Grid 网

在不同系统间迁移Python程序的方法与教程

《在不同系统间迁移Python程序的方法与教程》本文介绍了几种将Windows上编写的Python程序迁移到Linux服务器上的方法,包括使用虚拟环境和依赖冻结、容器化技术(如Docker)、使用An... 目录使用虚拟环境和依赖冻结1. 创建虚拟环境2. 冻结依赖使用容器化技术(如 docker)1. 创