数据库课程设计报告书

数据库课程设计报告书

课程设计报告书

单位房产管理系统

班 级: 方1005-2 学 号: 20105869 姓 名: 许晓飞 指导教师: 郭建方

石家庄铁道大学四方学院 20xx年6月23日

一 设计思想

首先,在SQL Server Management Studio中建立程序运行所需的几张表;其次,利用Microsoft Visual Studio 对程序中的各个功能界面进行设计,需要对数据库和Visual Studio进行连接,程序中的数据才能录入数据库,及实现对数据的添加删除和修改。在Visual Studio中利用C#语言对相应的按钮或组件进行设置和修改以实现其相应的功能。

二 系统完成功能及框图

(1) 系统模块:完成数据库维护、系统关闭功能

(2) 物业费用模块:对物价费用信息进行维护,包括新增、修改和删除费用信息。

(3) 房屋资源模块:对房屋资源进行添加、列表显示、查询

(4) 职工信息模块:对职工进行添加、列表显示、查询以及相应部门、职务进行维护

(5) 帮助模块:对用户使用本系统提供在线帮助

概念模型(E-R图):

(1)职工

数据库课程设计报告书

(2)物价标准

数据库课程设计报告书

(3)整体E-R图

数据库课程设计报告书

三 核心算法及说明

1.用户登录

private void button1_Click(object sender, EventArgs e)

