宾馆住宿管理系统

目录

一 需求分析 . ....................................................................................................................................................... 2 二 数据库概念结构设计 . ................................................................................................................................... 2

2.1功能模块分析 . ....................................................................................................................................... 2 2.2.系统模块设计 . .................................................................................................................................... 2 三 数据库设计 . ................................................................................................................................................... 3

3.1数据库概念结构设计 ............................................................................................................................ 3 3.2数据库逻辑结构设计 ............................................................................................................................ 5 四 宾馆住宿系统的实现 . ................................................................................................................................... 6

4.1 数据库的实现 . ...................................................................................................................................... 6 五 住宿管理系统的实现 . ................................................................................................................................. 10

5.1 登录窗口模块的创建与实现 ............................................................................................................. 10 5.2系统管理模块的创建与实现 ..............................................................................................................11 5.3客户信息管理模块的创建于实现 ..................................................................................................... 13 5.4 预定记录管理模块的创建于实现 ..................................................................................................... 16 5.5入住信息管理模块的创建于实现 ...................................................................................................... 19 5.6 客户结算管理模块的创建与实现 ..................................................................................................... 22 六 总结 . ............................................................................................................................................................. 24 七 参考文献 . ..................................................................................................................................................... 24

一 需求分析

随着外出人流因为生活,商业等方面的增多,宾馆的发展也日益的迅猛,由于顾客量的增多,客户登记时间的广泛,宾馆收益的日益增多,仅仅依靠手写的老式输入记账法,是无法满足宾馆的需求的,同时这也是浪费人力和时间的。开发这个数据库,目的就在于能够更好的对客房的预订情况,空余情况,顾客信息,顾客住宿时间和所用费用,客房房态等进行精确的查询,以便更好的完善和更新宾馆信息系统。 数据库的概念结构设计

二 数据库概念结构设计

2.1功能模块分析

根据宾馆的具体情况,系统主要功能如下:

1. 客房类型管理:提供有关客房类型状况的规范,如标准间,单人间的价格,设施的配置等信息。

2. 客房信息管理:管理各个房间的具体信息,如类型,位置等。 3. 客户信息管理:入住宾馆的客人具体信息的录入,保存等。 4. 查询功能:包括客户信息查询,客房信息查询,住宿信息查询,等。 5. 入住管理系统:登记入住信息,分配房间等。

6. 预订管理功能:登记预订客户,客房的信息以及浏览查询等。 7. 结算功能:客户退房收款等。 8. 系统管理:用户管理等。 2.2.系统模块设计

根据以上对系统的功能需求的分析,将系统的功能划分为三大模块: 1. 数据管理:包括客房类型管理,客房信息管理,客户信息管理。 2. 前台操作:包括各种信息的查询,入住和预订登记和结算的管理。 3. 系统管理:用户注册,修改密码,用户信息管理。 系统功能模块图如下:

功能模块结构图

三 数据库设计

3.1数据库概念结构设计

通过以上对数据库的设计,可得到几个数据库实体,其E-R 图如下 1. 客户实体图

2. 客房实体图

3. 客房类型实体图

4. 系统综合E-R 图

3.2数据库逻辑结构设计

客房类型(类型 面积 价格 额定床位 额定人数 是否有电视 是否有电话 是否有空调 是否有卫生间)

客房信息(房间号 类型 楼层) 客户信息(客户号 姓名 性别 籍贯)

入住记录(客户号 房间号 入住日期 结算日期 备注) 预定记录(客户号 房间号 预定日期 预定于之日期 预定天数) 系统用户( 用户名 密码)

四 宾馆住宿系统的实现

4.1 数据库的实现

create database 宾馆住宿管理系统 on primary (

name=宾馆住宿管理系统_data,

filename='F:\sql\宾馆住宿管理系统_data.mdf', size=5,

maxsize=unlimited, filegrowth=10% )

log on (

name=宾馆住宿管理系统_log,

filename='F:\sql\宾馆住宿管理系统_log.ldf', size=5,

maxsize=unlimited, filegrowth=10% )

create table 客房类型 (

类型 char(12) primary key, 面积 int not null, 价格 money not null, 额定床位 int , 额定人数 int,

是否有电视 char(2) default '有', 是否有电话 char(2) default '有', 是否有空调 char(2) default '有', 是否有卫生间 char(2) default '有' )

