コード例 #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);
            }
        }
コード例 #2
0
        public static MvcHtmlString ChatLieu_KichThuoc(this HtmlHelper helper, string SizeGuid, string SizeName, string Stuff, string ParentId, string SectionGuid)
        {
            string html = string.Empty;

            if (!string.IsNullOrWhiteSpace(SizeName))
            {
                html += SizeName;
            }

            if (!string.IsNullOrWhiteSpace(Stuff))
            {
                html += " - " + Stuff;
            }
            string title = string.Empty;
            string style = string.Empty;

            if (!string.IsNullOrWhiteSpace(ParentId))
            {
                shSectionService _section = new shSectionService();
                shSizeService    _size    = new shSizeService();
                shSetSize        size     = _size.FindByKey(ParentId);
                if (size != null)
                {
                    title = "Thuộc bộ sản phẩm: " + _section.SectionName(SectionGuid) + " [" + size.SizeName + "]";
                }
            }
            else
            {
                style = "font-weight:bold; cursor: pointer";
            }
            string span = "<span title='" + title + "' style='" + style + "' class='parent-size'>" + html + "</span>";

            return(new MvcHtmlString(span));
        }
コード例 #3
0
        public PartialViewResult EditSize(string SizeGuid, string SectionGuid, string ProductGuid)
        {
            shSizeService _size = new shSizeService();
            shSetSize     size  = _size.FindByKey(SizeGuid);

            if (size == null)
            {
                size = new shSetSize();
            }

            shSectionService           _section  = new shSectionService();
            IEnumerable <shProductSet> dsSection = _section.DanhSachSection_TheoProductGuid(ProductGuid);

            ViewBag.SectionGuid = new SelectList(dsSection, "SectionGuid", "SectionName", SectionGuid);

            IEnumerable <shSetSize> dsSize = _size.DanhSachSize_BySectionGuid(null, ProductGuid, null)
                                             .Where(x => string.IsNullOrWhiteSpace(x.ParentId) ||
                                                    string.IsNullOrEmpty(x.ParentId));

            foreach (var item in dsSize)
            {
                item.SizeName = _section.SectionName(item.SectionGuid) + " - " + item.SizeName;
            }
            ViewBag.Parent = new SelectList(dsSize, "SizeGuid", "SizeName", size.ParentId);
            //size.PriceCurrent = Format.SubStringDotInDecimal(size.PriceCurrent.Value);

            return(PartialView("EditSize", size));
        }
コード例 #4
0
ファイル: shSaleService.cs プロジェクト: Nghinv00/ShopOnLine
        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);
        }
コード例 #5
0
        public ActionResult dsNhap2(string ReceiptIsuueGuid, string SizeGuid, int?Number, string SizeAdd)
        {
            shGoodReceiptIsuueDetailService _goodDetail = new shGoodReceiptIsuueDetailService();
            List <shGoodReceiptIsuueDetail> dsNhap      = new List <shGoodReceiptIsuueDetail>();

            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)
                        {
                            dsNhap.Add(new shGoodReceiptIsuueDetail
                            {
                                ReceiptIsuueDetailGuid = obj[2],
                                ReceiptIsuueGuid       = ReceiptIsuueGuid,
                                ProductGuid            = size.ProductGuid,
                                SectionGuid            = size.SectionGuid,
                                SizeGuid = size.SizeGuid,
                                Number   = TypeHelper.ToInt32(obj[1]),
                            });
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(SizeGuid) || !string.IsNullOrWhiteSpace(SizeGuid))
            {
                size = _size.FindByKey(SizeGuid);
                dsNhap.Add(new shGoodReceiptIsuueDetail
                {
                    // ReceiptIsuueDetailGuid = GuidUnique.getInstance().GenerateUnique(),
                    ReceiptIsuueGuid = ReceiptIsuueGuid,
                    ProductGuid      = size.ProductGuid,
                    SectionGuid      = size.SectionGuid,
                    SizeGuid         = size.SizeGuid,
                    Number           = Number,
                });

                SizeAdd += SizeGuid + "$" + Number + "$" + "" + ";";
            }

            ViewBag.ReceiptIsuueGuid = ReceiptIsuueGuid;
            ViewBag.dsNhap           = dsNhap;

            ViewBag.SizeAdd = SizeAdd;

            return(PartialView("dsNhap", dsNhap));
        }
コード例 #6
0
        public static MvcHtmlString SizeName(this HtmlHelper helper, string SizeGuid)
        {
            shSizeService _size = new shSizeService();

            shSetSize size = _size.FindByKey(SizeGuid);

            if (size == null)
            {
                size = new shSetSize();
            }
            return(new MvcHtmlString(size.SizeName));
        }