{

SqlConnection coon = new SqlConnection();

coon.ConnectionString = "Data

Catalog=单位房产管理系统;Integrated Security=True"; Source=PC\\SQLEXPRESS;Initial

coon.Open();

SqlCommand sqltext = new SqlCommand("select * from 用户 where 用户名=@用户名 and 密码=@密码", coon);

sqltext.Parameters.Add("@用户名", SqlDbType.VarChar, 50); sqltext.Parameters.Add("@密码", SqlDbType.VarChar, 50);

sqltext.Parameters["@用户名"].Value = textBox1.Text;

sqltext.Parameters["@密码"].Value = textBox2.Text;

SqlDataReader thisReader = sqltext.ExecuteReader();

if (thisReader.Read())

{

MessageBox.Show("通过验证,欢迎进入系统!);

主界面 window2 = new 主界面();

window2.ShowDialog();

}

else

{

MessageBox.Show("用户名或密码错误系统将退出!);

this.Close();

}

coon.Close();

}

private void button2_Click(object sender, EventArgs e)

{

this.Close();

}

2.主界面

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;

namespace 单位住房管理系统最终

{

public partial class 主界面: Form

{

public 主界面()

{

InitializeComponent();

}

private void 职工信息添加ToolStripMenuItem_Click(object sender, EventArgs e) {

职工信息添加 window3 = new 职工信息添加();

window3.ShowDialog();

}

private void 职工信息修改ToolStripMenuItem_Click(object sender, EventArgs e) {

职工信息修改 window4 = new 职工信息修改();

window4.ShowDialog();

}

private void 职工信息删除ToolStripMenuItem_Click(object sender, EventArgs e) {

职工信息删除 window5 = new 职工信息删除();

window5.ShowDialog();

}

private void 职工信息查询ToolStripMenuItem_Click(object sender, EventArgs e) {

职工信息查询 window6 = new 职工信息查询();

window6.ShowDialog();

}

private void 职工信息显示ToolStripMenuItem_Click(object sender, EventArgs e) {

职工信息列表显示 window7 = new 职工信息列表显示();

window7.ShowDialog();

}

private void 房屋资源添加ToolStripMenuItem_Click(object sender, EventArgs e) {

房屋信息添加 window8 = new 房屋信息添加();

window8.ShowDialog();

}

private void 房屋资源查找¨ToolStripMenuItem_Click(object sender, EventArgs e) {

房屋资源查询 window9 = new 房屋资源查询();

window9.ShowDialog();

}

private void 房屋资源显示ToolStripMenuItem_Click(object sender, EventArgs e) {

房屋资源列表显示 window10 = new 房屋资源列表显示();

window10.ShowDialog();

}

private void 物业费用添加¨ToolStripMenuItem_Click(object sender, EventArgs e) {

物业用添加 window11 = new 物业费用添加();

window11.ShowDialog();

}

private void 物业费用单价修改ToolStripMenuItem_Click(object sender, EventArgs e)

{

物业单价修改 window12 = new 物业单价修改();

window12.ShowDialog();

}

private void 物业费用单价添加ToolStripMenuItem_Click_1(object sender, EventArgs e)

{

费用单价添加¨ window13 = new 费用单价添加();

window13.ShowDialog();

}

private void 物业费用查询ToolStripMenuItem_Click(object sender, EventArgs e) {

物业费用查询window14 = new 物业费用查询();

window14.ShowDialog();

}

private void 物业费用显示ToolStripMenuItem_Click(object sender, EventArgs e) {

费用列表显示window15 = new 费用列表显示();

window15.ShowDialog();

}

private void 在线帮助ToolStripMenuItem_Click(object sender, EventArgs e) {

MessageBox.Show("如有问题请与作者联系QQ:565128266");

}

private void 主界面_Load(object sender, EventArgs e)

{

}

}

}

3.学生信息删除

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection();

conn.ConnectionString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=单位住房管理系统;Integrated Security=True";

conn.Open();

string sqldelete = "delete from 职工 where 编号='" + comboBox1.Text.Trim() + "'";

SqlCommand sqld = new SqlCommand(sqldelete, conn);

sqld.ExecuteNonQuery();

string sqlselect = "select * from 职工";

SqlDataAdapter sd = new SqlDataAdapter(sqlselect, conn);

DataSet ds = new DataSet();

sd.Fill(ds, 职工");

dataGridView1.DataSource = ds.Tables["职??工?è"];

MessageBox.Show("删除成功!");

conn.Close();

}

4. 职工信息添加

private void button1_Click(object sender, EventArgs e)

{

SqlConnection sqlconn = new SqlConnection();

sqlconn.ConnectionString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=单位住房管理系统;Integrated Security=True";

sqlconn.Open();

SqlCommand sqlinsert = new SqlCommand("insert into 职工?编号,姓名,性别,参加工作时间,行政职务,专业技术职务,评上最高行政职务时间,评上最高专业技术职务时间,双职工姓名,现居住房号,档案号,房产证号,所在部门编号,是否为户主)values(@职工?@编号,@姓名,@性别,@参加工作时间,@行政职务,@专业技术职务,@评上最高行政职务时间,@评上最高专业技术职务时间,@双职工姓名,@现居住房号,@档案号,@房产证号,@所在部门编号,@是否为户主", sqlconn);

sqlinsert.Parameters.Add("@编号", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@姓名", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@性别", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@参加工作时间", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@行政职务", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@专业技术职务", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@评上最高行政职务时间", SqlDbType.VarChar,

50);

sqlinsert.Parameters.Add("@评上最高专业技术职务时间",

SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@双职工姓名", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@现居住房号", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@档案号", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@房产证号", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@所在部门编号", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@是否为户主", SqlDbType.VarChar, 50);

sqlinsert.Parameters["@编号"].Value = textBox1.Text;

sqlinsert.Parameters["@姓名"].Value = textBox2.Text;

sqlinsert.Parameters["@性别"].Value = textBox3.Text;

sqlinsert.Parameters["@参加工作时间"].Value = textBox4.Text;

sqlinsert.Parameters["@行政职务"].Value = textBox6.Text;

sqlinsert.Parameters["@专业技术职务"].Value = textBox7.Text;

sqlinsert.Parameters["@评上最高行政职务时间"].Value = textBox5.Text;

sqlinsert.Parameters["@评上最高专业技术职务时间"].Value = textBox8.Text; sqlinsert.Parameters["@双职工姓名"].Value = textBox13.Text;

sqlinsert.Parameters["@现居住房号"].Value = textBox9.Text;

sqlinsert.Parameters["@档案号"].Value = textBox10.Text;

sqlinsert.Parameters["@房产证号"].Value = textBox12.Text;

sqlinsert.Parameters["@所在部门编号"].Value = textBox14.Text;

sqlinsert.Parameters["@是否为户主"].Value = textBox11.Text;

sqlinsert.ExecuteNonQuery();

MessageBox.Show("添加成功!");

sqlconn.Close();

}

5.职工信息修改

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection();

conn.ConnectionString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=单位住房管理系统;Integrated Security=True";

conn.Open();

SqlCommand sqlupdate = new SqlCommand("update 职工 set 姓名?=@姓名,行政职务=@行政职务 where 编号=@编号", conn);

sqlupdate.Parameters.Add("@编号", SqlDbType.VarChar, 50);

sqlupdate.Parameters.Add("@姓名", SqlDbType.VarChar, 50);

sqlupdate.Parameters.Add("@行政职务", SqlDbType.VarChar, 50); sqlupdate.Parameters["@编号"].Value = comboBox1.Text.Trim();

sqlupdate.Parameters["@姓名"].Value = textBox1.Text.Trim();

sqlupdate.Parameters["@行政职务"].Value = textBox2.Text.Trim(); sqlupdate.ExecuteNonQuery();

string sqlselect1 = "select * from 职工";

SqlDataAdapter sd1 = new SqlDataAdapter(sqlselect1, conn);

DataSet ds1 = new DataSet();

sd1.Fill(ds1, "职工");

dataGridView1.DataSource = ds1.Tables["职工"];

MessageBox.Show("修改成功!");

conn.Close();

}

6.职工信息查询

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection();

conn.ConnectionString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=单位住房管理系统;Integrated Security=True";

conn.Open();

string sqlselect = "select * from 职工?è where 编号='" + comboBox1.Text + "'";

SqlDataAdapter sd = new SqlDataAdapter(sqlselect, conn);

DataSet ds = new DataSet();

sd.Fill(ds, "职工");

dataGridView1.DataSource = ds.Tables["职工"];

conn.Close();

}

