软件工程课程设计报告-宾馆信息管理系统.doc
. .分类号编号华北水利水电大学North China University of Water Resources and Electric Power实验报告课程:软件工程实验工程2:软件编码与测试题目:宾馆管理信息系统院系信息工程学院专业计算机科学与技术班级学号 202115717 XX卫朋指导教师庄晋林2021年 5 月 29 日华北水利水电大学软件工程实验报告20212021学年第二学期 2021 级计算机科学与技术专业一、实验容:宾馆管理信息系统任务:入住或预订客房时,用户要对客户管理模块或预订管理模块进展核对审查,并进展登记;客户换房时,要对换房信息进展查询和更新;客户退房时,要进展结算,并对更新客房信息。主要功能模块:1登录模块:对用户身份进展验证,只有合法用户才能进入系统;2系统管理模块:对系统用户进展管理,更改用户名、密码、权限等;3客房管理模块:对客房信息的添加、修改和删除等;4入住管理模块:对客户入住信息的登记、查询等功能5订房管理模块:对客户订房信息的登记、查询等。6换房管理模块:对客户换房信息的登记、查询等7宾馆结算模块:对已入住宾馆的顾客进展结算及对订房客户已交的押金进展结算、查询。二、程序源: Win7 64位电脑,vs2021编辑环境,sql2005数据库。程序源码: 1、登录设计:namespace宾馆管理信息系统publicpartialclasslogin1 : Form public login1() Initializeponent(); privateconnection c = newconnection();privatevoid button1_Click(object sender, EventArgs e) if (textBox1.Text.Trim().ToString()!= String.Empty && textBox2.Text.Trim().ToString() != String.Empty) string id = null, pw = null, gd = null;var result = from info in c.linq.loginwhere info.id = textBox1.Text.ToString().Trim()selectnew ID = info.id, pw = info.password, gd = info.grade, ;if (result.Count() = 0) MessageBox.Show("用户名不存在!"); elseif (result.Count() = 1) foreach (var p in result) id = p.ID; pw = p.pw; gd = p.gd; if (pw.Trim() = textBox2.Text.ToString().Trim() this.Hide();manger lf = newmanger(gd,textBox1.Text.Trim().ToString(); lf.Show(); else MessageBox.Show("密码错误!"); else MessageBox.Show("不能为空!"); privatevoid button2_Click(object sender, EventArgs e) this.Close(); privatevoid login1_FormClosed(object sender, FormClosedEventArgs e) System.Environment.Exit(0); 2、添加住户设计namespace宾馆管理信息系统publicpartialclassaddpeople : Form privateconnection c = newconnection();privatestring s;public addpeople(Form f,string s) this.Owner = f; Initializeponent();this.s = s;/房间号 boBox1.DropDownStyle = System.Windows.Forms.boBoxStyle.DropDownList; privatevoid button1_Click(object sender, EventArgs e) if (textBox1.Text.Trim().ToString() != String.Empty && boBox1.Text.Trim().ToString() != String.Empty && textBox3.Text.Trim().ToString() != String.Empty && textBox4.Text.Trim().ToString() != String.Empty) var result = from info in c.linq.roomwhere info.房间 = s.Trim().ToString()selectnew 房间号 = info.房间,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用, ;foreach (var item in result) if (item.房间单价 <= int.Parse(textBox4.Text.Trim().ToString() try guest r = newguest(); r.住店人XX = textBox1.Text.Trim().ToString(); r.XX = textBox2.Text.Trim().ToString(); r.性别 = boBox1.Text.Trim().ToString(); r.所交押金 = int.Parse(textBox4.Text.Trim().ToString(); r.人数 = textBox3.Text.Trim().ToString(); r.房间 = s; r.入住天数 = 1; r.入住时间 = System.DateTime.Now.Day.ToString(); var edit = c.linq.room.SingleOrDefault<room>(s1 => s1.房间 = s.Trim().ToString(); if (edit = null) return; edit.房间是否正在使用 = "是" c.linq.guest.InsertOnSubmit(r); c.linq.SubmitChanges();/修改student的属性;MessageBox.Show(textBox2.Text.Trim().ToString() + " 入住成功");this.Close(); catch MessageBox.Show("用户已存在!"); else MessageBox.Show("所交押金缺乏!"); else MessageBox.Show("不能为空!"); privatevoid addpeople_FormClosed(object sender, FormClosedEventArgs e) this.Owner.Owner.Show(); 3、添加房间设计:namespace宾馆管理信息系统publicpartialclassaddroom : Form public addroom(Form f) Initializeponent();this.Owner = f; boBox1.DropDownStyle = System.Windows.Forms.boBoxStyle.DropDownList;privateconnection c = newconnection();privatevoid button1_Click(object sender, EventArgs e) if (textBox1.Text.Trim().ToString() != String.Empty && boBox1.Text.Trim().ToString() != String.Empty && textBox3.Text.Trim().ToString() != String.Empty) try room r = newroom(); r.房间 = textBox1.Text.Trim().ToString(); r.房间种类 = boBox1.Text.Trim().ToString(); r.房间单价 = double.Parse( textBox3.Text.Trim().ToString(); r.房间是否正在使用 = "否" c.linq.room.InsertOnSubmit(r); c.linq.SubmitChanges();MessageBox.Show(textBox1.Text.Trim().ToString()+" 号房间添加成功");this.textBox1.Text = null;this.textBox3.Text = null;this.boBox1.Text = null;this.textBox1.Focus(); catch MessageBox.Show("房间号已存在!"); else MessageBox.Show("不能为空!"); privatevoid addroom_FormClosed(object sender, FormClosedEventArgs e) this.Owner.Show(); privatevoid button2_Click(object sender, EventArgs e) this.Close(); 4、查看所有房间信息设计:namespace宾馆管理信息系统publicpartialclassallroom : Form privateconnection c=newconnection ();public allroom(Form f) Initializeponent();this.Owner = f;this.listView1.Clear();this.listView1.View = View.LargeIcon;this.listView1.LargeImageList = this.imageList1;Random rd = newRandom();this.listView1.BeginUpdate();var result = from info in c.linq.roomselectnew 房间号 = info.房间,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用, ;foreach (var item in result) ListViewItem lvi = newListViewItem();if(item.房间是否使用.Trim()="否") lvi.ImageIndex =0; elseif (item.房间是否使用.Trim() = "是") lvi.ImageIndex = 1; lvi.Text = item.房间号.Trim().ToString();this.listView1.Items.Add(lvi); this.listView1.EndUpdate(); privatevoid listView1_ItemActivate(objectsender, EventArgs e) var result = from info in c.linq.roomwhere info.房间 = listView1.FocusedItem.Text.Trim().ToString()selectnew 房间号 = info.房间,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用, ;foreach (var item in result) DialogResult dr = MessageBox.Show("房间号:" + listView1.FocusedItem.Text.ToString() + "rn房间类型:" + item.房间类型 + "rn房间单价:" + item.房间单价); privatevoid allroom_FormClosed(object sender, FormClosedEventArgs e) this.Owner.Show(); 5、 预订房间设计:namespace宾馆管理信息系统publicpartialclassbookroom : Form privateconnection c = newconnection();public bookroom(Form f) Initializeponent();this.Owner = f;this.listView1.Clear();this.listView1.View = View.LargeIcon;this.listView1.LargeImageList = this.imageList1;Random rd = newRandom();this.listView1.BeginUpdate();var result = from info in c.linq.roomwhere info.房间是否正在使用="否"selectnew 房间号 = info.房间,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用, ;foreach (var item in result) ListViewItem lvi = newListViewItem(); lvi.ImageIndex =0; lvi.Text = item.房间号.Trim().ToString();this.listView1.Items.Add(lvi); this.listView1.EndUpdate();privatevoid bookroom_FormClosed(object sender, FormClosedEventArgs e) this.Owner.Show(); privatevoid listView1_ItemActivate(object sender, EventArgs e) var result = from info in c.linq.roomwhere info.房间 = listView1.FocusedItem.Text.Trim().ToString()selectnew 房间号 = info.房间,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用, ;foreach (var item in result) DialogResult dr = MessageBox.Show("房间号:" + listView1.FocusedItem.Text.ToString() + "rn房间类型:"+item.房间类型+"rn房间单价:"+item.房间单价+"rn确认使用么?", "提示", MessageBoxButtons.OKCancel);if (dr = DialogResult.OK) /用户选择确认的操作addpeople a = newaddpeople(this, listView1.FocusedItem.Text.Trim().ToString();this.Hide(); a.Show(); 6、查看所有用户设计:namespace宾馆管理信息系统publicpartialclasschakanyonghu : Form privateconnection c = newconnection();public chakanyonghu(Form f) this.Owner = f; Initializeponent();var result = from info in c.linq.loginselectnew 用户名 = info.id,用户类型 = info.grade, ; dataGridView1.DataSource = result; 7、修改房间的信息设计:namespace宾馆管理信息系统publicpartialclasschangeroom : Form privateconnection c = newconnection();public changeroom(Form f) Initializeponent();this.Owner = f;var result = from info in c.linq.roomselectnew 房间号 = info.房间,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用, ; dataGridView1.DataSource = result; privatevoid dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) string s = Convert.ToString(dataGridView10, e.RowIndex.Value).Trim();changeroom2 d = newchangeroom2(this, s); d.Show();this.Hide(); privatevoid button1_Click(object sender, EventArgs e) var result = from info in c.linq.roomselectnew 房间号 = info.房间,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用, ; dataGridView1.DataSource = result; namespace宾馆管理信息系统publicpartialclasschangeroom2 : Form privateconnection c = newconnection();privatestring s = null;public changeroom2(Form f,string s) Initializeponent(); boBox1.DropDownStyle = System.Windows.Forms.boBoxStyle.DropDownList; boBox2.DropDownStyle = System.Windows.Forms.boBoxStyle.DropDownList;this.Owner = f;this.s = s;var result = from info in c.linq.roomwhere info.房间=sselectnew 房间号 = info.房间,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用, ;foreach (var item in result) this.textBox2.Text = item.房间号;this.textBox1.Text = item.房间单价.ToString();this.boBox1.Text = item.房间类型;this.boBox2.Text = item.房间是否使用; privatevoid button1_Click(object sender, EventArgs e) if (textBox1.Text.Trim().ToString() != String.Empty && textBox2.Text.Trim().ToString() != String.Empty && boBox1.Text.Trim().ToString() != String.Empty && boBox2.Text.Trim().ToString() != String.Empty) var edit = c.linq.room.SingleOrDefault<room>(s1=>s1.房间=s);if (edit = null) return; /修改student的属性 edit.房间单价= double .Parse( textBox1.Text.Trim().ToString(); edit.房间种类 = boBox1.Text.Trim().ToString(); edit.房间是否正在使用 = boBox2.Text.Trim().ToString();/执行更新操作 c.linq.SubmitChanges();MessageBox.Show("房间信息修改成功");this.Close(); 8、删除用户信息设计:namespace宾馆管理信息系统publicpartialclassdelete : Form privatestring s;privateconnection c = newconnection();public delete(Form f) Initializeponent();this.Owner = f;var result = from info in c.linq.loginwhere info.grade="普通用户"selectnew 用户名 = info.id,用户类型 = info.grade, ; dataGridView1.DataSource = result; privatevoid dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) s = Convert.ToString(dataGridView10, e.RowIndex.Value).Trim();delete2 d = newdelete2(s,this ); d.Show();this.Hide(); privatevoid button2_Click(object sender, EventArgs e) var result = from info in c.linq.loginwhere info.grade = "普通用户"selectnew 用户名 = info.id,用户类型 = info.grade, ; dataGridView1.DataSource = result; namespace宾馆管理信息系统publicpartialclassdelete2 : Form privatestring h;privateconnection c = newconnection();public delete2(string s,Form f) Initializeponent(); h = s;this.Owner = f;var result = from info in c.linq.loginwhere info.id = sselectnew 用户名 = info.id,用户类型 = info.grade, ; dataGridView1.DataSource = result; privatevoid button1_Click(object sender, EventArgs e) var result = from m in c.linq.loginwhere m.id = hselect m; c.linq.login.DeleteAllOnSubmit(result); c.linq.SubmitChanges();MessageBox.Show("删除成功");this.Close(); 9、