机房收费系统——结账

2024-05-25 15:58
文章标签 系统 收费 机房 结账

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


结账在整个系统中应该算是最难的部分了,难点并不是知识点有多么深奥,主要是“麻烦”,如果不了解业务和以及系统适合的范围,我们很难清楚结账到底是怎么结的,针对“谁”或者“谁们”进行的结账,不简简单单的是管理员进行的工作而已。

想明白怎样结账之后就得考虑那些“钱”的问题,究竟钱从哪里来,要到哪里去,最后以什么样的形式出现在账单里等等,关于这些内容每个人有每个人的想法,只要想法正确,符合逻辑实际情况,都是正确的结账方式。下面是我的结账窗体,以我的思路介绍一下我的结账方式,可能也有不完善,理解不到位的地方,希望大家指正。


一、界面:


二、   特殊控件的使用(SSTab)


       1、在“部件”中勾选:


2、设置属性:


三、   结账:

1、窗体加载:

组合框中显示所有的操作员

DimstrSQL As String

Dimobjrst As ADODB.Recordset

Dimmsgtext As String

strSQL= "select * from user_Info where Level='" & "操作员" & "'"

Setobjrst = ExecuteSQL(strSQL, msgtext)


DoWhile objrst.EOF = False

        cbouserID.AddItem objrst.Fields(0)

        objrst.MoveNext

Loop

2、SSTab1_Click事件:

购卡按钮,显示该操作员的购卡情况,从注册表和退卡表中中查询信息,其中的购卡包含了已经退了的卡。

IfSSTab1.Caption = "购卡"Then

MSHFlexGrid1.Visible= True                    

MSHFlexGrid1.ColWidth(0) = 2000

MSHFlexGrid1.ColWidth(1) = 2000

        MSHFlexGrid1.ColWidth(2)= 2000

MSHFlexGrid1.ColWidth(3) = 2000

Dim strSQL1 As String

Dim objrst1 As ADODB.Recordset

Dimmsgtext1 As String

DimStrSQL4 As String

Dim objrst4 As ADODB.Recordset

Dim msgtext4 As String

strSQL1 = "select * from student_Info where username='" &Trim(cbouserID.Text) & "'"

Set objrst1 = ExecuteSQL(strSQL1, msgtext1)

StrSQL4= "select * from cancelcard_Info where userID='" &Trim(cbouserID.Text) & "'"

Set objrst4 = ExecuteSQL(StrSQL4, msgtext4)

WithMSHFlexGrid1

.Rows= 1

.Cols= 4

.TextMatrix(0,0) = "卡号"

.TextMatrix(0,1) = "学号"

.TextMatrix(0,2) = "日期"

.TextMatrix(0,3) = "时间"

DoWhile objrst1.EOF = False

                 .Rows = .Rows + 1

.Cols= 4

.TextMatrix(.Rows- 1, 0) = objrst1.Fields(0)

.TextMatrix(.Rows - 1, 1) =objrst1.Fields(1)

.TextMatrix(.Rows- 1, 2) = objrst1.Fields(11)

.TextMatrix(.Rows- 1, 3) = objrst1.Fields(12)                  

objrst1.MoveNext

Loop


DoWhile objrst4.EOF = False

   .Rows = .Rows + 1

     .Cols= 4

   .TextMatrix(.Rows - 1, 0) =objrst4.Fields(0)

   .TextMatrix(.Rows - 1, 1) =objrst4.Fields(6)

   .TextMatrix(.Rows - 1, 2) = objrst4.Fields(3)

    .TextMatrix(.Rows - 1, 3) =objrst4.Fields(4)

   objrst4.MoveNext

Loop

EndWith

End If

充值从充值表中查询信息,包含了某个卡号的初始充值记录和每一次的充值记录

If SSTab1.Caption = "充值" Then

MSHFlexGrid2.Visible = True

MSHFlexGrid2.ColWidth(0)= 2000

MSHFlexGrid2.ColWidth(1)= 2000

MSHFlexGrid2.ColWidth(2)= 2000

MSHFlexGrid2.ColWidth(3)= 2000

