Example #1
0
        public JsonResult editCourier(Courier courier)
        {
            using (DBContext db = new DBContext())
            {
                Courier oldCourier = db.Courier.Where(q => q.ID.Equals(courier.ID)).FirstOrDefault();

                if (oldCourier == null)
                {
                    Guser user = UserContext.user;

                    Store store = UserContext.store;

                    courier.CreatorID = user.ID;
                    courier.Creator = user.DisplayName;
                    courier.StoreId = store.ID;
                    courier.Status = Status.enable;

                    db.Courier.Add(courier);
                }
                else
                {
                    oldCourier.ModifyTime = DateTime.Now;
                    oldCourier.CourierTel = courier.CourierTel;
                    oldCourier.Status = courier.Status;

                    db.Entry(oldCourier).State = EntityState.Modified;
                }
                db.SaveChanges();
            }

            return Json(new { code = 1, msg = "保存成功" });
        }
Example #2
0
        public static void delete(string id, string basePath)
        {
            using (DBContext db = new DBContext())
            {
                Doc doc = db.Doc.Where(q => q.ID.Equals(id)).FirstOrDefault();

                if (doc == null) { return; }

                DirectoryInfo dir = new DirectoryInfo(string.Format("{0}{1}", basePath, doc.DirPath));
                dir.Delete(true);

                db.Doc.Remove(doc);
                db.SaveChanges();
            }
        }
        public JsonResult delOrder(string orderId)
        {
            using (DBContext db = new DBContext())
            {
                Order order = db.Order.Where(q => q.ID.Equals(orderId)).FirstOrDefault();

                if (order == null) { return Json(new { code = -1, msg = "找不到对应订单" }); }

                db.OrderItem.RemoveRange(db.OrderItem.Where(q => q.OrderId.Equals(orderId)));

                db.Order.Remove(order);

                db.SaveChanges();

                return Json(new { code = 1, msg = "删除成功" });
            }
        }
Example #4
0
        public static decimal RefreshPay(string id)
        {
            using (DBContext db = new DBContext())
            {
                Order order = db.Order.Where(q => q.ID.Equals(id)).FirstOrDefault();

                decimal pay = db.OrderItem.Where(q => q.OrderId.Equals(id)).Sum(q => q.Price * q.RealNumber * q.Discount);

                order.Payable = pay;
                order.Paid = pay;

                db.Entry(order).State = EntityState.Modified;

                db.SaveChanges();

                return pay;
            }
        }
Example #5
0
        public JsonResult changePassword(string oldPass, string newPass)
        {
            using (DBContext db = new DBContext())
            {
                string _oldPass = StringUtil.Md5Encrypt(oldPass);

                Guser user = UserContext.user;

                if (!user.PassWord.Equals(_oldPass)) { return Json(new { code = -1, msg = "原密码错误" }); }

                user.PassWord = StringUtil.Md5Encrypt(newPass);

                db.Entry(user).State = EntityState.Modified;

                db.SaveChanges();

                return Json(new { code = 1, msg = "修改成功,3秒后跳转到登录页面", url = "Login/LogOff" });
            }
        }
Example #6
0
        public JsonResult rejectOrder(string orderId, string reason)
        {
            using (DBContext db = new DBContext())
            {
                Order order = db.Order.Where(q => q.ID.Equals(orderId)).FirstOrDefault();

                if (order == null) { return Json(new { code = -1, msg = "找不到对应订单" }); }

                if (order.Status != OrderStatus.BeforeSend) { return Json(new { code = -2, msg = "非待发货状态的订单不能驳回" }); }

                order.ModifyTime = DateTime.Now;
                order.RejectReason = reason;
                order.Status = OrderStatus.Reject;

                db.SaveChanges();
            }

            return Json(new { code = 1, msg = "已驳回订单,请及时通知分店" });
        }
Example #7
0
        public JsonResult checkOrder(string orderId, string checkremark)
        {
            using (DBContext db = new DBContext())
            {
                Order order = db.Order.Where(q => q.ID.Equals(orderId)).FirstOrDefault();

                if (order == null) { return Json(new { code = -1, msg = "找不到对应订单" }); }

                if (order.Status != OrderStatus.Sended) { return Json(new { code = -2, msg = "非已发货状态的订单不能驳回" }); }

                order.ModifyTime = DateTime.Now;
                order.RejectReason = checkremark;
                order.Status = OrderStatus.Checked;

                db.SaveChanges();
            }

            return Json(new { code = 1, msg = "对账成功" });
        }