四 界面设计

数据库课程设计报告书

登录界面

数据库课程设计报告书

主界面

数据库课程设计报告书

职工信息添加界面

数据库课程设计报告书

职工信息修改界面

数据库课程设计报告书

职工信息查询界面

数据库课程设计报告书

职工信息删除界面

五 结论

通过这次数据库的课程设计,我对数据库这一学科又有了更深刻的认识。以前一直以为这是一个以理论知识为主的学科,可是通过这次课程设计才知道其实 数据库这一学科涉及的方面真的很广,它是各种计算机语言的沟通桥梁,可以将它们有机的结合在一起。这次我设计的是单位房产信息管理系统,通过这个系统可以很好的,有条不紊的将房产信息管理妥善。不论对于房产还是房主,查找房产信息便可以变的很便利。对于大的单位和房屋中介公司,都可以很好的应用。现在房地产方面更是飞速发展,人们生活水平变高,从而每家拥有的房子数量也变多了,因此,房产信息管理这一块儿,便变得很重要了。对于它的发展前景更是不容小觑。房产信息管理系统可以使房地产商或者中介厂商可以很好的掌握房主信息及房屋信息,而房主在有必要时更可以对自己的房子情况有所了解,更安全更便捷。在此次课程设计中,我遇到的困难真的很多,很大。因为之前对于数据库这一学科只了解理论上的知识,操作起来很不顺利。后来查了很多资料,并且请教指导老师,在老师和身边同学的帮助下才一点一点上手的。有时小到一个代码的错误,我都需要重新检查重新来过。过程虽然辛苦但是结果是好的,最后成功的时候真的很开心。再次很感谢老师和同学的帮助。

六 参考资料

王珊 萨师煊, 《数据库系统概论(第四版)》,高等教育出版社

康博 , 《C# 高级编程(第1版)》

/21aspnet/archive/2007/05/16/1612388

附录

1.用户登录

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.SqlClient;

namespace 单位住房管理系统最终

{

public partial class 登录 : Form

{

public 登录()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection coon = new SqlConnection();

coon.ConnectionString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=单位住房管理系统;Integrated Security=True";

coon.Open();

SqlCommand sqltext = new SqlCommand("select * from 用户 where 用户名=@用户名 and 密码=@密码, coon);

sqltext.Parameters.Add("@用户名", SqlDbType.VarChar, 50);

sqltext.Parameters.Add("@密码", SqlDbType.VarChar, 50);

sqltext.Parameters["@用户名"].Value = textBox1.Text;

sqltext.Parameters["@密码"].Value = textBox2.Text;

SqlDataReader thisReader = sqltext.ExecuteReader();

if (thisReader.Read())

{

MessageBox.Show("通过验证,欢迎进入系统!");

主界面 window2 = new 主界面();

window2.ShowDialog();

}

else

{

MessageBox.Show("用户名或密码错误,系统将退出!");

this.Close();

}

coon.Close();

}

private void button2_Click(object sender, EventArgs e)

{

this.Close();

}

}

}