create table 客房信息 (

房间号 int primary key, 类型 char(12) not null, 楼层 int not null

create table 客户信息 (

客户号 int primary key, 姓名 varchar(10) not null, 性别 char(2) default '女', 籍贯 varchar(20) not null )

create table 入住记录 (

客户号 int foreign key references 客户信息(客户号), 房间号 int foreign key references 客房信息(房间号), 入住日期 datetime not null, 结算日期 datetime not null, 备注 varchar(30) )

create table 预定记录 (

客户号 int foreign key references 客户信息(客户号), 房间号 int foreign key references 客房信息(房间号), 预定日期 datetime not null, 预定入住日期 datetime not null, 预定天数 tinyint not null )

create table 系统用户 (

用户名 varchar(10) primary key, 密码 varchar(10) not null )

create view 客房详细信息 as

select 客房信息. 房间号, 客房信息. 类型, 客房类型. 价格, 客房类型. 额定床位, 客房类型. 额定人数, 客房信息. 楼层,

客房类型. 是否有电视, 客房类型. 是否有电话, 客房类型. 是否有空调, 客房类型. 是否有卫生间 from 客房类型 left join 客房信息 on 客房类型. 类型=客房信息. 类型

create view 在住记录1 as

select 入住记录. 客户号, 客户信息. 姓名, 入住记录. 房间号, 客户信息. 性别, 入住记录. 入住日期 from 客户信息 left join 入住记录 on 客户信息. 客户号=入住记录. 客户号 where 入住记录. 备注='未退房'

create view 历史记录1

select 客户信息. 客户号, 客户信息. 姓名, 入住记录. 房间号, 入住记录. 入住日期, 入住记录. 结算日期, 入住天数=day(结算日期) -day(入住日期), 入住记录. 备注

from 客户信息 left join 入住记录 on 客户信息. 客户号=入住记录. 客户号 where 入住记录. 备注='已退房'

create view 在住记录2 as

select 入住记录. 客户号, 客户信息. 姓名, 入住记录. 房间号, 客户信息. 性别, 入住记录. 入住日期, 客房信息. 类型

from 入住记录, 客户信息, 客房信息

where 入住记录. 客户号=客户信息. 客户号 and 入住记录. 房间号=客房信息. 房间号 and 入住记录. 备注='未退房'

create view 在住记录3 as

select 在住记录2. 客户号, 在住记录2. 姓名, 在住记录2. 房间号, 在住记录2. 性别, 在住记录2. 入住日期, 在住记录2. 类型,

客房类型. 价格, 客房类型. 额定床位, 客房类型. 额定人数

from 客房类型 inner join 在住记录2 on 在住记录2. 类型=客房类型. 类型

create view 历史记录2 as

select 历史记录1. 客户号, 历史记录1. 姓名, 历史记录1. 房间号, 历史记录1. 入住日期, 历史记录1. 结算日期,

历史记录1. 入住天数, 客房信息. 类型

from 历史记录1 inner join 客房信息 on 历史记录1. 房间号=客房信息. 房间号

create view 历史记录3 as

select 历史记录2. 客户号, 历史记录2. 姓名, 历史记录2. 房间号, 历史记录2. 入住日期, 历史记录2. 结算日期,

历史记录2. 入住天数, 历史记录2. 类型, 客房类型. 价格, 结算金额=价格*入住天数 from 历史记录2 inner join 客房类型 on 历史记录2. 类型=客房类型. 类型

create view 预订信息1 as

select 客户信息. 客户号, 客户信息. 姓名, 客户信息. 性别, 预定记录. 房间号, 预定记录. 预定日期, 预定记录. 预定入住日期, 预定记录. 预定天数

from 客户信息 left join 预定记录 on 客户信息. 客户号=预定记录. 客户号

create view 预订信息2 as

select 预订信息1. 客户号, 预订信息1. 姓名, 预订信息1. 性别, 预订信息1. 房间号, 预订信息1. 预定日

期, 预订信息1. 预定入住日期,

预订信息1. 预定天数, 客房信息. 类型

from 预订信息1 left join 客房信息 on 预订信息1. 房间号= 客房信息. 房间号

create view 预订信息3 as

select 预订信息2. 客户号, 预订信息2. 姓名, 预订信息2. 性别, 预订信息2. 房间号, 预订信息2. 预定日期, 预订信息2. 预定入住日期,

预订信息2. 预定天数, 预订信息2. 类型, 客房类型. 价格, 客房类型. 额定床位, 客房类型. 额定人数, 预交押金=价格*预定天数

from 预订信息2 inner join 客房类型 on 预订信息2. 类型=客房类型. 类型

create view 客房在住人数统计 as

select 在住记录3. 房间号, 在住记录3. 类型, 在住人数=count(在住记录3. 房间号), 在住记录3. 额定人数

from 在住记录3

group by 在住记录3. 房间号, 在住记录3. 类型, 在住记录3. 额定人数

create view 客满房间 as

select 客房在住人数统计. 房间号, 客房在住人数统计. 类型, 客房在住人数统计. 在住人数, 客房在住人数统计. 额定人数

from 客房在住人数统计

where ((客房在住人数统计. 类型'双人间' or 客房在住人数统计. 类型'三人间')

and 客房在住人数统计. 在住人数>0) or (客房在住人数统计. 类型='双人间' and 客房在住人数统计. 在住人数=2) or

(客房在住人数统计. 类型='三人间' and 客房在住人数统计. 在住人数=3)

create view 未满房间 as

select 房间号, 类型 from 客房信息

where 房间号 not in (select 房间号 from 客满房间)

create view 空房 as

select 客房信息. 房间号, 客房信息. 类型, 客房类型. 额定人数 from 客房信息, 客房类型

where 客房信息. 类型= 客房类型. 类型 and 客房信息. 房间号 not in (select 房间号 from 入住记录 where 备注='未退房')

五 住宿管理系统的实现

5.1 登录窗口模块的创建与实现

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient;

namespace 用户登录窗口 {

public partial class login : Form {

public login() {

InitializeComponent(); }

private void button1_Click_1(object sender, EventArgs e) {

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456"); conn.Open();

string str = "select * from 系统用户 where 用户名='" + textBox1.Text + "' and 密码='" + textBox2.Text + "'";

SqlCommand cmd = new SqlCommand(str, conn); SqlDataReader dr = cmd.ExecuteReader();

if (dr.Read()) //如果找到用户信息,说明登录成功 {

MessageBox.Show("登陆成功!");

this.DialogResult = DialogResult.OK; } else {

MessageBox.Show("用户名或密码错误!"); textBox1.Text = textBox2.Text = ""; textBox1.Focus(); }

conn.Close(); }

private void button2_Click(object sender, EventArgs e)

{

this.Close();

}

}

}

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

namespace 用户登录窗口

{

static class Program

{

///


/// 应用程序的主入口点。

///

[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

login f = new login();

f.ShowDialog();

if (f.DialogResult.ToString() == "OK")

{

Application.Run(new MDIParent1());

}

}

}

}

5.2系统管理模块的创建与实现

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace 用户登录窗口

{

public partial class MDIParent1 : Form

{

// private int childFormNumber = 0;

public MDIParent1()

{

InitializeComponent();

}

private void 客户信息管理ToolStripMenuItem_Click(object sender, EventArgs e) {

Form3 Form3 = new Form3();

Form3.MdiParent = this;

Form3.Show();

}

private void 预订信息管理ToolStripMenuItem_Click(object sender, EventArgs e) {

Form4 Form4 = new Form4();

Form4.MdiParent = this;

Form4.Show();

}

private void 入住信息管理ToolStripMenuItem_Click(object sender, EventArgs e) {

Form5 Form5 = new Form5();

Form5.MdiParent = this;

Form5.Show();

}

private void 客户结算管理ToolStripMenuItem_Click(object sender, EventArgs e) {

Form6 Form6 = new Form6();

Form6.MdiParent = this;

Form6.Show();

}

}

}

