用VB+Mysql 实现员工宿舍管理系统

用VB+Mysql 实现员工宿舍管理系统,第1张

员工管理系统是典型的信息管理系统(MIS),其开发主要包括后台数据库的建立和维护以及前端应用程序的开发两个方面。对于前者要求建立起数据一致性和完整性强、数据安全性好的库。而对于后者则要求应用程序功能完备,易使用等特点。

经过分析,我们使用 MICROSOFT公司的 VISUAL BASIC开发工具,利用其提供的各种面向对象的开发工具,尤其是数据窗口这一能方便而简洁 *** 纵数据库的智能化对象,首先在短时间内建立系统应用原型,然后,对初始原型系统进行需求迭代,不断修正和改进,直到形成用户满意的可行系统。

整个系统从符合 *** 作简便、界面友好、灵活、实用、安全的要求出发。

论文主要介绍了本课题的开发背景,所要完成的功能和开发的过程。重点的说明了系统设计的重点、设计思想、难点技术和解决方案。

关键字 Visual Basic 6.0 Access2000 控件 窗体 域

Abstract The system of managing census register file is a typical application of managing information system (know as MIS),which mainly includes building up data-base of back-end and developing the application interface of front-end. The former required consistency and integrality and security of data. The later should make the application powerful and easily used.

By looking up lots of datum, we selected Visual Basic presented by Microsoft because of its objective tools in Win32. VB offered a series of ActiveX operating a data-base. It can give you a short-cut to build up a prototype of system application. The prototype could be modified and developed till users are satisfied with it.

Key Word Visual Basic 6.0、Access2000、ActiveX、Form、Field

目 录

第一章 导论... 2

第二章 系统需求分析... 3

第一节 系统设计背景介绍... 3

第二节 系统功能分析... 4

第三章 员工管理系统总体设计.... 5

第1节 系统设计.... 5

第2节 数据库设计... 9

第四章 详细设计工作.... 11

第1节 各功能模块创建及实现.... 11

第五章 系统功能测试... 25

第六章 结束语... 26

一.安装

1.下载

从MySQL AB的官方网站可以下载到最新版本的MySQL,目前最新的版本为5.0.37

下载URL:http://dev.mysql.com/downloads/mysql/5.0.html

附图:

选择"Windows(x86)ZIP/Setup.EXE"下载

(附注:到目前为止,MySQL提供了两种相同的数据库,一种是免费版本CommunityServer,另外一种是包含了技术支持服务和商业许可的版本,即EnterpriseServer.)

2.安装

直接双击setup.exe,安装自动进行,根据提示完成即可.

3.配置向导

按照提示完成即可,也可等安装完成之后单独运行ConfigWizard进行配置。

二.启动

1.手动启动MySQL服务

打开命令行界面,输入命令:

C:\Documents and Settings\Beyondone>mysqld

MySQL就将以前台程序方式运行,要想停止MySQL服务,可以调用一下命令:

C:\Documents and Settings\Beyondone>mysqladmin -u root shutdown

该命令调用MySQL管理工具mysqladmin连接服务器并告知它关闭服务。该命令使用MySQL root用户连接,这是MySQL权限系统中的默认管理账户。

推荐使用>mysqld --console命令启动mysql服务.此时可以从窗口中获得一些有用的启动信息,有助于了解服务器启动情况。

2.以Windows服务方式启动MySQL

可以在安装选项中选择将MySQL安装为Windows服务,那么MySQL就将自动安装成为Windows的一项服务,当Windows启动,停止时,MySQL也将自动启动,停止.MySQL自动安装成为Windows服务之后,也可以从控制面板的管理工具->"服务"选项中手动启动,停止MySQL服务。

还可以安装完MySQL之后以命令行方式手动将MySQL安装为Windows服务。

在安装MySQL Windows服务之前应当使用>mysqladmin -u root shutdown命令先停止正在运行的MySQL服务器。

如果MySQL root用户账户有密码,就需要调用命令>mysqladmin -u root -p shutdown,并根据提示输入密码。

使用>mysqld --install命令安装MySQL Windows服务,该命令安装MySQL为随Windows自启动服务.使用>mysqld --install-manual命令可以安装MySQL为手动启动模式服务。

使用>net start mysql命令手动启动MySQL服务。

使用>net stop mysql命令手动停止MySQL服务。

使用>mysqld  --remove命令卸载MySQL服务。

三.连接

服务器上的mysql服务启动之后,就可以连接服务器上的mysql数据库进行数据 *** 作了.

可以从服务器本机或是网络客户端连接mysql服务器.(决定于你的mysql相关授权表设定,即帐户权限设定)。

