第一次机房收费系统之管理员结账

2024-03-27 02:08

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

操作流程:

点击操作员用户名的combox控件,会出现所有操作员用户以上用户ID,选中ID下面显示操作员姓名,显示购卡,充值等界面的记录,最后计算出各个售卡退卡张数以及金额。进行结账。

使用的数据库表:

user_info(存放用户信息)
student_info(存放学生信息)
recharge_info(存放充值记录信息)
cancelcard_info(存放退卡信息)
checkday_info(日结账单)

计算公式:

充值金额=此用户为学生注册的金额+此用户为学生充值的金额
收费金额=固定用户的消费金额+临时用户的消费金额
退卡金额=此用户操作的为学生退卡的金额
总售卡数=售卡数—退卡数
应收金额=充值金额+消费金额—退卡金额

具体代码:

显示的操作:

Private Sub comboControlUID_Click()'对User_info表操作Dim mrcuser As ADODB.Recordset '用于存放记录集Dim userSQL As String '用于存放SQL语句Dim userMsgText As String '用于存放返回信息userSQL = "select * from user_info where userID='" & Trim(comboControlUID.Text) & "'"Set mrcuser = ExecuteSQL(userSQL, userMsgText)If mrcuser.EOF = True Thenmrcuser.CloseExit SubElsetxtUserName.Text = mrcuser.Fields(3)End IfCall ShowData1 '购卡Call ShowData2 '充值Call ShowData3 '退卡Call ShowData4 '临时用户Call All '汇总
End SubPrivate Sub ShowData1()'对Student_info表操作Dim mrcstudent As ADODB.Recordset '用于存放记录集Dim studentSQL As String '用于存放SQL语句Dim studentMsgText As String '用于存放返回信息studentSQL = "select * from student_info where UserID='" & Trim(comboControlUID.Text) & "' and Ischeck='未结账'"Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)If mrcstudent.EOF = True Thenmrcstudent.CloseMSHFlexGrid1.ClearWith MSHFlexGrid1.Rows = 1.CellAlignment = 4.TextMatrix(0, 0) = "学号".TextMatrix(0, 1) = "卡号".TextMatrix(0, 2) = "日期".TextMatrix(0, 3) = "时间"End WithExit SubElseWith MSHFlexGrid1.Rows = 1Do While mrcstudent.EOF = False.Rows = .Rows + 1.CellAlignment = 4.TextMatrix(.Rows - 1, 0) = Trim(mrcstudent.Fields(1)).TextMatrix(.Rows - 1, 1) = Trim(mrcstudent.Fields(0)).TextMatrix(.Rows - 1, 2) = Trim(mrcstudent.Fields(12)).TextMatrix(.Rows - 1, 3) = Trim(mrcstudent.Fields(13))mrcstudent.MoveNextLoopmrcstudent.CloseEnd WithEnd If
End Sub
Private Sub ShowData2()'对recharge_info表操作Dim mrcrecharge As ADODB.Recordset '用于存放记录集Dim rechargeSQL As String '用于存放SQL语句Dim rechargeMsgText As String '用于存放返回信息rechargeSQL = "select * from recharge_info where UserID ='" & Trim(comboControlUID.Text) & "' and status='未结账'"Set mrcrecharge = ExecuteSQL(rechargeSQL, rechargeMsgText)If mrcrecharge.EOF = True Thenmrcrecharge.CloseMSHFlexGrid2.ClearWith MSHFlexGrid2.Rows = 1.CellAlignment = 4.TextMatrix(0, 0) = "学号".TextMatrix(0, 1) = "卡号".TextMatrix(0, 2) = "充值金额".TextMatrix(0, 3) = "日期".TextMatrix(0, 4) = "时间"End WithExit SubElseWith MSHFlexGrid2.Rows = 1Do While mrcrecharge.EOF = False.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))mrcrecharge.MoveNextLoopmrcrecharge.CloseEnd WithEnd If
End SubPrivate Sub ShowData3()'对cancelcard_info表操作Dim mrccancelcard As ADODB.Recordset '用于存放记录集Dim cancelcardSQL As String '用于存放SQL语句Dim cancelcardMsgText As String '用于存放返回信息cancelcardSQL = "select * from cancelcard_info where UserID='" & Trim(comboControlUID.Text) & "' and status='未结账'"Set mrccancelcard = ExecuteSQL(cancelcardSQL, cancelcardMsgText)If mrccancelcard.EOF = True Thenmrccancelcard.CloseMSHFlexGrid3.ClearWith MSHFlexGrid3.Rows = 1.CellAlignment = 4.TextMatrix(0, 0) = "学号".TextMatrix(0, 1) = "卡号".TextMatrix(0, 2) = "日期".TextMatrix(0, 3) = "时间".TextMatrix(0, 4) = "退卡金额"End WithExit SubElseWith MSHFlexGrid3.Rows = 1Do While mrccancelcard.EOF = False.Rows = .Rows + 1.CellAlignment = 4.TextMatrix(.Rows - 1, 0) = Trim(mrccancelcard.Fields(1)).TextMatrix(.Rows - 1, 1) = Trim(mrccancelcard.Fields(2)).TextMatrix(.Rows - 1, 2) = Trim(mrccancelcard.Fields(3)).TextMatrix(.Rows - 1, 3) = Trim(mrccancelcard.Fields(4)).TextMatrix(.Rows - 1, 4) = Trim(mrccancelcard.Fields(2))mrccancelcard.MoveNextLoopmrccancelcard.CloseEnd WithEnd If
End SubPrivate Sub ShowData4()'再次对student_info表操作Dim mrcST As ADODB.RecordsetDim STSQL As StringDim STMsgText As StringSTSQL = "select * from student_info where UserID='" & Trim(comboControlUID.Text) & "' and Ischeck='未结账' and type='临时用户'"Set mrcST = ExecuteSQL(STSQL, STMsgText)If mrcST.EOF = True ThenmrcST.CloseWith MSHFlexGrid4.Rows = 1.CellAlignment = 4.TextMatrix(0, 0) = "学号".TextMatrix(0, 1) = "卡号".TextMatrix(0, 2) = "日期".TextMatrix(0, 3) = "时间"End WithElseWith MSHFlexGrid4.Rows = 1Do While mrcST.EOF = False.Rows = .Rows + 1.CellAlignment = 4.TextMatrix(.Rows - 1, 0) = Trim(mrcST.Fields(1)).TextMatrix(.Rows - 1, 1) = Trim(mrcST.Fields(0)).TextMatrix(.Rows - 1, 2) = Trim(mrcST.Fields(12)).TextMatrix(.Rows - 1, 3) = Trim(mrcST.Fields(13))mrcST.MoveNextLoopmrcST.CloseEnd WithEnd If
End Sub
Private Sub All()Dim Temporary As Double '临时收费Dim Money As Double '充值总金额Dim Cancel As Double '退卡金额'对Student_info表操作Dim mrcstudent As ADODB.Recordset '用于存放记录集Dim studentSQL As String '用于存放SQL语句Dim studentMsgText As String '用于存放返回信息'对recharge_info表操作Dim mrcrecharge As ADODB.Recordset '用于存放记录集Dim rechargeSQL As String '用于存放SQL语句Dim rechargeMsgText As String '用于存放返回信息'对cancelcard_info表操作Dim mrccancelcard As ADODB.Recordset '用于存放记录集Dim cancelcardSQL As String '用于存放SQL语句Dim cancelcardMsgText As String '用于存放返回信息'再次对student_info表操作Dim mrcST As ADODB.RecordsetDim STSQL As StringDim STMsgText As String'售卡张数studentSQL = "select * from student_info where UserID='" & Trim(comboControlUID.Text) & "' and Ischeck='未结账'"Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)If mrcstudent.RecordCount = 0 ThentxtSellCard.Text = "0"mrcstudent.CloseElsetxtSellCard.Text = mrcstudent.RecordCountmrcstudent.CloseEnd If'充值金额rechargeSQL = "select * from recharge_info where UserID ='" & Trim(comboControlUID.Text) & "' and status='未结账'"Set mrcrecharge = ExecuteSQL(rechargeSQL, rechargeMsgText)If mrcrecharge.EOF = True ThentxtReCharge.Text = "0"mrcrecharge.CloseElseMoney = 0Do While mrcrecharge.EOF = FalseMoney = Money + Val(mrcrecharge.Fields(3))mrcrecharge.MoveNextLooptxtReCharge.Text = Moneymrcrecharge.CloseEnd If'退卡张数和退卡金额cancelcardSQL = "select * from cancelcard_info where UserID='" & Trim(comboControlUID.Text) & "' and status='未结账'"Set mrccancelcard = ExecuteSQL(cancelcardSQL, cancelcardMsgText)If mrccancelcard.RecordCount = 0 ThentxtCancelCard.Text = "0"ElsetxtCancelCard.Text = mrccancelcard.RecordCountEnd IfIf mrccancelcard.EOF = True ThentxtCancelCharge.Text = "0"ElseCancel = 0Do While mrccancelcard.EOF = FalseCancel = Cancel + Val(mrccancelcard.Fields(2))mrccancelcard.MoveNextLooptxtCancelCharge = Cancelmrccancelcard.CloseEnd If'临时收费金额STSQL = "select * from student_info where UserID='" & Trim(comboControlUID.Text) & "' and Ischeck='未结账' and type='临时用户'"Set mrcST = ExecuteSQL(STSQL, STMsgText)If mrcST.EOF = True ThentxtTemporaryCharge.Text = "0"mrcST.CloseElseTemporary = 0Do While mrcST.EOF = FalseTemporary = Temporary + Val(mrcST.Fields(7))mrcST.MoveNextLooptxtTemporaryCharge.Text = TemporarymrcST.CloseEnd If'总售卡数txtAllSellCard.Text = Int(txtSellCard.Text) - Int(txtCancelCard.Text)'应收金额txtShouldCharge.Text = Val(txtReCharge.Text) + Val(txtTemporaryCharge.Text) - Val(txtCancelCharge.Text)End Sub

