校园用房管理系统说明书.docx
《校园用房管理系统说明书.docx》由会员分享,可在线阅读,更多相关《校园用房管理系统说明书.docx(23页珍藏版)》请在冰豆网上搜索。
校园用房管理系统说明书
中北大学
数据库课程设计
说明书
学院、系:
软件学院
专业:
软件工程
学生姓名:
郭智
学号:
1021010943
设计题目:
校园用房管理系统
起迄日期:
2012年5月28日-2012年6月22日
指导教师:
薛海丽
2012年6月21日
1需求分析
(1)系统要求
学校房屋基本信息、职工住宅房屋的管理、职工租赁房屋的管理、学生宿舍的管理、学校教学楼的管理等学校房屋管理所涉及的基本功能
(2).系统功能分析
职工界面
可以修改、查询职工信息,查询、修改房屋情况,查询、修改职工住房信息,修改、查询教学楼管理信息等。
学生界面
可以修改、查询学生信息,查询、修改宿舍情况,查询、修改学生住房信息,修改、查询教学楼管理信息等。
查询界面
可以查询职工、学生房屋信息;
可以查询教学楼管理情况;
删除界面
可以删除职工、学生房屋信息;
可以删除教学楼管理情况;
添加界面
可以添加职工、学生房屋信息;
可以添加教学楼管理情况;
更新界面
可以更新职工、学生房屋信息;
可以更新教学楼管理情况;
(3).数据流图
(4)数据字典
名字:
房屋信息表
描述:
描述房屋信息的记录表
定义:
房屋信息=住房编号+住房地址+住户管理
(5)设计平台
Windows平台下,使用面向对象程序设计语言,结合SQLServer进行开发。
2:
概念结构设计与逻辑结构设计
(1)程序分析
用C#语言编写一个基于数据库的校园用房管理系统,实现一个基于数据库校园用房管理系统,用户输入一个学号或工号后能在数据库中检索出该用户的信息,并显示出来。
要求使用SQLSERVER做为后台存储数据库,使用图形界面设计的方法。
而管理员可以添加,修改数据库中的信息。
(2)子系统结构
图1.1子系统结构
(3)表示校园用房管理系统中的实体和属性
教职工(工号,姓名,住址)
学生(学号,姓名,性别,所在系,所在宿舍)
教学楼(教学楼号,地址)
学生宿舍楼(楼号,地址,学生系别)
教师宿舍楼(宿舍楼号,种类,地址)
(4)局部E-R图设计
数据库需要表述的信息有以下几种:
(1)学生宿舍楼信息
1-1学生宿舍楼信息图
(2)教师宿舍信息
1-3教师宿舍楼信息图
(3)教职工信息
1-4教职工信息图
(4)教学楼信息
1-5教学楼信息图
(5)教职工住宿教师宿舍
(5)系统总体E-R图设计
3:
核心代码
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceWindowsApplication1
{
publicpartialclassForm1:
Form
{
publicForm1()
{
InitializeComponent();
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
Form2f2=newForm2();
f2.ShowDialog();
}
privatevoidbutton2_Click(objectsender,EventArgse)
{
Form3f3=newForm3();
f3.ShowDialog();
}
privatevoidbutton3_Click(objectsender,EventArgse)
{
Form4f4=newForm4();
f4.ShowDialog();
}
privatevoidbutton4_Click(objectsender,EventArgse)
{
Form7f7=newForm7();
f7.ShowDialog();
}
privatevoidbutton5_Click(objectsender,EventArgse)
{
AboutBox1a1=newAboutBox1();
a1.ShowDialog();
}
privatevoidbutton6_Click(objectsender,EventArgse)
{
this.Close();
}
privatevoidForm1_Load(objectsender,EventArgse)
{
}
}
}
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
namespaceWindowsApplication1
{
publicpartialclassForm3:
Form
{
SqlConnectioncon;
SqlCommandcmd;
publicForm3()
{
InitializeComponent();
}
privatevoidbutton6_Click(objectsender,EventArgse)
{
this.Close();
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
stringhno=textBox1.Text;
stringsql="selectadds,tno1,tnofromrentwhererno='"+hno+"';";
try
{
if(con.State==ConnectionState.Closed)
{
con.Open();
}
SqlDataAdapteradp1=newSqlDataAdapter(sql,con);
DataSetds=newDataSet();
adp1.Fill(ds);
textBox2.Text=ds.Tables[0].Rows[0][0].ToString();
textBox3.Text=ds.Tables[0].Rows[0][1].ToString();
textBox6.Text=ds.Tables[0].Rows[0][2].ToString();
}
catch(Exceptionex)
{
MessageBox.Show("查询失败!
原因是;"+ex.Message.ToString());
}
stringtno=textBox3.Text;
stringtname;
stringphone;
sql="selecttname,phonefrompersonwheretno='"+tno+"';";
try
{
if(con.State==ConnectionState.Closed)
{
con.Open();
}
SqlDataAdapteradp1=newSqlDataAdapter(sql,con);
DataSetds=newDataSet();
adp1.Fill(ds);
tname=ds.Tables[0].Rows[0][0].ToString();
phone=ds.Tables[0].Rows[0][1].ToString();
textBox4.Text=tname;
textBox5.Text=phone;
}
catch(Exceptionex)
{
MessageBox.Show("查询失败!
原因是;"+ex.Message.ToString());
}
tno=textBox6.Text;
sql="selecttname,phonefrompersonwheretno='"+tno+"';";
try
{
if(con.State==ConnectionState.Closed)
{
con.Open();
}
SqlDataAdapteradp1=newSqlDataAdapter(sql,con);
DataSetds=newDataSet();
adp1.Fill(ds);
tname=ds.Tables[0].Rows[0][0].ToString();
phone=ds.Tables[0].Rows[0][1].ToString();
textBox7.Text=tname;
textBox8.Text=phone;
}
catch(Exceptionex)
{
MessageBox.Show("查询失败!
原因是;"+ex.Message.ToString());
}
}
privatevoidbutton2_Click(objectsender,EventArgse)
{
stringhno=textBox1.Text;
stringadds=textBox2.Text;
stringtno1=textBox3.Text;
stringtno=textBox6.Text;
cmd.CommandText="InsertIntorent(rno,adds,tno1,tno)Values('"+hno+"','"+adds+"','"+tno1+"','"+tno+"');";
try
{
if(con.State==ConnectionState.Closed)
{
con.Open();
}
cmd.ExecuteNonQuery();
MessageBox.Show("房屋编号:
"+hno+"的信息添加成功!
");
}
catch(Exceptionex)
{
MessageBox.Show("添加失败!
原因是;"+ex.Message.ToString());
}
}
privatevoidbutton3_Click(objectsender,EventArgse)
{
stringhno=textBox1.Text;
cmd.CommandText="Deletefromrentwhererno='"+hno+"';";
try
{
if(con.State==ConnectionState.Closed)
{
con.Open();
}
cmd.ExecuteNonQuery();
MessageBox.Show("住房编号:
"+hno+"的信息删除成功!
");
}
catch(Exceptionex)
{
MessageBox.Show("删除失败!
原因是;"+ex.Message.ToString());
}
}
privatevoidbutton4_Click(objectsender,EventArgse)
{
stringhno=textBox1.Text;
stringadds=textBox2.Text;
stringtno1=textBox3.Text;
stringtno=textBox6.Text;
cmd.CommandText="UpdaterentSetadds='"+adds+"',tno1='"+tno1+"',tno='"+tno+"'Whererno='"+hno+"'";
try
{
if(con.State==ConnectionState.Closed)
{
con.Open();
}
cmd.ExecuteNonQuery();
MessageBox.Show("住房ID"+tno+"的信息修改成功!
");
}
catch(Exceptionex)
{
MessageBox.Show("修改失败!
原因是;"+ex.Message.ToString());
}
}
privatevoidbutton5_Click(objectsender,EventArgse)
{
Form6f6=newForm6();
f6.ShowDialog();
}
privatevoidForm3_Load(objectsender,EventArgse)
{
con=newSqlConnection("server=(local);database=hm;uid=sa;pwd=");
cmd=newSqlCommand("",con);
}
}
}
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
namespaceWindowsApplication1
{
publicpartialclassForm6:
Form
{
SqlConnectioncon;
SqlCommandcmd;
publicForm6()
{
InitializeComponent();
}
privatevoidbutton6_Click(objectsender,EventArgse)
{
this.Close();
}
privatevoidbutton4_Click(objectsender,EventArgse)
{
stringtno=textBox1.Text;
stringtname=textBox2.Text;
stringphone=textBox3.Text;
cmd.CommandText="UpdatepersonSettname='"+tname+"',phone='"+phone+"'Wheretno='"+tno+"'";
try
{
if(con.State==ConnectionState.Closed)
{
con.Open();
}
cmd.ExecuteNonQuery();
MessageBox.Show("用户ID"+tno+"的信息修改成功!
");
}
catch(Exceptionex)
{
MessageBox.Show("修改失败!
原因是;"+ex.Message.ToString());
}
}
privatevoidForm6_Load(objectsender,EventArgse)
{
con=newSqlConnection("server=(local);database=hm;uid=sa;pwd=");
cmd=newSqlCommand("",con);
}
privatevoidbutton2_Click(objectsender,EventArgse)
{
stringtno=textBox1.Text;
stringtname=textBox2.Text;
stringphone=textBox3.Text;
cmd.CommandText="InsertIntoperson(tno,tname,phone)Values('"+tno+"','"+tname+"','"+phone+"');";
try
{
if(con.State==ConnectionState.Closed)
{
con.Open();
}
cmd.ExecuteNonQuery();
MessageBox.Show("用户ID"+tno+"的信息添加成功!
");
}
catch(Exceptionex)
{
MessageBox.Show("添加失败!
原因是;"+ex.Message.ToString());
}
}
privatevoidbutton3_Click(objectsender,EventArgse)
{
stringtno=textBox1.Text;
cmd.CommandText="Deletefrompersonwheretno='"+tno+"';";
try
{
if(con.State==ConnectionState.Closed)
{
con.Open();
}
cmd.ExecuteNonQuery();
MessageBox.Show("用户ID"+tno+"的信息删除成功!
");
}
catch(Exceptionex)
{
MessageBox.Show("删除失败!
原因是;"+ex.Message.ToString());
}
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
stringtno=textBox1.Text;
stringtname;
stringphone;
stringsql="selecttname,phonefrompersonwheretno='"+tno+"';";
try
{
if(con.State==ConnectionState.Closed)
{
con.Open();
}
SqlDataAdapteradp1=newSqlDataAdapter(sql,con);
DataSetds=newDataSet();
adp1.Fill(ds);
tname=ds.Tables[0].Rows[0][0].ToString();
phone=ds.Tables[0].Rows[0][1].ToString();
textBox2.Text=tname;
textBox3.Text=phone;
}
catch(Exceptionex)
{
MessageBox.Show("查找失败!
原因是;"+ex.Message.ToString());
}
}
privatevoidlabel1_Click(objectsender,EventArgse)
{
}
}
}
4:
心得体会
作为这次数据库课程设计的小组长,我认识到了合理性分工的重要性,在我们这次设计中,中间经历了很多错误,但是我们分工明确,有条不紊的逐个将其击破,如果没有这次明确的分工,在遇到这些问题的时候,我们务必会变得一团乱麻,无从下手。
同时这次设计也让我认识到了学好专业知识是多么的重要,只有打下扎实的基础,才能了冷静的对待所有疑难的问题。