/// <summary> /// 预定取消按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Bt_due_to_cancellation_Click(object sender, RoutedEventArgs e) { if (operation == true) { MessageBox.Show("预定取消前请在已选房台中将目标房台移除", "大海提示", MessageBoxButton.OK, MessageBoxImage.Warning); Common.Clear(); GetData(); } if (Common.Equals(null)) { MessageBox.Show("请将房台移除后,再次预定取消", "大海提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } foreach (var item in Common) { //删除消费 CW_Consumption c = M.CW_Consumption.Where(m => m.ID_RoomStage == item.ID_RoomStage && m.Effective == true).Single(); M.CW_Consumption.Remove(c); M.SaveChanges(); //修改房间状态 SYS_RoomStage r = M.SYS_RoomStage.Where(m => m.ID_RoomStage == item.ID_RoomStage).Single(); r.State_RoomStage = "未用"; r.ID_Guest = null; M.Entry(r).State = System.Data.Entity.EntityState.Modified; M.SaveChanges(); } Common.Clear(); }
/// <summary> /// 房台id 获取 /// </summary> /// <returns></returns> private string Reture(string str, int id) { string room = string.Empty; foreach (var item in RightOc) { room += item.ID_RoomStage + ","; if (id >= 0) { if (Cb_add.IsChecked == true) { //添加消费 CW_Consumption c = new CW_Consumption(); c.ID_RoomStage = item.ID_RoomStage; c.Discount = Convert.ToDecimal(str); c.Effective = true; M.CW_Consumption.Add(c); M.SaveChanges(); } //修改选择房台信息 SYS_RoomStage r = M.SYS_RoomStage.Where(s => s.ID_RoomStage == item.ID_RoomStage).Single(); r.State_RoomStage = "预定"; r.ID_Guest = id; M.Entry(r).State = System.Data.Entity.EntityState.Modified; M.SaveChanges(); } } return(room); }
/// <summary> /// 确定按钮 /// </summary> private void confirm() { if (Tb_Room_table_number.Text.Trim() == string.Empty || Tb_Room_table_name.Text.Trim() == string.Empty || Tb_floor.Text.Trim() == string.Empty || Cb_real_estate.Text.Trim() == string.Empty) { Tools.Common_means.is_null(); return; } SYS_RoomStage rs = new SYS_RoomStage(); rs.MC_RoomStage = Tb_Room_table_name.Text.Trim(); rs.Number_RoomStage = Tb_Room_table_number.Text.Trim(); try { rs.floor = int.Parse(Tb_floor.Text.Trim()); } catch (Exception) { MessageBox.Show("楼层内容只能是数字", "大海提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } string id = Cb_real_estate.Text.Trim(); rs.ID_room_type = m.SYS_Room_status_type.Where(c => c.name_room_status_type == id).Single().ID_room_status_type; rs.State_RoomStage = "未用"; rs.ID_Class = 3; m.SYS_RoomStage.Add(rs); if (m.SaveChanges() > 0) { Tools.Common_means.operate_successfully("房台添加"); btq(); } }
/// <summary> /// 获取目标数据 /// </summary> /// <param name="id"></param>m /// <returns></returns> public SYS_RoomStage GetRoomStageID(int id) { SYS_RoomStage sYS_Room = (from tb in m.SYS_RoomStage where tb.ID_RoomStage == id select tb).Single(); ID_RoomStage = sYS_Room.ID_RoomStage; return sYS_Room; }
/// <summary> /// 加预定台按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Bt_add_scheduled_station_Click(object sender, RoutedEventArgs e) { if (!CbZhanghao.Text.Equals(null) && !Tb_odd.Text.Equals(null) && !TbDevelopmentTime.Text.Equals(null) && !Tb_vip_account.Text.Equals(null) && !Tb_number_of_people.Text.Equals(null) && !Tb_discount.Text.Equals(null) && !Tb_remark.Text.Equals(null)) { if (operation == false) { MessageBox.Show("加预定台前请在可选房台中选取目标房台添加到已选房台中", "大海提示", MessageBoxButton.OK, MessageBoxImage.Warning); Common.Clear(); GetData(); } string vip_account = Tb_vip_account.Text.Trim(); user_id = M.VIP_Table.Where(t => t.Accounts == vip_account).FirstOrDefault().ID_Guest; string discount = Tb_discount.Text.Trim(); string house_id = String.Empty;//房台id //要加的 foreach (var item in Common) { if (Cb_add.IsChecked == true) { //添加消费 CW_Consumption c = new CW_Consumption(); c.ID_RoomStage = item.ID_RoomStage; c.Discount = Convert.ToDecimal(discount); c.Effective = true; M.CW_Consumption.Add(c); M.SaveChanges(); } //修改选择房台状态 SYS_RoomStage r = M.SYS_RoomStage.Where(s => s.ID_RoomStage == item.ID_RoomStage).Single(); r.State_RoomStage = "预定"; r.ID_Guest = user_id; M.Entry(r).State = System.Data.Entity.EntityState.Modified; M.SaveChanges(); house_id += item.ID_RoomStage + ","; } YW_OpenStage o = M.YW_OpenStage.Where(w => w.GuestID == user_id).Single(); o.HouseStageID = house_id; M.Entry(o).State = System.Data.Entity.EntityState.Modified; if (M.SaveChanges() > 0) { MessageBox.Show("房台预加成功", "大海提示", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("请将信息填写完整", "大海提示", MessageBoxButton.OK, MessageBoxImage.Information); } }
/// <summary> /// 删除房台信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtDeleteRooms_Click(object sender, RoutedEventArgs e) { if (LRS.Count == 1) { int Room_id = LRS[0].ID_RoomStage; SYS_RoomStage sr = m.SYS_RoomStage.Where(p => p.ID_RoomStage == Room_id).SingleOrDefault(); m.SYS_RoomStage.Remove(sr); // m.SaveChanges(); m.Entry(sr).State = System.Data.Entity.EntityState.Modified; if (m.SaveChanges() > 0) { MessageBox.Show("房台删除成功!", "大海提示", MessageBoxButton.OK, MessageBoxImage.Asterisk); Push(); } } }
/// <summary> /// 预定取消 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtDueToCancellation_Click(object sender, RoutedEventArgs e) { //获取单号 string odd = TbOddNumbers.Text.ToString(); //房台id集合 string ftid = m.YW_Subscribe.Where(p => p.Number_Subscribe == odd).Single().HouseStageID; List<string> vs = ftid.Split(',').ToList(); foreach (var item in vs) { SYS_RoomStage SRS = m.SYS_RoomStage.Where(p => p.ID_RoomStage.ToString().Trim() == item.Trim()).SingleOrDefault(); SRS.ID_Guest = null; SRS.State_RoomStage = "未用"; } YW_Subscribe YWS = m.YW_Subscribe.Where(p => p.Number_Subscribe == odd).SingleOrDefault(); m.YW_Subscribe.Remove(YWS); if (m.SaveChanges()>0) { MessageBox.Show("预定取消成功!","大海提示",MessageBoxButton.OKCancel,MessageBoxImage.Asterisk); } }
/// <summary> /// 保存 /// </summary> public void Save() { string _name = String.Empty; if (!Integrity()) { return; } if (base_names == "Bt_the_guest_book") { _name = "预定"; //修改房台状态 SYS_RoomStage sr = m.SYS_RoomStage.Where(c => c.ID_RoomStage == ID_RoomStage).SingleOrDefault(); sr.State_RoomStage = "预定"; sr.ID_Guest = ID_Guest; sr.ID_room_type = int.Parse(ck_tag); m.Entry(sr).State = System.Data.Entity.EntityState.Modified; //添加预定信息 YW_Subscribe sb = new YW_Subscribe(); sb.ID_Guest = ID_Guest; sb.ID_VIP = ID_VIP; sb.ID_AgreementUser = ID_AgreementUser; sb.Number_Subscribe = Tb_Deposit_receipt_no.Text.Trim().ToString(); sb.Time_Predict = DateTime.Parse(Dp_the_date_of_arrival.Text.Trim()); sb.Time_Leave = DateTime.Parse(Dp_departure_time.Text.Trim()); sb.Number_People = int.Parse(Tb_number_of_people.Text.Trim()); sb.Money_Pledge = decimal.Parse(Tb_The_first_deposit.Text.Trim()); sb.State_Secrecy = true; sb.Remark = Tb_note.Text.Trim(); sb.Type_CheckIn = ck_tag; string _ID_houseID = string.Empty; foreach (var item in right) { _ID_houseID += item.ID_RoomStage + ","; } sb.HouseStageID = _ID_houseID; m.YW_Subscribe.Add(sb); m.SaveChanges(); int _IDsub = m.YW_Subscribe.Where(c => c.Number_Subscribe == sb.Number_Subscribe && c.State_Secrecy == true).Single().ID_Subscribe; //添加账单信息 预定押金的 CW_Bill cb = new CW_Bill(); cb.Price = decimal.Parse(Tb_The_first_deposit.Text.Trim()); cb.SuOp_ID = _IDsub; cb.Number_Bill = Tb_Deposit_receipt_no.Text.Trim(); cb.State_Bill = "未结账"; m.CW_Bill.Add(cb); m.SaveChanges(); int _IDbill = m.CW_Bill.Where(c => c.Number_Bill == cb.Number_Bill).Single().ID_Bill; //添加消费记录 CW_Consumption cp = new CW_Consumption(); cp.ID_Bill = _IDbill; cp.ID_RoomStage = ID_RoomStage; cp.ID_ProjectDetail = 0; cp.Prict = decimal.Parse(Tb_The_first_deposit.Text.Trim()); cp.Discount = 1; cp.Effective = true; m.CW_Consumption.Add(cp); } //房台登记 if (base_names == "Bt_The_guest_registration") { _name = "登记"; SYS_RoomStage sr = m.SYS_RoomStage.Where(c => c.ID_RoomStage == ID_RoomStage).SingleOrDefault(); //有预定的情况 if (sr.State_RoomStage.Trim() == "未用") { //添加账单信息 预定押金的 CW_Bill cb = new CW_Bill(); cb.Price = decimal.Parse(Tb_The_first_deposit.Text.Trim()); cb.SuOp_ID = 0; cb.Number_Bill = Tb_Deposit_receipt_no.Text.Trim(); cb.State_Bill = "未结账"; m.CW_Bill.Add(cb); m.SaveChanges(); int _IDbill = m.CW_Bill.Where(c => c.Number_Bill == cb.Number_Bill).Single().ID_Bill; //添加消费记录 CW_Consumption cp = new CW_Consumption(); cp.ID_Bill = _IDbill; cp.ID_RoomStage = ID_RoomStage; cp.ID_ProjectDetail = 0; cp.Prict = decimal.Parse(Tb_The_first_deposit.Text.Trim()); cp.Discount = 1; cp.Effective = true; m.CW_Consumption.Add(cp); } //修改房台状态 sr.State_RoomStage = "已用"; sr.ID_Guest = ID_Guest; sr.ID_room_type = int.Parse(ck_tag); m.Entry(sr).State = System.Data.Entity.EntityState.Modified; YW_OpenStage os = new YW_OpenStage(); os.ID_VIP = ID_VIP; os.ID_AgreementUser = m.AG_AgreementUser.Where(c => c.MC_AgreementUser == Cb_bargaining_unit_l.Text.Trim()).Single().ID_AgreementUser; os.Number_OpenStage = Tb_Deposit_receipt_no.Text.Trim().ToString(); os.Time_Predict = DateTime.Parse(Dp_the_date_of_arrival.Text.Trim()); os.Time_Leave = DateTime.Parse(Dp_departure_time.Text.Trim()); os.Number_People = int.Parse(Tb_number_of_people.Text.Trim()); os.Money_Pledge = decimal.Parse(Tb_The_first_deposit.Text.Trim()); os.State_Secrecy = true; os.Remark = Tb_note.Text.Trim(); os.Type_CheckIn = ck_tag; os.Content_Message = Tb_note.Text.Trim(); string _ID_houseID = string.Empty; foreach (var item in right) { _ID_houseID += item.ID_RoomStage + ","; } os.HouseStageID = _ID_houseID; m.YW_OpenStage.Add(os); } //客人续住 if (base_names == "Bt_guest_delay") { _name = "续住登记"; YW_OpenStage os = m.YW_OpenStage.Where(c => c.Number_OpenStage.Trim() == Tb_Deposit_receipt_no.Text.Trim()).SingleOrDefault(); os.Time_Leave = Dp_departure_time.SelectedDate.Value; m.Entry(os).State = System.Data.Entity.EntityState.Modified; } if (m.SaveChanges() > 0) { MessageBoxResult result = MessageBox.Show("房台" + _name + "成功", "大海提示", MessageBoxButton.OK, MessageBoxImage.Warning); if (result == MessageBoxResult.OK) { this.Close(); refresh(); } } }
/// <summary> /// 人民币结账 /// </summary> private void RMB_settlement() { try { if (!Tools.Tools.IsInteger(Tb_balance.Text)) { MessageBox.Show("请输入正确的数据类型", "大海提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } //钱够的情况 if (Tb_balance.Text != string.Empty) { //添加消费记录 CW_PayRecord c = new CW_PayRecord(); c.ID_Guest = ID_Guest; c.ID_Bill = ID_Bill; c.Price_Pay = decimal.Parse(Tb_guests_pay.Text.Trim()); c.Time_Pay = DateTime.Now.Date; c.PoP = Cb_payment_method.IsEnabled is false ?"人民币": Cb_payment_method.Text.Trim().ToString(); var co = m.CW_ConsumeDetail.Where(cc => cc.ID_Consumption == ID_Consumption && cc.State_ComsumeDetail == true).ToList(); foreach (var item in co) { //修改该消费记录状态 CW_ConsumeDetail cd = m.CW_ConsumeDetail.Where(cc => cc.ID_ComsumeDetail == item.ID_ComsumeDetail && cc.State_ComsumeDetail == true).SingleOrDefault(); cd.State_ComsumeDetail = false; m.Entry(cd).State = System.Data.Entity.EntityState.Modified; } //注销本次消费 CW_Consumption cp = m.CW_Consumption.Where(cc => cc.ID_Consumption == ID_Consumption && cc.Effective == true).Single(); cp.Effective = false; m.Entry(cp).State = System.Data.Entity.EntityState.Modified; CW_Bill cb = m.CW_Bill.Where(cc => cc.ID_Bill == ID_Bill && cc.State_Bill == null).Single(); cb.Time_PayBill = DateTime.Parse(Tb_The_check_time.Text.Trim()); cb.Remark = Tb_comment.Text.Trim().ToString(); cb.Price = decimal.Parse(Tb_guests_pay.Text.Trim()); cb.State_Bill = "已结账"; m.Entry(cb).State = System.Data.Entity.EntityState.Modified; SYS_RoomStage sr = m.SYS_RoomStage.Where(cc => cc.ID_RoomStage == ID_RoomStage && cc.ID_Guest == ID_Guest).Single(); sr.ID_Guest = null; sr.State_RoomStage = "未用"; m.Entry(sr).State = System.Data.Entity.EntityState.Modified; if (m.SaveChanges() > 0) { MessageBox.Show("结账成功", "大海提示", MessageBoxButton.OK, MessageBoxImage.Warning); } } else //当钱不够时 if (Tb_to_pay_the_balance.Text != string.Empty) { //添加消费记录 CW_PayRecord c = new CW_PayRecord(); c.ID_Guest = ID_Guest; c.ID_Bill = ID_Bill; c.Price_Pay = decimal.Parse(Tb_guests_pay.Text.Trim()); c.Time_Pay = DateTime.Now.Date; c.PoP = Cb_payment_method.IsEnabled is false ? "人民币" : Cb_payment_method.Text.Trim().ToString(); m.SaveChanges(); //修改本次消费 CW_Consumption cp = m.CW_Consumption.Where(cc => cc.ID_Consumption == ID_Consumption && cc.Effective == true).Single(); cp.Prict = decimal.Parse(Tb_to_pay_the_balance.Text.Trim()); m.Entry(cp).State = System.Data.Entity.EntityState.Modified; CW_Bill cb = m.CW_Bill.Where(cc => cc.ID_Bill == ID_Bill && cc.State_Bill == null).Single(); cb.Time_PayBill = DateTime.Parse(Tb_The_check_time.Text.Trim()); cb.Remark = Tb_comment.Text.Trim().ToString(); cb.Price = decimal.Parse(Tb_guests_pay.Text.Trim()); m.Entry(cb).State = System.Data.Entity.EntityState.Modified; if (m.SaveChanges() > 0) { MessageBox.Show("部分结账成功", "大海提示", MessageBoxButton.OK, MessageBoxImage.Warning); } } } catch (Exception e) { WPF_MvvMTest.Tools.Common_means.error_log(e); } }
/// <summary> /// 添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtAdd_Click(object sender, RoutedEventArgs e) { // 预约单号 //获取选中行 if (RsLeft ==null ||RsLeft.Count ==0) { RsLeft = STATIC_cache.StaticRoomStages; //STATIC_cache.StaticRoomStages.Clear(); } if (string.IsNullOrEmpty(zhanghao))//客户帐号 { MessageBox.Show("请选中客户信息","大海提示",MessageBoxButton.OK,MessageBoxImage.Asterisk); return; } var id = (from tv in m.VIP_Table join ty in m.YW_Subscribe on tv.ID_Guest equals ty.ID_Guest where tv.Accounts.Trim() == zhanghao.Trim() select new { ty.ID_Guest, ty.ID_Subscribe }).SingleOrDefault(); //没有对应的预约单就添加 if (id ==null) { string count = "YYD0" + (m.YW_Subscribe.ToList().Count + 1);//获取 预约单条数 EntityVo.STATIC_cache.Number_Subscribe = count; TbOddNumbers.Text = count.Trim(); YW_Subscribe s = new YW_Subscribe(); s.ID_Guest = m.VIP_Table.Where(p => p.Accounts.Trim() == zhanghao).Single().ID_Guest;//客人id s.ID_VIP = m.VIP_Table.Where(p => p.Accounts.Trim() == zhanghao).Single().ID_VIP;//vipid s.HouseStageID = "";//房台id s.Number_Subscribe = count;//单号 s.Remark = "我是黑大帅"; s.Type_CheckIn = "足浴"; m.YW_Subscribe.Add(s); s.State_Secrecy = true; m.SaveChanges(); } id = (from tv in m.VIP_Table join ty in m.YW_Subscribe on tv.ID_Guest equals ty.ID_Guest where tv.Accounts.Trim() == zhanghao.Trim() select new { ty.ID_Guest, ty.ID_Subscribe }).SingleOrDefault(); //roomStage.ID_RoomStage; // dgdt.ItemsSource[roomStage.ID_RoomStage]. //id.ID_Subscribe ///不知道为啥会报错 try { int id_sbb = id.ID_Subscribe; } catch (Exception) { return; } string strHouseStageID = m.YW_Subscribe.Where(p => p.ID_Subscribe == id.ID_Subscribe).SingleOrDefault().HouseStageID; if (RsLeft[0].ID_RoomStage.ToString().Trim() == strHouseStageID) { strHouseStageID = null; } YW_Subscribe y = m.YW_Subscribe.Where(p => p.ID_Subscribe == id.ID_Subscribe).SingleOrDefault(); y.HouseStageID = strHouseStageID + RsLeft[0].ID_RoomStage.ToString().Trim() + ","; m.Entry(y).State = System.Data.Entity.EntityState.Modified; m.SaveChanges(); int getIDR = RsLeft[0].ID_RoomStage; int krid= m.YW_Subscribe.Where(p => p.ID_Subscribe == id.ID_Subscribe).SingleOrDefault().ID_Guest; SYS_RoomStage o = m.SYS_RoomStage.Where(p => p.ID_RoomStage == getIDR).SingleOrDefault(); o.ID_Guest = krid; o.State_RoomStage = "预定"; //获取已修改的房台数据 List<RoomStage> rooms = (from tb in m.SYS_RoomStage where tb.ID_RoomStage == getIDR select new RoomStage { ID_RoomStage = tb.ID_RoomStage, Number_RoomStage = tb.Number_RoomStage,//房号 MC_RoomStage = tb.MC_RoomStage, //State_RoomStage = tb.State_RoomStage == "已用" ? "" : "否" }).ToList() ; if (m.SaveChanges()>0) { MessageBoxResult messageBoxResult = MessageBox.Show("添加成功!","大海提示",MessageBoxButton.OK,MessageBoxImage.Asterisk); if (messageBoxResult ==MessageBoxResult.OK) { // YYid Yydid = m.YW_Subscribe.Where(p => p.Number_Subscribe.Trim() == EntityVo.STATIC_cache.Number_Subscribe.Trim()).SingleOrDefault().ID_Subscribe; //右边表格刷新 EntityVo.STATIC_cache.Number_Subscribe View.Windows.W_UC.W_RoomTableDataGridRight w_RoomTableDataGridRight = new W_UC.W_RoomTableDataGridRight(Yydid,0,0); heeh.Content = null; heeh.Content = w_RoomTableDataGridRight; w_RoomTableDataGridRight.UserControl_Loaded(null, null); //左边表格刷新 View.Windows.W_UC.W_RoomTableDastaGridLeft w_RoomTableDataGridLeft = new W_UC.W_RoomTableDastaGridLeft(rooms); kexuanfangtai.Content = null; kexuanfangtai.Content = w_RoomTableDataGridLeft; w_RoomTableDataGridLeft.UserControl_Loaded(null,null); } } RsLeft.Clear(); }
/// <summary> /// 移除按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Remove_Click(object sender, RoutedEventArgs e) { //目标数据 string ycft = (m.YW_OpenStage.Where(p => p.ID_VIP == (m.VIP_Table.Where(q => q.Accounts.Trim().ToString() == zhanghao).FirstOrDefault().ID_VIP)).Single().HouseStageID); if (RsRight == null || RsRight.Count == 0) { RsRight = STATIC_cache.StaticRoomStages; } //预定房台.Except(RsRight[0].ID_RoomStage); //分割字符 List <string> vs = ycft.Split(',').ToList(); List <string> s = vs; //移出房台id string RRIDR = RsRight[0].ID_RoomStage.ToString(); for (int i = 0; i < vs.Count; i++) { if (vs[i] == "") { vs.RemoveAt(i); break; } if (vs[i] == RRIDR) { vs.RemoveAt(i); break; } } //剩下的房台id string ycftid = ""; foreach (var item in vs) { if (item == "") { break; } else { ycftid += item + ","; } } //目标订单id int ktid = m.YW_OpenStage.Where(p => p.ID_VIP == (m.VIP_Table.Where(o => o.Accounts.Trim() == zhanghao.Trim()).FirstOrDefault().ID_VIP)).Single().ID_OpenStage; YW_OpenStage Yos = m.YW_OpenStage.Where(p => p.ID_OpenStage == ktid).Single(); Yos.HouseStageID = ycftid; m.Entry(Yos).State = System.Data.Entity.EntityState.Modified; m.SaveChanges(); int Id_RoomStage = RsRight[0].ID_RoomStage; SYS_RoomStage RS = m.SYS_RoomStage.Where(p => p.ID_RoomStage == Id_RoomStage).Single(); RS.ID_Guest = null; RS.State_RoomStage = "未用"; m.Entry(RS).State = System.Data.Entity.EntityState.Modified; //获取已修改的房台数据 List <RoomStage> rooms = (from tb in m.SYS_RoomStage where tb.ID_RoomStage == Id_RoomStage select new RoomStage { ID_RoomStage = tb.ID_RoomStage, Number_RoomStage = tb.Number_RoomStage, //房号 MC_RoomStage = tb.MC_RoomStage, //State_RoomStage = tb.State_RoomStage == "已用" ? "" : "否" }).ToList(); if (m.SaveChanges() > 0) { //右边表格刷新 View.Windows.W_UC.W_RoomTableDataGridRight w_RoomTableDataGridRight = new W_UC.W_RoomTableDataGridRight(0, RsRight[0].ID_RoomStage, 0); heeh.Content = null; heeh.Content = w_RoomTableDataGridRight; w_RoomTableDataGridRight.UserControl_Loaded(null, null); //左边表格刷新 View.Windows.W_UC.W_RoomTableDastaGridLeft w_RoomTableDataGridLeft = new W_UC.W_RoomTableDastaGridLeft(rooms); kexuanfangtai.Content = null; kexuanfangtai.Content = w_RoomTableDataGridLeft; w_RoomTableDataGridLeft.UserControl_Loaded(null, null); } RsRight.Clear(); }
/// <summary> /// 添加按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtAdd_Click(object sender, RoutedEventArgs e) { //获取选中行 if (RsLeft == null || RsLeft.Count == 0) { RsLeft = STATIC_cache.StaticRoomStages; //STATIC_cache.StaticRoomStages.Clear(); } if (RsLeft == null || RsLeft.Count == 0) { MessageBox.Show("请选择需要添加的房台", "大海提示", MessageBoxButton.OK, MessageBoxImage.Asterisk); return; } string tbAccounts = TbAccounts.Text.Trim(); if (string.IsNullOrEmpty(tbAccounts)) { MessageBox.Show("请选择客人信息", "大海提示", MessageBoxButton.OK, MessageBoxImage.Asterisk); return; } else { //获取账号信息 zhanghao = m.VIP_Table.Where(p => p.ID_Guest == (m.SYS_Guest.Where(g => g.MC_Guest == tbAccounts).FirstOrDefault().ID_Guest)).FirstOrDefault().Accounts; } //会员id vip_id = m.VIP_Table.Where(p => p.Accounts == zhanghao).SingleOrDefault().ID_VIP; //客人id int krid = m.VIP_Table.Where(p => p.ID_VIP == vip_id).SingleOrDefault().ID_Guest; ////查看预约表中是否存在对应会员 p.State_Secrecy ==true 标志是否有效 int Sub = m.YW_Subscribe.Where(p => p.ID_VIP == vip_id && p.State_Secrecy == true).Count(); int Os_id = 0; int id_; int isOp = 0; List <RoomStage> _Rooms = rS; // 查询开台表信息 var id = (from tv in m.VIP_Table join to in m.YW_OpenStage on tv.ID_VIP equals to.ID_VIP where tv.Accounts.Trim() == zhanghao && to.State_Message == true select new { tv.ID_VIP, }).SingleOrDefault(); if (id != null) { id_ = id.ID_VIP; isOp = m.YW_OpenStage.Where(l => l.ID_VIP == id_ && l.State_Message == true).FirstOrDefault().ID_OpenStage; } //预约表中有对应的数据数据 if (Sub > 0) { string Sub_room_id = m.YW_Subscribe.Where(p => p.ID_VIP == vip_id && p.State_Secrecy == true).FirstOrDefault().HouseStageID; //开台表 YW_OpenStage oS = new YW_OpenStage(); oS.ID_VIP = vip_id; //oS.Number_People = Convert.ToInt32(TbPopulation.Text); oS.Remark = TbRemark.Text.ToString(); oS.HouseStageID = Sub_room_id.Trim(); oS.Type_CheckIn = "足浴"; oS.Remark = "鬼知道你备注什么"; oS.Content_Message = "谁设计的奇葩"; oS.Time_Predict = DateTime.Now; oS.State_Message = true; oS.GuestID = krid; m.YW_OpenStage.Add(oS); m.SaveChanges(); //查询新增的开台表id Os_id = m.YW_OpenStage.Where(p => p.ID_VIP == vip_id && p.State_Message == true).FirstOrDefault().ID_OpenStage; //改变预定表数据的有效性 YW_Subscribe yws = m.YW_Subscribe.Where(p => p.ID_VIP == vip_id && p.State_Secrecy == true).SingleOrDefault(); yws.State_Secrecy = false; m.Entry(yws).State = System.Data.Entity.EntityState.Modified; m.SaveChanges(); //改变房台状态 _Rooms.Clear(); List <string> vs = Sub_room_id.Split(',').ToList(); for (int i = 0; i < vs.Count; i++) { int vsid = 0; if (vs[i] == "") { vs.Remove(vs[i]); } else { try { vsid = Convert.ToInt32(vs[i]); } catch (Exception) { continue; } } // 改变房台状态 SYS_RoomStage sRs = m.SYS_RoomStage.Where(p => p.ID_RoomStage == vsid).SingleOrDefault(); sRs.ID_Guest = krid; sRs.State_RoomStage = "已用"; m.Entry(sRs).State = System.Data.Entity.EntityState.Modified; m.SaveChanges(); _Rooms.AddRange(from tb in m.SYS_RoomStage where tb.ID_RoomStage == vsid select new RoomStage { Number_RoomStage = tb.Number_RoomStage, MC_RoomStage = tb.MC_RoomStage, State_RoomStage = tb.State_RoomStage, Describe = tb.Describe, JionSign = (int)tb.JionSign, }); } } //如果开台表已存在开台表就只做修改 else if (isOp > 0) { YW_OpenStage os = m.YW_OpenStage.Where(p => p.ID_OpenStage == isOp).SingleOrDefault(); os.HouseStageID = os.HouseStageID + RsLeft[0].ID_RoomStage + ","; m.Entry(os).State = System.Data.Entity.EntityState.Modified; m.SaveChanges(); int room_id = RsLeft[0].ID_RoomStage; SYS_RoomStage rs = m.SYS_RoomStage.Where(p => p.ID_RoomStage == room_id).SingleOrDefault(); rs.State_RoomStage = "已用"; rs.ID_Guest = krid; m.Entry(rs).State = System.Data.Entity.EntityState.Modified; m.SaveChanges(); Os_id = isOp; } //假如没有就直接新增 else if (Sub == 0) { //根据会员 id 找到客人id int Guest_id = m.SYS_Guest.Where(p => p.ID_Guest == (m.VIP_Table.Where(v => v.ID_VIP == vip_id).FirstOrDefault().ID_Guest)).SingleOrDefault().ID_Guest; //房台状态 int id_Rs = rS[0].ID_RoomStage; SYS_RoomStage Sr = m.SYS_RoomStage.Where(p => p.ID_RoomStage == id_Rs).Single(); Sr.ID_Guest = krid; Sr.State_RoomStage = "已用"; m.Entry(Sr).State = System.Data.Entity.EntityState.Modified; m.SaveChanges(); //新增开台表 YW_OpenStage oS = new YW_OpenStage(); oS.ID_VIP = vip_id; oS.Number_People = 0; oS.Remark = TbRemark.Text.ToString(); oS.GuestID = Guest_id; oS.Type_CheckIn = "足浴"; oS.Remark = "鬼知道你备注什么"; oS.Content_Message = "谁设计的奇葩"; oS.State_Message = true; oS.HouseStageID = rS[0].ID_RoomStage + ","; oS.Time_Predict = DateTime.Now; oS.Time_Leave = DateTime.Now; m.YW_OpenStage.Add(oS); m.SaveChanges(); Os_id = m.YW_OpenStage.Where(p => p.ID_VIP == vip_id && p.State_Message == true).FirstOrDefault().ID_OpenStage; } //嵌套右边表格 View.Windows.W_UC.W_RoomTableDataGridRight w_RoomTableDataGridRight = new W_UC.W_RoomTableDataGridRight(0, 0, Os_id); w_RoomTableDataGridRight.RetM += new ReuntMessage(ReceiveRight);//定义委托 heeh.Content = w_RoomTableDataGridRight; heeh.IsSelected = true; //嵌套左边的表格 View.Windows.W_UC.W_RoomTableDastaGridLeft w_RoomTableDataGridLeft = new W_UC.W_RoomTableDastaGridLeft(_Rooms); w_RoomTableDataGridLeft.ReuntLeft += new GetGridMessage(ReceiveLeft);//定义委托 kexuanfangtai.Content = w_RoomTableDataGridLeft; kexuanfangtai.IsSelected = true; }
/// <summary> /// 人民币结账 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtRMBSettlement_Click(object sender, RoutedEventArgs e) { //假如钱不够 decimal ljxf = Convert.ToDecimal(TbTheCumulative.Text); decimal bkzf = Convert.ToDecimal(TbFodingTime.Text); if (bkzf < ljxf) { MessageBox.Show("你的钱不够哦,不要想着吃霸王餐哦", "大海提示", MessageBoxButton.OK, MessageBoxImage.Asterisk); return; } //客人账号信息 string krzh = TbGuestAccount.Text.Trim().ToString(); List <SYS_RoomStage> rS = m.SYS_RoomStage.Where(l => l.ID_Guest == m.VIP_Table.Where(k => k.Accounts == krzh).FirstOrDefault().ID_Grade).ToList(); int rs_id = rS[0].ID_RoomStage; foreach (var item in rS) { //房台id int ftid = item.ID_RoomStage; List <CW_Bill> CWb = m.CW_Bill.Where(p => p.ID_Bill == (m.CW_Consumption.Where(o => o.ID_RoomStage == ftid).FirstOrDefault().ID_Bill)).ToList(); foreach (var cW in CWb) { DateTime dtNow = DateTime.Now; //添加支付记录 CW_PayRecord cWpr = new CW_PayRecord(); cWpr.ID_Bill = cW.ID_Bill; cWpr.ID_Guest = rs_id; cWpr.Price_Pay = Convert.ToDecimal(TbTheCumulative.Text); cWpr.Time_Pay = dtNow; cWpr.PoP = "现金支付"; cWpr.State = true;//已支付 m.CW_PayRecord.Add(cWpr); m.SaveChanges(); int cwprid = m.CW_PayRecord.Where(p => p.ID_Bill == cW.ID_Bill && p.ID_Guest == rs_id && p.State == false).ToList()[0].ID_PayRecord; //账单 CW_Bill cwB = m.CW_Bill.Where(p => p.ID_Bill == cW.ID_Bill).SingleOrDefault(); cwB.Price = Convert.ToDecimal(TbTheCumulative.Text); cwB.State_Bill = "已结账"; cwB.Time_PayBill = dtNow; m.Entry(cwB).State = System.Data.Entity.EntityState.Modified; m.SaveChanges(); //消费记录明细 List <CW_ConsumeDetail> cwCD = m.CW_ConsumeDetail.Where(p => p.ID_Consumption == (m.CW_Consumption.Where(c => c.ID_RoomStage == ftid).FirstOrDefault().ID_Consumption)).ToList(); foreach (var cW_Cme in cwCD) { CW_ConsumeDetail cW_Consume = m.CW_ConsumeDetail.Where(p => p.ID_Consumption == cW_Cme.ID_Consumption).FirstOrDefault(); cW_Consume.State_ComsumeDetail = false; cW_Consume.ID_PayRecord = cwprid; m.Entry(cW_Consume).State = System.Data.Entity.EntityState.Modified; m.SaveChanges(); } } //修改房台状态 SYS_RoomStage sysRs = m.SYS_RoomStage.Where(p => p.ID_RoomStage == item.ID_RoomStage).SingleOrDefault(); sysRs.ID_Guest = null; sysRs.State_RoomStage = "未用"; m.Entry(sysRs).State = System.Data.Entity.EntityState.Modified; m.SaveChanges(); if (CWb.Count > 0) { MessageBoxResult mb = MessageBox.Show("结账成功", "大海提示", MessageBoxButton.OK, MessageBoxImage.Asterisk); if (mb == MessageBoxResult.OK) { this.Close(); } } } }
/// <summary> /// 页面加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Loaded(object sender, RoutedEventArgs e) { Tb_confidentiality.Visibility = Visibility.Hidden; Cb_Ifasecret.Visibility = Visibility.Hidden; #region 拉框 //主客姓名 Cb_The_customers_name.DisplayMemberPath = "MC_Guest"; Cb_The_customers_name.SelectedValuePath = "ID_Guest"; Cb_The_customers_name.ItemsSource = m.SYS_Guest.ToList(); //协议单位 Cb_bargaining_unit_l.DisplayMemberPath = "MC_AgreementUser"; Cb_bargaining_unit_l.SelectedValuePath = "ID_AgreementUser"; Cb_bargaining_unit_l.ItemsSource = m.AG_AgreementUser.ToList(); ID_RoomStage = STATIC_cache.ID_RoomStage; SYS_RoomStage s = m.SYS_RoomStage.Where(c => c.ID_RoomStage == ID_RoomStage).SingleOrDefault(); Tb_room_number.Text = s.Number_RoomStage; Tb_the_room.Text = s.MC_RoomStage; Tb_the_preset_prices.Text = s.preinstall.ToString(); #endregion //客人登记回填 if (base_names == "Bt_The_guest_registration") { //当客人已经预定时 List <SYS_RoomStage> rs = m.SYS_RoomStage.Where(c => c.ID_RoomStage == ID_RoomStage).ToList(); if (rs[0].State_RoomStage.Trim() == "预定") { var con = from tr in m.SYS_RoomStage join tv in m.VIP_Table on tr.ID_Guest equals tv.ID_Guest join tg in m.SYS_Guest on tr.ID_Guest equals tg.ID_Guest join trst in m.SYS_Room_status_type on tr.ID_room_type equals trst.ID_room_status_type join ts in m.YW_Subscribe on tr.ID_Guest equals ts.ID_Guest join tb in m.CW_Bill on ts.ID_Subscribe equals tb.SuOp_ID join tc in m.CW_Consumption on tr.ID_RoomStage equals tc.ID_RoomStage join ta in m.AG_AgreementUser on ts.ID_AgreementUser equals ta.ID_AgreementUser where tr.ID_RoomStage == ID_RoomStage select new { tv.Accounts, //账号 tr.Number_RoomStage, //房号 tr.preinstall, //预设房价 tr.practical, //实际房价 tg.MC_Guest, tg.sex, ts.Number_People, ts.Number_Subscribe, ts.Remark, tg.证件类型, tg.证件号码, tg.Address, ts.Time_Predict, ts.Time_Leave, trst.name_room_status_type, trst.ID_room_status_type, ts.Money_Pledge, tb.Number_Bill, ta.MC_AgreementUser, }; Tb_account_number.Text = con.Select(c => c.Accounts).FirstOrDefault().ToString().Trim(); Cb_The_customers_name.Text = con.Select(c => c.MC_Guest).FirstOrDefault().Trim(); Cb_gender.Text = con.Select(c => c.sex).FirstOrDefault() is true ? "男" : "女"; Tb_number_of_people.Text = con.Select(c => c.Number_People).FirstOrDefault().ToString(); Tb_actual_controller.Text = con.Select(c => c.practical).FirstOrDefault().ToString(); Cb_certificate_type.Text = con.Select(c => c.证件类型).FirstOrDefault().Trim(); Tb_ID_Number.Text = con.Select(c => c.证件号码).FirstOrDefault().Trim(); Tb_site.Text = con.Select(c => c.Address).FirstOrDefault().Trim(); Dp_the_date_of_arrival.SelectedDate = con.Select(c => c.Time_Predict).FirstOrDefault(); Dp_departure_time.SelectedDate = con.Select(c => c.Time_Leave).FirstOrDefault(); int ID_rst = con.Select(c => c.ID_room_status_type).FirstOrDefault(); Cb_assignment(ID_rst); Tb_The_first_deposit.Text = con.Select(c => c.Money_Pledge).FirstOrDefault().ToString(); Cb_bargaining_unit_l.Text = con.Select(c => c.MC_AgreementUser).FirstOrDefault().ToString().Trim(); Tb_The_VIP_card_number.Text = con.Select(c => c.Accounts).FirstOrDefault().ToString().Trim(); Tb_Deposit_receipt_no.Text = con.Select(c => c.Number_Subscribe).FirstOrDefault().Trim(); Tb_message_contents.IsEnabled = con.Select(c => c.Remark).FirstOrDefault().Trim() is null ? false : true; Tb_message_contents.Text = Tb_message_contents.IsEnabled ? con.Select(c => c.Remark).FirstOrDefault().Trim() : string.Empty; Tb_note.Text = con.Select(c => c.Remark).FirstOrDefault().Trim(); DateTime leve = (DateTime)con.Select(c => c.Time_Leave).Single(); DateTime predict = (DateTime)con.Select(c => c.Time_Predict).Single(); int datys = (int)(leve - predict).TotalDays; Tb_number_of_days.Text = datys.ToString(); Cb_The_customers_name.IsEnabled = false; Tb_room_name.Text = "客人预定登记"; this.Tb_away_goal.Text = "客人预定登记"; } } //客人续住 if (base_names == "Bt_guest_delay") { var con = from tr in m.SYS_RoomStage join tv in m.VIP_Table on tr.ID_Guest equals tv.ID_Guest join tg in m.SYS_Guest on tr.ID_Guest equals tg.ID_Guest join trst in m.SYS_Room_status_type on tr.ID_room_type equals trst.ID_room_status_type join to in m.YW_OpenStage on tv.ID_VIP equals to.ID_VIP join tc in m.CW_Consumption on tr.ID_RoomStage equals tc.ID_RoomStage join tb in m.CW_Bill on tc.ID_Bill equals tb.ID_Bill join ta in m.AG_AgreementUser on to.ID_AgreementUser equals ta.ID_AgreementUser where tr.ID_RoomStage == ID_RoomStage select new { tv.Accounts, //账号 tr.Number_RoomStage, //房号 tr.preinstall, //预设房价 tr.practical, //实际房价 tg.MC_Guest, tg.sex, to.Number_People, to.Number_OpenStage, to.Remark, tg.证件类型, tg.证件号码, tg.Address, to.Time_Predict, to.Time_Leave, trst.name_room_status_type, trst.ID_room_status_type, to.Money_Pledge, tb.Number_Bill, ta.MC_AgreementUser, tc.Discount, }; Tb_account_number.Text = con.Select(c => c.Accounts).FirstOrDefault().ToString().Trim(); Cb_The_customers_name.Text = con.Select(c => c.MC_Guest).FirstOrDefault().Trim(); Cb_gender.Text = con.Select(c => c.sex).FirstOrDefault() is true ? "男" : "女"; Tb_number_of_people.Text = con.Select(c => c.Number_People).FirstOrDefault().ToString(); Tb_actual_controller.Text = con.Select(c => c.practical).FirstOrDefault().ToString(); Cb_certificate_type.Text = con.Select(c => c.证件类型).FirstOrDefault().Trim(); Tb_ID_Number.Text = con.Select(c => c.证件号码).FirstOrDefault().Trim(); Tb_site.Text = con.Select(c => c.Address).FirstOrDefault().Trim(); Dp_the_date_of_arrival.SelectedDate = con.Select(c => c.Time_Predict).FirstOrDefault(); Dp_departure_time.SelectedDate = con.Select(c => c.Time_Leave).FirstOrDefault(); int ID_rst = con.Select(c => c.ID_room_status_type).FirstOrDefault(); Cb_assignment(ID_rst); Tb_The_first_deposit.Text = con.Select(c => c.Money_Pledge).FirstOrDefault().ToString(); Cb_bargaining_unit_l.Text = con.Select(c => c.MC_AgreementUser).FirstOrDefault().ToString().Trim(); Tb_The_VIP_card_number.Text = con.Select(c => c.Accounts).FirstOrDefault().ToString().Trim(); Tb_Deposit_receipt_no.Text = con.Select(c => c.Number_OpenStage).FirstOrDefault().Trim(); Tb_message_contents.IsEnabled = con.Select(c => c.Remark).FirstOrDefault().Trim() is null ? false : true; Tb_message_contents.Text = Tb_message_contents.IsEnabled ? con.Select(c => c.Remark).FirstOrDefault().Trim() : string.Empty; Tb_note.Text = con.Select(c => c.Remark).FirstOrDefault().Trim(); Tb_discount.Text = con.Select(c => c.Discount).FirstOrDefault().ToString(); Cb_The_customers_name.IsEnabled = false; DateTime leve = con.Select(c => c.Time_Leave).Single(); DateTime predict = con.Select(c => c.Time_Predict).Single(); int datys = (int)(leve - predict).TotalDays; Tb_number_of_days.Text = datys.ToString(); Tb_room_name.Text = "客人续住登记"; this.Tb_away_goal.Text = "客人续住登记"; BtAddition.IsEnabled = false; BtRemove.IsEnabled = false; foreach (FrameworkElement item in Gr_con.Children) { if (item is TextBox) { System.Windows.Controls.TextBox textBox = item as TextBox; textBox.IsEnabled = false; } if (item is ComboBox) { ComboBox comboBox = item as ComboBox; comboBox.IsEnabled = false; } if (item is CheckBox) { CheckBox checkBox = item as CheckBox; checkBox.IsEnabled = false; } } } Get_data(); DgLeft.ItemsSource = left; DgRight.ItemsSource = right; }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Save_Click(object sender, RoutedEventArgs e) { if (TbOddNumbers.Text == "" || TbOddNumbers.Text == null && TbDevelopmentTime.Text == "" || TbDevelopmentTime.Text == null && TbPopulation.Text == "" || TbPopulation.Text == null && TbDiscount.Text == "" || TbDiscount.Text == null && TbRemark.Text == "" || TbRemark.Text == null) { MessageBox.Show("你大爷的,漏数据了", "大海提示", MessageBoxButton.OK, MessageBoxImage.Asterisk); return; } vip_id = m.VIP_Table.Where(p => p.Accounts == zhanghao).SingleOrDefault().ID_VIP; //客人id int krid = m.VIP_Table.Where(p => p.ID_VIP == vip_id).SingleOrDefault().ID_Guest; //账单表 // string Mun = STATIC_cache.ScBill_id; //CW_Bill_id int YYid = 0; try { YYid = m.CW_Bill.Where(p => p.SuOp_ID == (m.YW_Subscribe.Where(S => S.ID_VIP == m.VIP_Table.Where(V => V.Accounts == zhanghao).FirstOrDefault().ID_VIP).FirstOrDefault().ID_Subscribe)).FirstOrDefault().SuOp_ID; } catch (Exception) { } if (YYid > 0) { CW_Bill cB = m.CW_Bill.Where(p => p.SuOp_ID == YYid).Single(); cB.Time_PayBill = null; cB.Remark = "该怎么形容你最贴切"; cB.Price = 0; cB.State_Bill = "正在消费"; m.Entry(cB).State = System.Data.Entity.EntityState.Modified; m.SaveChanges(); } else { CW_Bill cW_Bill = new CW_Bill(); cW_Bill.Time_PayBill = null; cW_Bill.Remark = "该怎么形容你最贴切"; cW_Bill.Price = 0; cW_Bill.State_Bill = "正在消费"; m.CW_Bill.Add(cW_Bill); m.SaveChanges(); } int cbid = m.CW_Bill.Where(p => p.SuOp_ID == YYid).Single().ID_Bill; //支付记录表录入 CW_PayRecord cP = new CW_PayRecord(); cP.ID_Guest = krid; cP.Price_Pay = 0; cP.Time_Pay = null; cP.PoP = ""; cP.State = false; cP.ID_Bill = cbid; m.CW_PayRecord.Add(cP); m.SaveChanges(); /**********/ //根据会员 id 找到客人id int Guest_id = m.SYS_Guest.Where(p => p.ID_Guest == (m.VIP_Table.Where(v => v.ID_VIP == vip_id).FirstOrDefault().ID_Guest)).SingleOrDefault().ID_Guest; try { int os = m.YW_OpenStage.Where(m => m.ID_VIP == vip_id && m.State_Message == true).SingleOrDefault().ID_OpenStage; } catch (Exception) { YW_OpenStage oS = new YW_OpenStage(); oS.ID_VIP = vip_id; oS.Number_People = 0; oS.Remark = TbRemark.Text.ToString(); oS.GuestID = Guest_id; oS.Type_CheckIn = "足浴"; oS.Remark = "鬼知道你备注什么"; oS.Content_Message = "谁设计的奇葩"; oS.State_Message = true; oS.HouseStageID = rS[0].ID_RoomStage + ","; oS.Time_Predict = DateTime.Now; oS.Time_Leave = DateTime.Now; m.YW_OpenStage.Add(oS); m.SaveChanges(); } /************/ //开台id int ktid = m.YW_OpenStage.Where(p => p.ID_VIP == (m.VIP_Table.Where(v => v.ID_Guest == krid).FirstOrDefault().ID_VIP)).SingleOrDefault().ID_OpenStage; //开台房台id string ktftid = m.YW_OpenStage.Where(p => p.ID_OpenStage == ktid).Single().HouseStageID; //分割数组 List <string> vs = ktftid.Split(',').ToList(); for (int i = 0; i < vs.Count(); i++) { if (vs[i] == "") { vs.Remove(vs[i]); break; } int ftid = Convert.ToInt32(vs[i]); //消费表 CW_Consumption cC = new CW_Consumption(); cC.ID_Bill = cbid; cC.ID_RoomStage = ftid; cC.Discount = Convert.ToDecimal(TbDiscount.Text) == 0 ? throw new NullReferenceException() : Convert.ToDecimal(TbDiscount.Text); cC.Time_Consumption = DateTime.Now.ToLocalTime(); m.CW_Consumption.Add(cC); //修改房台状态 SYS_RoomStage Rs = m.SYS_RoomStage.Where(m => m.ID_RoomStage == ftid).SingleOrDefault(); Rs.State_RoomStage = "已用"; } if (m.SaveChanges() > 0) { MessageBoxResult m = MessageBox.Show("开台成功!", "大海提示", MessageBoxButton.OK, MessageBoxImage.Asterisk); if (m == MessageBoxResult.OK) { this.Close(); Resh(); } } }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="routedEvent"></param> private void BtConfirm_Click(object sender, RoutedEventArgs routedEvent) { try { string strText = ""; string tbRoom_name = TbRoom_Name.Text.Trim().ToString() == "" ? strText = "房台名称不能为空" : TbRoom_Name.Text.Trim().ToString(); string cbStatus = CbStatus.Text.Trim().ToString() == "" ? strText = "请选择状态" : CbStatus.Text.Trim().ToString(); string tbDescribe = TbDescribe.Text.Trim().ToString() == "" ? strText = "请输入房台描述" : TbDescribe.Text.Trim().ToString(); //string cbClass = CbClass.SelectedIndex.ToString() == "0" ? strText = "请选中类型" : CbClass.SelectedIndex.ToString(); Model.SYS_Class sYS_ = (CbClass.SelectedItem) as Model.SYS_Class; int cbClass = sYS_.ID_Class; int numberRoomStage = my.SYS_RoomStage.Count(); int c = Convert.ToInt32(cbClass); int count = my.SYS_RoomStage.Where(p => p.MC_RoomStage.Trim().ToString() == tbRoom_name && p.State_RoomStage == cbStatus && p.Describe == tbDescribe && p.ID_Class == c).Count(); if (count > 0) { MessageBox.Show("已存在房台信息", "大海提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning); return; } else if (tbRoom_name != "" && cbStatus != "" && tbDescribe != "" && c > 0) { //修改 if (tupl != null) { strText = "房台修改成功"; Model.SYS_RoomStage r = my.SYS_RoomStage.Where(p => p.ID_RoomStage == Id_RoomStage).Single(); r.MC_RoomStage = tbRoom_name; r.State_RoomStage = cbStatus; r.Describe = tbDescribe; r.ID_Class = type_room; my.Entry(r).State = System.Data.Entity.EntityState.Modified; if (my.SaveChanges() > 0) { MessageBoxResult result = MessageBox.Show(strText, "大海提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning); if (result == MessageBoxResult.OK) { View.Usercontrol.UC_TealTimeExecutive u = new Usercontrol.UC_TealTimeExecutive(); u.UserControl_Loaded(null, null); this.Close(); } } } //添加 else if (tupl == null) { strText = "房台添加成功"; SYS_RoomStage m = new SYS_RoomStage(); m.MC_RoomStage = tbRoom_name; m.State_RoomStage = cbStatus; m.Number_RoomStage = (numberRoomStage + 1).ToString(); m.Describe = tbDescribe; m.ID_Class = type_room; my.SYS_RoomStage.Add(m); if (my.SaveChanges() > 0) { MessageBoxResult s = MessageBox.Show(strText, "大海提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning); // View.Usercontrol.UC_TealTimeExecutive u = new Usercontrol.UC_TealTimeExecutive(); if (s == MessageBoxResult.OK) { //调用委托 ChangC(); this.Close(); } } } } else { MessageBox.Show(strText, "大海提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning); } } catch (Exception e) { Debug.Write(e); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Bt_save_Click(object sender, RoutedEventArgs e) { //代码还有整合得空间,算了懒得去搞~ if (Cb_Founding_account.Text.Equals(string.Empty) && Tb_Founding_account.Equals(string.Empty) || Tb_Room_table.Text.Equals(string.Empty) || Tb_Room_table_name.Text.Equals(string.Empty) || Tb_odd.Text.Equals(string.Empty) || Tb_Founding_time.Text.Equals(string.Empty) || Tb_number_of_people.Text.Equals(string.Empty) || Tb_discount.Text.Equals(string.Empty) || Tb_account.Text.Equals(string.Empty) || Tb_postscript.Text.Equals(string.Empty)) { MessageBox.Show("请将信息填写完整", "大海提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } string hsid = string.Empty; //未定状态 if (Cb_Founding_account.IsVisible) { int?Guest = m.SYS_Guest.Where(c => c.MC_Guest.Trim() == Cb_Founding_account.Text).SingleOrDefault().ID_AgreementUser; foreach (var item in RightOc) { hsid += item.ID_RoomStage + ","; //账单表 CW_Bill b = new CW_Bill(); //b.ID_Bill = c.ID_Consumption; b.Number_Bill = Tb_odd.Text.Trim(); m.CW_Bill.Add(b); m.SaveChanges(); //消费表 CW_Consumption c = new CW_Consumption(); c.ID_RoomStage = item.ID_RoomStage; /// c.ID_Bill = b.ID_Bill; //c.ID_Bill = m.CW_Bill.AsEnumerable().Last().ID_Bill;//查询表格中最后一条数据 c.ID_Bill = m.CW_Bill.Where(t => t.Number_Bill == Tb_odd.Text.Trim() && t.State_Bill == null).Single().ID_Bill; c.Discount = Convert.ToDecimal(Tb_discount.Text.Trim()); c.Effective = true; m.CW_Consumption.Add(c); m.SaveChanges(); //房台 SYS_RoomStage r = m.SYS_RoomStage.Where(d => d.ID_RoomStage == item.ID_RoomStage).FirstOrDefault(); r.State_RoomStage = "已用"; r.ID_Guest = item.ID_Guest; m.Entry(r).State = System.Data.Entity.EntityState.Modified; m.SaveChanges(); } ; var ID_VIP = m.VIP_Table.Where(c => c.Accounts == Tb_account.Text.Trim()).FirstOrDefault().ID_VIP; //预约 YW_OpenStage o = new YW_OpenStage(); o.Number_People = int.Parse(Tb_number_of_people.Text.Trim());//人数 o.Number_OpenStage = Tb_odd.Text.Trim(); o.ID_VIP = ID_VIP; o.State_Secrecy = true; o.Remark = Tb_postscript.Text.Trim(); o.Type_CheckIn = "餐饮"; o.Content_Message = string.Empty; if (!Guest.Equals(null)) { o.ID_AgreementUser = (int)Guest; } o.HouseStageID = hsid; o.Time_Predict = Convert.ToDateTime(Tb_Founding_time.Text.Trim()); m.YW_OpenStage.Add(o); if (m.SaveChanges() > 0) { MessageBox.Show("开台成功", "大海提示", MessageBoxButton.OK, MessageBoxImage.Warning); Close(); return; } } //预定状态 if (Tb_Founding_account.IsVisible) { foreach (var item in RightOc) { //查看该房台是否存在消费但 var date = m.CW_Consumption.Where(c => c.ID_RoomStage == item.ID_RoomStage && c.Effective == true).FirstOrDefault(); if (date.Equals(null)) { CW_Bill b = new CW_Bill(); // b.ID_Bill = c.ID_Consumption; b.Number_Bill = Tb_odd.Text.Trim(); m.CW_Bill.Add(b); m.SaveChanges(); CW_Consumption c = new CW_Consumption(); c.ID_RoomStage = item.ID_RoomStage; c.Discount = Convert.ToDecimal(Tb_discount.Text.Trim()); c.ID_Bill = m.CW_Bill.Where(t => t.Number_Bill == Tb_odd.Text.Trim() && t.State_Bill == null).Single().ID_Bill; c.Effective = true; m.CW_Consumption.Add(c); m.SaveChanges(); } //修改房台信息 SYS_RoomStage r = m.SYS_RoomStage.Where(c => c.ID_RoomStage == item.ID_RoomStage && c.State_RoomStage.Trim() == "预定").SingleOrDefault(); r.ID_Guest = null; r.State_RoomStage = "已用"; m.Entry(r).State = System.Data.Entity.EntityState.Modified; } var ID_VIP = m.VIP_Table.Where(c => c.Accounts == Tb_account.Text.Trim()).FirstOrDefault().ID_VIP; //修改预定信息 YW_Subscribe w = m.YW_Subscribe.Where(c => c.ID_VIP == ID_VIP && c.State_Secrecy == true).SingleOrDefault(); w.State_Secrecy = false; m.Entry(w).State = System.Data.Entity.EntityState.Modified; m.SaveChanges(); YW_OpenStage o = new YW_OpenStage(); o.Number_People = int.Parse(Tb_number_of_people.Text.Trim());//人数 o.Number_OpenStage = Tb_odd.Text.Trim(); o.ID_VIP = ID_VIP; o.State_Secrecy = true; o.Remark = Tb_postscript.Text.Trim(); o.HouseStageID = hsid; o.Time_Predict = Convert.ToDateTime(Tb_Founding_time.Text.Trim()); o.Type_CheckIn = "餐饮"; o.Content_Message = string.Empty; m.YW_OpenStage.Add(o); if (m.SaveChanges() > 0) { MessageBox.Show("开台成功", "大海提示", MessageBoxButton.OK, MessageBoxImage.Warning); Close(); return; } } }