Exemple #1
0
        public shSale Insert_Update(
            string SaleGuid,
            int?SaleId,
            string SaleName,
            string SaleCode,
            string Description,
            int?CachTinhGiaTriKhuyenMai,
            string GiaTri,
            int?DieuKienApDung,
            DateTime?StartTime,
            DateTime?EndTime,
            int?SaleStatus,
            int?UserId,
            string MetaTitle,
            bool?Status,
            DateTime?CreateDate)
        {
            shSaleService _sale = new shSaleService();
            shSale        sale  = new shSale();

            if (!string.IsNullOrEmpty(SaleGuid) || !string.IsNullOrWhiteSpace(SaleGuid))
            {
                sale = _sale.FindByKey(SaleGuid);
            }
            else
            {
                sale.SaleGuid = GuidUnique.getInstance().GenerateUnique();
            }
            //sale.SaleDetailGuid
            sale.SaleName                = SaleName;
            sale.SaleCode                = SaleCode;
            sale.Description             = Description;
            sale.CachTinhGiaTriKhuyenMai = CachTinhGiaTriKhuyenMai;
            sale.GiaTri         = GiaTri;
            sale.DieuKienApDung = DieuKienApDung;
            sale.StartTime      = StartTime;
            sale.EndTime        = EndTime;
            sale.SaleStatus     = SaleStatus;
            sale.UserId         = UserId;
            sale.MetaTitle      = MetaTitle;
            sale.Status         = Status;
            sale.CreateDate     = CreateDate;

            if (sale.SaleId > 0)
            {
                _sale.Update(sale);
            }
            else
            {
                _sale.Insert(sale);
            }

            return(sale);
        }
Exemple #2
0
        public shSale ChuongTrinhKhuyenMaiHienTai(DateTime dt)
        {
            shSaleService        _sale = new shSaleService();
            IEnumerable <shSale> ds    = DanhSach();
            shSale sale = new shSale();

            sale = ds.Where(x => TypeHelper.CompareDate(dt, x.StartTime.GetValueOrDefault(dt)) ||
                            TypeHelper.CompareDate(x.EndTime.GetValueOrDefault(dt), dt))
                   .FirstOrDefault();

            return(sale);
        }
Exemple #3
0
        public decimal ProductPrice(string SizeGuid)
        {
            decimal price = default(decimal);

            if (!string.IsNullOrEmpty(SizeGuid) || !string.IsNullOrWhiteSpace(SizeGuid))
            {
                shSaleService _sale = new shSaleService();
                price = _sale.TinhToanSoTienKhuyenMaiCuaSanPham(DateTime.Now, null, SizeGuid);
            }

            return(price);
        }
Exemple #4
0
        public decimal ListProductPrice_Quantity(List <CartItem> ds, decimal MatHangGiamGia, decimal DiemThuong, decimal PhiGiaoHang)
        {
            shSaleService _sale = new shSaleService();
            decimal       price = default(decimal);

            foreach (var item in ds)
            {
                price += _sale.TinhToanSoTienKhuyenMaiCuaSanPham(DateTime.Now, null, item.SizeGuid) * item.Quantity;
            }

            if (ds.Count() > 0)
            {
                price -= MatHangGiamGia - DiemThuong - PhiGiaoHang;
            }


            return(price);
        }
Exemple #5
0
        public IEnumerable <shSale> DanhSach()
        {
            shSaleService _sale = new shSaleService();

            return(_sale.FindList().Where(x => x.Status == true).OrderBy(x => x.SaleId));
        }
Exemple #6
0
        public shSale ThemMoi_CapNhatKhuyenMai(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,
                                               int?UserId,
                                               bool Status, DateTime?CreateDate)
        {
            shSaleService _sale = new shSaleService();
            shSale        sale  = new shSale();

            // 1. Thêm mới bảng shSale
            #region shSale
            string GiaTri = string.Empty;

            if (CachTinhGiaTriKhuyenMai == C.Core.Common.CachTinhGiaTriKhuyenMai.GiamTheoPhanTramGiaTri.GetHashCode())
            {
                GiaTri = Format.FormatDecimalToString(Percent.GetValueOrDefault(0)).Replace(",", "");
                GiaTri = Convert.ToInt32(Percent.GetValueOrDefault(0)).ToString();
            }
            else if (CachTinhGiaTriKhuyenMai == C.Core.Common.CachTinhGiaTriKhuyenMai.GiamTheoSoTien.GetHashCode())
            {
                GiaTri = Convert.ToInt32(USD.GetValueOrDefault(0)).ToString();
            }

            sale = Insert_Update(
                SaleGuid,
                null,
                SaleName,
                SaleCode,
                Description,
                CachTinhGiaTriKhuyenMai,
                GiaTri,
                DieuKienApDung,
                TypeHelper.ToDate(StartTime),
                TypeHelper.ToDate(EndTime),
                SaleStatus,
                UserId,
                null,
                Status,
                CreateDate);
            #endregion

            // 2. Thêm mới bảng shSaleDetail
            #region ShSaleDetail
            string        MaCauHinh = Config.DieuKienApDungKhuyenMai_TatCaSanPham;
            List <string> DanhSach  = new List <string>();

            if (DieuKienApDung == DieuKienApDungKhuyenMai.TatCaSanPham.GetHashCode())
            {
                MaCauHinh = Config.DieuKienApDungKhuyenMai_TatCaSanPham;
                DanhSach.Add(Config.DieuKienApDungKhuyenMai_MaCauHinh_TatCaSanPham);
            }
            else if (DieuKienApDung == DieuKienApDungKhuyenMai.TheoDanhMuc.GetHashCode())
            {
                MaCauHinh = Config.DieuKienApDungKhuyenMai_TheoDanhMuc;
                DanhSach  = CagegoryChild.ToList();
            }
            else if (DieuKienApDung == DieuKienApDungKhuyenMai.TheoSanPhamRiengBiet.GetHashCode())
            {
                MaCauHinh = Config.DieuKienApDungKhuyenMai_TheoSanPham;
                DanhSach  = ProductGuid1.ToList();
            }


            shSaleDetailService _saleService = new shSaleDetailService();
            foreach (var item in DanhSach)
            {
                shSaleDetail saleDetail = _saleService.InsertOrUpdate(
                    null,
                    null,
                    sale.SaleGuid,
                    CachTinhGiaTriKhuyenMai,
                    GiaTri,
                    DieuKienApDung,
                    TypeHelper.ToDate(StartTime),
                    TypeHelper.ToDate(EndTime),
                    null,
                    null,
                    null,
                    null,
                    null,
                    null, null,
                    true,
                    DateTime.Now,
                    MaCauHinh,
                    item);
            }
            #endregion

            return(sale);
        }