Beispiel #1
0
        /// <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);
            }
        }
Beispiel #2
0
        /// <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>
        /// <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="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;
        }
Beispiel #6
0
        /// <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;
                }
            }
        }