Beispiel #1
0
        public ActionResult RatingOrder(string OrderGuid, int?OrderStatus, string Description)
        {
            shOrderService _order = new shOrderService();
            shOrder        order  = _order.FindByKey(OrderGuid);

            OrderStatus = C.Core.Common.OrderStatus.DaGiaoHang_DaXacNhan.GetHashCode();

            string MemberGuid = null;

            if (User.Identity.GetMemberLogin() != null)
            {
                MemberGuid = User.Identity.GetMemberLogin().MemberGuid;
            }
            shOrderHistoryService _orderHistory = new shOrderHistoryService();
            shOrderHistory        orderHistory  = _orderHistory.Insert_Update(
                null,
                order.OrderGuid,
                OrderStatus,
                MemberGuid,
                Description,
                null,
                true,
                DateTime.Now);

            order.OrderStatus = OrderStatus;
            _order.Update(order);

            if (Request.IsAjaxRequest())
            {
                return(Json("OK", JsonRequestBehavior.AllowGet));
            }

            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult Details(string OrderGuid)
        {
            shOrderService _order = new shOrderService();
            shOrder        order  = _order.FindByKey(OrderGuid);

            if (order == null)
            {
                order = new shOrder();
            }

            return(PartialView("Details", order));
        }
Beispiel #3
0
        public ActionResult RatingOrder(string OrderGuid)
        {
            shOrderService _order = new shOrderService();
            shOrder        order  = _order.FindByKey(OrderGuid);

            List <DropDownList> ds = OrderHelper.DanhSachTrangThaiGioHang(null);

            ViewBag.OrderStatus = new SelectList(ds, "Value", "Text", C.Core.Common.OrderStatus.DaGiaoHang_DaXacNhan.GetHashCode());


            return(PartialView("RatingOrder", order));
        }
Beispiel #4
0
        public ActionResult ChuyenXuLyDonHang(string OrderGuid)
        {
            shOrderService _order = new shOrderService();
            shOrder        order  = _order.FindByKey(OrderGuid);

            qtUserService        _user = new qtUserService();
            IEnumerable <qtUser> ds    = _user.DanhSachUser(null, TypeHelper.ToInt32(User.Identity.GetUserLogin().Unitid), null);

            ViewBag.UserId = new SelectList(ds, "UserId", "UserName", order.UserId);

            return(PartialView("ChuyenXuLyDonHang", order));
        }
Beispiel #5
0
        public static MvcHtmlString GiaTriDonhang(this HtmlHelper helper, string OrderGuid)
        {
            string html = string.Empty;

            shOrderService _order = new shOrderService();
            shOrder        order  = _order.FindByKey(OrderGuid);

            if (order != null)
            {
                html = "Giá trị đơn hàng: " + Format.FormatDecimalToString(order.Total.GetValueOrDefault(0) - order.FeeShip.GetValueOrDefault(0));
            }

            return(new MvcHtmlString(html));
        }
Beispiel #6
0
        public static MvcHtmlString ThongTinDonhang(this HtmlHelper helper, string OrderGuid)
        {
            string html = string.Empty;

            shOrderService _order = new shOrderService();
            shOrder        order  = _order.FindByKey(OrderGuid);

            if (order != null)
            {
                html = "Thông tin đơn hàng: " + order.FullName + "/" + order.Phone + "/" + order.Email + "/" + order.Address;
            }


            return(new MvcHtmlString(html));
        }
Beispiel #7
0
        public ActionResult DetailOrder(string OrderGuid)
        {
            shOrderService _service = new shOrderService();
            shOrder        order    = _service.FindByKey(OrderGuid);

            if (order == null)
            {
                order = new shOrder();
            }

            shOrderHistoryService        _orderHistory = new shOrderHistoryService();
            IEnumerable <shOrderHistory> ds            = _orderHistory.FindList().Where(x => x.OrderGuid == OrderGuid && x.Status == true).OrderBy(x => x.CreateDate);

            ViewBag.dsOrderHistory = ds;
            return(PartialView("DetailOrder", order));
        }
Beispiel #8
0
        public ActionResult OrderProcessing(string OrderGuid)
        {
            shOrderService _order = new shOrderService();
            shOrder        order  = _order.FindByKey(OrderGuid);

            List <DropDownList> ds = OrderHelper.DanhSachTrangThaiGioHang(null);

            ViewBag.OrderStatus = new SelectList(ds, "Value", "Text", C.Core.Common.OrderStatus.DangGiaoHang.GetHashCode());

            if (order == null)
            {
                order = new shOrder();
            }

            return(PartialView("OrderProcessing", order));
        }
Beispiel #9
0
        public ActionResult CheckOrderProcessing(string OrderGuid, int?OrderStatus, string Description)
        {
            shOrderService _order = new shOrderService();
            shOrder        order  = _order.FindByKey(OrderGuid);

            string message = "OK";

            shOrderDetailService        _orderdetail = new shOrderDetailService();
            IEnumerable <shOrderDetail> ds           = _orderdetail.DanhSachOrderDetailBy(order.OrderGuid, order.MemberGuid, null);

            bool          check = false;
            shSizeService _size = new shSizeService();
            shSetSize     size  = new shSetSize();

            foreach (var item in ds)
            {
                size = _size.FindByKey(item.SizeGuid);

                if (item.Number > size.Inventory)
                {
                    check = true;
                }
            }

            if (check)
            {
                message = "Số lượng hàng tồn trong kho không đủ. Xin vui lòng thao tác lại";
            }

            if (Request.IsAjaxRequest())
            {
                return(Json(message, JsonRequestBehavior.AllowGet));
            }

            return(RedirectToAction("Index"));
        }
Beispiel #10
0
        public ActionResult OrderStatus(string OrderGuid, int?Status, string Description)
        {
            shOrderService _order = new shOrderService();
            shOrder        order  = _order.FindByKey(OrderGuid);

            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        if (order != null)
                        {
                            shOrderHistoryService _orderHistory = new shOrderHistoryService();

                            // 1. Hủy đơn hàng
                            int UserId = 0;
                            if (User.Identity.GetUserLogin() != null)
                            {
                                UserId = User.Identity.GetUserLogin().Userid;
                            }

                            string         MemberGuid   = null;
                            shOrderHistory orderHistory = _orderHistory.Insert_Update(
                                null,
                                order.OrderGuid,
                                order.OrderStatus,
                                MemberGuid,
                                Description,
                                UserId,
                                true,
                                DateTime.Now);

                            order.OrderStatus = C.Core.Common.OrderStatus.HuyDonHang.GetHashCode();
                            _order.Update(order);

                            // 2. Thông báo cho member đơn hàng hủy
                            shMemberService _member   = new shMemberService();
                            shMember        member    = _member.FindByKey(order.MemberGuid);
                            int             MemberId  = member != null ? member.MemberId : 0;
                            ThongBaoService _thongbao = new ThongBaoService();
                            _thongbao.InsertOrUpdate(
                                null,
                                "Thông báo đơn hàng bị hủy",
                                "Đơn hàng của bạn đã bị hủy. Nếu có thắc mắc vui lòng liên hệ với quản trị viên để biết thêm chi tiết",
                                null,
                                UserId,
                                MemberId,
                                DateTime.Now,
                                false,
                                Config.THONG_BAO_DA_XU_LY_DON_HANG,
                                null
                                );

                            // 3. gửi email thông báo hủy đơn hàng

                            string noidungdonhang = EmailHelper.NoiDungDonHang(order, new List <CartItem>());
                            string noidungEmail   = EmailHelper.NoiDungMailThongBaoHuyDatHang(noidungdonhang);
                            EmailHelper.ThongBaoEmailDonHangMoiToiNguoiDatHang(member.Email, noidungEmail);
                        }

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }


            if (Request.IsAjaxRequest())
            {
                return(Json("OK", JsonRequestBehavior.AllowGet));
            }

            return(RedirectToAction("Index"));
        }