结账的操作

Private Sub cmdCloseCharge_Click()Dim ReMain As DoubleDim ReCharge As Double '充值金额Dim Cancel As Double '退卡金额Dim Consume As Double '总金额'对line_info表操作Dim mrcline As ADODB.Recordset '用于存放记录集Dim lineSQL As String '用于存放SQL语句Dim lineMsgText As String '用于存放返回信息'对Student_info表操作Dim mrcstudent As ADODB.Recordset '用于存放记录集Dim studentSQL As String '用于存放SQL语句Dim studentMsgText As String '用于存放返回信息'对recharge_info表操作Dim mrcrecharge As ADODB.Recordset '用于存放记录集Dim rechargeSQL As String '用于存放SQL语句Dim rechargeMsgText As String '用于存放返回信息'对cancelcard_info表操作Dim mrccancelcard As ADODB.Recordset '用于存放记录集Dim cancelcardSQL As String '用于存放SQL语句Dim cancelcardMsgText As String '用于存放返回信息'对checkday_info表再次操作Dim mrccheck As ADODB.Recordset '用于存放记录集Dim checkSQL As String '用于存放SQL语句Dim checkMsgText As String '用于存放返回信息'对CheckDay_info表操作Dim mrccheckday As ADODB.Recordset '用于存放记录集Dim checkdaySQL As String '用于存放SQL语句Dim checkdayMsgText As String '用于存放返回信息If comboControlUID.Text = "" ThenMsgBox "请选择人员!", vbOKOnly + vbInformation, "提示"comboControlUID.SetFocusExit SubElsecheckdaySQL = "select * from checkday_info where date='" & Date & "'"Set mrccheckday = ExecuteSQL(checkdaySQL, checkdayMsgText)lineSQL = "select * from line_info where status='正常下机' and offdate='" & Date & "'"Set mrcline = ExecuteSQL(lineSQL, lineMsgText)Consume = 0If mrcline.EOF = True ThenConsume = 0mrcline.CloseElseDo While mrcline.EOF = FalseConsume = Consume + Val(mrcline.Fields(11))mrcline.MoveNextLoopmrcline.CloseEnd If'student_info结账studentSQL = "select * from student_info where UserID='" & Trim(comboControlUID.Text) & "' and Ischeck='未结账'"Set mrcstudent = ExecuteSQL(studentSQL, studentMsgText)If mrcstudent.EOF = False ThenDo While mrcstudent.EOF = Falsemrcstudent.Fields(11) = "结账"mrcstudent.Updatemrcstudent.MoveNextLoopmrcstudent.CloseEnd If'recharge_info结账rechargeSQL = "select * from recharge_info where UserID ='" & Trim(comboControlUID.Text) & "' and status='未结账'"Set mrcrecharge = ExecuteSQL(rechargeSQL, rechargeMsgText)ReCharge = 0If mrcrecharge.EOF = False ThenDo While mrcrecharge.EOF = FalseReCharge = ReCharge + Val(mrcrecharge.Fields(3))mrcrecharge.Fields(7) = "结账"mrcrecharge.Updatemrcrecharge.MoveNextLoopmrcrecharge.CloseElseReCharge = 0mrcrecharge.CloseEnd If'cancelcard_info结账cancelcardSQL = "select * from cancelcard_info where UserID='" & Trim(comboControlUID.Text) & "' and status='未结账'"Set mrccancelcard = ExecuteSQL(cancelcardSQL, cancelcardMsgText)Cancel = 0If mrccancelcard.EOF = False ThenDo While mrccancelcard.EOF = FalseCancel = Cancel + Val(mrccancelcard.Fields(2))mrccancelcard.Fields(6) = "结账"mrccancelcard.Updatemrccancelcard.MoveNextLoopmrccancelcard.CloseElseCancel = 0mrccancelcard.CloseEnd IfcheckSQL = "select * from checkday_info where date='" & Date - 1 & "'"Set mrccheck = ExecuteSQL(checkSQL, checkMsgText)ReMain = 0If mrccheck.EOF = True ThenReMain = 0mrccheck.CloseElseReMain = Val(mrccheck.Fields(4))mrccheck.CloseEnd IfIf mrccheckday.EOF = True Thenmrccheckday.AddNewmrccheckday.Fields(0) = ReMainmrccheckday.Fields(1) = ReChargemrccheckday.Fields(2) = Consumemrccheckday.Fields(3) = Cancelmrccheckday.Fields(4) = ReCharge - Cancelmrccheckday.Fields(5) = Datemrccheckday.Updatemrccheckday.CloseMsgBox "结账成功!", vbOKOnly + vbInformation, "提示"Elsemrccheckday.Fields(0) = ReMainmrccheckday.Fields(1) = ReChargemrccheckday.Fields(2) = Consumemrccheckday.Fields(3) = Cancelmrccheckday.Fields(4) = ReCharge - Cancelmrccheckday.Fields(5) = Datemrccheckday.Updatemrccheckday.CloseMsgBox "结账成功!", vbOKOnly + vbInformation, "提示"End IfEnd If
End Sub