MSHFlexGrid2.ColWidth(4)= 2000

DimStrSQL2 As String

Dimobjrst2 As ADODB.Recordset

Dimmsgtext2 As String

StrSQL2 = "select * fromrecharge_Info where userID='" & Trim(cbouserID.Text) &"'"

Setobjrst2 = ExecuteSQL(StrSQL2, msgtext2)

WithMSHFlexGrid2

.Rows= 1

.Cols= 5

.TextMatrix(0,0) = "卡号"

.TextMatrix(0,1) = "学号"

.TextMatrix(0,2) = "充值金额"

.TextMatrix(0,3) = "日期"

.TextMatrix(0,4) = "时间"

                    

DoWhile objrst2.EOF = False

        .Rows = .Rows + 1

        .Cols = 5

        .TextMatrix(.Rows- 1, 0) =objrst2.Fields(0)

        .TextMatrix(.Rows- 1, 1) =objrst2.Fields(3)

        .TextMatrix(.Rows- 1, 2) =objrst2.Fields(1)

        .TextMatrix(.Rows- 1, 3) =objrst2.Fields(5)

        .TextMatrix(.Rows-1,4) =objrst2.Fields(6)

        objrst2.MoveNext

Loop

EndWith

End If

       退卡信息,从退卡表中查询信息

If SSTab1.Caption = "退卡" Then

MSHFlexGrid3.Visible = True

MSHFlexGrid3.ColWidth(0)= 2000

MSHFlexGrid3.ColWidth(1)= 2000

MSHFlexGrid3.ColWidth(2)= 2000

MSHFlexGrid3.ColWidth(3)= 2000

MSHFlexGrid3.ColWidth(4)= 2000

DimStrSQL3 As String

Dimobjrst3 As ADODB.Recordset

Dimmsgtext3 As String

StrSQL3 = "select * fromcancelcard_Info where userID='" & Trim(cbouserID.Text) &"'"

WithMSHFlexGrid3

.Rows= 1

.Cols= 5

.TextMatrix(0,0) = "卡号"

.TextMatrix(0,1) = "学号"

.TextMatrix(0,2) = "日期"

.TextMatrix(0,3) = "时间"

.TextMatrix(0,4) = "退卡金额"

DoWhile objrst3.EOF = False

     .Rows = .Rows + 1

     .Cols = 5

     .TextMatrix(.Rows - 1, 0) =objrst3.Fields(0)

     .TextMatrix(.Rows - 1, 1) =objrst3.Fields(6)

      .TextMatrix(.Rows - 1, 2) =objrst3.Fields(3)

      .TextMatrix(.Rows - 1, 3) =objrst3.Fields(4)

      .TextMatrix(.Rows - 1, 4) = objrst3.Fields(1)

      objrst3.MoveNext

Loop

EndWith

           

End If

If SSTab1.Caption = "退出" Then

UnloadMe

End If

If SSTab1.Caption = "临时用户" Then

Label3.Visible= True

Label3.Caption = "暂时没有添加功能!"

End If

‘汇总卡的情况,我针对的是单个操作员的汇总,结账的也是单个操作员。

If SSTab1.Caption = "汇总" Then

Frame1.Visible= True

End If

3、 结账按钮:

先检查有没有需要结账的用户:

strSQL(7) = "select * from student_Info whereusername='" & Trim(cbouserID.Text) & "' and ischeck='未结账'"

Set objrst(7) = ExecuteSQL(strSQL(7), msgtext(7))

If objrst(7).RecordCount = 0 Then

MsgBox "没有需要结账的用户!", vbOKOnly +vbExclamation, "提示"

Else

       

'售卡张数

strSQL(0) = "select cardno from student_Infowhere username='" & Trim(cbouserID.Text) & "'"

Set objrst(0) =ExecuteSQL(strSQL(0), msgtext(0))

If objrst(0).EOF = False Then

Text1.Text= objrst(0).RecordCount

Else

      Text1.Text = 0

End If

'退卡张数

strSQL(1) = "select cardno from cancelcard_Infowhere userID='" & Trim(cbouserID.Text) & "'"