mysql本身提供以一个字符界面的客户端程序MySQL Command Line Client,根据相应提示进行 *** 作即可。

mysql现在也提供图形界面的工具软件,包括mysql administrator,mysql query browser等等,官方网站可以免费下载,推荐使用。

可以通过cmd命令行连接:

>mysql -h hostname -u username -p password

这是mysql连接命令的完整格式.(或者--host=hostname,--user=username,--password=yourpass);

如果没有连接参数,mysql客户端程序使用默认值。默认hostname为localhost,默认用户名在windows中为odbc,在unix中为你的unix登录名。比如windows下>mysql命令等价于>mysql -h localhost -u odbc。(mysql在安装一个instance时会自动建立一个root帐户,在配置instance时,会有是否给root帐户设置初始密码以及是否建立anonymous帐户的选项,默认root帐户和anonymous帐户都没有密码.mysql中的anonymous帐户是指username为空即可以为任何值。

ResultSet 只有当前数据库连接存在时才有效,迭代循环是每次只能获取当前游标下数据:

所以你需要建立其他容器将获取的数据存储下来,我刚刚写的这个文件,是相当普通的一个DAO文件结构模式,可以好好看下。会让以后的工作变得更加得心应手。呵呵。

唉!我大餐都给你做好了,你还叫我往嘴里喂啊!

List<String>poList = new LinkedList<String>()

List<String>pnList = new LinkedList<String>()

List<String>prList = new LinkedList<String>()

while(res.next()){

po=res.getString("pno")poList.add(po)

pn=res.getString("pname")pnList.add(pn)

pr=res.getString("price")prList.add(pr)

}

/**************************************************************************************************/

import java.sql.*

import java.util.LinkedList

import java.util.List

/**课题:封装数据库的增删改查的工具类的实现。

*

* 假设相关数据库的表结构如下:

* 表名:user

* 列名及属性:id(int 自增),name(varchar(20)),tele(char(12)),birthday(date)

* @author shy2850

*/

public class UserDAO {

Connection conn

public UserDAO(Connection conn) {

this.conn = conn

}

public int save(User user) throws SQLException {

String sql = "insert into user values(0,?,?,?)"

PreparedStatement pstmt = conn.prepareStatement(sql)

pstmt.setString(1, user.getName())

pstmt.setString(2, user.getTele())

pstmt.setDate(3, user.getBirthday())

int n = pstmt.executeUpdate()

pstmt.close()

return n

}

public int delete(User user) throws SQLException{

String sql = "delete from user where id = "+user.getId()

Statement stmt = conn.createStatement()

int n = stmt.executeUpdate(sql)

stmt.close()

return n

}

public int update(User user) throws SQLException{

String sql = "update user set name=?, tele=?, birthday=? where id = "+user.getId()

PreparedStatement pstmt = conn.prepareStatement(sql)

pstmt.setString(2, user.getName())

pstmt.setString(3, user.getTele())

pstmt.setDate(4, user.getBirthday())

int n = pstmt.executeUpdate(sql)

pstmt.close()

return n

}

public User getUser(Integer id) throws SQLException{

String sql = "select * from user where id = " + id

Statement stmt = conn.createStatement()

ResultSet rs = stmt.executeQuery(sql)

User user = getUserFromResultSet(rs)

rs.close()

stmt.close()

return user

}

public List<User>getAll() throws SQLException{

List<User>userList = new LinkedList<User>()

String sql = "select * from user "

Statement stmt = conn.createStatement()

ResultSet rs = stmt.executeQuery(sql)

while (rs.next()) {

User u = getUserFromResultSet(rs)

userList.add(u)

}

return userList

}

static User getUserFromResultSet(ResultSet rs) throws SQLException{

Integer id = rs.getInt("id")

String name= rs.getString("name")

String tele= rs.getString("tele")

Date birthday = rs.getDate("birthday")

return new User(id, name, tele, birthday)

}

}

/**

* 构建数据库表的java类映射

*/

class User{

private Integer id

private String name

private String tele

private Date birthday

public User() {

}

public User(Integer id, String name, String tele, Date birthday) {

super()

this.id = id

this.name = name

this.tele = tele

this.birthday = birthday

}

public Integer getId() {

return id

}

public void setId(Integer id) {

this.id = id

}

public String getName() {

return name

}

public void setName(String name) {

this.name = name

}

public String getTele() {

return tele

}

public void setTele(String tele) {

this.tele = tele

}

public Date getBirthday() {

return birthday

}

public void setBirthday(Date birthday) {

this.birthday = birthday

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/7250270.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-03
下一篇 2023-04-03

发表评论

登录后才能评论

评论列表(0条)

保存