5.3客户信息管理模块的创建于实现

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

namespace 用户登录窗口

{

public partial class Form3 : Form

{

public Form3()

{

InitializeComponent();

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa; Password=123456");

conn.Open();

SqlCommand cmd = new SqlCommand("select distinct(籍贯) from 客户信息", conn); SqlDataReader dr = cmd.ExecuteReader();

while (dr.Read())

{

// MessageBox.Show(dr.GetString(0));

comboBox1.Items.Add(dr.GetString(0));

}

conn.Close();

}

private void Form3_Load(object sender, EventArgs e)

{

// TODO: 这行代码将数据加载到表“宾馆住宿管理系统DataSet1. 客户信息”中。您可以根据需要移动或移除它。

// this.客户信息TableAdapter.Fill(this.宾馆住宿管理系统DataSet1. 客户信息);

}

private void dataGridView1_Click(object sender, EventArgs e)

{

textBox1.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); textBox2.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); textBox3.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); textBox4.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString(); }

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter("select * from 客户信息", conn); DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

private void button2_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

conn.Open();

string str = "insert into 客户信息 values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')";

SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button3_Click(object sender, EventArgs e)

{

if (MessageBox.Show("确定要删除所选用户吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.Yes) return;

string 客户号 = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456");

conn.Open();

string str = "delete from 客户信息 where 客户号='" + 客户号 + "'";

SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button4_Click(object sender, EventArgs e)

{

if (MessageBox.Show("确定要修改所选用户吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.Yes) return;

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456");

conn.Open();

string str = "update 客户信息 set 姓名='" + textBox2.Text + "',性别='" + textBox3.Text + "',籍贯='" + textBox4.Text + "' where 客户号='" + textBox1.Text + "'"; SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button5_Click(object sender, EventArgs e)

{

string str = "select * from 客户信息 where ";

if (checkBox1.Checked)

str += "客户号='" + textBox5.Text + "' and ";

if (checkBox2.Checked)

str += "姓名='" + textBox6.Text + "' and ";

if (checkBox3.Checked)

str += "性别='" + textBox7.Text + "' and "; ;

if (checkBox4.Checked)

str += "籍贯='" + comboBox1.SelectedItem + "'";

else

str = str.Substring(0, str.Length - 4);

MessageBox.Show(str);

dataGridView1.DataSource = 0;

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter(str, conn);

DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

}

}

5.4 预定记录管理模块的创建于实现

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

namespace 用户登录窗口

{

public partial class Form4 : Form

{

public Form4()

{

InitializeComponent();

}

private void Form4_Load(object sender, EventArgs e)

{

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter("Select * from 预定记录", conn); DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

private void dataGridView1_Click(object sender, EventArgs e)

{

textBox1.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); textBox2.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); textBox3.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); textBox4.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString(); textBox5.Text = dataGridView1.SelectedRows[0].Cells[4].Value.ToString(); }

private void button2_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456");

conn.Open();

string str = "insert into 预定记录 values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "')"; SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button3_Click(object sender, EventArgs e)

{

if (MessageBox.Show("确定要删除所选用户吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.Yes) return;

string 客户号 = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456");

conn.Open();

string str = "delete from 预定记录 where 客户号='" + 客户号 + "'";

SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button4_Click(object sender, EventArgs e)

{

if (MessageBox.Show("确定要修改所选用户吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.Yes) return;

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456");

conn.Open();

string str = "update 预定记录 set 房间号='" + textBox2.Text + "',预定日期='" + textBox3.Text + "', 预定入住日期='" + textBox4.Text + "', 预定天数='" + textBox5.Text + "' where 客户号='" + textBox1.Text + "'";

SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button5_Click(object sender, EventArgs e)

{

string str = "Select * from 预定记录 where ";

if (checkBox1.Checked)//客户号选择

str += "客户号='" + textBox6.Text + "'and";

if (checkBox2.Checked)//房间号选择

str += "房间号='" + textBox7.Text + "'and";

if (checkBox3.Checked)//预定日期选择

str += "预定日期='" + textBox8.Text + "'and";

if (checkBox4.Checked)//预定入住日期选择

str += "预定入住日期='" + textBox9.Text + "'";

else//如果没有选择预定天数

str = str.Substring(0, str.Length - 3);//去掉末尾的and

MessageBox.Show(str);

dataGridView1.DataSource = 0;

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter(str, conn);

DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

}

}

5.5入住信息管理模块的创建于实现

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

namespace 用户登录窗口

{

public partial class Form5 : Form

{

public Form5()

{

InitializeComponent();

}

private void Form5_Load(object sender, EventArgs e)

{

}

private void dataGridView1_Click(object sender, EventArgs e)

{

textBox1.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); textBox2.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); textBox3.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); textBox4.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString(); textBox5.Text = dataGridView1.SelectedRows[0].Cells[4].Value.ToString();

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter("Select * from 入住记录", conn); DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

private void button2_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

conn.Open();

string str = "insert into 入住记录 values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "')"; SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button3_Click(object sender, EventArgs e)

{

if (MessageBox.Show("确定要修改所选用户吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.Yes) return;

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

conn.Open();

string str = "update 入住记录 set 房间号='" + textBox2.Text + "',入住日期='" + textBox3.Text + "',结算日期='" + textBox4.Text + "',备注='" + textBox5.Text + "' where 客户号='" + textBox1.Text + "'";

SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button4_Click(object sender, EventArgs e)

{

if (MessageBox.Show("确定要删除所选用户吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.Yes) return;

string ids = " ";

foreach (DataGridViewRow row in dataGridView1.SelectedRows)

{

ids += "'" + row.Cells[0].Value.ToString() + "',";

}

ids = ids.Substring(0, ids.Length - 1);

MessageBox.Show(ids);

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

conn.Open();

string str = "delete from 入住记录 where 客户号 in (" + ids + ")";

SqlCommand cmd = new SqlCommand(str, conn);

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

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button5_Click(object sender, EventArgs e)

{

string str = "select * from 入住记录 where ";

if (checkBox1.Checked)

str += "客户号='" + textBox6.Text + "'and ";

if (checkBox2.Checked)

str += "房间号='" + textBox7.Text + "'and ";

if (checkBox3.Checked)

str += "入住日期='" + textBox8.Text + "'and ";

if (checkBox4.Checked)

str += "结算日期='" + textBox9.Text + "'and ";

if (checkBox5.Checked)

str += "备注='" + textBox10.Text + "'";

else

str = str.Substring(0, str.Length - 4);

MessageBox.Show(str);

dataGridView1.DataSource = 0;

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter(str, conn);

DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

}

}

5.6 客户结算管理模块的创建与实现

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

namespace 用户登录窗口

{

public partial class Form6 : Form

{

public Form6()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter("select * from 入住记录", conn); DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

private void button2_Click(object sender, EventArgs e)

{

if (MessageBox.Show("确定要进行结算吗?", " 提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.Yes)

return;

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456");

conn.Open();

string str = "update 入住记录 set 备注='已退房' where 客户号='" + textBox1.Text + "'";

SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

Form2 Form2=new Form2();

Form2.Show ();

}

}

}

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

namespace 用户登录窗口

{

public partial class Form2 : Form

{

public Form2()

{

InitializeComponent();

}

private void Form2_Load(object sender, EventArgs e)

{

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter("select * from 历史记录3 where 客户号='"+textBox1 .Text+"'", conn);

DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

}

}

六 总结

在做宾馆客房管理前,我对管理系统的理解只停留在知道它怎么用,大概有什么功能。但是突然间叫我自己也做一个系统,我刚开始挺兴奋的,想着自己终于也可以走一些系统了。可是在兴奋过后,我突然就感觉到我应刚要怎么样做才行啊,语句,代码什么都不会,但是在这一段时间的学习中,我懂得了挺多东西的。虽然,在这中间遇到了挺多问题的,并且我在遇到问题经过自己的努力之后还是不明白,而别人很快就懂了,我就变得很烦躁,但是在经过了同学的帮忙后,这些都不成问题了。在这一次的课程设计中,我总结了几点对我印象比较深刻的:

第一,让我发愁的是对宾馆客房的具体业务流程不太熟悉,通过查找各宾馆管理的资料,经过反复的修改论证,才完成了系统的分析和设计工作。

第二,面临的困难是不熟悉软件开发工具。我只好翻阅了有关C#的书籍,同时又不断向老师和同学们请教,才逐渐熟练和掌握了开发工具。

第三,在软件开发的过程中,开始编写菜单、窗口、表结构时,进展还是比较顺利,但当有些字段、表关联、数据窗口混淆在一起的时候,作者被搞得晕头转向。最后不得不重新整理表结构,修改字段名称,到 SQLServer中去修改数据库,才将系统的结构最终确定下来。对于源代码的编写,也是经过反复的修改测试,才使系统的设计功能得以正确实现。 总之,理论+实践=知识,程序设计过程中,我以理论为指导,以实践为主体,将理论与实践紧密结合起来,亲身体会到只有将理论与实践有效的结合起来,才能使理论指导实践,又反过来丰富理论,二者相得益彰,使学习效率大大提高。

七 参考文献

[1]. 萨师煊,王珊 .数据库系统概论. 北京:高等教育出版社,1998年.

[2].马威,吕文哲,曹瑞. 信息系统开发教程—使用C#和SQL Server 2005.清华大学出版社,2007

目录

一 需求分析 . ....................................................................................................................................................... 2 二 数据库概念结构设计 . ................................................................................................................................... 2

2.1功能模块分析 . ....................................................................................................................................... 2 2.2.系统模块设计 . .................................................................................................................................... 2 三 数据库设计 . ................................................................................................................................................... 3

3.1数据库概念结构设计 ............................................................................................................................ 3 3.2数据库逻辑结构设计 ............................................................................................................................ 5 四 宾馆住宿系统的实现 . ................................................................................................................................... 6

4.1 数据库的实现 . ...................................................................................................................................... 6 五 住宿管理系统的实现 . ................................................................................................................................. 10

5.1 登录窗口模块的创建与实现 ............................................................................................................. 10 5.2系统管理模块的创建与实现 ..............................................................................................................11 5.3客户信息管理模块的创建于实现 ..................................................................................................... 13 5.4 预定记录管理模块的创建于实现 ..................................................................................................... 16 5.5入住信息管理模块的创建于实现 ...................................................................................................... 19 5.6 客户结算管理模块的创建与实现 ..................................................................................................... 22 六 总结 . ............................................................................................................................................................. 24 七 参考文献 . ..................................................................................................................................................... 24

一 需求分析

随着外出人流因为生活,商业等方面的增多,宾馆的发展也日益的迅猛,由于顾客量的增多,客户登记时间的广泛,宾馆收益的日益增多,仅仅依靠手写的老式输入记账法,是无法满足宾馆的需求的,同时这也是浪费人力和时间的。开发这个数据库,目的就在于能够更好的对客房的预订情况,空余情况,顾客信息,顾客住宿时间和所用费用,客房房态等进行精确的查询,以便更好的完善和更新宾馆信息系统。 数据库的概念结构设计

二 数据库概念结构设计

2.1功能模块分析

根据宾馆的具体情况,系统主要功能如下:

1. 客房类型管理:提供有关客房类型状况的规范,如标准间,单人间的价格,设施的配置等信息。

2. 客房信息管理:管理各个房间的具体信息,如类型,位置等。 3. 客户信息管理:入住宾馆的客人具体信息的录入,保存等。 4. 查询功能:包括客户信息查询,客房信息查询,住宿信息查询,等。 5. 入住管理系统:登记入住信息,分配房间等。

6. 预订管理功能:登记预订客户,客房的信息以及浏览查询等。 7. 结算功能:客户退房收款等。 8. 系统管理:用户管理等。 2.2.系统模块设计

根据以上对系统的功能需求的分析,将系统的功能划分为三大模块: 1. 数据管理:包括客房类型管理,客房信息管理,客户信息管理。 2. 前台操作:包括各种信息的查询,入住和预订登记和结算的管理。 3. 系统管理:用户注册,修改密码,用户信息管理。 系统功能模块图如下:

功能模块结构图

三 数据库设计

3.1数据库概念结构设计

通过以上对数据库的设计,可得到几个数据库实体,其E-R 图如下 1. 客户实体图

2. 客房实体图

3. 客房类型实体图

4. 系统综合E-R 图

3.2数据库逻辑结构设计

客房类型(类型 面积 价格 额定床位 额定人数 是否有电视 是否有电话 是否有空调 是否有卫生间)

客房信息(房间号 类型 楼层) 客户信息(客户号 姓名 性别 籍贯)

入住记录(客户号 房间号 入住日期 结算日期 备注) 预定记录(客户号 房间号 预定日期 预定于之日期 预定天数) 系统用户( 用户名 密码)

四 宾馆住宿系统的实现

4.1 数据库的实现

create database 宾馆住宿管理系统 on primary (

name=宾馆住宿管理系统_data,

filename='F:\sql\宾馆住宿管理系统_data.mdf', size=5,

maxsize=unlimited, filegrowth=10% )

log on (

name=宾馆住宿管理系统_log,

filename='F:\sql\宾馆住宿管理系统_log.ldf', size=5,

maxsize=unlimited, filegrowth=10% )

create table 客房类型 (

类型 char(12) primary key, 面积 int not null, 价格 money not null, 额定床位 int , 额定人数 int,

是否有电视 char(2) default '有', 是否有电话 char(2) default '有', 是否有空调 char(2) default '有', 是否有卫生间 char(2) default '有' )

create table 客房信息 (

房间号 int primary key, 类型 char(12) not null, 楼层 int not null

create table 客户信息 (

客户号 int primary key, 姓名 varchar(10) not null, 性别 char(2) default '女', 籍贯 varchar(20) not null )

create table 入住记录 (

客户号 int foreign key references 客户信息(客户号), 房间号 int foreign key references 客房信息(房间号), 入住日期 datetime not null, 结算日期 datetime not null, 备注 varchar(30) )

create table 预定记录 (

客户号 int foreign key references 客户信息(客户号), 房间号 int foreign key references 客房信息(房间号), 预定日期 datetime not null, 预定入住日期 datetime not null, 预定天数 tinyint not null )

create table 系统用户 (

用户名 varchar(10) primary key, 密码 varchar(10) not null )

create view 客房详细信息 as

select 客房信息. 房间号, 客房信息. 类型, 客房类型. 价格, 客房类型. 额定床位, 客房类型. 额定人数, 客房信息. 楼层,

客房类型. 是否有电视, 客房类型. 是否有电话, 客房类型. 是否有空调, 客房类型. 是否有卫生间 from 客房类型 left join 客房信息 on 客房类型. 类型=客房信息. 类型

create view 在住记录1 as

select 入住记录. 客户号, 客户信息. 姓名, 入住记录. 房间号, 客户信息. 性别, 入住记录. 入住日期 from 客户信息 left join 入住记录 on 客户信息. 客户号=入住记录. 客户号 where 入住记录. 备注='未退房'

create view 历史记录1

select 客户信息. 客户号, 客户信息. 姓名, 入住记录. 房间号, 入住记录. 入住日期, 入住记录. 结算日期, 入住天数=day(结算日期) -day(入住日期), 入住记录. 备注

from 客户信息 left join 入住记录 on 客户信息. 客户号=入住记录. 客户号 where 入住记录. 备注='已退房'

create view 在住记录2 as

select 入住记录. 客户号, 客户信息. 姓名, 入住记录. 房间号, 客户信息. 性别, 入住记录. 入住日期, 客房信息. 类型

from 入住记录, 客户信息, 客房信息

where 入住记录. 客户号=客户信息. 客户号 and 入住记录. 房间号=客房信息. 房间号 and 入住记录. 备注='未退房'

create view 在住记录3 as

select 在住记录2. 客户号, 在住记录2. 姓名, 在住记录2. 房间号, 在住记录2. 性别, 在住记录2. 入住日期, 在住记录2. 类型,

客房类型. 价格, 客房类型. 额定床位, 客房类型. 额定人数

from 客房类型 inner join 在住记录2 on 在住记录2. 类型=客房类型. 类型

create view 历史记录2 as

select 历史记录1. 客户号, 历史记录1. 姓名, 历史记录1. 房间号, 历史记录1. 入住日期, 历史记录1. 结算日期,

历史记录1. 入住天数, 客房信息. 类型

from 历史记录1 inner join 客房信息 on 历史记录1. 房间号=客房信息. 房间号

create view 历史记录3 as

select 历史记录2. 客户号, 历史记录2. 姓名, 历史记录2. 房间号, 历史记录2. 入住日期, 历史记录2. 结算日期,

历史记录2. 入住天数, 历史记录2. 类型, 客房类型. 价格, 结算金额=价格*入住天数 from 历史记录2 inner join 客房类型 on 历史记录2. 类型=客房类型. 类型

create view 预订信息1 as

select 客户信息. 客户号, 客户信息. 姓名, 客户信息. 性别, 预定记录. 房间号, 预定记录. 预定日期, 预定记录. 预定入住日期, 预定记录. 预定天数

from 客户信息 left join 预定记录 on 客户信息. 客户号=预定记录. 客户号

create view 预订信息2 as

select 预订信息1. 客户号, 预订信息1. 姓名, 预订信息1. 性别, 预订信息1. 房间号, 预订信息1. 预定日

期, 预订信息1. 预定入住日期,

预订信息1. 预定天数, 客房信息. 类型

from 预订信息1 left join 客房信息 on 预订信息1. 房间号= 客房信息. 房间号

create view 预订信息3 as

select 预订信息2. 客户号, 预订信息2. 姓名, 预订信息2. 性别, 预订信息2. 房间号, 预订信息2. 预定日期, 预订信息2. 预定入住日期,

预订信息2. 预定天数, 预订信息2. 类型, 客房类型. 价格, 客房类型. 额定床位, 客房类型. 额定人数, 预交押金=价格*预定天数

from 预订信息2 inner join 客房类型 on 预订信息2. 类型=客房类型. 类型

create view 客房在住人数统计 as

select 在住记录3. 房间号, 在住记录3. 类型, 在住人数=count(在住记录3. 房间号), 在住记录3. 额定人数

from 在住记录3

group by 在住记录3. 房间号, 在住记录3. 类型, 在住记录3. 额定人数

create view 客满房间 as

select 客房在住人数统计. 房间号, 客房在住人数统计. 类型, 客房在住人数统计. 在住人数, 客房在住人数统计. 额定人数

from 客房在住人数统计

where ((客房在住人数统计. 类型'双人间' or 客房在住人数统计. 类型'三人间')

and 客房在住人数统计. 在住人数>0) or (客房在住人数统计. 类型='双人间' and 客房在住人数统计. 在住人数=2) or

(客房在住人数统计. 类型='三人间' and 客房在住人数统计. 在住人数=3)

create view 未满房间 as

select 房间号, 类型 from 客房信息

where 房间号 not in (select 房间号 from 客满房间)

create view 空房 as

select 客房信息. 房间号, 客房信息. 类型, 客房类型. 额定人数 from 客房信息, 客房类型

where 客房信息. 类型= 客房类型. 类型 and 客房信息. 房间号 not in (select 房间号 from 入住记录 where 备注='未退房')

五 住宿管理系统的实现

5.1 登录窗口模块的创建与实现

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient;

namespace 用户登录窗口 {

public partial class login : Form {

public login() {

InitializeComponent(); }

private void button1_Click_1(object sender, EventArgs e) {

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456"); conn.Open();

string str = "select * from 系统用户 where 用户名='" + textBox1.Text + "' and 密码='" + textBox2.Text + "'";

SqlCommand cmd = new SqlCommand(str, conn); SqlDataReader dr = cmd.ExecuteReader();

if (dr.Read()) //如果找到用户信息,说明登录成功 {

MessageBox.Show("登陆成功!");

this.DialogResult = DialogResult.OK; } else {

MessageBox.Show("用户名或密码错误!"); textBox1.Text = textBox2.Text = ""; textBox1.Focus(); }

conn.Close(); }

private void button2_Click(object sender, EventArgs e)

{

this.Close();

}

}

}

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

namespace 用户登录窗口

{

static class Program

{

///


/// 应用程序的主入口点。

///

[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

login f = new login();

f.ShowDialog();

if (f.DialogResult.ToString() == "OK")

{

Application.Run(new MDIParent1());

}

}

}

}

5.2系统管理模块的创建与实现

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace 用户登录窗口

{

public partial class MDIParent1 : Form

{

// private int childFormNumber = 0;

public MDIParent1()

{

InitializeComponent();

}

private void 客户信息管理ToolStripMenuItem_Click(object sender, EventArgs e) {

Form3 Form3 = new Form3();

Form3.MdiParent = this;

Form3.Show();

}

private void 预订信息管理ToolStripMenuItem_Click(object sender, EventArgs e) {

Form4 Form4 = new Form4();

Form4.MdiParent = this;

Form4.Show();

}

private void 入住信息管理ToolStripMenuItem_Click(object sender, EventArgs e) {

Form5 Form5 = new Form5();

Form5.MdiParent = this;

Form5.Show();

}

private void 客户结算管理ToolStripMenuItem_Click(object sender, EventArgs e) {

Form6 Form6 = new Form6();

Form6.MdiParent = this;

Form6.Show();

}

}

}

5.3客户信息管理模块的创建于实现

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

namespace 用户登录窗口

{

public partial class Form3 : Form

{

public Form3()

{

InitializeComponent();

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa; Password=123456");

conn.Open();

SqlCommand cmd = new SqlCommand("select distinct(籍贯) from 客户信息", conn); SqlDataReader dr = cmd.ExecuteReader();

while (dr.Read())

{

// MessageBox.Show(dr.GetString(0));

comboBox1.Items.Add(dr.GetString(0));

}

conn.Close();

}

private void Form3_Load(object sender, EventArgs e)

{

// TODO: 这行代码将数据加载到表“宾馆住宿管理系统DataSet1. 客户信息”中。您可以根据需要移动或移除它。

// this.客户信息TableAdapter.Fill(this.宾馆住宿管理系统DataSet1. 客户信息);

}

private void dataGridView1_Click(object sender, EventArgs e)

{

textBox1.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); textBox2.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); textBox3.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); textBox4.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString(); }

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter("select * from 客户信息", conn); DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

private void button2_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

conn.Open();

string str = "insert into 客户信息 values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')";

SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button3_Click(object sender, EventArgs e)

{

if (MessageBox.Show("确定要删除所选用户吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.Yes) return;

string 客户号 = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456");

conn.Open();

string str = "delete from 客户信息 where 客户号='" + 客户号 + "'";

SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button4_Click(object sender, EventArgs e)

{

if (MessageBox.Show("确定要修改所选用户吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.Yes) return;

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456");

conn.Open();

string str = "update 客户信息 set 姓名='" + textBox2.Text + "',性别='" + textBox3.Text + "',籍贯='" + textBox4.Text + "' where 客户号='" + textBox1.Text + "'"; SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button5_Click(object sender, EventArgs e)

{

string str = "select * from 客户信息 where ";

if (checkBox1.Checked)

str += "客户号='" + textBox5.Text + "' and ";

if (checkBox2.Checked)

str += "姓名='" + textBox6.Text + "' and ";

if (checkBox3.Checked)

str += "性别='" + textBox7.Text + "' and "; ;

if (checkBox4.Checked)

str += "籍贯='" + comboBox1.SelectedItem + "'";

else

str = str.Substring(0, str.Length - 4);

MessageBox.Show(str);

dataGridView1.DataSource = 0;

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter(str, conn);

DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

}

}

5.4 预定记录管理模块的创建于实现

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

namespace 用户登录窗口

{

public partial class Form4 : Form

{

public Form4()

{

InitializeComponent();

}

private void Form4_Load(object sender, EventArgs e)

{

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter("Select * from 预定记录", conn); DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

private void dataGridView1_Click(object sender, EventArgs e)

{

textBox1.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); textBox2.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); textBox3.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); textBox4.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString(); textBox5.Text = dataGridView1.SelectedRows[0].Cells[4].Value.ToString(); }

private void button2_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456");

conn.Open();

string str = "insert into 预定记录 values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "')"; SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button3_Click(object sender, EventArgs e)

{

if (MessageBox.Show("确定要删除所选用户吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.Yes) return;

string 客户号 = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456");

conn.Open();

string str = "delete from 预定记录 where 客户号='" + 客户号 + "'";

SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button4_Click(object sender, EventArgs e)

{

if (MessageBox.Show("确定要修改所选用户吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.Yes) return;

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456");

conn.Open();

string str = "update 预定记录 set 房间号='" + textBox2.Text + "',预定日期='" + textBox3.Text + "', 预定入住日期='" + textBox4.Text + "', 预定天数='" + textBox5.Text + "' where 客户号='" + textBox1.Text + "'";

SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button5_Click(object sender, EventArgs e)

{

string str = "Select * from 预定记录 where ";

if (checkBox1.Checked)//客户号选择

str += "客户号='" + textBox6.Text + "'and";

if (checkBox2.Checked)//房间号选择

str += "房间号='" + textBox7.Text + "'and";

if (checkBox3.Checked)//预定日期选择

str += "预定日期='" + textBox8.Text + "'and";

if (checkBox4.Checked)//预定入住日期选择

str += "预定入住日期='" + textBox9.Text + "'";

else//如果没有选择预定天数

str = str.Substring(0, str.Length - 3);//去掉末尾的and

MessageBox.Show(str);

dataGridView1.DataSource = 0;

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter(str, conn);

DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

}

}

5.5入住信息管理模块的创建于实现

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

namespace 用户登录窗口

{

public partial class Form5 : Form

{

public Form5()

{

InitializeComponent();

}

private void Form5_Load(object sender, EventArgs e)

{

}

private void dataGridView1_Click(object sender, EventArgs e)

{

textBox1.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); textBox2.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); textBox3.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); textBox4.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString(); textBox5.Text = dataGridView1.SelectedRows[0].Cells[4].Value.ToString();

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter("Select * from 入住记录", conn); DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

private void button2_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

conn.Open();

string str = "insert into 入住记录 values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "')"; SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button3_Click(object sender, EventArgs e)

{

if (MessageBox.Show("确定要修改所选用户吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.Yes) return;

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

conn.Open();

string str = "update 入住记录 set 房间号='" + textBox2.Text + "',入住日期='" + textBox3.Text + "',结算日期='" + textBox4.Text + "',备注='" + textBox5.Text + "' where 客户号='" + textBox1.Text + "'";

SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button4_Click(object sender, EventArgs e)

{

if (MessageBox.Show("确定要删除所选用户吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.Yes) return;

string ids = " ";

foreach (DataGridViewRow row in dataGridView1.SelectedRows)

{

ids += "'" + row.Cells[0].Value.ToString() + "',";

}

ids = ids.Substring(0, ids.Length - 1);

MessageBox.Show(ids);

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

conn.Open();

string str = "delete from 入住记录 where 客户号 in (" + ids + ")";

SqlCommand cmd = new SqlCommand(str, conn);

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

cmd.ExecuteNonQuery();

conn.Close();

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

button1_Click(sender, e);

}

private void button5_Click(object sender, EventArgs e)

{

string str = "select * from 入住记录 where ";

if (checkBox1.Checked)

str += "客户号='" + textBox6.Text + "'and ";

if (checkBox2.Checked)

str += "房间号='" + textBox7.Text + "'and ";

if (checkBox3.Checked)

str += "入住日期='" + textBox8.Text + "'and ";

if (checkBox4.Checked)

str += "结算日期='" + textBox9.Text + "'and ";

if (checkBox5.Checked)

str += "备注='" + textBox10.Text + "'";

else

str = str.Substring(0, str.Length - 4);

MessageBox.Show(str);

dataGridView1.DataSource = 0;

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter(str, conn);

DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

}

}

5.6 客户结算管理模块的创建与实现

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

namespace 用户登录窗口

{

public partial class Form6 : Form

{

public Form6()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter("select * from 入住记录", conn); DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

private void button2_Click(object sender, EventArgs e)

{

if (MessageBox.Show("确定要进行结算吗?", " 提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.Yes)

return;

SqlConnection conn = new SqlConnection("Data Source=.; Initial Catalog=宾馆住宿管理系统; User ID=sa; Password=123456");

conn.Open();

string str = "update 入住记录 set 备注='已退房' where 客户号='" + textBox1.Text + "'";

SqlCommand cmd = new SqlCommand(str, conn);

cmd.ExecuteNonQuery();

conn.Close();

Form2 Form2=new Form2();

Form2.Show ();

}

}

}

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

namespace 用户登录窗口

{

public partial class Form2 : Form

{

public Form2()

{

InitializeComponent();

}

private void Form2_Load(object sender, EventArgs e)

{

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=宾馆住宿管理系统;User Id=sa;Password=123456");

SqlDataAdapter myAdapter = new SqlDataAdapter("select * from 历史记录3 where 客户号='"+textBox1 .Text+"'", conn);

DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet, "a");

dataGridView1.DataSource = myDataSet.Tables["a"];

}

}

}

六 总结

在做宾馆客房管理前,我对管理系统的理解只停留在知道它怎么用,大概有什么功能。但是突然间叫我自己也做一个系统,我刚开始挺兴奋的,想着自己终于也可以走一些系统了。可是在兴奋过后,我突然就感觉到我应刚要怎么样做才行啊,语句,代码什么都不会,但是在这一段时间的学习中,我懂得了挺多东西的。虽然,在这中间遇到了挺多问题的,并且我在遇到问题经过自己的努力之后还是不明白,而别人很快就懂了,我就变得很烦躁,但是在经过了同学的帮忙后,这些都不成问题了。在这一次的课程设计中,我总结了几点对我印象比较深刻的:

第一,让我发愁的是对宾馆客房的具体业务流程不太熟悉,通过查找各宾馆管理的资料,经过反复的修改论证,才完成了系统的分析和设计工作。

第二,面临的困难是不熟悉软件开发工具。我只好翻阅了有关C#的书籍,同时又不断向老师和同学们请教,才逐渐熟练和掌握了开发工具。

第三,在软件开发的过程中,开始编写菜单、窗口、表结构时,进展还是比较顺利,但当有些字段、表关联、数据窗口混淆在一起的时候,作者被搞得晕头转向。最后不得不重新整理表结构,修改字段名称,到 SQLServer中去修改数据库,才将系统的结构最终确定下来。对于源代码的编写,也是经过反复的修改测试,才使系统的设计功能得以正确实现。 总之,理论+实践=知识,程序设计过程中,我以理论为指导,以实践为主体,将理论与实践紧密结合起来,亲身体会到只有将理论与实践有效的结合起来,才能使理论指导实践,又反过来丰富理论,二者相得益彰,使学习效率大大提高。

七 参考文献

[1]. 萨师煊,王珊 .数据库系统概论. 北京:高等教育出版社,1998年.

[2].马威,吕文哲,曹瑞. 信息系统开发教程—使用C#和SQL Server 2005.清华大学出版社,2007


相关内容

  • 宾馆饭店接待境外人员临时住宿工作要求汇编
  • 宾馆饭店接待境外人员临时住宿 工作要求汇编 一.境外人员需要申报临时住宿登记的情形 1.根据国家法律规定,境外人员(外国人.台湾同胞.港澳同胞.华侨)在宾馆.饭店.旅店.招待所.学校等企业.事业单位或者机关.团体及其它中国机构内住宿,应当出示有效出入境或者居留证件,并填写临时住宿登记表. 2.长期在 ...

  • 旅馆业管理制度
  • 验证登记制度 一.本宾馆设立独立的登记台,建立旅客登记单,安装旅馆业治安管理信息系统,并配备专职前台登记人员对住宿旅客进行登记. 二.宾馆须凭本人有效身份证件登记住宿,严禁借用.冒用他人证件登记住宿或一人登记多人住宿 三.宾馆前台登记人员须对旅客出示的有效身份证件进行认真核对,对人 证相符的旅客在住 ...

  • 验证登记制度
  • 验证登记制度 (一)本宾馆设立独立的登记台,建立旅客登记单,安装旅馆业治安管理信息系统,并配备专职前台登记人员对住宿旅客进行登记. (二)宾馆须凭本人有效身份证件登记住宿,严禁借用.冒用他人证件登记 住宿或一人登记多人住宿. (三)宾馆前台登记人员须对旅客出示的有效身份证件进行认真核对,对人证相符的 ...

  • 宾馆业治安管理五项制度
  • 物品寄存制度 一.宾馆必须设置旅客财务保管室.寄存室.寄存柜,配备保险箱,专人保管.昼夜值班,确保旅客财物安全. 二.登记员.服务员要督促旅客寄存贵重物品和现金.执意不存的让其在登记簿上签字证明. 三.建立<现金.贵重物品登记簿>,对住宿旅客寄存的财务进行严格的登记.实行"三对 ...

  • 杭州公布36家卫生检测不合格宾馆旅店
  • 新换的被单上会有熨平线 董吕平 摄 怎么判断被套床单到底是不是新换的? 可以找一下熨平线 记者 董吕平 通讯员 王旖琴 "十一"国庆长假即将来临,杭州也将引来新一波旅游高峰.就在近日,杭州市卫生监督部门对住宿场所展开了一系列大检查,共监督检查了3369家住宿场所,有243家住宿场 ...

  • 宾馆住宿管理系统论文
  • 盐 城 师 范 学 院 毕业设计 2011-2012学年度 信息科学与技术 学院 计算机科学与技术(数字媒体)专业 班级 08(4) 学号 08263349 课题名称学生姓名 指导教师 高 雄 王创伟 2012 年 3 月 09 日 摘 要 宾馆管理系统的引入使宾馆内部能集中管理,集中控制,快速反应 ...

  • GMAT培训目录
  • GMAT培训目录   GMAT*强化周末走读班 班级2个 适合学员: 大学英语六级以上,词汇量6000 左右的学员. 课程简介: 主要讲解GMAT的考试内容及考试规律,分逻辑.数学.阅读.语法.写作.提升考试能力.   GMAT*强化精品春季住宿班 班级3个 适合学员: 大学英语六级以上,词 ...

  • 订票和住宿管理规定
  • 员工出差.订票和住宿的管理规定 根据集团工作安排,为进一步规范我司员工出差报销制度,有效节省公司各项费用支出,对公司员工出差.住宿和乘坐的交通工具作出如下规定: 1.员工出差必须提前到行政事务部按照出差申请表的内容如实填写该表,并经部门部长同意.经过行政事务部确认后,方可离开工作岗位,否则将按旷工予 ...

  • 庐山宾馆住宿
  • 庐山宾馆住宿-推荐九江海外旅行社 庐山在中国近现代史上影响非常大,堪称中国的政治名山.1895年起,英.法.美等西方国家曾在此大兴土木,留下了大量的西式建筑,形成了今日牯岭镇的雏形.北伐战争结束后,这里成为中华民国政府的"夏都",是中国的政治中心之一.1937年6月,周恩来代表中 ...