Set objrst(1) = ExecuteSQL(strSQL(1), msgtext(1))

If objrst(1).RecordCount = 0 Then

    Text2.Text = 0

MsgBox"没有记录", vbOKOnly +vbExclamation, "提示"

Else

If objrst(1).EOF = False Then

          Text2.Text= objrst(1).RecordCount

End If

End If

'充值金额

strSQL(2) = "select addmoney from recharge_Infowhere userID='" & Trim(cbouserID.Text) & "'"

Set objrst(2) = ExecuteSQL(strSQL(2), msgtext(2))

strSQL(3) = "select recharge from cancelcard_Infowhere userID='" & Trim(cbouserID.Text) & "'"

Set objrst(3) = ExecuteSQL(strSQL(3), msgtext(3))

recash1 = 0

objrst(2).MoveFirst

  Do While Not(objrst(2).EOF)

        recash1= recash1 + objrst(2).Fields("addmoney")

        objrst(2).MoveNext

  Loop

  recash2 = 0

If objrst(3).RecordCount = 0 Then

        Text3.Text= recash1

Else

        objrst(3).MoveFirst

        Do WhileNot (objrst(3).EOF)

                      recash2 = recash2 +objrst(3).Fields("recharge")

               objrst(3).MoveNext

         Loop

         Text3.Text= recash1 + recash2

End If

'退还金额

strSQL(4) = "select returncash fromcancelcard_Info where userID='" & Trim(cbouserID.Text) &"'"

Set objrst(4) = ExecuteSQL(strSQL(4), msgtext(4))

If objrst(4).RecordCount = 0 Then

Text5.Text= 0

Else

returncash= 0

      objrst(4).MoveFirst

      Do WhileNot (objrst(4).EOF)

            returncash = returncash +objrst(4).Fields("returncash")

            objrst(4).MoveNext

            Text5.Text = returncash

       Loop

End If

'总售卡张数

strSQL(5) = "select cardno from student_Infowhere username='" & Trim(cbouserID.Text) & "'"

Set objrst(5) = ExecuteSQL(strSQL(5), msgtext(5))

If objrst(5).EOF = False Then

          text6.Text= objrst(5).RecordCount + objrst(1).RecordCount

End If

 '应收总金额

text7.Text = Val(Trim(Text3.Text) - Trim(Text5.Text))

strSQL(6) = "select * from student_Info where username='"& Trim(cbouserID.Text) & "' and ischeck='未结账'"

Set objrst(6) = ExecuteSQL(strSQL(6), msgtext(6))

If objrst(6).RecordCount >0 Then

objrst(6).MoveFirst

DoWhile objrst(6).EOF = False

       objrst(6).Fields(10) = "已结账"

           objrst(6).MoveNext

         Loop

           objrst(6).Close

Else

           MsgBox"没有需要结账的用户!",vbOKOnly + vbExclamation, "提示"

           Exit Sub

End If

       MsgBox "结账成功!",vbOKOnly + vbExclamation, "提示"

End If

 

‘填写日结账单表的内容

'上期余额

strSQL(9) = "select addmoney from recharge_Infowhere date='" & Date & "'and userID='" &cbouserID.Text & "'"

Set objrst(9) = ExecuteSQL(strSQL(9), msgtext(9))

Dim m As Integer

strSQL(13) = "select * from line_Info whereloginondate='" & Date & "'and username='" &cbouserID.Text & "'"

Set objrst(13) = ExecuteSQL(strSQL(13), msgtext(13))

If objrst(13).RecordCount = 0 Then

       m = 0

Else

m= objrst(13).RecordCount - 1

End If

recash7 = 0

Do While Not (objrst(9).EOF)

        recash7 = recash7 +objrst(9).Fields("addmoney")

      objrst(9).MoveNext

 Loop

      recash8 =0

Do While Not (objrst(13).EOF)

      recash8 =recash8 + objrst(13).Fields("consumcash")

      objrst(13).MoveNext

  Loop

strSQL(14) = "select top " & m &" * from line_Info where loginondate='" & Date & "'andusername='" & cbouserID.Text & "'order by serial"

