Home Database Mysql Tutorial 基于Access数据库的抽奖系统设计

基于Access数据库的抽奖系统设计

Jun 07, 2016 pm 04:21 PM
access based on lottery database system design

摘 要 介绍了抽奖信息管理系统的设计思路和基本原理,结合Access,通过软件系统开发,实现了具有随机性和相对均衡性的抽奖。 关键词 抽奖系统 Access VBA 随机 相对均衡性 引言 当今社会,各种各样的抽奖活动相当普遍,抽奖活动的基本原则和主要特征是随机性

  摘 要 介绍了抽奖信息管理系统的设计思路和基本原理,结合Access,通过软件系统开发,实现了具有随机性和相对均衡性的抽奖。

  关键词 抽奖系统 Access VBA 随机 相对均衡性

  引言

  当今社会,各种各样的抽奖活动相当普遍,抽奖活动的基本原则和主要特征是随机性,但对于某一团体内部的抽奖活动来说,还有一个相对均衡的问题,所谓相对均衡就是指让各个部门的中奖概率和其人数占总人数的比重大致相等。基于Access,结合其内置VBA语言,通过程序设计实现抽奖的随机,通过算法研究实现抽奖的相对均衡。本文主要介绍了系统原理以及主要程序的设计。

  系统组成及原理

  抽奖系统主要由来宾登记、奖票管理、幸运抽奖、获奖查询四个基本模块构成,登记模块登记参加抽奖人员,奖票管理模块初始化参加抽奖人员名单,抽奖模块实现抽奖功能,获奖查询模块查询获奖结果。其中,抽奖模块中可以实现奖励等级、总抽奖数、每一次抽奖数的控制。系统架构框图如图1。

基于Access数据库的抽奖系统设计

  图1 系统架构

  系统初始化

  来宾登记模块中已经收录了参加抽奖的人员名单以及所属部门,在奖票管理模块中,当点击初始化按钮时通过内部程序设计首先把上次的抽奖结果清空,同时利用 Rnd在参加抽奖的人员名单前随机生成一系列的序号,为幸运抽奖模块中的随机抽奖做准备[1]。主要初始化程序代码如下:

  DoCmd.SetWarnings False

  DoCmd.OpenQuery "删除对奖票号", acNormal, acEdit

  DoCmd.OpenQuery "追加对奖票号", acNormal, acEdit

  DoCmd.SetWarnings True

  Set qrs = CurrentDb.OpenRecordset("对奖票号")

  qrs.MoveFirst

  i = 1

  Do While Not qrs.EOF

  qrs.Edit

  qrs!序号 = Int((211 - 1) * Rnd)

  qrs!对奖号码 = i

  qrs.Update

  i = i + 1

  qrs.MoveNext

  Loop

  MsgBox ("对奖名单初始化完毕。")

  qrs.Close

  抽奖功能的实现

  通过抽奖模块实现最终抽奖功能。

  通过奖励等级组合框控制抽奖等级,通过抽奖数量组合框控制每批次抽奖数量,通过总抽奖数组合框控制总抽奖数。当奖励等级分别为一、二、三等奖时,抽奖数量和总抽奖数默认值分别

  为5、10、10和10、30、50。各组合框的具体数值也可以通过上下箭头控制。抽奖界面如图2。

