Exemple #1
0
        public static string TinhToanGiaTienSauKhiGiam(shSetSize first, shSetSize last)
        {
            string price = string.Empty;

            decimal _price = default(decimal);

            if (first != null)
            {
                if (first.PriceCurrent == null)
                {
                    first.PriceCurrent = 0;
                }
                else
                {
                    shSaleService _sale = new shSaleService();
                    shSale        sale  = _sale.ChuongTrinhKhuyenMaiHienTai(DateTime.Now);

                    _price = _sale.TinhToanSoTienKhuyenMaiCuaSanPham(DateTime.Now, first.ProductGuid, first.SizeGuid);
                }
            }
            if (_price > 0)
            {
                return(_price.ToString());
            }
            else
            {
                return(string.Empty);
            }
        }
        public ActionResult TinhToanGiaTriKhuyenMai(string ProductGuid, string SizeGuid)
        {
            shSaleService _sale = new shSaleService();

            decimal SoTienSanPhamSauKM = _sale.TinhToanSoTienKhuyenMaiCuaSanPham(DateTime.Now, ProductGuid, SizeGuid);

            string sotien = string.Empty;

            if (SoTienSanPhamSauKM > 0)
            {
                sotien = Format.FormatDecimalToString(SoTienSanPhamSauKM);
            }

            return(Json(sotien, JsonRequestBehavior.AllowGet));
        }
        public PartialViewResult ListSale(int?page)
        {
            int pageCurrent = 1;

            if (page.HasValue)
            {
                pageCurrent = page.Value;
            }

            shSaleService       _sale  = new shSaleService();
            IPagedList <shSale> dsSale = _sale.DanhSach_PhanTrang(pageCurrent, Config.PAGE_SIZE_20);

            ViewBag.ListSale = dsSale;
            return(PartialView("ListSale", dsSale));
        }
        public ActionResult Create(string id)
        {
            shSaleService _sale = new shSaleService();
            shSale        sale  = _sale.FindByKey(id);

            if (sale != null)
            {
            }
            else
            {
                sale = new shSale();
            }

            ViewBag.Status    = new SelectList(SaleHelper.DanhsachTrangThaiKhuyenMai(), "Value", "Text", sale.SaleStatus);
            ViewBag.KhuyenMai = new SelectList(SaleHelper.DanhsachCachTinhGiaTriKhuyenMai(), "Value", "Text", sale.CachTinhGiaTriKhuyenMai);

            return(View(new shSale()));
        }
        public ActionResult Create(string SaleGuid, string SaleName,
                                   string SaleCode, int?SaleStatus, string Description,
                                   string StartTime, string EndTime, int?CachTinhGiaTriKhuyenMai,
                                   decimal?Percent, double?USD, int?DieuKienApDung,
                                   string[] CagegoryChild,
                                   string[] ProductGuid1)
        {
            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        shSaleService _sale = new shSaleService();
                        shSale        sale  = _sale.ThemMoi_CapNhatKhuyenMai(
                            SaleGuid,
                            SaleName,
                            SaleCode,
                            SaleStatus,
                            Description,
                            StartTime,
                            EndTime,
                            CachTinhGiaTriKhuyenMai,
                            Percent,
                            USD,
                            DieuKienApDung,
                            CagegoryChild,
                            ProductGuid1,
                            User.Identity.GetUserLogin().Userid,
                            true,
                            DateTime.Now);

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

            return(RedirectToAction("Index"));
        }
Exemple #6
0
        public static MvcHtmlString ChuongTrinhKhuyenMaiSanPham(this HtmlHelper helper, string ProductGuid, int LoaiHienThi)
        {
            string        html       = string.Empty;
            shSaleService _sale      = new shSaleService();
            shSaleDetail  saleDetail = _sale.KiemTraSanPhamNamTrongChuongTrinhKhuyenMai(DateTime.Now, ProductGuid, null);

            if (LoaiHienThi == 1)
            {
                html = SaleHelper.TenCachTinhGiaTriKhuyenMai(saleDetail.CachTinhGiaTriKhuyenMai.GetValueOrDefault(CachTinhGiaTriKhuyenMai.GiamTheoPhanTramGiaTri.GetHashCode()));
            }
            else if (LoaiHienThi == 2)
            {
                html = SizeHelper.FormatGiaTriKhuyenMai(
                    saleDetail.CachTinhGiaTriKhuyenMai.GetValueOrDefault(CachTinhGiaTriKhuyenMai.GiamTheoPhanTramGiaTri.GetHashCode()),
                    saleDetail.GiaTri);
            }
            else if (LoaiHienThi == 3)
            {
                html = saleDetail.StartDate.GetValueOrDefault(DateTime.Now).ToString("dd-MM") + " - " +
                       saleDetail.EndDate.GetValueOrDefault(DateTime.Now).ToString("dd-MM");
            }

            return(new MvcHtmlString(html));
        }