2.主界面

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;

namespace 单位住房管理系统最终

{

public partial class 主界面: Form

{

public 主界面()

{

InitializeComponent();

}

private void 职工信息添加ToolStripMenuItem_Click(object sender, EventArgs e) {

职工信息添加 window3 = new 职工信息添加();

window3.ShowDialog();

}

private void 职工信息修改ToolStripMenuItem_Click(object sender, EventArgs e) {

职工信息修改 window4 = new 职工信息修改();

window4.ShowDialog();

}

private void 职工信息删除ToolStripMenuItem_Click(object sender, EventArgs e) {

职工信息删除 window5 = new 职工信息删除();

window5.ShowDialog();

}

private void 职工信息查询ToolStripMenuItem_Click(object sender, EventArgs e) {

职工信息查询 window6 = new 职工信息查询();

window6.ShowDialog();

}

private void 职工信息显示ToolStripMenuItem_Click(object sender, EventArgs e) {

职工信息列表显示 window7 = new 职工信息列表显示();

window7.ShowDialog();

}

private void 房屋资源添加ToolStripMenuItem_Click(object sender, EventArgs e) {

房屋信息添加 window8 = new 房屋信息添加();

window8.ShowDialog();

}

private void 房屋资源查找¨ToolStripMenuItem_Click(object sender, EventArgs e) {

房屋资源查询 window9 = new 房屋资源查询();

window9.ShowDialog();

}

private void 房屋资源显示ToolStripMenuItem_Click(object sender, EventArgs e) {

房屋资源列表显示 window10 = new 房屋资源列表显示();

window10.ShowDialog();

}

private void 物业费用添加¨ToolStripMenuItem_Click(object sender, EventArgs e) {

物业用添加 window11 = new 物业费用添加();

window11.ShowDialog();

}

private void 物业费用单价修改ToolStripMenuItem_Click(object sender, EventArgs e)

{

物业单价修改 window12 = new 物业单价修改();

window12.ShowDialog();

}

private void 物业费用单价添加ToolStripMenuItem_Click_1(object sender,

EventArgs e)

{

费用单价添加¨ window13 = new 费用单价添加();

window13.ShowDialog();

}

private void 物业费用查询ToolStripMenuItem_Click(object sender, EventArgs e) {

物业费用查询window14 = new 物业费用查询();

window14.ShowDialog();

}

private void 物业费用显示ToolStripMenuItem_Click(object sender, EventArgs e) {

费用列表显示window15 = new 费用列表显示();

window15.ShowDialog();

}

private void 在线帮助ToolStripMenuItem_Click(object sender, EventArgs e) {

MessageBox.Show("如有问题请与作者联系QQ:565128266");

}

private void 主界面_Load(object sender, EventArgs e)

{

}

}

}

3.职工信息添加

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.SqlClient;

namespace 单位住房管理系统最终