コード例 #7
0
        public ActionResult EditSize(string SizeGuid, string ProductGuid, string SectionGuid, string SizeName, decimal?PriceCurrent, string Stuff, string Parent)
        {
            shSizeService _size = new shSizeService();
            shSetSize     size  = new shSetSize();

            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        size = _size.InsertUpdateSize(
                            SizeGuid,
                            null,
                            ProductGuid,
                            SectionGuid,
                            SizeName,
                            null,
                            PriceCurrent,
                            null,
                            null,
                            null,
                            null,
                            null,
                            true,
                            DateTime.Now,
                            Stuff,
                            Parent);

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


            if (Request.IsAjaxRequest())
            {
                string data = "fail";
                if (size.SizeId > 0)
                {
                    data = "ok";
                }

                return(Json(data, JsonRequestBehavior.AllowGet));
            }

            return(RedirectToAction("Index"));
        }
コード例 #8
0
        public static string TinhToanGiaTienMaxMin(shSetSize first, shSetSize last)
        {
            string price = string.Empty;

            if (first != null)
            {
                if (first.PriceCurrent == null)
                {
                    first.PriceCurrent = 0;
                }
                price += Format.FormatDecimalToString(first.PriceCurrent.Value).Replace(',', '.');
            }

            return(price);
        }
コード例 #9
0
        public static string TinhToanKichThuocMaxMin(shSetSize first, shSetSize last)
        {
            string size = string.Empty;

            if (first != null)
            {
                size += first.SizeName;
            }

            //if (last != null)
            //{
            //    size += " - " + last.SizeName;
            //}

            return(size);
        }
コード例 #10
0
        public static MvcHtmlString SizeNameByParentId_SectionGuid_PriceCurrent(this HtmlHelper helper, string ParentId, string SectionGuid)
        {
            shSizeService _size = new shSizeService();
            shSetSize     size  = _size.DanhSachSize()
                                  .Where(x => x.ParentId == ParentId &&
                                         x.SectionGuid == SectionGuid)
                                  .FirstOrDefault();

            string html = string.Empty;

            if (size != null && !string.IsNullOrEmpty(size.SizeName) && !string.IsNullOrWhiteSpace(size.SizeName))
            {
                html = Format.FormatDecimalToString(size.PriceCurrent.GetValueOrDefault(0)).Replace(',', '.');
            }

            return(new MvcHtmlString(html));
        }
コード例 #11
0
        public static MvcHtmlString SizeNameByParentId_SectionGuid(this HtmlHelper helper, string ParentId, string SectionGuid)
        {
            shSizeService _size = new shSizeService();
            shSetSize     size  = _size.DanhSachSize()
                                  .Where(x => x.ParentId == ParentId &&
                                         x.SectionGuid == SectionGuid)
                                  .FirstOrDefault();

            string html = string.Empty;

            if (size != null && !string.IsNullOrEmpty(size.SizeName) && !string.IsNullOrWhiteSpace(size.SizeName))
            {
                html = size.SizeName;
            }

            return(new MvcHtmlString(html));
        }
コード例 #12
0
        public static MvcHtmlString SectionName_SizeName(this HtmlHelper helper, string SectionGuid, string SizeGuid)
        {
            string           html     = string.Empty;
            shSectionService _section = new shSectionService();
            shProductSet     section  = _section.FindByKey(SectionGuid);

            if (section != null)
            {
                html += section.SectionName;
            }

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

            if (size != null)
            {
                html += "    " + size.SizeName + "    " + size.Stuff;
            }
            return(new MvcHtmlString(html));
        }
コード例 #13
0
        public static MvcHtmlString IconUpdate_Delete(this HtmlHelper helper, string SizeGuid)
        {
            shSizeService _size = new shSizeService();
            shSetSize     size  = _size.FindByKey(SizeGuid);

            if (size == null)
            {
                size = new shSetSize();
            }

            string icon = "<a href='javascript:void(0)' onclick=Edit('" + SizeGuid + "','" + size.SectionGuid + "')>" +
                          "<span class='fa fa-pencil-square-o' aria-hidden='true' style='transform: scale(1.3, 1.3);' title='Sửa'></span>" +
                          "</a>";

            icon += "&nbsp;&nbsp;";

            icon += "<a href='javascript:void(0)' onclick=Delete('" + SizeGuid + "','" + size.SectionGuid + "')>" +
                    "<span class='fa fa-trash' aria-hidden='true' style='transform: scale(1.3, 1.3);' title='Xóa'></span> " +
                    "</a>";

            return(new MvcHtmlString(icon));
        }
コード例 #14
0
        public ActionResult XoaSanPhamDaChon(string ReceiptIsuueGuid, string SizeGuid, string SizeAdd)
        {
            string dsSize = string.Empty;
            List <shGoodReceiptIsuueDetail> dsNhap = new List <shGoodReceiptIsuueDetail>();
            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 && obj[0] != "" && obj[0] != null && obj[0] != SizeGuid)
                    {
                        dsSize += obj[0] + "$" + obj[1] + "$" + obj[2] + "$" + ";";
                    }
                }
            }

            return(dsNhap2(ReceiptIsuueGuid, null, null, dsSize));
        }
コード例 #15
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"));
        }
コード例 #16
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);
        }
コード例 #17
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);
        }