Exemple #1
0
        private void OperateOrder()
        {
            try
            {
                if (!string.IsNullOrEmpty(this.hOperation.Value))
                {
                    IOrder orderBiz = new OrderBiz();
                    if (this.hOperation.Value.IndexOf('|') > -1)
                    {
                        var op     = this.hOperation.Value.Split('|')[0];
                        var listId = base.ParseInt(this.hOperation.Value.Split('|')[1]);
                        if (listId == 0)
                        {
                            this.lMsg.InnerText = "处理失败,参数 LIST_ID 不正确!";
                            return;
                        }
                        if (op == "cancel")
                        {
                            var condition = new OrderListEntity();
                            condition.LIST_ID     = listId;
                            condition.CANCEL_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss");
                            orderBiz.UpdateOrderListEntity(condition);
                        }
                        if (op == "confirm")
                        {
                            var condition = new OrderListEntity();
                            condition.LIST_ID      = listId;
                            condition.CONFIRM_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss");
                            orderBiz.UpdateOrderListEntity(condition);
                        }
                        else if (op == "finish")
                        {
                            //假如存在已完成同样的菜单,更新原有的数量
                            var curOrderListEntity = orderBiz.GetOrderListEntity(listId);
                            var condition          = new OrderListEntity();
                            condition.FOOD_ID  = curOrderListEntity.FOOD_ID;
                            condition.ORDER_ID = OrderId;
                            var list = orderBiz.GetOrderListEntityList(condition);

                            condition = null;
                            if (list != null && list.Count > 0)
                            {
                                foreach (OrderListEntity e in list)
                                {
                                    if (!string.IsNullOrEmpty(e.FINISH_TIME) && string.IsNullOrEmpty(e.CANCEL_TIME))
                                    {
                                        condition         = new OrderListEntity();
                                        condition.LIST_ID = e.LIST_ID;
                                        condition.COUNT   = e.COUNT;
                                    }
                                }
                            }

                            if (condition != null)
                            {
                                condition.COUNT += curOrderListEntity.COUNT;
                                orderBiz.UpdateOrderListEntity(condition);
                                orderBiz.DeleteOrderListEntity(new OrderListEntity()
                                {
                                    LIST_ID = curOrderListEntity.LIST_ID
                                });
                            }
                            else
                            {
                                condition             = new OrderListEntity();
                                condition.LIST_ID     = listId;
                                condition.FINISH_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss");
                                orderBiz.UpdateOrderListEntity(condition);
                            }
                        }
                        else if (op == "cancelfinish")
                        {
                            //假如存在已完成同样的菜单,更新原有的数量
                            var curOrderListEntity = orderBiz.GetOrderListEntity(listId);
                            var condition          = new OrderListEntity();
                            condition.FOOD_ID  = curOrderListEntity.FOOD_ID;
                            condition.ORDER_ID = OrderId;
                            var list = orderBiz.GetOrderListEntityList(condition);

                            condition = null;
                            if (list != null && list.Count > 0)
                            {
                                foreach (OrderListEntity e in list)
                                {
                                    if (!string.IsNullOrEmpty(e.CONFIRM_TIME) && string.IsNullOrEmpty(e.FINISH_TIME) && string.IsNullOrEmpty(e.CANCEL_TIME))
                                    {
                                        condition         = new OrderListEntity();
                                        condition.LIST_ID = e.LIST_ID;
                                        condition.COUNT   = e.COUNT;
                                    }
                                }
                            }

                            if (condition != null)
                            {
                                condition.COUNT += curOrderListEntity.COUNT;
                                orderBiz.UpdateOrderListEntity(condition);
                                orderBiz.DeleteOrderListEntity(new OrderListEntity()
                                {
                                    LIST_ID = curOrderListEntity.LIST_ID
                                });
                            }
                            else
                            {
                                condition             = new OrderListEntity();
                                condition.LIST_ID     = listId;
                                condition.FINISH_TIME = string.Empty;
                                orderBiz.UpdateOrderListEntity(condition);
                            }
                        }
                    }
                    else
                    {
                        if (this.hOperation.Value == "confirmall" || this.hOperation.Value == "finishall")
                        {
                            orderBiz.BatchProcessOrder(OrderId, this.hOperation.Value);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.lMsg.InnerText = "处理失败,原因:" + ex.ToString();
            }
        }