Set objrst(14) = ExecuteSQL(strSQL(14), msgtext(14))

      recash10 =0

If objrst(14).RecordCount = 0 Then

       recash10= 0

Else

Do While Not (objrst(14).EOF)

           recash10 = recash10 +objrst(14).Fields("consumcash")

           objrst(14).MoveNext

Loop

End If

       

'今日充值金额

strSQL(8) = "select addmoney from recharge_Infowhere date='" & Date & "'and userID='" &cbouserID.Text & "'"

Set objrst(8) = ExecuteSQL(strSQL(8), msgtext(8))

recash3 = 0

Do While Not (objrst(8).EOF)

       recash3 =recash3 + objrst(8).Fields("addmoney")

       objrst(8).MoveNext

  Loop

'今日消费金额

strSQL(11) = "select consumcash from line_Infowhere loginondate='" & Date & "'and username='" &cbouserID.Text & "'"

Set objrst(11) = ExecuteSQL(strSQL(11), msgtext(11))

recash5 = 0

Do While Not (objrst(11).EOF)

        recash5= recash5 + objrst(11).Fields("consumcash")

        objrst(11).MoveNext

  Loop

'今日退卡金额

strSQL(12) = "select * from cancelcard_Info whereloginondate='" & Date & "'and userID='" &cbouserID.Text & "'"

Set objrst(12) = ExecuteSQL(strSQL(12), msgtext(12))

Do While Not (objrst(12).EOF)

        recash6= recash6 + objrst(12).Fields("returncash")

        objrst(12).MoveNext

Loop

strSQL(10) = "select * from checkday_Info wheredate='" & Date & "'and username='" & cbouserID.Text& "'"

Set objrst(10) = ExecuteSQL(strSQL(10), msgtext(10))

'如果是第一次添加的信息

If objrst(10).RecordCount = 0 Then

       objrst(10).AddNew

objrst(10).Fields(6)= Trim(cbouserID.Text)

objrst(10).Fields(0)= 0

       objrst(10).Fields(1) = recash3

      objrst(10).Fields(2)= recash5

            If objrst(12).RecordCount = 0 Then

                    objrst(10).Fields(3) = 0

            Else

                    objrst(10).Fields(3) = recash6

            End If

objrst(10).Fields(4)= recash7 - recash8

                    objrst(10).Fields(5) = Date

                    objrst(10).Update

               

     Else

           objrst(10).Fields(0)= recash7 - recash10

           objrst(10).Fields(1)= recash3

           objrst(10).Fields(2)= recash5

           If objrst(12).RecordCount = 0 Then

                objrst(10).Fields(3) = 0

           Else

                objrst(10).Fields(3) = recash6

           End If

'本次余额

  Dim strSQLn AsString

  Dim objrstn AsADODB.Recordset

  Dim msgtextnAs String

  strSQLn ="select * from line_Info where loginondate='" & Date &"'and username='" & cbouserID.Text & "'"

  Set objrstn =ExecuteSQL(strSQLn, msgtextn)

 recash9 = 0

 Do While Not(objrstn.EOF)

           recash9 = recash9 +objrstn.Fields("consumcash")

            objrstn.MoveNext

      Loop

   objrst(10).Fields(4)= recash7 - recash9

   objrst(10).Fields(5)= Date

   objrst(10).Fields(6)= Trim(cbouserID.Text)

   objrst(10).Update

End If

    日结账单主要是对每一天的操作进行总结,我认为关键是结账的方式,因为对于一个或者多个操作员,每天可以结账若干次,我管理员要对每次的结账内容汇总,随时更新数据表中的数据,这个时候的关键就是上期余额的获取,用什么方法在更新数据之前先保存本次余额作为下一次的上期余额等。

我做的方法有漏洞的地方,我采用了标识字段的方法,用总的充值金额和消费金额做减法,至于消费金额分为总的消费金额和前n-1次的消费金额,如何查询到钱n-1次的消费金额,采用的查询条件是什么,这些是对数据库进行的操作。

       对于数据库的操作,我在做整个系统的过程中尽量每种方式都尝试着换着用,增删改查的功能都以不同的形式展示了,下一篇博客详细介绍整个机房中对数据库中的四种基本功能的运用总结。

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



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