{

public partial class 职工信息添加: Form

{

public 职工信息添加()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection sqlconn = new SqlConnection();

sqlconn.ConnectionString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=单位住房管理系统;Integrated Security=True";

sqlconn.Open();

SqlCommand sqlinsert = new SqlCommand("insert into 职工?编号,姓名,性别,参加工作时间,行政职务,专业技术职务,评上最高行政职务时间,评上最高专业技术职务时间,双职工姓名,现居住房号,档案号,房产证号,所在部门编号,是否为户主)values(@职工?@编号,@姓名,@性别,@参加工作时间,@行政职务,@专业技术职务,@评上最高行政职务时间,@评上最高专业技术职务时间,@双职工姓名,@现居住房号,@档案号,@房产证号,@所在部门编号,@是否为户主", sqlconn);

sqlinsert.Parameters.Add("@编号", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@姓名", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@性别", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@参加工作时间", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@行政职务", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@专业技术职务", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@评上最高行政职务时间", SqlDbType.VarChar,

50);

sqlinsert.Parameters.Add("@评上最高专业技术职务时间",

SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@双职工姓名", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@现居住房号", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@档案号", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@房产证号", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@所在部门编号", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@是否为户主", SqlDbType.VarChar, 50); sqlinsert.Parameters["@编号"].Value = textBox1.Text;

sqlinsert.Parameters["@姓名"].Value = textBox2.Text;

sqlinsert.Parameters["@性别"].Value = textBox3.Text;

sqlinsert.Parameters["@参加工作时间"].Value = textBox4.Text;

sqlinsert.Parameters["@行政职务"].Value = textBox6.Text;

sqlinsert.Parameters["@专业技术职务"].Value = textBox7.Text;

sqlinsert.Parameters["@评上最高行政职务时间"].Value = textBox5.Text;

sqlinsert.Parameters["@评上最高专业技术职务时间"].Value = textBox8.Text; sqlinsert.Parameters["@双职工姓名"].Value = textBox13.Text;

sqlinsert.Parameters["@现居住房号"].Value = textBox9.Text;

sqlinsert.Parameters["@档案号"].Value = textBox10.Text;

sqlinsert.Parameters["@房产证号"].Value = textBox12.Text;

sqlinsert.Parameters["@所在部门编号"].Value = textBox14.Text;

sqlinsert.Parameters["@是否为户主"].Value = textBox11.Text;

sqlinsert.ExecuteNonQuery();

MessageBox.Show("添加成功!");

sqlconn.Close();

4.职工信息修改

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.SqlClient;

namespace 单位住房管理系统最终

{

public partial class 职工信息修改: Form

{

public 职工信息修改()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection();

conn.ConnectionString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=单位住房管理系统;Integrated Security=True";

conn.Open();

SqlCommand sqlupdate = new SqlCommand("update 职工 set 姓名?=@姓名,行政职务=@行政职务 where 编号=@编号", conn);

sqlupdate.Parameters.Add("@编号", SqlDbType.VarChar, 50);

sqlupdate.Parameters.Add("@姓名", SqlDbType.VarChar, 50);

sqlupdate.Parameters.Add("@行政职务", SqlDbType.VarChar, 50); sqlupdate.Parameters["@编号"].Value = comboBox1.Text.Trim();

sqlupdate.Parameters["@姓名"].Value = textBox1.Text.Trim();

sqlupdate.Parameters["@行政职务"].Value = textBox2.Text.Trim(); sqlupdate.ExecuteNonQuery();

string sqlselect1 = "select * from 职工";

SqlDataAdapter sd1 = new SqlDataAdapter(sqlselect1, conn);

DataSet ds1 = new DataSet();

sd1.Fill(ds1, "职工");

dataGridView1.DataSource = ds1.Tables["职工"];

MessageBox.Show("修改成功!");

conn.Close();

}

5.职工信息删除

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.SqlClient;

namespace 单位住房管理系统最终

{

public partial class 职工信息删除: Form

{

public 职工信息删除()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection();

conn.ConnectionString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=单位住房管理系统;Integrated Security=True";

conn.Open();

SqlCommand sqlupdate = new SqlCommand("update 职工 set 姓名?=@姓名,行政职务=@行政职务 where 编号=@编号", conn);

sqlupdate.Parameters.Add("@编号", SqlDbType.VarChar, 50);

sqlupdate.Parameters.Add("@姓名", SqlDbType.VarChar, 50);

sqlupdate.Parameters.Add("@行政职务", SqlDbType.VarChar, 50); sqlupdate.Parameters["@编号"].Value = comboBox1.Text.Trim();

sqlupdate.Parameters["@姓名"].Value = textBox1.Text.Trim();

sqlupdate.Parameters["@行政职务"].Value = textBox2.Text.Trim(); sqlupdate.ExecuteNonQuery();

string sqlselect1 = "select * from 职工";

SqlDataAdapter sd1 = new SqlDataAdapter(sqlselect1, conn);

DataSet ds1 = new DataSet();

sd1.Fill(ds1, "职工");

dataGridView1.DataSource = ds1.Tables["职工"];

MessageBox.Show("修改成功!");

conn.Close();

}

6.职工信息查询

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.SqlClient;

namespace 单位住房管理系统最终

{

public partial class 职工信息查询: Form

{

public 职工信息查询()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection();

conn.ConnectionString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=单位住房管理系统;Integrated Security=True";

conn.Open();

string sqlselect = "select * from 职工?è where 编号='" + comboBox1.Text + "'";

SqlDataAdapter sd = new SqlDataAdapter(sqlselect, conn);

DataSet ds = new DataSet();

sd.Fill(ds, "职工");

dataGridView1.DataSource = ds.Tables["职工"];

conn.Close();

}

7. 物业费用添加

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.SqlClient;

namespace 单位住房管理系统最终

{

public partial class 物业费用添加 : Form

{

public 物业费用添加()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection sqlconn = new SqlConnection();

sqlconn.ConnectionString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=单单位住房管理系统;Integrated Security=True";

sqlconn.Open();

SqlCommand sqlinsert = new SqlCommand("insert into 物业费用(编号,房号,水基数,水现在值,电基数,电现在值,燃气基数,燃气现在值,当前年份,当前月份)values(@编号,@房号,@水基数,@水现在值,@电基数,@电现在值,@燃气基数,@燃气现在值,@当前年份,@当前月份)", sqlconn);

sqlinsert.Parameters.Add("@编号", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@房号", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@水基数", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@水现值", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@电基数?", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@电现在值", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@燃气基数", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@燃气现在值", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@当前年份", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@当前月份", SqlDbType.VarChar, 50); sqlinsert.Parameters["@编?号"].Value = textBox1.Text;

sqlinsert.Parameters["@房号"].Value = textBox2.Text;

sqlinsert.Parameters["@水基数"].Value = textBox3.Text;

sqlinsert.Parameters["@水现在值"].Value = textBox4.Text;

sqlinsert.Parameters["@电基数"].Value = textBox5.Text;

sqlinsert.Parameters["@电现在值"].Value = textBox6.Text;

sqlinsert.Parameters["@燃气基数"].Value = textBox7.Text;

sqlinsert.Parameters["@燃气现在值"].Value = textBox8.Text;

sqlinsert.Parameters["@当前年份"].Value = textBox9.Text;

sqlinsert.Parameters["@当前月份"].Value = textBox10.Text;

sqlinsert.ExecuteNonQuery();

MessageBox.Show("添加成功!");

sqlconn.Close();

}

private void button2_Click(object sender, EventArgs e) {

textBox1.Text = "";

textBox2.Text = "";

textBox3.Text = "";

textBox4.Text = "";

textBox5.Text = "";

}

}

}

textBox6.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = ""; textBox10.Text = "";

8.物业费用查询

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.SqlClient;

namespace 单位住房管理系统最终

{

public partial class 物业查询? : Form

{

public 物业费用查询()

{

InitializeComponent();

}

private void Form14_Load(object sender, EventArgs e)

{

this.物业费用TableAdapter.Fill(this.单位住房管理系统DataSet12.物业费用); }

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection();

conn.ConnectionString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=单单位住房管理系统;Integrated Security=True";

conn.Open();

string sqlselect = "select * from 物业费用 where 编号='" + comboBox1.Text + "'";

SqlDataAdapter sd = new SqlDataAdapter(sqlselect, conn);

DataSet ds = new DataSet();

sd.Fill(ds, "物业费用");

dataGridView1.DataSource = ds.Tables["物业费用"];

conn.Close();

}

}

}

9.物业单价修改

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.SqlClient;

namespace 单位住房管理系统最终

{

public partial class 物业单价修改: Form

{

public 物业单价修改()

{

InitializeComponent();

}

private void Form12_Load(object sender, EventArgs e)

{

this.价格标准TableAdapter1.Fill(this.单位住房管理系统DataSet11.价格标准);

this.价格标准TableAdapter.Fill(this.单位住房管理系统DataSet10.价格标准);

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection();

conn.ConnectionString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=单位住房管理系统;Integrated Security=True";

conn.Open();

SqlCommand sqlupdate = new SqlCommand("update 价价格标准 set 水单价=@水单价,电单价=@电单价,燃气单价=@燃气单价 where 编号=@编号", conn); sqlupdate.Parameters.Add("@编号", SqlDbType.VarChar, 50);

sqlupdate.Parameters.Add("@水单价", SqlDbType.VarChar, 50);

sqlupdate.Parameters.Add("@电单价", SqlDbType.VarChar, 50);

sqlupdate.Parameters.Add("@燃气单价", SqlDbType.VarChar, 50); sqlupdate.Parameters["@编号].Value = comboBox1.Text.Trim();

sqlupdate.Parameters["@水单价].Value = textBox1.Text.Trim();

sqlupdate.Parameters["@电单价"].Value = textBox2.Text.Trim();

sqlupdate.Parameters["@燃气单价"].Value = textBox2.Text.Trim(); sqlupdate.ExecuteNonQuery();

string sqlselect1 = "select * from 价格标准";

SqlDataAdapter sd1 = new SqlDataAdapter(sqlselect1, conn);

DataSet ds1 = new DataSet();

sd1.Fill(ds1, "价格标准");

dataGridView1.DataSource = ds1.Tables["价格标准"];

MessageBox.Show("修改成功!");

conn.Close();

}

}

}

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.SqlClient;

namespace 单位住房管理系统最终

{

public partial class 费用单价添加 : Form

{

public 费用单价添加()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection sqlconn = new SqlConnection();

sqlconn.ConnectionString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=单位住房管理系统;Integrated Security=True";

sqlconn.Open();

SqlCommand sqlinsert = new SqlCommand("insert into 价格标准(编号,水单

价,电单价,燃气单价)values(@编号,@水单价,@电单价,@燃气单价)", sqlconn); sqlinsert.Parameters.Add("@编号", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@水单价", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@电单价", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@燃气单价", SqlDbType.VarChar, 50); sqlinsert.Parameters["@编号"].Value = textBox1.Text;

sqlinsert.Parameters["@水单价"].Value = textBox2.Text;

sqlinsert.Parameters["@电单价"].Value = textBox3.Text;

sqlinsert.Parameters["@燃气单价"].Value = textBox4.Text;

sqlinsert.ExecuteNonQuery();

MessageBox.Show("添加成功");

sqlconn.Close();

}

}

}

11.房屋资源查询

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.SqlClient;

namespace 单位住房管理系统最终

{

public partial class 房屋资源查询 : Form

{

public 房屋资源查询()

{

InitializeComponent();

}

private void Form9_Load(object sender, EventArgs e)

{

this.房产情况TableAdapter1.Fill(this.单位住房管理系统DataSet8.房产情况); this.房产情况TableAdapter.Fill(this.单位房产管理DataSet7.房产情况);

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection();

conn.ConnectionString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=单位住房管理系统;Integrated Security=True";

conn.Open();

string sqlselect = "select * from 房产情况 where 房产编号='" + comboBox1.Text + "'";

SqlDataAdapter sd = new SqlDataAdapter(sqlselect, conn);

DataSet ds = new DataSet();

sd.Fill(ds, "房产情况");

dataGridView1.DataSource = ds.Tables["房产情况"];

conn.Close();

}

}

}

12.房屋信息添加

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.SqlClient;

namespace 单位住房管理系统最终

{

public partial class 房屋信息添加 : Form

{

public 房屋信息添加()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection sqlconn = new SqlConnection();

sqlconn.ConnectionString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=

单位住房管理系统Integrated Security=True";

sqlconn.Open();

SqlCommand sqlinsert = new SqlCommand("insert into 房产情况(房产变化,房号使用面积,现居住人id,上一居住人id,最早居住人id,阳台面积)values(@房产变化,@房号使用面积,@现居住人id,@上一居住人id,@最早居住人id,@阳台面积)", sqlconn);

sqlinsert.Parameters.Add("@房产编号", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@房号", SqlDbType.VarChar, 50);

sqlinsert.Parameters.Add("@使用面积", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@现居住人id", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@上一居住人id", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@最早居住人id", SqlDbType.VarChar, 50); sqlinsert.Parameters.Add("@阳台面积", SqlDbType.VarChar, 50); sqlinsert.Parameters["@房产编号"].Value = textBox1.Text;

sqlinsert.Parameters["@房号"].Value = textBox2.Text;

sqlinsert.Parameters["@使用面积"].Value = textBox3.Text;

sqlinsert.Parameters["@现居住人id"].Value = textBox5.Text;

sqlinsert.Parameters["@上一居住人d"].Value = textBox6.Text;

sqlinsert.Parameters["@最早居住人id"].Value = textBox7.Text;

sqlinsert.Parameters["@阳台面积"].Value = textBox4.Text;

sqlinsert.ExecuteNonQuery();

MessageBox.Show("添加成功!");

sqlconn.Close();

}

private void button2_Click(object sender, EventArgs e)

{

textBox1.Text = "";

textBox2.Text = "";

textBox3.Text = "";

textBox4.Text = "";

textBox5.Text = "";

textBox6.Text = "";

textBox7.Text = "";

}

}

}

相关推荐