Esempio n. 1
0
        public decimal TinhToanSoTienKhuyenMaiCuaSanPham(DateTime dt, string ProductGuid, string SizeGuid)
        {
            shSaleDetail saleDetail = KiemTraSanPhamNamTrongChuongTrinhKhuyenMai(dt, ProductGuid, SizeGuid);

            shSizeService _size = new shSizeService();
            shSetSize     size  = _size.FindByKey(SizeGuid);

            if (size == null)
            {
                size = new shSetSize();
            }
            decimal price = default(decimal);

            if (saleDetail.SaleDetailId > 0)  // Tồn tại sản phẩm nằm trong danh sach được khuyến mại
            {
                if (saleDetail.CachTinhGiaTriKhuyenMai == CachTinhGiaTriKhuyenMai.GiamTheoPhanTramGiaTri.GetHashCode())
                {
                    price = size.PriceCurrent.GetValueOrDefault(0) - (size.PriceCurrent.GetValueOrDefault(0) * Convert.ToInt32(saleDetail.GiaTri)) / 100;
                }
                else if (saleDetail.CachTinhGiaTriKhuyenMai == CachTinhGiaTriKhuyenMai.GiamTheoSoTien.GetHashCode())
                {
                    price = size.PriceCurrent.GetValueOrDefault(0) - Convert.ToInt32(saleDetail.GiaTri);
                }
                return(Convert.ToInt32(price));
            }

            return(price);
        }
Esempio n. 2
0
        public string SizeName(string SizeGuid)
        {
            if (!string.IsNullOrWhiteSpace(SizeGuid) || !string.IsNullOrEmpty(SizeGuid))
            {
                shSizeService _size = new shSizeService();

                shSetSize size = _size.FindByKey(SizeGuid);

                if (size == null)
                {
                    return(string.Empty);
                }
                return(size.SizeName);
            }
            return(string.Empty);
        }
Esempio n. 3
0
        public shSetSize InsertUpdateSize(string SizeGuid, int?SizeId, string ProductGuid, string SectionGuid, string SizeName, string Description, decimal?PriceCurrent, int?PercentCurrent, decimal?PriceAfterPercents, int?Number, int?SizeStatus, int?SortOrder, bool?Status, DateTime?CreateDate, string Stuff, string Parent)
        {
            shSizeService _size = new shSizeService();
            shSetSize     size  = new shSetSize();

            if (!string.IsNullOrWhiteSpace(SizeGuid))
            {
                size = _size.FindByKey(SizeGuid);
            }
            else
            {
                size.SizeGuid = GuidUnique.getInstance().GenerateUnique();
            }

            //size.SizeId = SizeId
            size.ProductGuid        = ProductGuid;
            size.SectionGuid        = SectionGuid;
            size.SizeName           = SizeName;
            size.Description        = Description;
            size.PriceCurrent       = PriceCurrent;
            size.PercentCurrent     = PercentCurrent;
            size.PriceAfterPercents = PriceAfterPercents;
            size.Number             = Number;
            size.SizeStatus         = SizeStatus;
            size.SortOrder          = SortOrder;
            size.Status             = Status;
            size.CreateDate         = CreateDate;

            Stuff = Stuff.Trim().TrimEnd().TrimStart();

            size.Stuff    = Stuff;
            size.ParentId = Parent;

            if (size.SizeId > 0)
            {
                _size.Update(size);
            }
            else
            {
                _size.Insert(size);
            }

            return(size);
        }
Esempio n. 4
0
        public IEnumerable <shSetSize> DanhSachSection_Size(string ProductGuid)
        {
            shSizeService              _size    = new shSizeService();
            shSectionService           _section = new shSectionService();
            IEnumerable <shProductSet> dsParent = _section.DanhSachSection_TheoProductGuid(ProductGuid);
            IEnumerable <shSetSize>    dsChild  = new List <shSetSize>();
            List <shSetSize>           dsSize   = new List <shSetSize>();

            foreach (var parent in dsParent)
            {
                dsChild = _size.DanhSachSize_BySectionGuid_ParentNull(parent.SectionGuid, ProductGuid, null);

                foreach (var child in dsChild)
                {
                    child.SizeName = parent.SectionName + " - " + child.SizeName + " - " + child.Stuff;
                    dsSize.Add(child);
                }
            }

            return(dsSize);
        }
Esempio n. 5
0
        public IEnumerable <shSetSize> DanhSachSize()
        {
            shSizeService _size = new shSizeService();

            return(_size.FindList().OrderByDescending(m => m.SizeId).OrderBy(m => m.SizeId).Where(m => m.Status == true));
        }
