七讲酒店客房管理系统三.ppt

上传人:本田雅阁 文档编号:2328070 上传时间:2019-03-22 格式:PPT 页数:19 大小:154.51KB
返回 下载 相关 举报
七讲酒店客房管理系统三.ppt_第1页
第1页 / 共19页
七讲酒店客房管理系统三.ppt_第2页
第2页 / 共19页
七讲酒店客房管理系统三.ppt_第3页
第3页 / 共19页
亲,该文档总共19页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《七讲酒店客房管理系统三.ppt》由会员分享,可在线阅读,更多相关《七讲酒店客房管理系统三.ppt(19页珍藏版)》请在三一文库上搜索。

1、第七讲 酒店客房管理系统(三),教育部“十二五”职业教育国家规划教材,Visual C#程序设计与软件项目实训电子工业出版社 郑伟 谭恒松 编著,ISBN:9787121246128,教材网站:http:/ void btnAdd_Click(object sender, EventArgs e) string sql ; string roomType=cboRoomType.Text; string roomNumber=txtRoomNumber.Text; float roomPrice=float.Parse(txtRoomPrice.Text); string remarks=tx

2、tRemarks.Text; int result; sql = “insert into RoomInfo(RoomNumber,RoomType,RoomPrice,Remarks) values( “ + roomNumber + “,“ + roomType + “,“ + roomPrice + “,“ + remarks + “)“;/定义插入语句,客房添加功能模块设计,if (txtRoomNumber.Text != “ ,客房添加功能模块设计,else MessageBox.Show(“客房添加失败!“, “错误提示“, MessageBoxButtons.OK, Messa

3、geBoxIcon.Error); else MessageBox.Show(“请检查数据输入的正确性!“, “错误提示“, MessageBoxButtons.OK, MessageBoxIcon.Information); ,客房添加功能模块设计,1已完成工作: (1)窗体控件属性设置; (2)客房信息的添加功能; (3)窗体的退出功能。 2待完善工作: (1)文本框的输入规范检查; (2)重复客房检查,即如果输入重复的客房号,代码如何修改?,客房管理模块设计,客房管理模块设计,(1)首先需要定义一个方法,用于将数据绑定到DataGridView控件,代码如下: public void D

4、ataBind()/定义一个函数用于绑定数据到DataGridView string sql = “select * from RoomInfo“; DataSet ds = DBHelper.GetDataSet(sql);/执行SQL语句,将结果存在ds中 dgvRoomInfo.DataSource = ds.Tables0;/将ds中的表作为DataGridView的数据源 ,客房管理模块设计,(1)首先需要定义一个方法,用于将数据绑定到DataGridView控件,代码如下: public void DataBind()/定义一个函数用于绑定数据到DataGridView strin

5、g sql = “select * from RoomInfo“; DataSet ds = DBHelper.GetDataSet(sql);/执行SQL语句,将结果存在ds中 dgvRoomInfo.DataSource = ds.Tables0;/将ds中的表作为DataGridView的数据源 ,客房管理模块设计,(2)登录窗体时,将数据绑定到DataGridView控件,代码如下: private void RoomManage_Load(object sender, EventArgs e) DataBind(); ,客房管理模块设计,(3)双击“修改”按钮,进入该按钮的单击事件,

6、编写代码如下: private void btnEdit_Click(object sender, EventArgs e) string sql;/定义一个变量用来输入修改语句,用于修改客房信息 string roomType = cboRoomType.Text; string roomNumber = txtRoomNumber.Text; float roomPrice = float.Parse(txtRoomPrice.Text); string remarks = txtRemarks.Text; int result;/定义修改语句执行后的影响行数,客房管理模块设计,sql =

7、 “update RoomInfo set RoomType=“ + roomType + “,RoomPrice=“ + roomPrice + “,Remarks=“ + remarks + “ where RoomNumber=“ + roomNumber + “; if (txtRoomNumber.Text != “ ,客房管理模块设计,else MessageBox.Show(“客房修改失败!“, “错误提示“, MessageBoxButtons.OK, MessageBoxIcon.Error); else MessageBox.Show(“请检查数据输入的正确性!“, “错误

8、提示“, MessageBoxButtons.OK, MessageBoxIcon.Information); ,客房管理模块设计,(4)双击“删除”按钮,进入该按钮的单击事件,编写代码如下: private void btnDel_Click(object sender, EventArgs e) string sql;/定义一个变量用来删除插入语句,用于删除客房信息 string RoomNumber = txtRoomNumber.Text; sql = “delete RoomInfo where RoomNumber=“ + RoomNumber + “; int result =

9、DBHelper.ExecuteSql(sql);/执行删除语句,返回影响行数,客房管理模块设计,if (result = 1)/根据返回影响行数判断是否删除数据成功 MessageBox.Show(“客房删除成功!“, “成功提示“, MessageBoxButtons.OK, MessageBoxIcon.Information); DataBind(); else MessageBox.Show(“客房删除失败!“, “错误提示“, MessageBoxButtons.OK, MessageBoxIcon.Error); ,客房管理模块设计,(5)需要选择dgvRoomInfo控件的内容

10、时,将数据填充到文本框中,编写代码如下: private void dgvRoomInfo_CellClick(object sender, DataGridViewCellEventArgs e) cboRoomType.Text = dgvRoomInfo.CurrentCell.OwningRow.Cells1.Value.ToString(); txtRoomNumber.Text = dgvRoomInfo.CurrentCell.OwningRow.Cells0.Value.ToString(); txtRoomPrice.Text = dgvRoomInfo.CurrentCell.OwningRow.Cells2.Value.ToString(); txtRemarks.Text = dgvRoomInfo.CurrentCell.OwningRow.Cells4.Value.ToString(); ,客房管理模块设计,待完善工作: (1)文本框的输入规范检查; (2)异常处理; (3)当没选中客房时,单击“删除”按钮,代码如何修改; (4)如果该客房已经入住客户,则不能删除客房信息,如何修改代码? (5)将DataGridView的列标题显示为中文,代码如何修改?,THANK YOU,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1