Example #8
0
        public static Doc save(string name, string type, string storeId, string dir)
        {
            using (DBContext db = new DBContext())
            {
                Doc doc = new Doc()
                {
                    Creator = UserContext.user.DisplayName,
                    CreatorID = UserContext.user.ID,
                    Name = name,
                    DocType = type,
                    StoreId = storeId,
                    DirPath = dir
                };

                db.Doc.Add(doc);
                db.SaveChanges();

                return doc;
            }
        }
Example #9
0
        public JsonResult submitOrder(string orderId, string remark)
        {
            using (DBContext db = new DBContext())
            {
                Order order = db.Order.Where(q => q.ID.Equals(orderId)).FirstOrDefault();

                if (order == null) { return Json(new { code = -1, msg = "找不到对应订单" }); }

                if (order.Status != OrderStatus.BeforeSubmit) { return Json(new { code = -2, msg = "订单已被提交过,无法重复提交" }); }

                decimal pay = db.OrderItem.Where(q => q.OrderId.Equals(orderId)).Sum(q => q.Price * q.OrderNumber * q.Discount);

                if (pay == 0) { return Json(new { code = -2, msg = "请不要提交没有额度的订单" }); }

                order.Payable = pay;
                order.Paid = pay;
                order.Remark = remark;
                order.SubmitTime = DateTime.Now;
                order.Status = OrderStatus.BeforeSend;

                db.SaveChanges();
            }

            return Json(new { code = 1, msg = "提交订单成功" });
        }
Example #10
0
        public JsonResult deleteNotice(string noticeId)
        {
            using (DBContext db = new DBContext())
            {
                Notice notice = db.Notice.Where(q => q.ID.Equals(noticeId)).FirstOrDefault();

                if (notice == null) { return Json(new { code = -1, msg = "您要删除的公告不存在" }); }

                db.Notice.Remove(notice);

                db.SaveChanges();

                return Json(new { code = 1, msg = "删除成功" });
            }
        }
Example #11
0
        public JsonResult delItem(string itemId)
        {
            string orderId = string.Empty;

            using (DBContext db = new DBContext())
            {
                OrderItem item = db.OrderItem.Where(q => q.ID.Equals(itemId)).FirstOrDefault();

                if (item == null) { return Json(new { code = -1, msg = "找不到对应商品" }); }

                orderId = item.OrderId;

                db.OrderItem.Remove(item);

                db.SaveChanges();
            }

            Order.RefreshPay(orderId);

            return Json(new { code = 1, msg = "删除成功" });
        }
Example #12
0
        public JsonResult editRole(GuserRole role)
        {
            using (DBContext db = new DBContext())
            {
                //判断名称是否重复
                GuserRole sameName = db.GuserRole.Where(q => q.RoleName.Equals(role.RoleName) && !q.ID.Equals(role.ID)).FirstOrDefault();

                if (sameName != null) { return Json(new { code = -1, msg = "已有同名角色" }); }

                //判断权限值是否重复
                GuserRole sameAuth = db.GuserRole.Where(q => q.RoleVal.Equals(role.RoleVal) && !q.ID.Equals(role.ID)).FirstOrDefault();

                if (sameAuth != null) { return Json(new { code = -2, msg = "已有相同权限的角色" }); }

                GuserRole oldRole = db.GuserRole.Where(q => q.ID.Equals(role.ID)).FirstOrDefault();

                if (oldRole == null)
                {
                    role.CreatorID = UserContext.user.ID;
                    role.Creator = UserContext.user.DisplayName;
                    role.Status = Status.enable;

                    db.GuserRole.Add(role);
                }
                else
                {
                    List<Guser> users = db.Guser.Where(q => q.RoleId.Equals(role.ID)).ToList();

                    if (users.Count > 0 && role.Status == Status.disable) { return Json(new { code = -3, msg = "不能禁用已有用户的角色" }); }

                    oldRole.ModifyTime = DateTime.Now;
                    oldRole.RoleName = role.RoleName;
                    oldRole.RoleVal = role.RoleVal;
                    oldRole.Status = role.Status;

                    db.Entry(oldRole).State = EntityState.Modified;
                }
                db.SaveChanges();
            }

            return Json(new { code = 1, msg = "保存成功" });
        }
