Exemplo n.º 1
0
 public void ClearCart(int orderId)
 {
     var dt = GetUnConfirmOrderData(orderId);
     if (dt != null && dt.Rows.Count > 0)
     {
         using (TransactionScope ts = new TransactionScope())
         {
             foreach (DataRow dr in dt.Rows)
             {
                 var condition = new OrderListEntity();
                 condition.LIST_ID = int.Parse(dr["LIST_ID"].ToString());
                 DeleteOrderListEntity(condition);
             }
             ts.Complete();
         }
     }
 }
Exemplo n.º 2
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();
            }
        }
Exemplo n.º 3
0
 public void DeleteOrderListEntity(OrderListEntity condition_entity)
 {
     condition_entity.Delete();
 }
Exemplo n.º 4
0
 public void UpdateOrderListEntity(OrderListEntity condition_entity)
 {
     condition_entity.Update();
 }
Exemplo n.º 5
0
        public void UpdateOrder(int orderId, decimal price, string foodOp, OrderListEntity entity)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                //更新主表价格
                var orderMainEntity = new OrderMainEntity();
                orderMainEntity.ORDER_ID = orderId;
                orderMainEntity.PRICE = price;
                UpdateOrderMainEntity(orderMainEntity);

                //更新子表明细
                var dt = GetUnConfirmOrderData(orderId, entity.FOOD_ID);
                if (foodOp == "add")
                {
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        var condition = new OrderListEntity();
                        condition.LIST_ID = int.Parse(dt.Rows[0]["LIST_ID"].ToString());
                        condition.COUNT = int.Parse(dt.Rows[0]["COUNT"].ToString()) + 1;
                        UpdateOrderListEntity(condition);
                    }
                    else
                    {
                        entity.ORDER_ID = orderId;
                        entity.COUNT = 1;
                        entity.ORDER_FLAG = "1";
                        entity.ORDER_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss");
                        InsertOrderListEntity(entity);
                    }
                }
                else if (foodOp == "cut")
                {
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        var count = int.Parse(dt.Rows[0]["COUNT"].ToString());
                        if (count <= 1)
                        {
                            var condition = new OrderListEntity();
                            condition.LIST_ID = int.Parse(dt.Rows[0]["LIST_ID"].ToString());
                            DeleteOrderListEntity(condition);
                        }
                        else
                        {
                            var condition = new OrderListEntity();
                            condition.LIST_ID = int.Parse(dt.Rows[0]["LIST_ID"].ToString());
                            condition.COUNT = count - 1;
                            UpdateOrderListEntity(condition);
                        }
                    }
                }
                else if (foodOp == "remark")
                {
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        var condition = new OrderListEntity();
                        condition.LIST_ID = int.Parse(dt.Rows[0]["LIST_ID"].ToString());
                        condition.TASTE = entity.TASTE;
                        condition.REMARK = entity.REMARK;
                        UpdateOrderListEntity(condition);
                    }
                }

                ts.Complete();
            }
        }
Exemplo n.º 6
0
 public void InsertOrderListEntity(OrderListEntity condition_entity)
 {
     condition_entity.Insert();
 }
Exemplo n.º 7
0
 public List<OrderListEntity> GetOrderListEntityList(OrderListEntity condition_entity)
 {
     GenericWhereEntity<OrderListEntity> where_entity = new GenericWhereEntity<OrderListEntity>();
     if (condition_entity.LIST_ID != null)
         where_entity.Where(n => (n.LIST_ID == condition_entity.LIST_ID));
     if (condition_entity.ORDER_ID != null)
         where_entity.Where(n => (n.ORDER_ID == condition_entity.ORDER_ID));
     if (condition_entity.FOOD_ID != null)
         where_entity.Where(n => (n.FOOD_ID == condition_entity.FOOD_ID));
     return EntityExecution.SelectAll(where_entity);
 }