ABSTRACT
The sports meeting administrative system of track and field is a typical information management system. It makes games management simple and convenient for organizer to arrange and manage the games with reason. It makes no-paper work possible, and save a lot of manpower and material resources. This paper use "Visual Basic" as the development tool and "Access 2003" as the background data base first, then introduce the background of development, and the developing and operating of the system through photographs and charts. Design the characteristic fully utilizing VISUAL BASIC and ACCESS database to be apt to use and develop fast to improve programming efficiency and dependability . At the same time, the development of system principle, the system characteristic function and the planning design are introduced. it is developed based on the sufficient analysis and the systemic argumentation of the games management system. It not only can complete the general operation of games management, but also have the characteristics such as programmer reasonable, operating simply, running reliably and excellent secrecy.
Keywords: Visual Basic Sports meeting of track and field Access
strsql = "select * from 田赛成绩 where 姓名='" & Combo2.Text & "' and 项目名称='" & Combo1.Text & "'"
Set rs = cnn.Execute(strsql)
If rs.EOF = True Then '该项目成绩没有被记录,可以入库
strsql3 = "insert into 田赛成绩 values('" & Combo2.Text & "','" & Combo1.Text & "','" & Text3.Text & "')"
cnn.Execute (strsql3)
MsgBox "修改成功!", vbOKOnly, "提示"
Text3.Text = ""
Else
strsql4 = "update 田赛成绩 set 成绩='" & Text3.Text & "' where 姓名='" & Combo2.Text & "' and 项目名称='" & Combo1.Text & "'"
cnn.Execute (strsql4)
Text3.Text = ""
End If
单击图(4)中的输出就是得出田赛项目的最终成绩即得出田赛项目的名次。田赛输出是把每个田赛项目中的前几名的人员成绩信息输出到最终成绩表中,从田赛成绩中的开始查找田赛项目,则从田赛成绩表中把从项目名单中查找到的项目的前几名成绩信息输出到最终成绩表中。然后再从田赛成绩中查找下一个田赛项目,再把该项目的前几名输出到最终成绩表中,以此循环直到田赛成绩中的项目全部查完。输出部分的代码如下:
strsql6 = "select 每项目取的名次 from 参数表"
Set rs = cnn.Execute(strsql6)
strsql = "select distinct 项目名称 from 田赛成绩"
Set rs1 = cnn.Execute(strsql)
i = 0
Do While Not rs1.EOF
strsql1 = "select * from 田赛成绩 where 项目名称='" & rs1.Fields(0) & "'order by 成绩 desc"
Set rs2 = cnn.Execute(strsql1)
For j = 0 To Val(rs.Fields(0)) - 1
strsql3 = "select * from 最终成绩 where 姓名='" & rs2.Fields(0) & "' and 项目名称='" & rs2.Fields(1) & "'"
Set rs = cnn.Execute(strsql3)
If rs.EOF Then
strsql0 = "select 分数 from 名次分数表 where 名次=" & j + 1 & ""
Set rs5 = cnn.Execute(strsql0)
strsql2 = "insert into 最终成绩(姓名,项目名称,成绩,名次,分数) values('" & rs2.Fields(0) & "','" & rs2.Fields(1) & "','" & rs2.Fields(2) & "','" & j + 1 & "','" & rs5.Fields(0) & "')"
cnn.Execute (strsql2)
End If
rs2.MoveNext
Next
rs1.MoveNext
i = i + 1
Loop
5.5 查询输出
查询输出模块中有七种不同的查询:运动员成绩查询、代表队成绩查询、项目成绩查询、总分表、项目名次表、成绩名次表和成绩汇册。这些查询都是使用SQL语句进行查询,不同的就是SQL语句中的条件不同面已,因此在代码方面都差不多,如项目成绩查询。项目成绩查询界面如图5-5所示。
图5-5 查询界面
从图(5)中的项目名称中选择一个项目,然后单击查询就会输出该项目的所有运动员的比赛成绩。部分代码如下:
If Combo1.Text = "" Then
MsgBox "请选择项目名称!", vbOKOnly, "提示"
Else
strsql = "select 项目类型 from 运动项目名单 where 项目名称='" & Combo1.Text & "'"
Set rs = cnn.Execute(strsql
If rs.Fields(0) = "田赛项目" Then
strsql1 = "select * from 田赛成绩 where 项目名称='" & Combo1.Text & "'"
Set rs1 = cnn.Execute(strsql1)
With MSHFlexGrid1 '详细查询的信息显示
.Rows = 2
.CellAlignment = 4
.TextMatrix(0, 0) = "姓名"
.TextMatrix(0, 1) = "项目名称"
.TextMatrix(0, 2) = "成绩"
Do While Not rs1.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 2, 0) = rs1.Fields(0)
.TextMatrix(.Rows - 2, 1) = Trim(rs1.Fields(1))
.TextMatrix(.Rows - 2, 2) = rs1.Fields(2)
rs1.MoveNext
Loop
'.Rows = .Rows - 1
End With
End If
End if
上述代码只是实现选择的项目是田赛项目的成绩输出,选择的项目是径赛项目和全能项目这里就不列出来了。实现项目成绩查询首先选择项目名称再查询,先判断选择的项目是哪一种类型的项目,如果是全能项目或田赛项目则第一行是姓名、项目名称和成绩,如果是径赛项目第一行就是姓名、项目名称、初赛成绩、预赛成绩和决赛成绩,从第二行开始就是该项目所有运动员的成绩信息。
5.6 系统工具
系统工具是为本系统服务的工具,方便本系统的使用。如数据库备份与恢复就是为了防止系统的数据库出现错误,可以通过还原数据库来修正这个错误。而数据表的浏览是让人清楚数据库中有哪些表及表的属性,让人更清楚明白数据库表的结构。这里就以数据库备份与还原为例,界面如图5-6所示
图5-6备份与还原界面 图5-7 备份完成界面
只要单击下图(6)中备份或恢复即可完成备份或恢复操作。图(7)就是完成了数据库备份成功后的界面。备份数据库就是把系统中的数据库压缩拷贝到另外的路径文件下面。
Dim FileName As String
Dim FileBack As String
Dim Info As String
FileName = mypath & "db1.mdb"
FileBack = mypath & "backup/db.bak"
Info = "正在备份数据库" & FileName
BackupDatabase FileName, FileBack, Info
MsgBox "备份数据库成功!", vbInformation, "提示"