/// <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 (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(); }