Exemplo n.º 1
0
 public bool Update(OrderDinnerEntity obj)
 {
     try
     {
         Update("OrderDinnerMap.Update", obj);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 2
0
 public bool Save(OrderDinnerEntity obj)
 {
     try
     {
         Insert("OrderDinnerMap.Insert", obj);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 3
0
        public ActionResult setOrder(string userid, DateTime orderDate, int orderNumber, string footTime)
        {
            try
            {
                JsonResult     result = new JsonResult();
                UserInfoEntity user   = userLogic.Load(userid);
                Random         rad    = new Random();
                if (user != null)
                {
                    string Condition = " and (CancUser is null or CancUser = '') and userid='" + userid + "'  and orderdate between '" + orderDate.ToString("yyyy-MM-dd 00:00:00") + "'  and  '" + orderDate.ToString("yyyy-MM-dd 23:59:59") + "' and typecode=" + footTime;
                    int    rowCount  = dinnerlogic.Count(Condition);
                    if (rowCount > 0)
                    {
                        result.Data = new { status = 200, msg = "此期间,订餐您已经预定!" };
                        return(Json(result, JsonRequestBehavior.AllowGet));
                    }


                    OrderDinnerEntity ordDinner = new OrderDinnerEntity();
                    ordDinner.OrdId      = userid + "-" + DateTime.Now.ToString("yyMMddHHmmss") + rad.Next(10, 99);
                    ordDinner.OrdName    = userid + "-预定餐饮";
                    ordDinner.UserId     = userid;
                    ordDinner.OrderDate  = orderDate;
                    ordDinner.TypeCode   = footTime;
                    ordDinner.Quantity   = orderNumber;
                    ordDinner.OrdStatus  = "0";
                    ordDinner.CreateUser = userid;
                    ordDinner.CreateDate = DateTime.Now;
                    bool isok = dinnerlogic.Save(ordDinner);
                    if (isok)
                    {
                        result.Data = new { status = 100, msg = "success" };
                    }
                    else
                    {
                        result.Data = new { status = 200, msg = "订餐失败" };
                    }
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    result.Data = new { status = 200, msg = "用户不存在", userid = "" };
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                JsonResult result = new JsonResult();
                result.Data = new { status = 200, msg = ex.Message, userid = "" };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 4
0
 public Task <bool> SaveAsync(OrderDinnerEntity obj)
 {
     try
     {
         Insert("OrderDinnerMap.Insert", obj);
         //return new Task<bool>(() => true);
         return(Task.FromResult(true));
     }
     catch
     {
         return(Task.FromResult(false));
         //return new Task<bool>(() => false);
     }
 }
Exemplo n.º 5
0
 public OrderDinnerEntity Load(string code)
 {
     try
     {
         if (!string.IsNullOrEmpty(code))
         {
             OrderDinnerEntity dinner = QueryForObject <OrderDinnerEntity>("OrderDinnerMap.Load", code);
             return(dinner);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 6
0
 public ActionResult cancelOrderByIds(string[] cancelOrderIds)
 {
     try
     {
         JsonResult result = new JsonResult();
         if (cancelOrderIds.Length == 0)
         {
             result.Data = new { status = 200, msg = "没有需要取消的点餐数据!", orders = "" };
             return(Json(result, JsonRequestBehavior.AllowGet));
         }
         foreach (var item in cancelOrderIds)
         {
             if (item != "")
             {
                 OrderDinnerEntity dinner       = dinnerlogic.Load(item);
                 DateTime          orderTimeEnd = DateTime.Parse(dinner.OrderDate.ToString("yyyy-MM-dd 23:59:59"));
                 if (DateTime.Now.CompareTo(orderTimeEnd) > 0)
                 {
                     result.Data = new { status = 200, msg = "此预定不允许取消,只能当天取消!", orders = "" };
                     return(Json(result, JsonRequestBehavior.AllowGet));
                 }
             }
         }
         bool isok = dinnerlogic.CancelOrderDinner(cancelOrderIds);
         if (isok)
         {
             result.Data = new { status = 100, msg = "success", orders = "" };
             return(Json(result, JsonRequestBehavior.AllowGet));
         }
         else
         {
             result.Data = new { status = 200, msg = "取消失败!", orders = "" };
             return(Json(result, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         JsonResult result = new JsonResult();
         result.Data = new { status = 200, msg = ex.Message, orders = "" };
         return(Json(result, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 7
0
        public bool CancelOrderDinner(string[] cancelOrderIds)
        {
            using (TransactionScope trans = new TransactionScope())
            {
                try
                {
                    bool isok = true;
                    foreach (var itemstring in cancelOrderIds)
                    {
                        OrderDinnerEntity dinner = access.Load(itemstring);
                        if (dinner != null)
                        {
                            dinner.CancDate = DateTime.Now;
                            dinner.CancUser = dinner.CreateUser;
                            isok            = access.Update(dinner);
                            if (isok == false)
                            {
                                return(false);
                            }
                        }
                    }

                    if (isok == true)
                    {
                        trans.Complete();
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
Exemplo n.º 8
0
        public ActionResult setOrderBySurvey(string orderid, string survey)
        {
            JsonResult        result    = new JsonResult();
            OrderDinnerEntity orderEnty = dinnerlogic.Load(orderid);

            if (orderEnty != null)
            {
                SatisfactionEntity model = new SatisfactionEntity();
                model.SatisId     = orderid + "-" + DateTime.Now.ToString("yyMMddHHmmss");
                model.OrderId     = orderid;
                model.SatisResult = survey;
                model.CreateDate  = DateTime.Now;
                bool isok = Satislogic.Save(model);
                result.Data = new { status = 100, msg = "成功!" };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            else
            {
                result.Data = new { status = 200, msg = "此订单不存在!" };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            //return Json(result, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 9
0
 public bool Update(OrderDinnerEntity obj)
 {
     return(access.Update(obj));
 }
Exemplo n.º 10
0
 public bool Save(OrderDinnerEntity obj)
 {
     return(access.Save(obj));
 }
Exemplo n.º 11
0
        public async Task <ActionResult> setBatchOrder(string userid, DateTime startDate, DateTime endDate, int orderNumber, string footTime)
        {
            try
            {
                JsonResult     result = new JsonResult();
                UserInfoEntity user   = userLogic.Load(userid);
                Random         rad    = new Random();
                if (user != null)
                {
                    if ((startDate.CompareTo(DateTime.Now) < 0) || (endDate.CompareTo(DateTime.Now) < 0))
                    {
                        result.Data = new { status = 200, msg = "开始日期或结束日期不能早于或者等于当前日期" };
                        return(Json(result, JsonRequestBehavior.AllowGet));
                    }
                    // 取消不算
                    string Condition = " and (CancUser is null or CancUser = '') and userid='" + userid + "'  and orderdate between '" + startDate.ToString("yyyy-MM-dd 00:00:00") + "'  and  '" + endDate.ToString("yyyy-MM-dd 23:59:59") + "' and typecode=" + footTime;
                    int    rowCount  = dinnerlogic.Count(Condition);
                    if (rowCount > 0)
                    {
                        result.Data = new { status = 200, msg = "此期间,您已经预定!" };
                        return(Json(result, JsonRequestBehavior.AllowGet));
                    }
                    TimeSpan tsCha   = endDate - startDate;
                    int      daysCha = tsCha.Days; // 相差几天
                    IList <OrderDinnerEntity> dinnerList = new List <OrderDinnerEntity>();
                    for (int row = 0; row <= daysCha; row++)
                    {
                        DateTime          dtOrderDate = startDate.AddDays(row);
                        OrderDinnerEntity ordDinner   = new OrderDinnerEntity();
                        ordDinner.OrdId      = userid + "-" + DateTime.Now.ToString("yyMMddHHmmss") + rad.Next(10, 99);
                        ordDinner.OrdName    = userid + "-预定餐饮";
                        ordDinner.UserId     = userid;
                        ordDinner.OrderDate  = dtOrderDate;
                        ordDinner.TypeCode   = footTime;
                        ordDinner.Quantity   = orderNumber;
                        ordDinner.OrdStatus  = "0";
                        ordDinner.CreateUser = userid;
                        ordDinner.CreateDate = DateTime.Now;
                        dinnerList.Add(ordDinner);
                    }

                    var taskResult = await Task.FromResult(dinnerlogic.setBatchOrder(dinnerList));

                    Task <bool> isok = taskResult;
                    if (isok.Result == true)
                    {
                        result.Data = new { status = 100, msg = "success" };
                    }
                    else
                    {
                        result.Data = new { status = 200, msg = "订餐失败" };
                    }
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    result.Data = new { status = 200, msg = "用户不存在" };
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                JsonResult result = new JsonResult();
                result.Data = new { status = 200, msg = ex.Message, userid = "" };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }