软件工程课程设计-宾馆信息管理系统
- 格式:doc
- 大小:407.56 KB
- 文档页数:29
分类号编号华北水利水电大学North China University of Water Resources and Electric Power实验报告课程:软件工程实验项目2:软件编码与测试题目:宾馆管理信息系统院系信息工程学院专业计算机科学与技术班级学号201415717姓名李卫朋指导教师庄晋林2017年5 月29 日华北水利水电大学软件工程实验报告2016~2017学年第二学期2014 级计算机科学与技术专业一、实验内容:宾馆管理信息系统任务:入住或预订客房时,用户要对客户管理模块或预订管理模块进行核对审查,并进行登记;客户换房时,要对换房信息进行查询和更新;客户退房时,要进行结算,并对更新客房信息。
主要功能模块:(1)登录模块:对用户身份进行验证,只有合法用户才能进入系统;(2)系统管理模块:对系统用户进行管理,更改用户名、密码、权限等;(3)客房管理模块:对客房信息的添加、修改和删除等;(4)入住管理模块:对客户入住信息的登记、查询等功能(5)订房管理模块:对客户订房信息的登记、查询等。
(6)换房管理模块:对客户换房信息的登记、查询等(7)宾馆结算模块:对已入住宾馆的顾客进行结算及对订房客户已交的押金进行结算、查询。
二、程序源:Win7 64位电脑,vs2012编辑环境,sql2005数据库。
程序源码:1、登录设计:namespace宾馆管理信息系统{public partial class login1 : Form{public login1(){InitializeComponent();}private connection c = new connection();private void 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()select new{ID = info.id,pw = info.password,gd = info.grade,};if (result.Count() == 0){MessageBox.Show("用户名不存在!");}else if (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 = new manger(gd,textBox1.Text.Trim().ToString()); lf.Show();}else{MessageBox.Show("密码错误!");}}}else{MessageBox.Show("不能为空!");}}private void button2_Click(object sender, EventArgs e){this.Close();}private void login1_FormClosed(object sender, FormClosedEventArgs e){System.Environment.Exit(0);}}}2、添加住户设计namespace宾馆管理信息系统{public partial class addpeople : Form{private connection c = new connection();private string s;public addpeople(Form f,string s){this.Owner = f;InitializeComponent();this.s = s;//房间号comboBox1.DropDownStyle = boBoxStyle.DropDownList;}private void button1_Click(object sender, EventArgs e){if (textBox1.Text.Trim().ToString() != String.Empty && comboBox1.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()select new{房间号 = info.房间号码,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用,};foreach (var item in result){if (item.房间单价 <= int.Parse(textBox4.Text.Trim().ToString())){try{guest r = new guest();{r.住店人身份证号码 = textBox1.Text.Trim().ToString();r.姓名 = textBox2.Text.Trim().ToString();r.性别 = comboBox1.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("不能为空!");}}private void addpeople_FormClosed(object sender, FormClosedEventArgs e){this.Owner.Owner.Show();}}}3、添加房间设计:namespace宾馆管理信息系统{public partial class addroom : Form{public addroom(Form f){InitializeComponent();this.Owner = f;comboBox1.DropDownStyle = boBoxStyle.DropDownList;}private connection c = new connection();private void button1_Click(object sender, EventArgs e){if (textBox1.Text.Trim().ToString() != String.Empty && comboBox1.Text.Trim().ToString() != String.Empty && textBox3.Text.Trim().ToString() != String.Empty){try{room r = new room();{r.房间号码 = textBox1.Text.Trim().ToString();r.房间种类 = comboBox1.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;boBox1.Text = null;this.textBox1.Focus();}catch{MessageBox.Show("房间号已存在!");}}else{MessageBox.Show("不能为空!");}}private void addroom_FormClosed(object sender, FormClosedEventArgs e){this.Owner.Show();}private void button2_Click(object sender, EventArgs e){this.Close();}}}4、查看所有房间信息设计:namespace宾馆管理信息系统{public partial class allroom : Form{private connection c=new connection ();public allroom(Form f){InitializeComponent();this.Owner = f;this.listView1.Clear();this.listView1.View = rgeIcon;rgeImageList = this.imageList1;Random rd = new Random();this.listView1.BeginUpdate();var result = from info in c.linq.roomselect new{房间号 = info.房间号码,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用, };foreach (var item in result){ListViewItem lvi = new ListViewItem();if(item.房间是否使用.Trim()=="否"){lvi.ImageIndex =0;}else if (item.房间是否使用.Trim() == "是"){lvi.ImageIndex = 1;}lvi.Text = item.房间号.Trim().ToString();this.listView1.Items.Add(lvi);}this.listView1.EndUpdate();}private void listView1_ItemActivate(object sender, EventArgs e){var result = from info in c.linq.roomwhere info.房间号码 == listView1.FocusedItem.Text.Trim().ToString()select new{房间号 = info.房间号码,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用,};foreach (var item in result){DialogResult dr = MessageBox.Show("房间号:" + listView1.FocusedItem.Text.ToString() + "\r\n房间类型:" + item.房间类型 + "\r\n房间单价:" + item.房间单价);}}private void allroom_FormClosed(object sender, FormClosedEventArgs e){this.Owner.Show();}}}5、预订房间设计:namespace宾馆管理信息系统{public partial class bookroom : Form{private connection c = new connection();public bookroom(Form f){InitializeComponent();this.Owner = f;this.listView1.Clear();this.listView1.View = rgeIcon;rgeImageList = this.imageList1;Random rd = new Random();this.listView1.BeginUpdate();var result = from info in c.linq.roomwhere info.房间是否正在使用=="否"select new{房间号 = info.房间号码,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用,};foreach (var item in result){ListViewItem lvi = new ListViewItem();lvi.ImageIndex =0;lvi.Text = item.房间号.Trim().ToString();this.listView1.Items.Add(lvi);}this.listView1.EndUpdate();private void bookroom_FormClosed(object sender, FormClosedEventArgs e){this.Owner.Show();}private void listView1_ItemActivate(object sender, EventArgs e){var result = from info in c.linq.roomwhere info.房间号码 == listView1.FocusedItem.Text.Trim().ToString()select new{房间号 = info.房间号码,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用,};foreach (var item in result){DialogResult dr = MessageBox.Show("房间号:" + listView1.FocusedItem.Text.ToString() + "\r\n房间类型:"+item.房间类型+"\r\n房间单价:"+item.房间单价+"\r\n确认使用么?", "提示", MessageBoxButtons.OKCancel);if (dr == DialogResult.OK){//用户选择确认的操作addpeople a = new addpeople(this, listView1.FocusedItem.Text.Trim().ToString());this.Hide();a.Show();}}}}}6、查看所有用户设计:namespace宾馆管理信息系统{public partial class chakanyonghu : Form{private connection c = new connection();public chakanyonghu(Form f){this.Owner = f;InitializeComponent();var result = from info in c.linq.loginselect new{用户名 = info.id,用户类型 = info.grade,};dataGridView1.DataSource = result;}}}7、修改房间的信息设计:namespace宾馆管理信息系统{public partial class changeroom : Form{private connection c = new connection();public changeroom(Form f){InitializeComponent();this.Owner = f;var result = from info in c.linq.roomselect new{房间号 = info.房间号码,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用,};dataGridView1.DataSource = result;}private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) {string s = Convert.ToString(dataGridView1[0, e.RowIndex].Value).Trim();changeroom2 d = new changeroom2(this, s);d.Show();this.Hide();}private void button1_Click(object sender, EventArgs e){var result = from info in c.linq.roomselect new{房间号 = info.房间号码,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用,};dataGridView1.DataSource = result;}}}namespace宾馆管理信息系统{public partial class changeroom2 : Form{private connection c = new connection();private string s = null;public changeroom2(Form f,string s){InitializeComponent();comboBox1.DropDownStyle = boBoxStyle.DropDownList; comboBox2.DropDownStyle = boBoxStyle.DropDownList;this.Owner = f;this.s = s;var result = from info in c.linq.roomwhere info.房间号码==sselect new{房间号 = info.房间号码,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用,};foreach (var item in result){this.textBox2.Text = item.房间号;this.textBox1.Text = item.房间单价.ToString();boBox1.Text = item.房间类型;boBox2.Text = item.房间是否使用;}}private void button1_Click(object sender, EventArgs e){if(textBox1.Text.Trim().ToString() != String.Empty && textBox2.Text.Trim().ToString() != String.Empty && comboBox1.Text.Trim().ToString() != String.Empty && comboBox2.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.房间种类 = comboBox1.Text.Trim().ToString();edit.房间是否正在使用 = comboBox2.Text.Trim().ToString();//执行更新操作c.linq.SubmitChanges();MessageBox.Show("房间信息修改成功");this.Close();}}}}8、删除用户信息设计:namespace宾馆管理信息系统{public partial class delete : Form{private string s;private connection c = new connection();public delete(Form f){InitializeComponent();this.Owner = f;var result = from info in c.linq.loginwhere info.grade=="普通用户"select new{用户名 = info.id,用户类型 = info.grade,};dataGridView1.DataSource = result;}private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) {s = Convert.ToString(dataGridView1[0, e.RowIndex].Value).Trim();delete2 d = new delete2(s,this );d.Show();this.Hide();}private void button2_Click(object sender, EventArgs e){var result = from info in c.linq.loginwhere info.grade == "普通用户"select new{用户名 = info.id,用户类型 = info.grade,};dataGridView1.DataSource = result;}}}namespace宾馆管理信息系统{public partial class delete2 : Form{private string h;private connection c = new connection();public delete2(string s,Form f){InitializeComponent();h = s;this.Owner = f;var result = from info in c.linq.loginwhere info.id == sselect new{用户名 = info.id,用户类型 = info.grade,};dataGridView1.DataSource = result;}private void 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、删除房间信息设计:namespace宾馆管理信息系统{public partial class deleteroom : Form{private connection c = new connection();public deleteroom(Form f){InitializeComponent();this.Owner = f;var result = from info in c.linq.roomselect new{房间号 = info.房间号码,房间类型 = info.房间种类,房间单价=info.房间单价,房间是否使用=info.房间是否正在使用,};dataGridView1.DataSource = result;}private void button2_Click(object sender, EventArgs e) {var result = from info in c.linq.roomselect new{房间号 = info.房间号码,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用,};dataGridView1.DataSource = result;}private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) {string s = Convert.ToString(dataGridView1[0, e.RowIndex].Value).Trim();deleteroom2 d = new deleteroom2(this,s);d.Show();this.Hide();}}}namespace宾馆管理信息系统{public partial class deleteroom2 : Form{private connection c = new connection();private string h;public deleteroom2(Form f,string h){InitializeComponent();this.Owner = f;this.h = h;var result = from info in c.linq.roomwhere info.房间号码 == hselect new{房间号 = info.房间号码,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用,};dataGridView1.DataSource = result;}private void button1_Click(object sender, EventArgs e){var result = from m in c.linq.roomwhere m.房间号码 == hselect m;foreach (var item in result){if (item.房间是否正在使用.Trim().ToString() == "否"){c.linq.room.DeleteAllOnSubmit(result);c.linq.SubmitChanges();MessageBox.Show("删除成功");this.Close();}else{MessageBox.Show("该房间正在使用,请先退房!");}}}}}10、查看住户信息:namespace宾馆管理信息系统{public partial class guestmessage : Form{private connection c = new connection();public guestmessage(Form f){this.Owner = f;InitializeComponent();comboBox1.DropDownStyle = boBoxStyle.DropDownList;}private void button1_Click(object sender, EventArgs e){if (comboBox1.Text.Trim().ToString() != string.Empty && textBox1.Text.Trim().ToString() !=string.Empty){switch (comboBox1.Text.Trim().ToString()){case"房间号":var edit = c.linq.guest.SingleOrDefault<guest>(s1 => s1.房间号码.Trim() ==textBox1.Text.Trim().ToString());if (edit != null){MessageBox.Show("房间号:" + edit.房间号码 + "\t\n" + "人数:" + edit.人数 + "\t\n" + "入住天数:" + edit.入住天数 + "\t\n" + "押金:" + edit.所交押金 + "\t\n" + "姓名:" + edit.姓名 + "\t\n" + "身份证号码:" + edit.住店人身份证号码);}else{MessageBox.Show("房间为空!");}break;case"用户姓名":var edit1 = c.linq.guest.SingleOrDefault<guest>(s1 => s1.姓名.Trim() ==textBox1.Text.Trim().ToString());if (edit1 != null){MessageBox.Show("房间号:"+ edit1.房间号码 + "\t\n"+ "人数:" + edit1.人数 + "\t\n" + "入住天数:" + edit1.入住天数 + "\t\n" + "押金:" + edit1.所交押金 + "\t\n" + "姓名:" + edit1.姓名 + "\t\n" + "身份证号码:" + edit1.住店人身份证号码);}else{MessageBox.Show(textBox1.Text.Trim().ToString() + "不存在");}break;case"身份证号":var edit2 = c.linq.guest.SingleOrDefault<guest>(s1 => s1.住店人身份证号码.Trim() == textBox1.Text.Trim().ToString());if (edit2 != null){MessageBox.Show("房间号:"+ edit2.房间号码 + "\t\n"+ "人数:" + edit2.人数 + "\t\n" + "入住天数:" + edit2.入住天数 + "\t\n" + "押金:" + edit2.所交押金 + "\t\n" + "姓名:" + edit2.姓名 + "\t\n" + "身份证号码:" + edit2.住店人身份证号码);}else{MessageBox.Show(textBox1.Text.Trim().ToString() + "不存在");}break;}}else{MessageBox.Show("不能为空!");}}}}11、新用户注册namespace宾馆管理信息系统{public partial class login2 : Form{private connection c = new connection();public login2(){InitializeComponent();comboBox1.DropDownStyle = boBoxStyle.DropDownList;}public login2(Form f){InitializeComponent();this.Owner = f;comboBox1.DropDownStyle = boBoxStyle.DropDownList;}private void button1_Click(object sender, EventArgs e){if(textBox1.Text.Trim().ToString() != String.Empty && textBox2.Text.Trim().ToString() != String.Empty && textBox3.Text.Trim().ToString() != String.Empty && comboBox1.Text.Trim().ToString() != String.Empty){if (comboBox1.Text.Trim().ToString() == "管理员" || comboBox1.Text.Trim().ToString() == "普通用户"){if (this.textBox2.Text.Trim().ToString() == textBox3.Text.Trim().ToString()){try{login l = new login();{l.id = textBox1.Text.Trim().ToString();l.password = textBox2.Text.Trim().ToString();l.grade = comboBox1.Text.Trim().ToString();}c.linq.login.InsertOnSubmit(l);c.linq.SubmitChanges();MessageBox.Show("注册成功");}catch{MessageBox.Show("用户名已存在!");}}else{MessageBox.Show("请再次输入确定密码!");}}else{MessageBox.Show("请选择正确的用户类型!");boBox1.Focus();}}else{MessageBox.Show("不能为空!");}}}}12、主界面设计:namespace宾馆管理信息系统{public partial class manger : Form{private string i,j;//public manger(){InitializeComponent();}public manger(string i,string j){InitializeComponent();this.i = i;this.j = j;}private void button1_Click(object sender, EventArgs e) {this.Hide();login2 l = new login2(this);l.Show();}private void manger_Load(object sender, EventArgs e) {if (i.Trim().Equals("管理员")){this.panel1.Visible = true;this.panel2.Visible = true ;}else if (i.Trim().Equals("普通用户")){this.panel2.Visible = true;this.panel1.Visible = false;}}private void button3_Click(object sender, EventArgs e){this.Hide();delete l = new delete(this);l.Show();}private void manger_FormClosed(object sender, FormClosedEventArgs e) {System.Environment.Exit(0);}private void button4_Click(object sender, EventArgs e){this.Hide();chakanyonghu l = new chakanyonghu(this);l.Show();}private void button5_Click(object sender, EventArgs e){this.Hide();xiugaimima l = new xiugaimima(this, j);l.Show();}private void button6_Click(object sender, EventArgs e){this.Hide();addroom l = new addroom(this);l.Show();}private void button7_Click(object sender, EventArgs e){this.Hide();deleteroom l = new deleteroom(this);l.Show();}private void button8_Click(object sender, EventArgs e){this.Hide();changeroom l = new changeroom(this);l.Show();}private void button2_Click(object sender, EventArgs e){this.Hide();bookroom l = new bookroom(this);l.Show();}private void button9_Click(object sender, EventArgs e){this.Hide();unsubscribe l = new unsubscribe(this);l.Show();}private void button10_Click(object sender, EventArgs e){this.Hide();allroom l = new allroom(this);l.Show();}private connection c = new connection();private ArrayList arl = new ArrayList();private void button11_Click(object sender, EventArgs e){var result = from m in c.linq.guestselect m;foreach (var item in result){if (item.入住时间.Trim() != System.DateTime.Now.Day.ToString()){var edit = c.linq.room.SingleOrDefault<room>(s => s.房间号码 == item.房间号码);if (item.所交押金 >= (item.入住天数 + 1) * edit.房间单价){item.入住天数++;item.入住时间 = System.DateTime.Now.Day.ToString();c.linq.SubmitChanges();}else{try{exitroom r = new exitroom();{r.押金不足的房间号 = item.房间号码;}c.linq.exitroom.InsertOnSubmit(r);c.linq.SubmitChanges();}catch{}MessageBox.Show("请提醒"+item.房间号码+"号房的"+item.姓名+"退房或者续交房费"); }}}var result1 = from m in c.linq.exitroomselect m;dataGridView1.DataSource = result1;}private void button12_Click(object sender, EventArgs e){var result1 = from m in c.linq.exitroomselect m;dataGridView1.DataSource = result1;}private void button13_Click(object sender, EventArgs e){rejiaofei r = new rejiaofei(this);this.Hide();r.Show();}private void button14_Click(object sender, EventArgs e){guestmessage m = new guestmessage(this);this.Hide();m.Show();}private void button15_Click(object sender, EventArgs e){this.Close();}private void button16_Click(object sender, EventArgs e){this.Hide();login1 l = new login1();l.Show();}}}13、用户再次缴费:namespace宾馆管理信息系统{public partial class rejiaofei : Form{private connection c = new connection();public rejiaofei(Form f){InitializeComponent();this.Owner = f;}private void button1_Click(object sender, EventArgs e){try{var edit = c.linq.guest.SingleOrDefault<guest>(s1 => s1.房间号码.Trim() == this.textBox1.Text.Trim().ToString());edit.所交押金 = edit.所交押金 + int.Parse(textBox2.Text.Trim().ToString()); edit.入住天数++;edit.入住时间 = System.DateTime.Now.Day.ToString();var result3 = from m in c.linq.exitroomwhere m.押金不足的房间号 == textBox1.Text.Trim().ToString()select m;c.linq.exitroom.DeleteAllOnSubmit(result3);c.linq.SubmitChanges();MessageBox.Show("缴纳成功!");}catch{MessageBox.Show("缴纳失败,请核对房间号!");}}private void rejiaofei_FormClosed(object sender, FormClosedEventArgs e){this.Owner.Show();}}}15、退房设计:namespace宾馆管理信息系统{public partial class unsubscribe : Form{private connection c = new connection();public unsubscribe(Form f){this.Owner = f;InitializeComponent();}private void button1_Click(object sender, EventArgs e){if (textBox1.Text.Trim().ToString() != string.Empty){var result = from info in c.linq.roomwhere info.房间号码==textBox1.Text.Trim().ToString()select new{房间号 = info.房间号码,房间类型 = info.房间种类,房间单价 = info.房间单价,房间是否使用 = info.房间是否正在使用,};if (result.Count() == 0){MessageBox.Show("请输入正确的房间号!");this.textBox1.Focus();}else if (result.Count() == 1){foreach (var item in result){if (item.房间是否使用.Trim() == "是"){DialogResult dr = MessageBox.Show("房间号:" + textBox1.Text.ToString() + "\r\n确认退房么?", "提示", MessageBoxButtons.OKCancel);if (dr == DialogResult.OK){var result1 = from info in c.linq.guestwhere info.房间号码 == textBox1.Text.Trim().ToString()select new{房间号 = info.房间号码,入住天数 = info.入住天数,所交押金 = info.所交押金,姓名 = info.姓名,};foreach (var item1 in result1){double i = item1.入住天数 * item.房间单价;double j = item1.所交押金 - i;MessageBox.Show("入住天数:" + item1.入住天数 + "\t\n总押金:" + item1.所交押金 + "\t\n消费金额:" + i + "应找回:" + j);var edit = c.linq.room.SingleOrDefault<room>(s1 => s1.房间号码 ==textBox1.Text.Trim().ToString());if (edit == null){return;}edit.房间是否正在使用 = "否";//执行更新操作var result2 = from m in c.linq.guestwhere m.房间号码 == textBox1.Text.Trim().ToString()select m;var result3 = from m in c.linq.exitroomwhere m.押金不足的房间号 == textBox1.Text.Trim().ToString()select m;c.linq.exitroom.DeleteAllOnSubmit(result3);c.linq.guest.DeleteAllOnSubmit(result2);c.linq.SubmitChanges();MessageBox.Show("房号为"+item1.房间号+"的"+item1 .姓名+"退房成功!");this.Close();}}}else{MessageBox.Show("该房间并未订购!无法退订!");}}}}else{MessageBox.Show("请输入房间号!");this.textBox1.Focus();}}}}16、修改用户密码:namespace宾馆管理信息系统{public partial class xiugaimima : Form{private connection c=new connection ();private string i;public xiugaimima(Form f,string i){this.Owner = f;this.i = i;InitializeComponent();}private void button1_Click(object sender, EventArgs e){if(textBox1.Text.Trim().ToString() != String.Empty && textBox2.Text.Trim().ToString() != String.Empty && textBox3.Text.Trim().ToString() != String.Empty){string id = null, pw = null, gd = null;var result = from info in c.linq.loginwhere info.id == this.iselect new{ID = info.id,pw = info.password,gd = info.grade,};foreach (var p in result){id = p.ID;pw = p.pw;gd = p.gd;}if (pw.Trim() == textBox1.Text.ToString().Trim()){if (textBox2.Text.Trim().ToString().Equals(textBox3.Text.Trim().ToString())){var edit = c.linq.login.SingleOrDefault<login>(s=>s.id==i);if (edit == null){return;}edit.password = textBox3.Text.Trim().ToString();//执行更新操作c.linq.SubmitChanges();MessageBox.Show("密码修改成功");this.Dispose();login1 l = new login1();l.Show();}}else{MessageBox.Show("密码错误!");}}else{MessageBox.Show("不能为空!");}}}}三、测试方案设计:1、测试数据房间信息:账户信息:住户信息:2、测试结果:测试次数结果登录响应时间(秒)1 登录成功0.52 登录成功0.43 登录成功0.6平均时间:0.5修改密码通过密保找回成功0.5重设密码验证密保并成功设置0.5平均时间:0.5四、测试结果分析:经过测试,数据在储存和使用过程中不会丢失,但是数据的安全性不是很高。