Example #13
0
        public JsonResult editNotice(Notice notice)
        {
            using (DBContext db = new DBContext())
            {
                //判断标题是否重复
                Notice sameTitle = db.Notice.Where(q => q.Title.Equals(notice.Title) && !q.ID.Equals(notice.ID)).FirstOrDefault();

                if (sameTitle != null) { return Json(new { code = -1, msg = "已存在相同标题的公告" }); }

                Notice oldNotice = db.Notice.Where(q => q.ID.Equals(notice.ID)).FirstOrDefault();

                if (oldNotice == null)
                {
                    notice.CreatorID = UserContext.user.ID;
                    notice.Creator = UserContext.user.DisplayName;
                    notice.Status = NoticeStatus.Draft;

                    db.Notice.Add(notice);
                }
                else
                {
                    if (oldNotice.Status == NoticeStatus.Published) { return Json(new { code = -2, msg = "已发布的公告不可以修改" }); }

                    oldNotice.ModifyTime = DateTime.Now;
                    oldNotice.Title = notice.Title;
                    oldNotice.Content = notice.Content;
                    oldNotice.Status = notice.Status;

                    db.Entry(oldNotice).State = EntityState.Modified;
                }
                db.SaveChanges();
            }

            return Json(new { code = 1, msg = "保存成功" });
        }
        public JsonResult deleteNumber(string id)
        {
            using (DBContext db = new DBContext())
            {
                StoreProduct product = db.StoreProduct.Where(q => q.ID.Equals(id)).FirstOrDefault();

                if (product == null) { return Json(new { code = -1, msg = "您要删除的用户不存在" }); }

                db.StoreProduct.Remove(product);

                db.SaveChanges();

                return Json(new { code = 1, msg = "删除成功" });
            }
        }
