当前位置:首页 > 《HHL酒店管理系统》课程设计报告书V1.0 - 图文
string time = this.textBox1.Text.Trim(); string year = time.Substring(0, 4);
string sql = \R_ID as 房号,R_money as 房价,R_type as 房间类型,R_status as 房间状态,R_intime as 入住时间,R_daoqitime as 退房时间,R_notes as 备注from Room where year(R_daoqitime)='\ + year + \;
SqlDataAdapter dapt = new SqlDataAdapter(sql, con); dapt.Fill(dst, \);
dataGridView1.DataSource = dst.Tables[0];
float sun = 0;
for (int i = 0; i < dataGridView1.RowCount; i++) {
if (!dataGridView1.Rows[i].IsNewRow)
sun = sun + float.Parse(dataGridView1[1, i].Value.ToString()); }
label1.Text = \按年报表查询,总额为:\ + sun.ToString() + \元\;
con.Close(); } }
else {
MessageBox.Show(\格式不正确,请输入xxxx-xx-xx或输入xxxx-xx或输入xxxx\);
} }
- 33 -
运行结果:
查询2012-6-24的一天的营业额
6.6住宿记录查询功能的实现
代码如下:
SqlConnection con = myCon.getCon();
con.Open();
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, \);
dataGridView1.DataSource = ds.Tables[0];
con.Close();
- 34 -
运行结果:
6.7房间类型管理功能的实现
代码如下:
if (comboBox1.Text == \) {
MessageBox.Show(\请选择需要更改的房间类型!\); } else {
SqlConnection cnn = myCon.getCon(); cnn.Open();
string sql = \ +
comboBox1.SelectedItem.ToString() + \ + this.comboBox2.Text + \; SqlCommand cmd = new SqlCommand(sql, cnn); cmd.ExecuteNonQuery();
MessageBox.Show(\更新成功!\); }
- 35 -
运行结果: 更改前
更新后
6.8房间信息管理功能的实现
代码如下:
private void button1_Click(object sender, EventArgs e) {
SqlConnection cnn = myCon.getCon();
string sql = \R_ID from Room where R_ID='\ + this.textBox1.Text + \;
cnn.Open();
SqlCommand cmd = new SqlCommand(sql, cnn); string rt = (string)cmd.ExecuteScalar(); if (textBox1.Text == rt)
MessageBox.Show(\已存在房间号!\);
- 36 -
共分享92篇相关文档