相关文章

JWT + 拦截器实现无状态登录系统

《JWT+拦截器实现无状态登录系统》JWT(JSONWebToken)提供了一种无状态的解决方案:用户登录后,服务器返回一个Token,后续请求携带该Token即可完成身份验证,无需服务器存储会话... 目录✅ 引言 一、JWT 是什么? 二、技术选型 三、项目结构 四、核心代码实现4.1 添加依赖(pom

基于Python实现自动化邮件发送系统的完整指南

《基于Python实现自动化邮件发送系统的完整指南》在现代软件开发和自动化流程中,邮件通知是一个常见且实用的功能,无论是用于发送报告、告警信息还是用户提醒,通过Python实现自动化的邮件发送功能都能... 目录一、前言:二、项目概述三、配置文件 `.env` 解析四、代码结构解析1. 导入模块2. 加载环

linux系统上安装JDK8全过程

《linux系统上安装JDK8全过程》文章介绍安装JDK的必要性及Linux下JDK8的安装步骤,包括卸载旧版本、下载解压、配置环境变量等,强调开发需JDK,运行可选JRE,现JDK已集成JRE... 目录为什么要安装jdk?1.查看linux系统是否有自带的jdk:2.下载jdk压缩包2.解压3.配置环境

Linux查询服务器系统版本号的多种方法

《Linux查询服务器系统版本号的多种方法》在Linux系统管理和维护工作中,了解当前操作系统的版本信息是最基础也是最重要的操作之一,系统版本不仅关系到软件兼容性、安全更新策略,还直接影响到故障排查和... 目录一、引言:系统版本查询的重要性二、基础命令解析:cat /etc/Centos-release详

更改linux系统的默认Python版本方式

《更改linux系统的默认Python版本方式》通过删除原Python软链接并创建指向python3.6的新链接,可切换系统默认Python版本,需注意版本冲突、环境混乱及维护问题,建议使用pyenv... 目录更改系统的默认python版本软链接软链接的特点创建软链接的命令使用场景注意事项总结更改系统的默

在Linux系统上连接GitHub的方法步骤(适用2025年)

《在Linux系统上连接GitHub的方法步骤(适用2025年)》在2025年,使用Linux系统连接GitHub的推荐方式是通过SSH(SecureShell)协议进行身份验证,这种方式不仅安全,还... 目录步骤一:检查并安装 Git步骤二:生成 SSH 密钥步骤三:将 SSH 公钥添加到 github

Linux系统中查询JDK安装目录的几种常用方法

《Linux系统中查询JDK安装目录的几种常用方法》:本文主要介绍Linux系统中查询JDK安装目录的几种常用方法,方法分别是通过update-alternatives、Java命令、环境变量及目... 目录方法 1:通过update-alternatives查询(推荐)方法 2:检查所有已安装的 JDK方

Linux系统之lvcreate命令使用解读

《Linux系统之lvcreate命令使用解读》lvcreate是LVM中创建逻辑卷的核心命令,支持线性、条带化、RAID、镜像、快照、瘦池和缓存池等多种类型,实现灵活存储资源管理,需注意空间分配、R... 目录lvcreate命令详解一、命令概述二、语法格式三、核心功能四、选项详解五、使用示例1. 创建逻

使用Python构建一个高效的日志处理系统

《使用Python构建一个高效的日志处理系统》这篇文章主要为大家详细讲解了如何使用Python开发一个专业的日志分析工具,能够自动化处理、分析和可视化各类日志文件,大幅提升运维效率,需要的可以了解下... 目录环境准备工具功能概述完整代码实现代码深度解析1. 类设计与初始化2. 日志解析核心逻辑3. 文件处

golang程序打包成脚本部署到Linux系统方式

《golang程序打包成脚本部署到Linux系统方式》Golang程序通过本地编译(设置GOOS为linux生成无后缀二进制文件),上传至Linux服务器后赋权执行,使用nohup命令实现后台运行,完... 目录本地编译golang程序上传Golang二进制文件到linux服务器总结本地编译Golang程序