//确定落单
        private void CommitOrder()
        {
            if (string.IsNullOrEmpty(ContactNumber))
            {
                MessageBox.Show("请填写联系电话");
                return;
            }
            if (string.IsNullOrEmpty(OrderPeople))
            {
                MessageBox.Show("请填写或者选择订餐人");
                return;
            }
            if (string.IsNullOrEmpty(Address))
            {
                MessageBox.Show("请填写订餐人地址");
                return;
            }
            bool flag = false;
            //1.将订餐人信息插入到外卖客户信息表中
            TakeoutClientInfo info = _DataService.FindTakeoutClientByTelephone(ContactNumber);
            if (info == null)
            {
                info = new TakeoutClientInfo()
                {
                    OrderPeopleId = new Random().Next(1000) + 1,
                    Order_people = OrderPeople,
                    Telephone = ContactNumber,
                    Address = Address,
                    Create_by = SubjectUtils.GetAuthenticationId(),     //操作人id
                    Create_datetime = DateTime.Now,
                    Status = 0,
                    Deleted = 0
                };

                flag = _DataService.AddTakeoutClientInfo(info);
            }
            else
            {
                info.Order_people = OrderPeople;
                info.Telephone = ContactNumber;
                info.Address = Address;
                info.Status = 0;
                info.Deleted = 0;
                info.Update_by = 0;    //操作人id
                info.Update_datetime = DateTime.Now;
                flag = _DataService.UpdateTakeoutClientInfo(info);
            }
            if (flag)
            {
                TakeoutOrder to = new TakeoutOrder();
                to.OrderPeopleId = info.OrderPeopleId;
                to.OrderId = 1222;   //订单号,去订单中查询获取
                to.DeliveryManNum = DeliveryMan;    //需要去员工数据库查找确定
                to.Num = "Q000";
                to.AdvanceAmount = 0;
                to.DeliverTime = DateTime.Now;    //送出时指定
                to.SendTime = DateTime.Now;
                to.Status = 0;     //0表示未送出状态,1表示在送出状态,2表示送达未签收状态,3.送达已签收状态
                to.Deleted = 0;
                to.CreateBy = SubjectUtils.GetAuthenticationId();     //操作人id
                to.CreateDatetime = DateTime.Now;
                //2.将订单信息插入到订单表中
                flag = _DataService.AddTakeoutOrder(to);
                if (flag)
                {
                    //关闭所有页面
                    //通知主线程执行关闭操作
                    DispatcherHelper.CheckBeginInvokeOnUI(()=>TakeoutOrderWindow.getInstance().Close());
                    //3.在厨房打印出厨打单
                    return;
                }
            }
            DispatcherHelper.CheckBeginInvokeOnUI(() => MessageBox.Show("外卖单录入失败"));
        }
        //修改外卖单
        public bool UpdateTakeoutOrder(TakeoutOrder To)
        {
            if (To == null)
            {
                return false;
            }
            //修改  直接修改
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                try
                {
                    var type = entities.TakeoutOrder.SingleOrDefault(bt => bt.OrderId == To.OrderId);
                    if (type != null)
                    {
                        type.OrderPeopleId = To.OrderPeopleId;
                        type.DeliveryManNum = To.DeliveryManNum;
                        type.Num = To.Num;
                        type.AdvanceAmount = To.AdvanceAmount;
                        type.DeliverTime = To.DeliverTime;
                        type.SendTime = To.SendTime;
                        type.Status = To.Status;
                        type.Deleted = To.Deleted;
                        type.UpdateBy = To.UpdateBy;
                        type.UpdateDatetime = To.UpdateDatetime;
                        entities.SaveChanges();
                        return true;
                    }

                }
                catch (Exception e)
                {
                    e.ToString();
                    return false;
                }
                return false;
            }
        }
        //删除外卖单

        public bool DeletedTakeoutOrder(int id)
        {
            if (id < 0)
            {
                return false;
            }
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                try
                {
                    TakeoutOrder booktype = new TakeoutOrder()
                    {
                        TakeoutId = id,
                    };
                    DbEntityEntry<TakeoutOrder> entry = entities.Entry<TakeoutOrder>(booktype);
                    entry.State = EntityState.Deleted;
                    entities.SaveChanges();
                    return true;
                }
                catch (Exception e)
                {
                    e.ToString();
                    return false;
                }

            }
        }
        //添加外卖单
        public bool AddTakeoutOrder(TakeoutOrder To)
        {
            if (To == null)
            {
                return false;
            }
            //添加
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {

                try
                {
                    entities.TakeoutOrder.Add(To);
                    entities.SaveChanges();
                    return true;
                }
                catch (Exception e)
                {
                    e.ToString();
                    return false;
                }
            }
        }