《HHL酒店管理系统》课程设计报告书V1.0 - 图文 联系客服

发布时间 : 星期二 文章《HHL酒店管理系统》课程设计报告书V1.0 - 图文更新完毕开始阅读59851230a32d7375a41780ae

6.2换房功能的实现

代码如下:

SqlConnection con = myCon.getCon();

if (textBox1.Text.Trim() == \ || textBox2.Text.Trim() == \) {

MessageBox.Show(\请输入客户名和房间号!\); } else {

con.Open();

string consql = \ + textBox1.Text.Trim() + \;

SqlCommand command = new SqlCommand(consql, con); int num = Convert.ToInt32(command.ExecuteScalar()); string Num = Convert.ToString(num); //MessageBox.Show(Num);

consql = \ + Num + \;

command = new SqlCommand(consql, con);

string state = (string)command.ExecuteScalar(); if (state != \已入住\) {

MessageBox.Show(\该客户已经退房,不能进行换房操作!\); } else {

consql = \ + textBox2.Text.Trim();

command = new SqlCommand(consql, con); state = (string)command.ExecuteScalar(); if (state != \空房\) {

MessageBox.Show(\该房间不能换!\); } else {

consql = \ + Num; command = new SqlCommand(consql, con);

string str = (string)command.ExecuteScalar(); ////MessageBox.Show(str);

consql = \ + str; command = new SqlCommand(consql, con); DateTime s1 =

- 21 -

Convert.ToDateTime(command.ExecuteScalar());

consql = \R_daoqitime from Room where R_ID=\ + str; command = new SqlCommand(consql, con); DateTime s2 =

Convert.ToDateTime(command.ExecuteScalar());

consql = \空房' where R_ID=\+str ;

command = new SqlCommand(consql, con); command.ExecuteNonQuery();

consql = \已入住', R_intime='\ + s1 + \ + s2 + \ + textBox2.Text.Trim(); command = new SqlCommand(consql, con); command.ExecuteNonQuery();

consql = \Customer set R_ID=\ + textBox2.Text.Trim() + \ + Num;

command = new SqlCommand(consql, con); command.ExecuteNonQuery();

StringBuilder sql = new StringBuilder();

sql.Append(\客户号 , C_name AS 客户名称, C_sex AS 性别, R_ID AS 房号, C_AllMoney AS 总费用, C_money AS 费用, C_Phone AS 联系电话, C_Cardid AS 身份证号, C_time AS 入住时间, C_daoqitime AS 退房时间, C_notes AS 备注 from Customer\);

SqlDataAdapter dapt = new SqlDataAdapter(sql.ToString(), con);

ds = new DataSet();

dapt.Fill(ds, \);

MessageBox.Show(\换房成功!\);

dataGridView1.DataSource = ds.Tables[0]; con.Close(); } }

- 22 -

运行结果: 换房前信息

由原来的202房换为108房

- 23 -

6.3续房功能的实现

代码如下:

SqlConnection con = myCon.getCon(); con.Open();

if (textBox1.Text.Trim() == \ || textBox2.Text.Trim() == \) {

MessageBox.Show(\请输入房间号和续房天数!\); } else {

string sql = \ + textBox1.Text.Trim(); try {

command = new SqlCommand(sql, con); //con.Open();

string state = (string)command.ExecuteScalar(); if (state == \已入住\) {

sql = \ + textBox1.Text.Trim();

command = new SqlCommand(sql, con); int day = (int)command.ExecuteScalar();

day = Convert.ToInt32(textBox2.Text.Trim()); //if(day>)

string d = Convert.ToString(day);

sql = \ + d + \ + textBox1.Text.Trim();

command = new SqlCommand(sql, con); command.ExecuteNonQuery(); MessageBox.Show(\续房成功!\);

sql = \房号,R_floor as 楼层,R_money as 房价,R_type as 房间类型,R_status as 房间状态,R_intime as 入住时间,R_daoqitime as 退房时间,R_notes as 备注 from Room\;

SqlDataAdapter dapt = new SqlDataAdapter(sql.ToString(), con);

ds = new DataSet(); dapt.Fill(ds, \);

- 24 -