优化方面:

1.背景图随窗体改变而改变

Dim H As Single '定义窗体高的变量
Dim W As Single '定义窗体高的变量
Private Sub Form_Load()'对User_info表操作Dim mrcuser As ADODB.Recordset '用于存放记录集Dim userSQL As String '用于存放SQL语句Dim userMsgText As String '用于存放返回信息userSQL = "select * from user_info where level='操作员'or level='管理员'"Set mrcuser = ExecuteSQL(userSQL, userMsgText)If mrcuser.EOF = True ThenMsgBox "无用户数据记录!", vbOKOnly + vbInformation, "提示"Exit SubElseDo While mrcuser.EOF = FalsecomboControlUID.AddItem mrcuser.Fields(0)mrcuser.MoveNextLoopEnd IfWith MSHFlexGrid1.Rows = 1.CellAlignment = 4.TextMatrix(0, 0) = "学号".TextMatrix(0, 1) = "卡号".TextMatrix(0, 2) = "日期".TextMatrix(0, 3) = "时间"End WithWith MSHFlexGrid2.Rows = 1.CellAlignment = 4.TextMatrix(0, 0) = "学号".TextMatrix(0, 1) = "卡号".TextMatrix(0, 2) = "充值金额".TextMatrix(0, 3) = "日期".TextMatrix(0, 4) = "时间"End WithWith MSHFlexGrid3.Rows = 1.CellAlignment = 4.TextMatrix(0, 0) = "学号".TextMatrix(0, 1) = "卡号".TextMatrix(0, 2) = "日期".TextMatrix(0, 3) = "时间".TextMatrix(0, 4) = "退卡金额"End WithWith MSHFlexGrid4.Rows = 1.CellAlignment = 4.TextMatrix(0, 0) = "学号".TextMatrix(0, 1) = "卡号".TextMatrix(0, 2) = "日期".TextMatrix(0, 3) = "时间"End WithH = Me.HeightW = Me.Width
End SubPrivate Sub Form_Resize()Me.Height = HMe.Width = WMe.PaintPicture Me.Picture, 0, 0, Me.ScaleWidth, Me.ScaleHeight '实现背景图随窗体变大而改变
End Sub

2.不可输入值

Private Sub comboControlUID_KeyPress(KeyAscii As Integer)KeyAscii = 0 '不可输入值
End Sub

3.禁止粘贴

Private Sub txtSellCard_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)If Button = 2 ThenClipboard.ClearEnd If
End Sub

4.限制字符类型
https://blog.csdn.net/TGB__15__ZYB/article/details/86636625

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



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

相关文章

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. 创