Esempio n. 6
0
        public shGoodReceiptIsuue NhapDuLieuKhoHang(
            string ReceiptIsuueGuid,
            string SizeAdd,
            int?TrangThai,
            int?LoaiPhieu,
            int?Kho,
            string GhiChu,
            int UserId,
            int?Phieu,
            string ReceiptIsuueName,
            bool?Status,
            DateTime?CreateDate)
        {
            // 1. insert-update phiếu nhập kho
            shGoodReceiptIsuue receipt = Insert_Update(
                ReceiptIsuueGuid,
                null,
                Phieu,
                ReceiptIsuueName,
                null,
                Kho,
                null,
                LoaiPhieu,
                null,
                GhiChu,
                UserId,
                TrangThai,
                Status,
                CreateDate);

            // 2. chi tiết phiếu
            shGoodReceiptIsuueDetailService _receiptDetail = new shGoodReceiptIsuueDetailService();
            shSizeService _size = new shSizeService();
            shSetSize     size  = new shSetSize();

            if (!string.IsNullOrEmpty(SizeAdd) || !string.IsNullOrWhiteSpace(SizeAdd))
            {
                string[] dsSizeAdd = SizeAdd.Split(';');

                foreach (var childSize in dsSizeAdd)
                {
                    string[] obj = childSize.Split('$');

                    if (obj != null)
                    {
                        size = _size.FindByKey(obj[0]);
                        if (size != null)
                        {
                            // 1. Thêm mới chi tiết đơn hàng nhập
                            shGoodReceiptIsuueDetail receiptDetail = _receiptDetail.Insert_Update(
                                obj[2],
                                null,
                                receipt.ReceiptIsuueGuid,
                                size.ProductGuid,
                                size.SectionGuid,
                                size.SizeGuid,
                                TypeHelper.ToInt32(obj[1]),
                                true,
                                CreateDate,
                                Phieu
                                );

                            // 2.  cập nhật số lượng shSize
                            size.Number    += receiptDetail.Number;
                            size.Inventory += receiptDetail.Number;

                            _size.Update(size);
                        }
                    }
                }
            }

            return(receipt);
        }
Esempio n. 7
0
        public shGoodReceiptIsuue XuatDuLieuDonHang(string OrderGuid, int?OrderStatus, string Description, int UserId, int Phieu, int MaKho, int LoaiPhieu, string GhiChu, int TrangThai, bool?Status, DateTime?CreateDate, string MaDonHang)
        {
            // 1. Cập nhật trạng thái đơn hàng
            shOrderService _order = new shOrderService();
            shOrder        order  = _order.FindByKey(OrderGuid);

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

            shGoodReceiptIsuue receipt = new shGoodReceiptIsuue();

            if (OrderStatus != C.Core.Common.OrderStatus.HuyDonHang.GetHashCode())
            {
                // 2. ghi lịch sử cập nhật đơn hàng
                shOrderHistoryService _orderHistory = new shOrderHistoryService();
                shOrderHistory        orderHistory  = _orderHistory.Insert_Update(
                    null,
                    order.OrderGuid,
                    OrderStatus,
                    null,
                    Description,
                    UserId,
                    true,
                    DateTime.Now);

                // 3. Tạo hóa đơn xuất kho
                receipt = Insert_Update(
                    null,
                    null,
                    Phieu,
                    null,
                    null,
                    MaKho,
                    null,
                    LoaiPhieu,
                    MaDonHang,
                    GhiChu,
                    UserId,
                    TrangThai,
                    Status,
                    CreateDate
                    );


                // 4 Cập nhật số lượng tồn của mỗi sản phẩm
                shOrderDetailService        _orderdetail = new shOrderDetailService();
                IEnumerable <shOrderDetail> ds           = _orderdetail.DanhSachOrderDetailBy(order.OrderGuid, order.MemberGuid, null);

                shSizeService _size = new shSizeService();
                shSetSize     size  = new shSetSize();
                foreach (var item in ds)
                {
                    size = _size.FindByKey(item.SizeGuid);
                    if (size == null)
                    {
                        size = new shSetSize();
                    }

                    // 5.. Tạo chi tiết hóa đơn xuất hàng hóa
                    shGoodReceiptIsuueDetailService _receiptDetail = new shGoodReceiptIsuueDetailService();
                    shGoodReceiptIsuueDetail        receiptDetail  = _receiptDetail.Insert_Update(
                        null,
                        null,
                        receipt.ReceiptIsuueGuid,
                        size.ProductGuid,
                        size.SectionGuid,
                        size.SizeGuid,
                        item.Number,
                        Status,
                        CreateDate,
                        Phieu);

                    // 6.Update số lượng tồn ở bảng size

                    size.Inventory = size.Inventory - item.Number;
                    _size.Update(size);
                }

                // 5. Thông báo cho Khach hàng biết đơn hàng đã xử lý
                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 đang trong quá trình xử lý",
                    "Đơn hàng của bạn đang trong quá trình vận chuyển. Vui lòng kiểm tra thông tin cá nhân trong quá trình chúng tôi vận chuyển sản phẩm",
                    null,
                    UserId,
                    MemberId,
                    DateTime.Now,
                    false,
                    Config.THONG_BAO_DA_XU_LY_DON_HANG,
                    null
                    );

                // 6. Gửi Email báo xử lý đơn hàng

                string noidungdonhang = EmailHelper.NoiDungDonHang(order, new List <CartItem>());
                string noidungEmail   = EmailHelper.NoiDungMailThongBaoXuLyDatHang(noidungdonhang);

                EmailHelper.ThongBaoEmailDonHangMoiToiNguoiDatHang(member.Email, noidungEmail);
            }


            return(receipt);
        }