//显示房子信息 private void ShowHouseInfo() { string Room_id; string name; string AdvanceForegift; HouseHelper hh = new HouseHelper(); DBHelper db = null; db = new DBHelper(); string sql = string.Format("select * from Guest,Room where State='{0}' and Guest.R_id = Room.R_id and faceDate ='{1}'", "待客", ""); SqlDataReader sdr = db.SelectAll(sql); while (sdr.Read()) { Room_id = hh.GetRoomId(sdr["R_id"].ToString()); name = sdr["Uname"].ToString(); AdvanceForegift = sdr["AdvanceForegift"].ToString(); ListViewItem lviDM = new ListViewItem(Room_id); lviDM.Tag = sdr["R_id"].ToString(); string[] str = { name, AdvanceForegift }; lviDM.SubItems.AddRange(str); lvDeposit.Items.Add(lviDM); } }
//显示可供房信息 private void ShowOldHouseOne() { cboGuest.Items.Clear(); HouseHelper hh = new HouseHelper(); DBHelper db = null; db = new DBHelper(); try { string sql = string.Format("select R_RoomId from Room where State='{0}'", "待客"); SqlDataReader sdr = db.SelectAll(sql); while (sdr.Read()) { cboGuest.Items.Add(sdr["R_RoomId"].ToString()); } sdr.Close(); db = new DBHelper(); sql = string.Format("select G_GuestId from Guest where R_id='{0}' and Fact='{1}'", hh.GetR_id(cboGuest.Text), ""); SqlDataReader sdr2 = db.SelectAll(sql);; if (sdr2.Read()) { guestIdTwo = sdr["G_GuestId"].ToString(); } sdr2.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { db.GetClose(); } }
//双击可供房间事件 private void lvHollowHouse_DoubleClick(object sender, EventArgs e) { if (lvHollowHouse.SelectedItems.Count >= 1) { //创建一个listView项 ListViewItem lviHouse = new ListViewItem(lvHollowHouse.SelectedItems[0].Text); lviHouse.Tag = lvHollowHouse.SelectedItems[0].Tag; lviHouse.SubItems[0].Tag = lvHollowHouse.SelectedItems[0].SubItems[0].Tag.ToString(); //判断是否是预订,如果是,则再判断是否在这个时间段 if (lvHollowHouse.SelectedItems[0].SubItems[0].Tag.ToString() == "预订") { HouseHelper hh = new HouseHelper(); if (hh.ValidateIsBook(lvHollowHouse.SelectedItems[0].Text, dtpComeDate.Text)) { } else { MessageBox.Show("此房间这个时间段,已经预订", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } //创建数组 将选中项的子项存在数中 string[] strTemp = { lvHollowHouse.SelectedItems[0].SubItems[1].Text, lvHollowHouse.SelectedItems[0].SubItems[2].Text }; //添加子项 lviHouse.SubItems.AddRange(strTemp); //添加到入住客房中 lvSelectHouse.Items.Add(lviHouse); //移出已经存在的 lvHollowHouse.Items.Remove(lvHollowHouse.SelectedItems[0]); } }
//填充数据 private void FillDate(string RoomId) { DBHelper db = null; try { db = new DBHelper(); string sql = string.Format("select * from Room where R_RoomId='{0}'", RoomId); SqlDataReader sdr = db.SelectAll(sql); string type; double price; if (sdr.Read()) { HouseHelper hh = new HouseHelper(); type = hh.GetHouseType(sdr["RoomType"].ToString()); price = Convert.ToDouble(sdr["price"]); ListViewItem lviHosue = new ListViewItem(RoomId); //if (sdr["State"].ToString()=="预订") //{ // if (hh.ValidateIsBook(tvHouse.SelectedNode.Text, dtpComeDate.Text)) // { // } // else // { // MessageBox.Show("此房间这个时间段,已经预订", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; // } //} string[] str = { type, price.ToString() }; lviHosue.Tag = tvHouse.SelectedNode.Tag; lviHosue.SubItems.AddRange(str); lvNeedHouse.Items.Add(lviHosue); txtMainHouse.Text = lvNeedHouse.Items[0].SubItems[0].Text; this.tvHouse.SelectedNode.Remove(); } sdr.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { db.GetClose(); } }
//显示服务 private void ShowServer(int type) { lvServer.Items.Clear(); string U_UsersId; string S_content; string State; string Date; string sql; DBHelper db = null; try { db = new DBHelper(); if (type == 0) { sql = string.Format("select * from Service"); } else { sql = string.Format("select * from Service where State='{0}'", cboLook.Text); } SqlDataReader sdr = db.SelectAll(sql); HouseHelper hh = new HouseHelper(); while (sdr.Read()) { U_UsersId = sdr["U_UsersId"].ToString(); S_content = sdr["S_content"].ToString(); State = sdr["State"].ToString(); Date = sdr["Date"].ToString(); ListViewItem lviServer = new ListViewItem(U_UsersId); lviServer.Tag = sdr["S_serviceId"].ToString(); string[] str = { S_content, State, Date }; lviServer.Tag = sdr["S_serviceId"].ToString(); lviServer.SubItems.AddRange(str); lvServer.Items.Add(lviServer); } sdr.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { db.GetClose(); } }
//写入商品消费表中 private void Consume() { string G_GuestId = ""; AutoId ai = new AutoId(); //自动生成id 辅助类 HouseHelper hh = new HouseHelper(); //辅助类 DBHelper db = null; //连数据库类 db = new DBHelper(); try { string sql; string C_ConsumeId; string R_id = hh.GetR_id(cboRoomId.Text); sql = string.Format("select G_GuestId from Guest where R_id='{0}' and faceDate='{1}'", R_id, ""); SqlDataReader sdr = db.SelectAll(sql); if (sdr.Read()) { G_GuestId = sdr["G_GuestId"].ToString(); } sdr.Close(); int rows = 0; //循环写入 for (int i = 0; i < lvSelect.Items.Count; i++) { C_ConsumeId = ai.GetId("C_ConsumeId", "Consume"); sql = string.Format("insert into Consume values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", C_ConsumeId, G_GuestId, lvSelect.Items[i].SubItems[0].Text, lvSelect.Items[i].SubItems[2].Text, lvSelect.Items[i].SubItems[3].Text, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "商品消费", UserHelper.LoginId, ""); //MessageBox.Show(sql); rows = db.UpdateDeleteAdd(sql); } if (rows > 0) { MessageBox.Show("消费成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("消费失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { db.GetClose(); } }
//显示价格等信息 private void ShowInfo(string room_id, int type) { string price = ""; DBHelper db = null; try { db = new DBHelper(); string sql = string.Format("select * from Room where R_RoomId='{0}'", room_id); SqlDataReader sdr = db.SelectAll(sql); if (sdr.Read()) { if (type == 0) { price = sdr["price"].ToString(); this.lblOldPrice.Text = price; } else { lblNewHouse.Text = sdr["price"].ToString(); } } sdr.Close(); HouseHelper hh = new HouseHelper(); string R_id = hh.GetR_id(room_id); sql = string.Format("select comeDate,G_GuestId from Guest where R_id='{0}' and faceDate='{1}'", R_id, ""); sdr = db.SelectAll(sql); if (sdr.Read()) { if (type == 0) { lblOldDate.Text = sdr["comeDate"].ToString(); lblOldDate.Tag = sdr["G_GuestId"].ToString(); } } sdr.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { db.GetClose(); } }
//显示可供房间信息 private void Showhollow(int type) { lvHollowHouse.Items.Clear(); string R_RoomId; string RoomTypeId; double price; DBHelper db = null; string sql = ""; try { db = new DBHelper(); type++; sql = string.Format("select * from Room where (State='{0}') and RoomType='{1}'", "空净", type); SqlDataReader sdr = db.SelectAll(sql); while (sdr.Read()) { R_RoomId = sdr["R_RoomId"].ToString(); RoomTypeId = sdr["RoomType"].ToString(); price = Convert.ToDouble(sdr["price"]); HouseHelper hh = new HouseHelper(); RoomTypeId = hh.GetHouseType(sdr["RoomType"].ToString()); ListViewItem lviHouse = new ListViewItem(R_RoomId); lviHouse.Tag = sdr["R_id"].ToString(); lviHouse.SubItems[0].Tag = sdr["State"].ToString();; string[] strHouse = { RoomTypeId, price.ToString() }; lviHouse.SubItems.AddRange(strHouse); lvHollowHouse.Items.Add(lviHouse); } sdr.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { db.GetClose(); } }
private void cboUnite_SelectedIndexChanged(object sender, EventArgs e) { DBHelper db = null; HouseHelper hh = new HouseHelper(); db = new DBHelper(); string sql = string.Format("select G_GuestId from Guest where R_id='{0}' and Fact='{1}'", hh.GetR_id(cboUnite.Text), ""); SqlDataReader sdr2 = db.SelectAll(sql); if (sdr2.Read()) { guestIdTwo = sdr2["G_GuestId"].ToString(); } sdr2.Close(); // MessageBox.Show(guestIdTwo); }
//显示信息 private void ShowHouseInfo() { lvHollowHouse.Items.Clear(); lvSelectHouse.Items.Clear(); string Room_id; string Type; string Price; HouseHelper hh = new HouseHelper(); DBHelper db = null; try { string sql = string.Format("select * from Room where State='{0}'", "空净"); db = new DBHelper(); SqlDataReader sdr = db.SelectAll(sql); while (sdr.Read()) { Room_id = sdr["R_RoomId"].ToString(); Type = hh.GetHouseType(sdr["RoomType"].ToString()); Price = sdr["price"].ToString(); ListViewItem lviHouse = new ListViewItem(Room_id); string[] str = { Type, Price }; lviHouse.SubItems.AddRange(str); lvHollowHouse.Items.Add(lviHouse); } sdr.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { db.GetClose(); } }
//入住酒店 private void House() { int count = lvSelectHouse.Items.Count; if (IsAwoke.foregiftSmall == "1") { double money = 0; for (int i = 0; i < count; i++) { money += Convert.ToDouble(lvSelectHouse.Items[i].SubItems[2].Text); } if (Convert.ToDouble(txtAdvanceForegift.Text) < money && txtCust.Text == "") { MessageBox.Show("押金小于房款!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); txtAdvanceForegift.Focus(); txtAdvanceForegift.SelectAll(); return; } } int rows = 0; for (int i = 0; i < count; i++) { AutoId auto = new AutoId(); string G_GuestId = auto.GetId("G_GuestId", "Guest"); //MessageBox.Show(G_GuestId); string Room_id = lvSelectHouse.Items[i].SubItems[0].Text; string R_id = lvSelectHouse.Items[i].Tag.ToString(); string uName = txtName.Text; string sex = ""; if (rdoMan.Checked) { sex = "男"; } else { sex = "女"; } string CertificateType = cboCertificate.Text; string CertificateID = txtCertificateId.Text; string CertificatePic = picName; string Address = txtAddress.Text; string contactTel = txtContactTel.Text; string Underwrite = ""; string comeDate = dtpComeDate.Text; string Bookleave = dtpBookleave.Text; string faceDate = ""; string R_price = lvSelectHouse.Items[i].SubItems[2].Text; string Due = ""; string Fact = ""; string locate = ""; string Operator = UserHelper.LoginId; string remark = txtRemark.Text; string U_UserId = txtCust.Text; string sql = string.Format("insert into Guest values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}')", G_GuestId, R_id, U_UserId, uName, sex, CertificateType, CertificateID, CertificatePic, Address, contactTel, 0, Underwrite, comeDate, Bookleave, faceDate, R_price, Due, Fact, locate, Operator, remark ); DBHelper db = null; try { db = new DBHelper(); rows = db.UpdateDeleteAdd(sql); sql = string.Format("update Room set State='{0}', R_Count = R_Count + '{2}' where R_id ='{1}'", "待客", R_id, 1); //MessageBox.Show(sql); int temp = db.UpdateDeleteAdd(sql); if (cboIsAwoke.Checked) { sql = string.Format("insert into Awoke values('{0}','{1}','{2}','{3}','{4}')", auto.GetId("A_AwokeId", "Awoke"), lvSelectHouse.Items[i].SubItems[0].Text + "号房到期", "未读", dtpBookleave.Text, txtRemark.Text ); db.UpdateDeleteAdd(sql); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { db.GetClose(); } } HouseHelper Uhh = new HouseHelper(); string URoom_id = lvSelectHouse.Items[0].SubItems[0].Text; string R_id2 = Uhh.GetR_id(lvSelectHouse.Items[0].Text); DBHelper Udb = null; string Usql = string.Format("update Guest set AdvanceForegift='{0}' where R_id='{1}'", txtAdvanceForegift.Text, R_id2); Udb = new DBHelper(); Udb.UpdateDeleteAdd(Usql); if (rows > 0) { MessageBox.Show("入住成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("入住失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
//导出excel private void tsbtnExcelHouse_Click(object sender, EventArgs e) { HouseHelper hh = new HouseHelper(); hh.getListView(this.lvHouse, "房源表"); }
//导出excel private void tsbtnExcelCust_Click(object sender, EventArgs e) { HouseHelper hh = new HouseHelper(); hh.getListView(this.lvAdmin, "管理员表"); }
//合并 private void Unite() { string roomId; string price; string G_GuestId; DBHelper db = null; HouseHelper hh = new HouseHelper(); AutoId ai = new AutoId(); //自动生成id类 db = new DBHelper(); string sql = ""; //大量申明 string U_UserId = ""; string Uname = ""; string Sex = ""; string CertificateType = ""; string CertificateID = ""; string CertificatePic = ""; string Address = ""; string contactTel = ""; string Underwrite = ""; string comeDate = ""; string Bookleave = ""; string faceDate = ""; string Due = ""; string Fact = ""; string locate = ""; string Operator = UserHelper.LoginId; string remark = ""; string R_id = hh.GetR_id(cboNewHouse.Text); MessageBox.Show(R_id); sql = string.Format("select * from Guest where R_id = '{0}' and faceDate = '{1}' ", R_id, ""); SqlDataReader sdr = db.SelectAll(sql); if (sdr.Read()) { U_UserId = sdr["U_UserId"].ToString(); Uname = sdr["Uname"].ToString(); Sex = sdr["Sex"].ToString(); CertificateType = sdr["CertificateType"].ToString(); CertificateID = sdr["CertificateID"].ToString(); CertificatePic = sdr["CertificatePic"].ToString(); Address = sdr["Address"].ToString(); contactTel = sdr["contactTel"].ToString(); Underwrite = sdr["Underwrite"].ToString(); comeDate = dtpComeDate.Text; Bookleave = dtpBookleave.Text; faceDate = ""; } sdr.Close(); int rows = 0; for (int i = 0; i < lvSelectHouse.Items.Count; i++) { G_GuestId = ai.GetId("G_GuestId", "Guest"); roomId = hh.GetR_id(lvSelectHouse.Items[i].SubItems[0].Text); price = lvSelectHouse.Items[i].SubItems[2].Text; //MessageBox.Show(Uname.ToString()); sql = string.Format("insert into Guest values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}')", G_GuestId, roomId, U_UserId, Uname, Sex, CertificateType, CertificateID, CertificatePic, Address, contactTel, txtAdvanceForegift.Text, Underwrite, comeDate, Bookleave, faceDate, price, Due, Fact, locate, Operator, remark ); rows = db.UpdateDeleteAdd(sql); sql = string.Format("update Room set State='{0}' where R_id='{1}'", "待客", hh.GetR_id(lvSelectHouse.Items[i].SubItems[0].Text)); db.UpdateDeleteAdd(sql); } if (rows > 0) { MessageBox.Show("合并成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("合并失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
//导出excel private void tsbtnExcelUnderwrite_Click(object sender, EventArgs e) { HouseHelper hh = new HouseHelper(); hh.getListView(lvUnderwrite, "签单详细表"); }
//OK按钮 private void btnTransact_Click(object sender, EventArgs e) { if (!ValidateInput()) { return; } if (lvNeedHouse.Items.Count <= 0) { MessageBox.Show("您没选任何房间!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } HouseHelper hh = new HouseHelper(); AutoId auto = new AutoId(); int count = lvNeedHouse.Items.Count; string room_id; string type; string r_type; double R_price; int rows = 0; DBHelper db = null; try { db = new DBHelper(); if (IsAwoke.foregiftSmall == "1") { double money = 0; for (int i = 0; i < count; i++) { money += Convert.ToDouble(lvNeedHouse.Items[i].SubItems[2].Text); } if (Convert.ToDouble(txtAdvanceForegift.Text) < money && txtCust.Text == "") { MessageBox.Show("押金小于房款!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } for (int i = 0; i < count; i++) { string G_GuestId = auto.GetId("G_GuestId", "Guest"); room_id = lvNeedHouse.Items[i].SubItems[0].Text; type = lvNeedHouse.Items[i].SubItems[1].Text; r_type = lvNeedHouse.Items[i].SubItems[2].Text; R_price = Convert.ToDouble(lvNeedHouse.Items[i].SubItems[2].Text); string R_id = hh.GetR_id(room_id); string cust = txtCust.Text; string Uname = txtName.Text; string sex = rdoMan.Checked ? "南" : "女"; string CertificateType = cboCertificate.Text; string CertificateID = txtCertificateId.Text; string Address = txtAddress.Text; string contactTel = txtContactTel.Text; string AdvanceForegift = txtAdvanceForegift.Text; string Underwrite = ""; string comeDate = dtpComeDate.Text; string Bookleave = dtpBookleave.Text; string faceDate = ""; string Due = ""; string Fact = ""; string locate = ""; string Operator = UserHelper.LoginId; string remark = txtRemark.Text; string sql = string.Format("insert into Guest values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}')", G_GuestId, R_id, cust, Uname, sex, CertificateType, CertificateID, picName, Address, contactTel, 0, Underwrite, comeDate, Bookleave, faceDate, R_price, Due, Fact, locate, Operator, remark ); rows = db.UpdateDeleteAdd(sql); sql = string.Format("update Room set State='{0}', R_Count = R_Count + '{2}' where R_id ='{1}'", "待客", R_id, 1); db.UpdateDeleteAdd(sql); if (cboIsAwoke.Checked) { sql = string.Format("insert into Awoke values('{0}','{1}','{2}','{3}','{4}')", auto.GetId("A_AwokeId", "Awoke"), lvNeedHouse.Items[i].SubItems[0].Text + "号房到期", "未读", dtpBookleave.Text, txtRemark.Text ); db.UpdateDeleteAdd(sql); } } HouseHelper Uhh = new HouseHelper(); string URoom_id = txtMainHouse.Text; string UR_id = lvNeedHouse.Items[0].Tag.ToString(); DBHelper Udb = null; string Usql = string.Format("update Guest set AdvanceForegift='{0}' where R_id='{1}'", txtAdvanceForegift.Text, UR_id); Udb = new DBHelper(); Udb.UpdateDeleteAdd(Usql); if (rows > 0) { MessageBox.Show("入住成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { db.GetClose(); } }
//导出excel private void tsbtnExcelLoginLog_Click(object sender, EventArgs e) { HouseHelper hh = new HouseHelper(); hh.getListView(lvLoginLog, "日志表"); }
//退房方法 private void ExitHouse() { //判断是否签单 if (!Underwrite && chkCust.Checked == false) { if (txtSpare.Text == "") { MessageBox.Show("金额不能为空!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //金额不足不能退房 if (Convert.ToDouble(txtSpare.Text) < 0) { MessageBox.Show("金额不足!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); txtPaicl.SelectAll(); txtPaicl.Focus(); return; } } if (chkCust.Checked == false) { if (cboUnderwrite.Text == "" && chkUnderwrite.Checked == true) { MessageBox.Show("签单单位不能为空!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } if (!isHaveMoney() && chkUnderwrite.Checked == false && chkCust.Checked == true) { MessageBox.Show("会员余额不足本次消费!请充值!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (chkCust.Checked == true && txtPass.Text == "") { txtPass.Focus(); return; } //辅助类实例化 HouseHelper hh = new HouseHelper(); int rows = 0; //受影响的行数 DBHelper db = null; db = new DBHelper(); string sql; //循环修改入住状态为空净 for (int i = 0; i < lvFitout.Items.Count; i++) { //获得房间的R_Id string R_id = lvFitout.Items[i].SubItems[0].Tag.ToString(); string time = DateTime.Now.ToString(); if (hh.IshaveBook(R_id)) { sql = string.Format("update Room set State ='{0}' where R_id='{1}'", "预订", R_id); } else { sql = string.Format("update Room set State ='{0}' where R_id='{1}'", "整理", R_id); } //return; rows = db.UpdateDeleteAdd(sql); sql = string.Format("update Guest set faceDate = '{0}' where R_id = '{1}' and (faceDate = '{2}' or faceDate is null)", time, R_id, ""); db.UpdateDeleteAdd(sql); if (!Underwrite) { //sql = string.Format("update Guest set Fact='{0}' where G_GuestId='{1}'", lblDeal.Text, lvFitout.Items[0].SubItems[0].Text); //MessageBox.Show(sql); //db.UpdateDeleteAdd(sql); if (i == 0) { AutoId ai = new AutoId(); string money = Convert.ToString(Convert.ToDouble(lblDeal.Text) * IsAwoke.discount); sql = string.Format("insert Consume values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", ai.GetId("C_ConsumeId", "Consume"), lvFitout.Items[0].SubItems[0].Text, "房间消费", money.ToString(), 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "1", UserHelper.LoginId, "" ); db.UpdateDeleteAdd(sql); } } else { AutoId ai = new AutoId(); string A_Id = ai.GetId("A_Id", "UnderwriteAnnal"); string Room_id = lvFitout.Items[i].SubItems[1].Text; string G_GuestId = lvFitout.Items[i].SubItems[0].Text; string Underwritestr = cboUnderwrite.Text; string U_money = lvFitout.Items[i].SubItems[7].Text; string State = "未付"; sql = string.Format("insert UnderwriteAnnal values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')", A_Id, Room_id, G_GuestId, Underwritestr, U_money, 0, 0, 0, State, Room_id + "号房费"); db.UpdateDeleteAdd(sql); if (i == 0) { sql = string.Format("update UnderwriteAnnal set U_money = U_money - '{0}' where G_GuestId='{1}'", Convert.ToDouble(lblYaJin.Text), G_GuestId); db.UpdateDeleteAdd(sql); } } } //如果是签单 if (Underwrite) { for (int i = 0; i < lvConsume.Items.Count; i++) { AutoId ai = new AutoId(); string A_Id = ai.GetId("A_Id", "UnderwriteAnnal"); string Room_id = lvFitout.Items[0].SubItems[1].Text; string G_GuestId = lvFitout.Items[0].SubItems[0].Text; string Underwritestr = cboUnderwrite.Text; string U_money = lvConsume.Items[i].SubItems[4].Text; string State = "未付"; string Remark = lvConsume.Items[i].SubItems[0].Text; sql = string.Format("insert UnderwriteAnnal values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')", A_Id, Room_id, G_GuestId, Underwritestr, U_money, 0, 0, 0, State, Remark); db.UpdateDeleteAdd(sql); } } //判断是否是会员 if (chkCust.Checked) { db = new DBHelper(); double score = Convert.ToDouble(lblDeal.Text) / 100; sql = string.Format("update Users set Score = Score + '{0}',U_money = U_money -'{1}' where U_UsersId='{2}' ", score, lblDeal.Text, lblU_UserId.Text); db.UpdateDeleteAdd(sql); } if (rows > 0) { MessageBox.Show("退房成功", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("退房失败", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
//导出excel private void tsmiExcel_Click(object sender, EventArgs e) { HouseHelper hh = new HouseHelper(); hh.getListView(this.lvConsole, "房源表信息"); }
//刷新 public void ShowHouseState(int type) { HouseHelper hh = new HouseHelper(); mf.lvConsole.Items.Clear(); string R_RoomId = ""; string RoomType = ""; string state = ""; string floot = ""; string Uname = ""; string AdvanceForegift = ""; string Underwrite = ""; string comeDate = ""; string Bookleave = ""; string R_price = ""; string Operator = ""; string remark = ""; string sql = ""; DBHelper db = null; try { if (type == 0) { sql = string.Format("select * from temp left join Book on temp.R_id=Book.R_id and Book.State !='解除预订'"); } else if (type >= 1 && type <= 7) { sql = string.Format("select * from temp left join Book on temp.R_id=Book.R_id where temp.RoomType={0}", type); } else { string tempType = ""; if (type == 8) { tempType = "空净"; } else if (type == 9) { tempType = "待客"; } else if (type == 10) { tempType = "预订"; } else if (type == 11) { tempType = "自用"; } else if (type == 12) { tempType = "整理"; } sql = string.Format("select * from temp left join Book on temp.R_id=Book.R_id where temp.state='{0}'", tempType); } db = new DBHelper(); SqlDataReader sdr = db.SelectAll(sql); while (sdr.Read()) { R_RoomId = sdr[1].ToString(); RoomType = hh.GetHouseType(sdr[5].ToString()); state = sdr[3].ToString(); floot = sdr[4].ToString(); Uname = sdr[9].ToString(); AdvanceForegift = sdr[10].ToString(); Underwrite = sdr[11].ToString(); comeDate = sdr[12].ToString(); Bookleave = sdr[13].ToString(); R_price = sdr[2].ToString(); Operator = sdr[15].ToString(); remark = sdr[16].ToString(); if (sdr[21].ToString() == "预订" || sdr[21].ToString() == "待客") { Uname = sdr[27].ToString(); //MessageBox.Show(Uname); AdvanceForegift = sdr[22].ToString(); Underwrite = sdr[23].ToString(); comeDate = sdr[24].ToString(); Bookleave = sdr[25].ToString(); Operator = sdr[26].ToString(); remark = sdr[33].ToString(); } if (state == "空净") { Uname = ""; AdvanceForegift = ""; comeDate = ""; Bookleave = ""; Operator = ""; remark = ""; } ListViewItem lviHouse = new ListViewItem(R_RoomId); lviHouse.Tag = sdr["G_GuestId"].ToString(); // MessageBox.Show(lviHouse.Tag.ToString()); string[] strRoom = { RoomType, state, floot, Uname, AdvanceForegift, Underwrite, comeDate, Bookleave, R_price, Operator, remark }; lviHouse.SubItems.AddRange(strRoom); mf.lvConsole.Items.Add(lviHouse); } sdr.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { db.GetClose(); } }