Example #15
0
        public JsonResult deleteProduct(string productId)
        {
            using (DBContext db = new DBContext())
            {
                Product product = db.Product.Where(q => q.ID.Equals(productId)).FirstOrDefault();

                if (product == null) { return Json(new { code = -1, msg = "您要删除的用户不存在" }); }

                if (!string.IsNullOrEmpty(product.DocId))
                {
                    string basePath = string.Format(@"{0}Upload\", Server.MapPath("/"));

                    Doc.delete(product.DocId, basePath);
                }

                db.Product.Remove(product);

                db.SaveChanges();

                return Json(new { code = 1, msg = "删除成功" });
            }
        }
Example #16
0
        public JsonResult editItem(OrderItem item)
        {
            using (DBContext db = new DBContext())
            {
                //判断订单是否存在
                Order order = db.Order.Where(q => q.ID.Equals(item.OrderId)).FirstOrDefault();

                if (order == null) { return Json(new { code = -1, msg = "找不到对应订单" }); }

                if (order.Status > OrderStatus.BeforeSubmit && UserContext.store != null) { return Json(new { code = -2, msg = "您没有权限修改已提交过的订单" }); }

                if (order.Status == OrderStatus.Sended) { return Json(new { code = -3, msg = "订单已发货,无法修改" }); }

                if (order.Status == OrderStatus.Reject) { return Json(new { code = -4, msg = "订单已被驳回,无法修改" }); }

                //判断订单中是否已有此样商品
                OrderItem sameItem = db.OrderItem.Where(q => q.OrderId.Equals(item.OrderId) && q.ProductId.Equals(item.ProductId) && !q.ID.Equals(item.ID)).FirstOrDefault();

                if (sameItem != null) { return Json(new { code = -5, msg = "订单中已有相同商品" }); }

                OrderItem oldItem = db.OrderItem.Where(q => q.ID.Equals(item.ID)).FirstOrDefault();

                if (oldItem == null)
                {
                    Product product = db.Product.Where(q => q.ID.Equals(item.ProductId)).FirstOrDefault();

                    if (product == null) { return Json(new { code = -6, msg = "抱歉,找不到对应商品" }); }

                    item.ID = StringUtil.UniqueID();
                    item.ProductCode = product.ProductCode;
                    item.ProductName = product.ProductName;
                    item.Price = product.Price;
                    item.RealNumber = item.OrderNumber;

                    db.OrderItem.Add(item);
                }
                else
                {
                    oldItem.OrderNumber = item.OrderNumber;
                    oldItem.RealNumber = item.OrderNumber;

                    db.Entry(oldItem).State = EntityState.Modified;
                }

                db.SaveChanges();
            }

            Order.RefreshPay(item.OrderId);

            return Json(new { code = 1, msg = "保存成功" });
        }
Example #17
0
        public JsonResult deleteStore(string storeId)
        {
            using (DBContext db = new DBContext())
            {
                Store store = db.Store.Where(q => q.ID.Equals(storeId)).FirstOrDefault();

                if (store == null) { return Json(new { code = -1, msg = "您要删除的门店不存在" }); }

                db.Store.Remove(store);

                db.SaveChanges();

                return Json(new { code = 1, msg = "删除成功" });
            }
        }
Example #18
0
        public JsonResult editProduct(Product product)
        {
            using (DBContext db = new DBContext())
            {
                //判断编号是否重复
                Product sameCode = db.Product.Where(q => q.ProductCode.Equals(product.ProductCode) && !q.ID.Equals(product.ID)).FirstOrDefault();

                if (sameCode != null) { return Json(new { code = -1, msg = "商品编号已被注册" }); }

                Product oldProduct = db.Product.Where(q => q.ID.Equals(product.ID)).FirstOrDefault();

                if (oldProduct == null)
                {
                    product.CreatorID = UserContext.user.ID;
                    product.Creator = UserContext.user.DisplayName;
                    product.Name = product.ProductName;
                    product.Status = Status.enable;
                    product.StoreId = UserContext.store.ID;

                    db.Product.Add(product);
                }
                else
                {
                    if (UserContext.store != null && UserContext.store.ID != oldProduct.StoreId) { return Json(new { code = -2, msg = "抱歉,您没有权限修改本商品" }); }

                    if (!string.IsNullOrEmpty(oldProduct.DocId) && !oldProduct.DocId.Equals(product.DocId))
                    {
                        string basePath = string.Format(@"{0}Upload\", Server.MapPath("/"));

                        Doc.delete(oldProduct.DocId, basePath);
                    }

                    oldProduct.ModifyTime = DateTime.Now;
                    oldProduct.ProductCode = product.ProductCode;
                    oldProduct.Name = product.ProductName;
                    oldProduct.ProductType = product.ProductType;
                    oldProduct.Price = product.Price;
                    oldProduct.AllowReturn = product.AllowReturn;
                    oldProduct.Remark = product.Remark;
                    oldProduct.DocId = product.DocId;
                    oldProduct.Status = product.Status;

                    db.Entry(oldProduct).State = EntityState.Modified;
                }
                db.SaveChanges();
            }

            return Json(new { code = 1, msg = "保存成功" });
        }
Example #19
0
        public JsonResult editDict(Dictionary dict)
        {
            using (DBContext db = new DBContext())
            {
                Dictionary oldOne = db.Dictionary.Where(q => q.ID.Equals(dict.ID)).FirstOrDefault();

                if (oldOne == null)
                {
                    dict.CreatorID = UserContext.user.ID;
                    dict.Creator = UserContext.user.DisplayName;

                    db.Dictionary.Add(dict);
                }
                else
                {
                    oldOne.SortOrder = dict.SortOrder;
                    oldOne.Name = dict.Name;

                    //只有子项的值可以修改
                    if (!string.IsNullOrEmpty(oldOne.ParentCode))
                    {
                        oldOne.Code = dict.Code;
                    }

                    oldOne.ModifyTime = DateTime.Now;

                    db.Entry(oldOne).State = EntityState.Modified;
                }
                db.SaveChanges();
            }

            return Json(new { code = 1, msg = "保存成功" });
        }
Example #20
0
        public JsonResult editUser(Guser user)
        {
            using (DBContext db = new DBContext())
            {
                //判断编号是否重复
                Guser sameAccount = db.Guser.Where(q => q.Account.Equals(user.Account) && !q.ID.Equals(user.ID)).FirstOrDefault();

                if (sameAccount != null) { return Json(new { code = -1, msg = "用户编号已被注册" }); }

                Guser oldUser = db.Guser.Where(q => q.ID.Equals(user.ID)).FirstOrDefault();

                if (oldUser == null)
                {
                    user.CreatorID = UserContext.user.ID;
                    user.Creator = UserContext.user.DisplayName;
                    user.Name = user.DisplayName;
                    user.PassWord = StringUtil.Md5Encrypt("888");
                    user.Status = Status.enable;

                    db.Guser.Add(user);
                }
                else
                {
                    oldUser.ModifyTime = DateTime.Now;
                    oldUser.CardNumber = user.CardNumber;
                    oldUser.Name = user.DisplayName;
                    oldUser.RoleId = user.RoleId;
                    oldUser.Sex = user.Sex;
                    oldUser.Tel = user.Tel;
                    oldUser.Status = user.Status;

                    db.Entry(oldUser).State = EntityState.Modified;
                }
                db.SaveChanges();
            }

            return Json(new { code = 1, msg = "保存成功" });
        }
Example #21
0
        public JsonResult editStore(Store store)
        {
            using (DBContext db = new DBContext())
            {
                //判断店名是否重复
                Store sameName = db.Store.Where(q => q.StoreName.Equals(store.StoreName) && !q.ID.Equals(store.ID)).FirstOrDefault();

                if (sameName != null) { return Json(new { code = -1, msg = "门店名称已被注册" }); }

                Store oldStore = db.Store.Where(q => q.ID.Equals(store.ID)).FirstOrDefault();

                if (oldStore == null)
                {
                    //生成流水号
                    int code = db.Store.Count() == 0 ? 80000 : Convert.ToInt32(db.Store.Max(q => q.StoreCode)) + 1;

                    store.StoreCode = code.ToString();
                    store.CreatorID = UserContext.user.ID;
                    store.Creator = UserContext.user.DisplayName;
                    store.Name = store.StoreName;
                    store.Status = Status.enable;

                    db.Store.Add(store);
                }
                else
                {
                    oldStore.ModifyTime = DateTime.Now;
                    oldStore.Name = store.StoreName;
                    oldStore.UserId = store.UserId;
                    oldStore.Address = store.Address;
                    oldStore.Lng = store.Lng;
                    oldStore.Lat = store.Lat;
                    oldStore.Presider = store.Presider;
                    oldStore.Tel = store.Tel;
                    oldStore.StoreType = store.StoreType;
                    oldStore.Discount = store.Discount;
                    oldStore.Alipay = store.Alipay;
                    oldStore.WeiXin = store.WeiXin;
                    oldStore.Bank = store.Bank;
                    oldStore.BankName = store.BankName;
                    oldStore.BankAccount = store.BankAccount;
                    oldStore.Status = store.Status;

                    db.Entry(oldStore).State = EntityState.Modified;
                }
                db.SaveChanges();
            }

            return Json(new { code = 1, msg = "保存成功" });
        }
Example #22
0
        public JsonResult deleteUser(string userId)
        {
            using (DBContext db = new DBContext())
            {
                Guser user = db.Guser.Where(q => q.ID.Equals(userId)).FirstOrDefault();

                if (user == null) { return Json(new { code = -1, msg = "您要删除的用户不存在" }); }

                db.Guser.Remove(user);

                db.SaveChanges();

                return Json(new { code = 1, msg = "删除成功" });
            }
        }
Example #23
0
        public JsonResult sendProduct(string orderId, decimal pay, string expressCode, string expressUrl)
        {
            if (pay <= 0) { return Json(new { code = -1, msg = "订单金额必须为正数" }); }

            using (DBContext db = new DBContext())
            {
                Order order = db.Order.Where(q => q.ID.Equals(orderId)).FirstOrDefault();

                if (order == null) { return Json(new { code = -2, msg = "找不到对应订单" }); }

                if (order.Status != OrderStatus.BeforeSend) { return Json(new { code = -3, msg = "订单已发货,无法重复发货" }); }

                Guser user = UserContext.user;

                order.ModifyTime = DateTime.Now;
                order.Paid = pay;
                order.ExpressCode = expressCode;
                order.ExpressUrl = expressUrl;
                order.DeliverId = user.ID;
                order.DeliverName = user.DisplayName;
                order.DeliverTel = user.Tel;
                order.Status = OrderStatus.Sended;

                db.SaveChanges();
            }

            return Json(new { code = 1, msg = "提交订单成功" });
        }
Example #24
0
        public JsonResult deleteCourier(string courierId)
        {
            using (DBContext db = new DBContext())
            {
                Courier courier = db.Courier.Where(q => q.ID.Equals(courierId)).FirstOrDefault();

                if (courier == null) { return Json(new { code = -1, msg = "您要删除的送餐员不存在" }); }

                db.Courier.Remove(courier);

                db.SaveChanges();

                return Json(new { code = 1, msg = "删除成功" });
            }
        }
        public JsonResult editNumber(StoreProduct product)
        {
            using (DBContext db = new DBContext())
            {
                Store store = UserContext.store;

                //判断是否已存在相同商品
                StoreProduct sameProduct = db.StoreProduct.Where(q => q.ProductID.Equals(product.ProductID) && q.StoreID.Equals(store.ID) && !q.ID.Equals(product.ID)).FirstOrDefault();

                if (sameProduct != null) { return Json(new { code = -1, msg = "已存在相同商品" }); }

                StoreProduct oldOne = db.StoreProduct.Where(q => q.ID.Equals(product.ID)).FirstOrDefault();

                if (oldOne == null)
                {
                    product.ID = StringUtil.UniqueID();
                    product.StoreID = store.ID;

                    db.StoreProduct.Add(product);
                }
                else
                {
                    oldOne.ProductNumber = product.ProductNumber;
                    oldOne.OnlinePrice = product.OnlinePrice;
                    oldOne.OfflinePrice = product.OfflinePrice;

                    db.Entry(oldOne).State = EntityState.Modified;
                }
                db.SaveChanges();
            }

            return Json(new { code = 1, msg = "保存成功" });
        }
Example #26
0
        public JsonResult deleteRole(string roleId)
        {
            using (DBContext db = new DBContext())
            {
                GuserRole role = db.GuserRole.Where(q => q.ID.Equals(roleId)).FirstOrDefault();

                if (role == null) { return Json(new { code = -1, msg = "您要删除的角色不存在" }); }

                List<Guser> users = db.Guser.Where(q => q.RoleId.Equals(roleId)).ToList();

                if (users.Count > 0) { return Json(new { code = -2, msg = "该角色下已有用户,不能删除" }); }

                db.GuserRole.Remove(role);

                db.SaveChanges();

                return Json(new { code = 1, msg = "删除成功" });
            }
        }
Example #27
0
        public JsonResult editItem(OrderItem item)
        {
            using (DBContext db = new DBContext())
            {
                //判断订单是否存在
                Order order = db.Order.Where(q => q.ID.Equals(item.OrderId)).FirstOrDefault();

                if (order == null) { return Json(new { code = -1, msg = "找不到对应订单" }); }

                if (order.Status == OrderStatus.Sended) { return Json(new { code = -2, msg = "订单已发货,无法修改" }); }

                if (order.Status == OrderStatus.Reject) { return Json(new { code = -3, msg = "订单已被驳回,无法修改" }); }

                OrderItem oldItem = db.OrderItem.Where(q => q.ID.Equals(item.ID)).FirstOrDefault();

                if (oldItem == null)
                {
                    return Json(new { code = -4, msg = "找不到对应商品" });
                }

                oldItem.Discount = item.Discount;
                oldItem.RealNumber = item.RealNumber;

                db.Entry(oldItem).State = EntityState.Modified;

                db.SaveChanges();
            }

            decimal pay = Order.RefreshPay(item.OrderId);

            return Json(new { code = 1, msg = "保存成功", pay = pay });
        }
Example #28
0
        public ActionResult addOrder()
        {
            Guser user = UserContext.user;

            Store store = UserContext.store;

            if (store == null) { return null; }

            using (DBContext db = new DBContext())
            {
                DateTime now = DateTime.Now;

                string code = db.Order.Where(q => q.StoreId.Equals(store.ID)).Max(q => q.OrderCode);

                string start = string.Format("{0}{1}", store.StoreCode, now.ToString("yyMMdd"));

                if (code == null || !code.StartsWith(start))
                {
                    code = string.Format("{0}{1}00", store.StoreCode, now.ToString("yyMMdd"));
                }
                else
                {
                    int num = Convert.ToInt16(code.Substring(start.Length)) + 1;

                    if (num > 99) { return null; }

                    string numStr = num > 9 ? num.ToString() : "0" + num;

                    code = start + numStr;
                }

                Order order = new Order()
                {
                    Creator = user.DisplayName,
                    CreatorID = user.ID,
                    OrderCode = code,
                    StoreId = store.ID,
                    StoreName = store.StoreName,
                    Tel = user.Tel,
                    Status = OrderStatus.BeforeSubmit,
                    SubmitTime = now
                };

                db.Order.Add(order);
                db.SaveChanges();

                return RedirectToAction("Index", "OrderEdit", new { orderId = order.ID });
            }
        }