Пример #1
0
        public shSaleDetail KiemTraSanPhamNamTrongChuongTrinhKhuyenMai(DateTime dt, string ProductGuid, string SizeGuid)
        {
            shSale       sale       = ChuongTrinhKhuyenMaiHienTai(dt);
            shSaleDetail saleDetail = new shSaleDetail();

            if (sale == null)
            {
                return(saleDetail);
            }

            shSaleDetailService        _saleService = new shSaleDetailService();
            IEnumerable <shSaleDetail> ds           = _saleService.DanhSachBySaleGuid(sale.SaleGuid);

            if (sale.DieuKienApDung == DieuKienApDungKhuyenMai.TatCaSanPham.GetHashCode())
            {
                saleDetail = ds.FirstOrDefault();
                return(saleDetail);
            }
            else if (sale.DieuKienApDung == DieuKienApDungKhuyenMai.TheoDanhMuc.GetHashCode())
            {
                shProductService _product = new shProductService();
                shProduct        product  = _product.FindByKey(ProductGuid);

                foreach (var item in ds)
                {
                    if (item.CategoryGuidProductGuid == product.CategoryGuid)
                    {
                        saleDetail = item;
                        return(item);
                    }
                }
            }
            else if (sale.DieuKienApDung == DieuKienApDungKhuyenMai.TheoSanPhamRiengBiet.GetHashCode())
            {
                shProductService _product = new shProductService();
                shProduct        product  = _product.FindByKey(ProductGuid);

                foreach (var item in ds)
                {
                    if (item.CategoryGuidProductGuid == product.ProductGuid)
                    {
                        saleDetail = item;
                        return(item);
                    }
                }
            }
            return(saleDetail);
        }
Пример #2
0
        public shSaleDetail InsertOrUpdate(
            string SaleDetailGuid,
            int?SaleDetailId,
            string SaleGuid,
            int?CachTinhGiaTriKhuyenMai,
            string GiaTri,
            int?DieuKienApDung,
            DateTime?StartDate,
            DateTime?EndDate,
            String CategoryGuid,        //
            string ProductGuid,         //
            int?Percents,               //
            string Description,         //
            string Notes,               //
            decimal?PriceAfterPercents, //
            string SaleAttach,          //
            bool?Status,                //
            DateTime?CreateDate,        //
            string MaCauHinh,
            string CategoryGuidProductGuid
            )
        {
            shSaleDetailService _sale = new shSaleDetailService();
            shSaleDetail        sale  = new shSaleDetail();

            if (!string.IsNullOrEmpty(SaleDetailGuid) || !string.IsNullOrWhiteSpace(SaleDetailGuid))
            {
                sale = _sale.FindByKey(SaleDetailGuid);
            }
            else
            {
                sale.SaleDetailGuid = GuidUnique.getInstance().GenerateUnique();
            }

            //sale.SaleDetailId = SaleDetailId;
            sale.SaleGuid = SaleGuid;
            sale.CachTinhGiaTriKhuyenMai = CachTinhGiaTriKhuyenMai;
            sale.GiaTri                  = GiaTri;
            sale.DieuKienApDung          = DieuKienApDung;
            sale.StartDate               = StartDate;
            sale.EndDate                 = EndDate;
            sale.CategoryGuid            = CategoryGuid;
            sale.ProductGuid             = ProductGuid;
            sale.Percents                = Percents;
            sale.Description             = Description;
            sale.Notes                   = Notes;
            sale.PriceAfterPercents      = PriceAfterPercents;
            sale.SaleAttach              = SaleAttach;
            sale.Status                  = Status;
            sale.CreateDate              = CreateDate;
            sale.CategoryGuidProductGuid = CategoryGuidProductGuid;
            sale.MaCauHinh               = MaCauHinh;

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

            return(sale);
        }
Пример #3
0
        public IEnumerable <shSaleDetail> DanhSach()
        {
            shSaleDetailService _sale = new shSaleDetailService();

            return(_sale.FindList().Where(x => x.Status == true).OrderBy(x => x.SaleDetailId));
        }
Пример #4
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);
        }