基于Access数据库的抽奖系统设计

  图 2 抽 奖 界 面

  其程序设计比较简单,主要程序如下:

  ……

  If Me!奖励等级.Value = 1 Then

  Me!总数量.Value = 10

  End If

  If Me!奖励等级.Value = 2 Then

  Me!总数量.Value = 30

  End If

  If Me!奖励等级.Value = 3 Then

  Me!总数量.Value = 50

  End If

  Forms!抽奖.Q_抽奖统计.Requery

  If Me!奖励等级.Value = 1 Then

  Me!抽奖数量.Value = 5

  End If

  If Me!奖励等级.Value = 2 Or Me!奖励等级.Value = 3 Then

  Me!抽奖数量.Value = 10

  End If

  ……

  通过点击开始按钮开始抽奖,同时按钮标题变为停止,再次点击停止此批次抽奖,同时按钮标题变为开始,继续点击开始下一批次抽奖,如此反复,直至完成总抽奖数,此时提示“抽奖总数已到”,如果未完成总抽奖数就开始另外一轮抽奖,则提示“抽奖限制”。

  内部抽奖主要解决随机性和相对均衡两个问题。系统初始化在参加抽奖人员名单前随机生成了序号,通过查询“号码重排序”将参加抽奖人员名单按照序号升序排列,抽奖时按照序号顺序抽奖,实现了随机的要求。相对均衡要求大致按照各个部门人数占总人数的百分比来分配中奖人数,本系统采用各个部门占总人数的百分比乘以抽奖总数的方法来大致确定各个部门的中奖人数,有小数的数字通过程序设计进行四舍五入处理。需要注意的是,若使所有的部门中奖人数都要用四舍五入的方法进行处理则可能出现错误,为了避免这种情况需要选定一个部门,,使其中奖人数等于总抽奖数减去其他各个部门中奖人数之和[2]。抽奖模块的主要程序代码如下:

  ……

  N = 0

  cnt = Me!电科.Value + Me!电气.Value + Me!自动化.Value + Me!通信.Value + Me!院办.Value + Me!退休.Value

  Do While Me!抽奖数量.Value > N And Not qrs.EOF And cnt

  '电科抽奖

  ’四舍五入确定电科中奖数

  If Me!电科.Value

  If qrs.单位 = "电科" And qrs!批次.Value = 0 Then

  Me!电科.Value = Me!电科.Value + 1

  qrs.Edit

  qrs!奖励等级.Value = Me!奖励等级.Value

  qrs!批次.Value = Me!批次.Value

  qrs.Update

  N = N + 1

  End If

  Else

  End If

  ……

  '退休抽奖

  cnt = Me!电科.Value + Me!电气.Value + Me!自动化.Value + Me!通信.Value + Me!院办.Value + Me!退休.Value

  cnt2= Me!电科.Value + Me!电气.Value + Me!自动化.Value + Me!通信.Value + Me!院办.Value

  '剩余数量分配给退休

  If Me!退休.Value

  If qrs22.单位 = "退休" And qrs!批次.Value = 0 Then

  Me!退休.Value = Me!退休.Value + 1

  qrs.Edit

  qrs22!奖励等级.Value = Me!奖励等级.Value

  qrs22!批次.Value = Me!批次.Value

  qrs22.Update

  N = N + 1

  End If

  Else

  End If

  ……

  ’判断是否完成抽奖

  cnt = Me!电科.Value + Me!电气.Value + Me!自动化.Value + Me!通信.Value + Me!院办.Value + Me!退休.Value

  If cnt = Me!总数量.Value Then

  MsgBox ("抽奖总数已到。")

  Me.可抽奖.Value = 0

  Else

  MsgBox ("抽奖限制。")

  End If

  ……

  结论

  本系统利用Access数据库,结合其内置VBA语言,探讨了系统初始化、抽奖的随机性和相对均衡性等关键问题,满足了抽奖的要求。进行适当调整,该系统可以应用于多种抽奖场合。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MySQL: An Introduction to the World's Most Popular Database MySQL: An Introduction to the World's Most Popular Database Apr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

Why Use MySQL? Benefits and Advantages Why Use MySQL? Benefits and Advantages Apr 12, 2025 am 12:17 AM

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

How to configure zend for apache How to configure zend for apache Apr 13, 2025 pm 12:57 PM

How to configure Zend in Apache? The steps to configure Zend Framework in an Apache Web Server are as follows: Install Zend Framework and extract it into the Web Server directory. Create a .htaccess file. Create the Zend application directory and add the index.php file. Configure the Zend application (application.ini). Restart the Apache Web server.

How to monitor Nginx SSL performance on Debian How to monitor Nginx SSL performance on Debian Apr 12, 2025 pm 10:18 PM

This article describes how to effectively monitor the SSL performance of Nginx servers on Debian systems. We will use NginxExporter to export Nginx status data to Prometheus and then visually display it through Grafana. Step 1: Configuring Nginx First, we need to enable the stub_status module in the Nginx configuration file to obtain the status information of Nginx. Add the following snippet in your Nginx configuration file (usually located in /etc/nginx/nginx.conf or its include file): location/nginx_status{stub_status

What is apache server? What is apache server for? What is apache server? What is apache server for? Apr 13, 2025 am 11:57 AM

Apache server is a powerful web server software that acts as a bridge between browsers and website servers. 1. It handles HTTP requests and returns web page content based on requests; 2. Modular design allows extended functions, such as support for SSL encryption and dynamic web pages; 3. Configuration files (such as virtual host configurations) need to be carefully set to avoid security vulnerabilities, and optimize performance parameters, such as thread count and timeout time, in order to build high-performance and secure web applications.

How to use Debian Apache logs to improve website performance How to use Debian Apache logs to improve website performance Apr 12, 2025 pm 11:36 PM

This article will explain how to improve website performance by analyzing Apache logs under the Debian system. 1. Log Analysis Basics Apache log records the detailed information of all HTTP requests, including IP address, timestamp, request URL, HTTP method and response code. In Debian systems, these logs are usually located in the /var/log/apache2/access.log and /var/log/apache2/error.log directories. Understanding the log structure is the first step in effective analysis. 2. Log analysis tool You can use a variety of tools to analyze Apache logs: Command line tools: grep, awk, sed and other command line tools.

MySQL vs. Other Databases: Comparing the Options MySQL vs. Other Databases: Comparing the Options Apr 15, 2025 am 12:08 AM

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.

Using Dicr/Yii2-Google to integrate Google API in YII2 Using Dicr/Yii2-Google to integrate Google API in YII2 Apr 18, 2025 am 11:54 AM

VprocesserazrabotkiveB-enclosed, Мнепришлостольностьсясзадачейтерациигооглапидляпапакробоглесхетсigootrive. LEAVALLYSUMBALLANCEFRIABLANCEFAUMDOPTOMATIFICATION, ČtookazaLovnetakProsto, Kakaožidal.Posenesko

See all articles