学 号 09770223
大型数据库技术
大作业
通讯录及相关信息管理
学班成
生姓名 徐婷婷 级 09软件2班 绩
电子与信息工程系
2011年5月9日
目录
摘要 .................................................................................................................................................. 3 第一章 设计内容与要求 ................................................................................................................. 4
1.1设计内容 ........................................................................................................................... 4 1.2设计要求 ........................................................................................................................... 4 第二章 需求分析 ............................................................................................................................. 4
2.1背景 .................................................................................................................................... 4 2.2数据需求 ............................................................................................................................ 4 2.3事物需求 ............................................................................................................................ 4 第三章 概念逻辑结构设计 ............................................................................................................. 5
3.1 E-R 图 ................................................................................................................................. 5 3.2 关系模型 ........................................................................................................................... 6 第四章 数据库及表设计 ................................................................................................................. 8
4.1通讯录管理系统: ............................................................................................................ 8 4.2存储过程: ........................................................................................................................ 9 4.3触发器: ............................................................................................................................ 9 第五章 程序 ................................................................................................................................... 10 第六章 设计体会 ........................................................................................................................... 15
2
摘要
本管理系统是严格按照软件工程的思想,利用c#和SQL来开发的,此通讯录系统的功能是存储通讯联系人的各方面信息,方便交流,对各个联系人信息的查找以及校内信息的查看,具有对各种信息进行添加,删除,查询和修改的功能。
3
第一章设计内容与要求
1.1设计内容
通讯录管理系统 1.2设计要求
1)通讯录中信息包括部门电话、职工电话及一周内事务安排
2)登录管理:包括对3类用户的管理(管理员、校内员工、外校人员) 3)管理员可实现对校内及校外人员的管理(添加、删除、修改) 4)校内员工可查询校内信息及信息的添加、删除、修改 5)校外人员可查询部门信息
第二章 需求分析
2.1背景
对于一些大企业,以及学校来说,对于人员的管理已必不可少,因此,必须制定一套合理、有效,规范和实用的通讯录管理系统,对成员以及职工进行信息的统一管理。 2.2数据需求
通讯录管理信息系统需要完成功能主要有: (1)成员基本信息的录入、添加 、修改、删除。 (2)职工基本信息的录入、添加、修改、删除。 (3)校内信息的录入、添加、修改、删除。 (4)各部门信息的录入、添加、修改、删除。 2.3事物需求
(1)成员信息管理 1)对成员信息的查询 2)对成员信息的添加和删除 (2)职工信息管理 1)对职工信息的查询 2)对职工信息的添加和删除 (3)部门信息管理
1)校外人员对部门信息的查询 (4)校内信息管理
1)校内员工对校内信息的添加、删除、修改
4
第三章 概念逻辑结构设计
3.1 E-R 图 编号 姓名 用 户 密码 类别
名称 编号 电话
部门 标题 内容 编号 添加 时间 校内 信 息
电话 姓名
部门名
称
部门电职工
话
编号 一周事务 添加时间 5
管理 管理员 成 员 职工信息 部门信息 校外人员 校内人员 查询 校内信息 3.2 关系模型
用 户 主键 编号 姓名 密码 用户类别 部 门 主键 编号 名称 电话
校 内 信 息 主键 编号 信息标题 信息内容 添加时间
管理
6
职 工 主键
编号 姓名 电话 部门名称 部门电话 一周事务 添加时间
7
第四章数据库及表设计
4.1通讯录管理系统:
Create database communication
Use communication
create table com_user(
User_id int not null primary key identity(1,1), User_name char(20) not null, User_pass char(20) not null, User_style int not null )
create table com_user_worker(
Usw_id int not null primary key identity(1,1), Usw_user_id int not null, Usw_worker_id int not null )
create table com_department( Dep_id int not null primary key identity(1,1), Dep_name char(20) not null, Dep_phone int null )
create table com_workers(
Wor_id int not null primary key identity(1,1), Wor_name char(20) not null, Wor_phone int null,
Wor_depart_name char(20) not null, Wor_depart_phone int null, Wor_week_task text null, Wor_addtime date not null )
create table com_campus_information(
cam_id int not null primary key identity(1,1), cam_title text not null, cam_content text not null, cam_addtime date not null
8
)
4.2存储过程: 示例: Create procedure proc_workers @wor_name char(20), @wor_phone int, @wor_depart_name char(20), @wor_depart_phone int, @wor_week_task text As Insert into com_workers (wor_name, wor_phone, wor_depart_name, wor_depart_phone, wor_week_task)values(@wor_name, @wor_phone, @wor_depart_name, @wor_depart_phone, @wor_week_task) Go
Exec proc_workers test,123456,jiaowuchu,12345,ascde
4.3触发器: Create trigger insert_or_update_workers Before insert or update on com_workers For each row As begin If (wor_addtime=null) Then wor_addtime=now; End if; End;
9
第五章 程序
10
部分程序代码: using System;
using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System.Windows.Forms; using System.Data.OleDb; using System.Data.SqlClient;
namespace communication {
public partial class Form1 : Form {
public string user_name; private string password; public string user_style;
public SqlConnection MyConnection; public SqlDataReader Reader;
11
public Form1() {
InitializeComponent(); }
//连接数据库函数
public void db_connect() {
String Connect = \"server=(local);uid=sa;pwd=;database=communication\"; MyConnection = new SqlConnection(Connect); MyConnection.Open(); }
//数据库行为操作函数
public void db_operate(string sqlstring) {
SqlCommand MyCommand = new SqlCommand(sqlstring, MyConnection); Reader = MyCommand.ExecuteReader(); }
private void button1_Click(object sender, EventArgs e) {
user_name = textBox1.Text.ToString(); password = textBox2.Text.ToString();
//连接数据库返回用户名对应的密码 db_connect();
string SqlString = \"select user_pass,user_style from com_user where user_name=\"+user_name;
db_operate(SqlString);
while(Reader.Read()) {
if (Reader[\"user_pass\"].ToString() == password) {
user_style = Reader[\"user_style\"].ToString(); Form f2 = new Form2(this); this.Hide(); f2.ShowDialog(); this.Close(); } else {
Console.WriteLine(\"密码错误!\");
12
} }
MyConnection.Close(); } } }
using System;
using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System.Windows.Forms; using System.Data.OleDb; using System.Data.SqlClient;
namespace communication {
public partial class Form2 : Form {
private Form1 formParent = new Form1(); public string us_style; public string us_name; string query_style;
public SqlConnection MyConnection; public SqlDataReader Reader;
public Form2() {
InitializeComponent(); }
//构造函数用于接受父窗体对象以获取user_style的值 public Form2(Form1 form) {
InitializeComponent(); this.formParent = form; }
private void Form2_Load(object sender, EventArgs e) {
us_name=formParent.user_name; us_style = formParent.user_style;
13
switch(int.Parse(us_style)) {
case 1: label6.Text=us_name;label7.Text = \"管理员\"; break;
case 2: label6.Text=us_name;label7.Text = \"校内人员\"; break;
case 3: label6.Text = us_name; label7.Text = \"校外人员\"; break; }
formParent.db_connect(); }
private void button1_Click(object sender, EventArgs e) {
query_style = comboBox1.Text.ToString(); switch(query_style) {
case \"成员信息\":formParent.db_operate(\"select *from com_user\"); while (Reader.Read()) {
//将信息显示到richTextBox1 } break;
case \"校内信息\":formParent.db_operate(\"select *from com_campus_information\"); while (Reader.Read()) {
//将信息显示到richTextBox1 } break;
case \"部门信息\":formParent.db_operate(\"select *from com_department\"); while (Reader.Read()) {
//将信息显示到richTextBox1 } break;
case \"职工信息\":formParent.db_operate(\"select *from com_workers\"); while (Reader.Read()) {
//将信息显示到richTextBox1 } break; } }
14
} }
第六章 设计体会
经过一个星期的课程设计,收获颇多。通过这一次的课程设计,进一步加强了我动手,思考和解决问题的能力。不但对数据库这门课程有了更深的了解也体会到了数据库在计算机领域的重要性。
在设计过程中也因为对c# 语言的不熟悉,耗去了大半的时间,之后通过看书学习,对SQL以及c# 都重新有了更深的了解,不但掌握了SQL与c# 的链接,还掌握了一些控件的使用方法,真正达到了学与用的结合,对自己今后参与开发数据库系统奠定了很坚实的基础。
在实验过程中,从需求分析开始,对数据库设计理念及思想上有更高的认识,到概念设计和逻辑设计,E-R图的表示,懂得了不少有关数据库开发过程中的知识,并掌握了SQL语的插入,删除,修改,查询等语句,增强了自己在数据库中应用SQL语言的灵活性。
15
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- igat.cn 版权所有 赣ICP备2024042791号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务