public ActionResult DsProduct(string CategoryGuid, int?page) { int pageCurrent = 1; if (page.HasValue) { pageCurrent = page.Value; } shCategoryService _category = new shCategoryService(); IEnumerable <shCategory> ds = _category.DanhSachCategory_ByParentId(CategoryGuid); shProductService _product = new shProductService(); List <shProduct> dsProduct = new List <shProduct>(); foreach (var item in ds) { dsProduct.AddRange(_product.DanhSachProduct_TheoDanhMuc(item.CategoryGuid)); } dsProduct.AddRange(_product.DanhSachProduct_TheoDanhMuc(CategoryGuid)); ViewBag.dsProduct = dsProduct.OrderByDescending(x => x.ProductId).ToPagedList(pageCurrent, Config.PAGE_SIZE_8); ViewBag.CategoryGuid = CategoryGuid; return(PartialView("dsProduct", ViewBag.dsProduct)); }
public ActionResult dsProduct(string ProductAdd) { List <shProduct> ds = new List <shProduct>(); shProduct product = new shProduct(); shProductService _product = new shProductService(); if (!string.IsNullOrEmpty(ProductAdd) || !string.IsNullOrWhiteSpace(ProductAdd)) { string[] dsProduct = ProductAdd.Split(';'); if (dsProduct != null) { foreach (var child in dsProduct) { product = _product.FindByKey(child); if (product != null) { ds.Add(product); } } } } ViewBag.ProductAdd = ProductAdd; return(PartialView("dsProduct", ds)); }
public List <TreeView> ProductByCategoryGuid(string CategoryGuid) { if (!string.IsNullOrWhiteSpace(CategoryGuid)) { TreeView zTree = null; List <TreeView> dsTreeview = new List <TreeView>(); shProductService _product = new shProductService(); IEnumerable <shProduct> dsProduct = _product.DanhSachProduct_TheoDanhMuc(CategoryGuid); foreach (var item in dsProduct) { zTree = new TreeView(); zTree.name = item.ProductName; zTree.id = item.ProductId.ToString(); //zTree.pId = UnitId.ToString(); zTree.isParent = false; zTree.children = null; zTree.click = null; zTree.open = true; dsTreeview.Add(zTree); } return(dsTreeview); } return(new List <TreeView>()); }
public ActionResult Create(string id, string s, string p) { shSectionService _section = new shSectionService(); shProductService _product = new shProductService(); shProductSet section = new shProductSet(); if (!string.IsNullOrWhiteSpace(s)) { section = _section.FindByKey(s); ViewBag.parent = string.IsNullOrWhiteSpace(section.ParentId) ? 0 : 1; } section.ProductGuid = id; ViewBag.ProductName = _product.ProductName(id); ViewBag.ProductGuid = id; IEnumerable <shProductSet> dsSection = _section.DanhSachSection() .Where(x => x.ProductGuid == id && x.ParentId == null && x.SectionGuid != s) .OrderBy(x => x.SectionId); ViewBag.dsSection = new SelectList(dsSection, "SectionGuid", "SectionName", null); ViewBag.p = p; return(View(section)); }
public JsonResult ProductTreeview(bool?IsSection, string ProductGuid) { shProductService _product = new shProductService(); shProduct product = _product.FindByKey(ProductGuid); if (!IsSection.HasValue) { IsSection = false; } if (product == null) { product = new shProduct(); } TreeView tongthe = new TreeView(); tongthe.name = product.ProductName; tongthe.id = product.ProductGuid; tongthe.pId = null; tongthe.open = true; tongthe.isParent = true; tongthe.click = "shProduct('" + product.ProductGuid + "', '', '', '0')"; tongthe.children = GetProductTreeview(IsSection.Value, ProductGuid); return(Json(tongthe, JsonRequestBehavior.AllowGet)); }
public ActionResult Carousel() { shProductService _product = new shProductService(); IEnumerable <shProduct> model = _product.DanhSachTopHotProduct(); return(PartialView(model)); }
public ActionResult HighLight(string[] cbxItem2, int?page) { shProductService _product = new shProductService(); _product.HighLight(cbxItem2); return(RedirectToAction("Index", new { page = page })); }
/// <summary> /// Những sản phẩm liên quan /// </summary> /// <param name="ProductGuid"></param> /// <returns></returns> public ActionResult RelatedProducts(string ProductGuid, string CategoryGuid) { shProductService _product = new shProductService(); IEnumerable <shProduct> dsProduct = _product.DanhSachProduct_TheoDanhMuc(CategoryGuid) .Where(x => x.ProductGuid != ProductGuid); return(PartialView("RelatedProducts", dsProduct)); }
public ActionResult Create(string id) { Session[Config.DesignImage] = new List <ProductMultiUpload>(); Session[Config.MaterialImage] = new List <ProductMultiUpload>(); if (!string.IsNullOrWhiteSpace(id)) { shProductService _product = new shProductService(); shProduct product = _product.FindByKey(id); if (product != null) { shCategoryService _category = new shCategoryService(); ViewBag.citySel = _category.CategoryName(product.CategoryGuid); ViewBag.ProductGuid = product.ProductGuid; #region Image shProductImageService _productImage = new shProductImageService(); IEnumerable <shProductImage> DsDesignImage = _productImage.DanhSachProductImage_ByCategory(product.ProductGuid, Config.ProductImageCategory_Design); IEnumerable <shProductImage> DsMaterialImage = _productImage.DanhSachProductImage_ByCategory(product.ProductGuid, Config.ProductImageCategory_Material); ViewBag.DsDesignImage = DsDesignImage; ViewBag.DsMaterialImage = DsMaterialImage; #endregion return(View(product)); } else { return(View(new shProduct())); } } if (TempData["ERROR"] != null) { ModelState.AddModelError("", TempData["ERROR"].ToString()); shCategoryService _category = new shCategoryService(); if (TempData["CategoryGuid"] != null) { ViewBag.citySel = _category.CategoryName(TempData["CategoryGuid"].ToString()); } ViewBag.CategoryGuid = TempData["CategoryGuid"]; ViewBag.ProductGuid = TempData["ProductGuid"]; ViewBag.ProductName = TempData["ProductName"]; ViewBag.Description = TempData["Description"]; ViewBag.Details = TempData["Details"]; TempData["ERROR"] = null; } return(View(new shProduct())); }
public ActionResult DialogHighLight(string ProductGuid) { shProductService _product = new shProductService(); shProduct product = _product.FindByKey(ProductGuid); if (product == null) { product = new shProduct(); } return(PartialView("DialogHighLight", product)); }
public static MvcHtmlString ProductName(this HtmlHelper helper, string ProductGuid) { string html = string.Empty; if (!string.IsNullOrEmpty(ProductGuid) || !string.IsNullOrWhiteSpace(ProductGuid)) { shProductService _product = new shProductService(); shProduct product = _product.FindByKey(ProductGuid); html = product.ProductName; } return(new MvcHtmlString(html)); }
public ActionResult TopSanPham(string StartTime, string EndTime, string TheLoai) { DateTime _tungay = DateTime.Now; if (!string.IsNullOrEmpty(StartTime) || !string.IsNullOrWhiteSpace(StartTime)) { _tungay = TypeHelper.ToDate(StartTime); } DateTime _denngay = DateTime.Now; if (!string.IsNullOrEmpty(EndTime) || !string.IsNullOrWhiteSpace(EndTime)) { _denngay = TypeHelper.ToDate(EndTime); } List <BieuDoTop> dsBieuDo = new List <BieuDoTop>(); BieuDoTop top = new BieuDoTop(); shOrderDetailService _orderDetail = new shOrderDetailService(); shProductService _product = new shProductService(); ShopOnlineDb db = new ShopOnlineDb(); IEnumerable <shOrderDetail> dsOrderDetail = _orderDetail.DanhSachOrderDetail_TheoThoiGian(_tungay, _denngay); int TongSoLuong = TinhTongSoLuong(dsOrderDetail); IEnumerable <string> dsDistinct = dsOrderDetail.Select(x => x.ProductGuid).Distinct(); foreach (var item in dsDistinct) { IEnumerable <shOrderDetail> dsTheoSanPham = dsOrderDetail.Where(x => x.ProductGuid == item); top = new BieuDoTop(); top.label = _product.ProductName(item); top.y = TinhTongSoLuong(dsTheoSanPham); if (TheLoai == Config.SoLuong) { top.indexLabel = top.y.ToString(); } else if (TheLoai == Config.DoanhThu) { top.indexLabel = Format.FormatDecimalToString(TinhTongSoTien(dsTheoSanPham)); } dsBieuDo.Add(top); } dsBieuDo = dsBieuDo.OrderBy(x => x.y).Take(Config.Top_10).ToList(); if (Request.IsAjaxRequest()) { return(Json(dsBieuDo, JsonRequestBehavior.AllowGet)); } return(PartialView("TopSanPhamTheoSoLuong")); }
public static MvcHtmlString ProductLink(this HtmlHelper helper, string ProductGuid) { string html = string.Empty; if (!string.IsNullOrEmpty(ProductGuid) || !string.IsNullOrWhiteSpace(ProductGuid)) { shProductService _product = new shProductService(); shProduct product = _product.FindByKey(ProductGuid); html = " <a href='" + product.MetaTitle + "-" + product.ProductId + "' target='_blank'>" + product.ProductName + "</a>"; } return(new MvcHtmlString(html)); }
public ActionResult AddItem(string ProductGuid, int Quantity, string SectionGuid, string SizeGuid) { var cart = Session[CartSession]; shProductService _product = new shProductService(); shProduct product = _product.FindByKey(ProductGuid); if (cart != null) { var list = (List <CartItem>)cart; if (list.Exists(x => (x.Product.ProductGuid == ProductGuid) && (x.SectionGuid == SectionGuid) && (x.SizeGuid == SizeGuid))) { foreach (var item in list) { if ((item.Product.ProductGuid == ProductGuid) && (item.SectionGuid == SectionGuid) && (item.SizeGuid == SizeGuid)) { item.Quantity += Quantity; } } } else { var item = new CartItem(); item.Product = product; item.Quantity = Quantity; item.SectionGuid = SectionGuid; item.SizeGuid = SizeGuid; list.Add(item); } Session[CartSession] = list; } else { var item = new CartItem(); item.Product = product; item.Quantity = Quantity; item.SectionGuid = SectionGuid; item.SizeGuid = SizeGuid; var listCart = new List <CartItem>(); listCart.Add(item); Session[CartSession] = listCart; } if (Request.IsAjaxRequest()) { return(Json("OK", JsonRequestBehavior.AllowGet)); } return(RedirectToAction("trang-chu")); }
public PartialViewResult ListProductHighLight(int?page) { int pageCurrent = 1; if (page.HasValue) { pageCurrent = page.Value; } shProductService _product = new shProductService(); IPagedList <shProduct> dsProduct = _product.DanhSachTopHotProduct().ToPagedList(pageCurrent, Config.PAGE_SIZE_10); ViewBag.ListProductHighLight = dsProduct; return(PartialView("ListProductHighLight", dsProduct)); }
public void LoadDuLieu() { shOrderService _order = new shOrderService(); @ViewBag.DonHang = _order.SoDonHangTrongNgay(DateTime.Now); @ViewBag.DoanhThuTheoNgay = Format.FormatDecimalToString(_order.DoanhThuTheoNgay(DateTime.Now)); shMemberService _member = new shMemberService(); @ViewBag.NewMember = _member.DanhSachMemberDangKyMoi(); shProductService _product = new shProductService(); shSectionService _section = new shSectionService(); shSizeService _size = new shSizeService(); @ViewBag.SoLuongTon = _size.SoLuongTonSetSize(); }
public PartialViewResult ListProduct(int?page) { int pageCurrent = 1; if (page.HasValue) { pageCurrent = page.Value; } shProductService _product = new shProductService(); IPagedList <shProduct> dsProduct = _product.DanhSachProduct_PhanTrang(pageCurrent, Config.PAGE_SIZE_20, null); ViewBag.ListProduct = dsProduct; ViewBag.page = pageCurrent; return(PartialView("ListProduct", dsProduct)); }
public ActionResult Details(int?id) { shProductService _product = new shProductService(); shProduct product = _product.FindList().Where(x => x.ProductId == id).FirstOrDefault(); shProductImageService _productImage = new shProductImageService(); IEnumerable <shProductImage> dsImage = _productImage.DanhSachProductImage_ByProductGuid(product.ProductGuid); ViewBag.dsImageMauMa = dsImage.Where(x => x.ProductImageCategory == Config.ProductImageCategory_Design); ViewBag.dsImageChatLieu = dsImage.Where(x => x.ProductImageCategory == Config.ProductImageCategory_Material); shSectionService _section = new shSectionService(); IEnumerable <shProductSet> dsSection = _section.DanhSachSection_TheoProductGuid_ParentNull(product.ProductGuid); shProductSet section = new shProductSet(); if (dsSection != null && dsSection.Count() > 0) { section = dsSection.FirstOrDefault(); } shSizeService _size = new shSizeService(); IEnumerable <shSetSize> dsSize = _size.DanhSachSize_BySectionGuid(section.SectionGuid, product.ProductGuid, null); ViewBag.ProductSize = section.SectionName + " --- " + CommonHelper.TinhToanKichThuocMaxMin(dsSize.FirstOrDefault(), dsSize.LastOrDefault()); ViewBag.ProductPrice = CommonHelper.TinhToanGiaTienMaxMin(dsSize.FirstOrDefault(), dsSize.LastOrDefault()); // Tính toán số tiền sau khuyến mại string productSale = CommonHelper.TinhToanGiaTienSauKhiGiam(dsSize.FirstOrDefault(), dsSize.LastOrDefault()); if (!string.IsNullOrEmpty(productSale) && !string.IsNullOrWhiteSpace(productSale)) { ViewBag.ProductSale = Format.FormatDecimalToString(Convert.ToDecimal(productSale)); } ViewBag.ListSection = dsSection; return(View(product)); }
public ActionResult DialogHighLight(string ProductGuid, string ImageCarousel) { using (var context = new ShopOnlineDb()) { using (var dbContextTransaction = context.Database.BeginTransaction()) { try { // 1. cập nhật ảnh đại diện sản phẩm shProductService _product = new shProductService(); _product.UploadImageProduct(ProductGuid, ImageCarousel); // 2. Upload file sản phẩm nổi bật shProductImageService _productImage = new shProductImageService(); shProductImage productImage = new shProductImage(); productImage = _productImage.Insert_UpdateProductImage( null, null, ProductGuid, ImageCarousel, null, User.Identity.GetUserLogin().Userid, true, DateTime.Now, Config.ProductImageCategory_Design, Config.Product_Image_HighLight ); dbContextTransaction.Commit(); } catch (Exception ex) { dbContextTransaction.Rollback(); } } } if (Request.IsAjaxRequest()) { return(Json("OK", JsonRequestBehavior.AllowGet)); } return(RedirectToAction("Index")); }
public PartialViewResult ListProduct(int?page) { int pageCurrent = 1; if (page.HasValue) { pageCurrent = page.Value; } shProductService _product = new shProductService(); int?UserId = CommonHelper.KiemTraTaiKhoanCoPhaiLanhDaoDonVi(User.Identity.GetUserLogin().Userid, Config.LANH_DAO_DON_VI); IPagedList <shProduct> dsProduct = _product.DanhSachProduct_PhanTrang(pageCurrent, Config.PAGE_SIZE_20, UserId); ViewBag.ListProduct = dsProduct; ViewBag.page = pageCurrent; return(PartialView("ListProduct", dsProduct)); }
public PartialViewResult ListComment(int?page) { int pageCurrent = 1; if (page.HasValue) { pageCurrent = page.Value; } shProductService _product = new shProductService(); IEnumerable <shProduct> dsProduct = _product.DanhSachProduct(); shCommentService _comment = new shCommentService(); IEnumerable <string> dsComment_Product = _comment.DanhSachComment(true).Select(x => x.ProductGuid).Distinct(); dsProduct = dsProduct.Join(dsComment_Product, x => x.ProductGuid, comment => comment, (x, ProductGuid) => x); ViewBag.dsProduct = dsProduct.ToPagedList(pageCurrent, Config.PAGE_SIZE_20); return(PartialView("ListComment", ViewBag.dsProduct)); }
public ActionResult Section(string id) { if (!string.IsNullOrWhiteSpace(id)) { shProductService _product = new shProductService(); shProduct product = _product.FindByKey(id); if (product != null) { shCategoryService _category = new shCategoryService(); return(View(product)); } else { return(View(new shProduct())); } } return(View()); }
public ActionResult DeleteHighLight(string[] cbxItem1, int?page) { using (var context = new ShopOnlineDb()) { using (var dbContextTransaction = context.Database.BeginTransaction()) { try { shProductService _product = new shProductService(); _product.UnSubcribeHighLight(cbxItem1); dbContextTransaction.Commit(); } catch (Exception ex) { dbContextTransaction.Rollback(); } } } return(RedirectToAction("Index", new { page = page })); }
public static int?FindPageProduct(string ProductGuid, int ProductId, int PageSize) { try { int page = 1; shProductService _product = new shProductService(); List <shProduct> dsProduct = _product.DanhSachProduct().ToList(); page = dsProduct.FindIndex(x => x.ProductGuid == ProductGuid); page = (int)page / PageSize; page++; return(page); } catch (Exception) { return(1); } }
public ActionResult Preview(string ProductGuid) { shProductService _product = new shProductService(); shProduct product = _product.FindByKey(ProductGuid); if (product != null) { #region Image shProductImageService _productImage = new shProductImageService(); IEnumerable <shProductImage> DsDesignImage = _productImage.DanhSachProductImage_ByCategory(product.ProductGuid, Config.ProductImageCategory_Design); IEnumerable <shProductImage> DsMaterialImage = _productImage.DanhSachProductImage_ByCategory(product.ProductGuid, Config.ProductImageCategory_Material); ViewBag.DsDesignImage = DsDesignImage; ViewBag.DsMaterialImage = DsMaterialImage; #endregion shSectionService _section = new shSectionService(); IEnumerable <shProductSet> dsSection = _section.DanhSachSection_TheoProductGuid_ParentNull(product.ProductGuid); ViewBag.Section = dsSection; return(PartialView("Preview", product)); } return(PartialView("Preview", new shProduct())); }
public ActionResult Create(string ProductGuid, string CategoryGuid, int?ProductId, string ProductName, string CompleteSetInclude, string Details, int?Number, int?SortOrder, string UserManual, bool?Status, string Description, string DeleteImage) { List <ProductMultiUpload> dsDesignImage = (List <ProductMultiUpload>)Session[Config.DesignImage]; List <ProductMultiUpload> dsMaterialImage = (List <ProductMultiUpload>)Session[Config.MaterialImage]; shProductService _product = new shProductService(); string Image = ""; if (dsDesignImage.Count() > 0) { var obj = dsDesignImage.FirstOrDefault(); if (obj != null) { Image = obj.value; } } shProduct product = new shProduct(); using (var context = new ShopOnlineDb()) { using (var dbContextTransaction = context.Database.BeginTransaction()) { try { // 1. Inser , Upload Product product = _product.Inser_UpdateProduct( ProductGuid, ProductId.Value, CategoryGuid, ProductName, null, CompleteSetInclude, Details, UserManual, null, null, Number, Image, null, null, SortOrder, null, null, Status, DateTime.Now, Description); if (!(product.ProductId > 0)) { TempData["ERROR"] = "Cập nhật dữ liệu bản ghi không thành công. Xin vui lòng thao tác lại"; TempData["ProductGuid"] = ProductGuid; TempData["CategoryGuid"] = CategoryGuid; TempData["ProductName"] = ProductName; TempData["Description"] = Description; TempData["Details"] = Details; return(RedirectToAction("Create", new { id = ProductGuid })); } // 2. nếu người dùng có upload file lưu lại lịch sử trong bảng ProductImage shProductImageService _productImage = new shProductImageService(); _productImage.InsertAllImageProduct(product.ProductGuid, User.Identity.GetUserLogin().Userid, dsDesignImage, dsMaterialImage, null, null, true, DateTime.Now); // 3. Delete Image _productImage.DeleteAllImageProduct(DeleteImage); dbContextTransaction.Commit(); } catch (Exception ex) { dbContextTransaction.Rollback(); } } } int?page = CommonHelper.FindPageProduct(product.ProductGuid, product.ProductId, Config.PAGE_SIZE_20); return(RedirectToAction("Index", new { page })); }
public IEnumerable <TimKiemNangCao> TimKiemNangCao(string keyword) { List <TimKiemNangCao> ds = new List <TimKiemNangCao>(); TimKiemNangCao timkiem = new TimKiemNangCao(); // 1. Tìm kiếm trong bảng sản phẩm shProductService _product = new shProductService(); IEnumerable <shProduct> dsProduct = _product.FindList().Where(x => TypeHelper.CompareString(x.ProductName, keyword)); foreach (var product in dsProduct) { timkiem = new TimKiemNangCao(); timkiem.CategoryId = TheLoaiTimKiemNangCao.SanPham.GetHashCode(); timkiem.Category = "Sản phẩm"; timkiem.Name = product.ProductName; timkiem.MetaTitle = product.MetaTitle + "-" + product.ProductId; timkiem.keyword = keyword; timkiem.CreatedDate = product.CreateDate; timkiem.Description = " Bộ sản phẩm có kết cấu và giá sản phẩm: Kích ..."; timkiem.ProductGuid = product.ProductGuid; ds.Add(timkiem); } // 3. Tìm kiếm trong bảng set sản phẩm shSectionService _section = new shSectionService(); IEnumerable <shProductSet> dsSet = _section.FindList().Where(x => TypeHelper.CompareString(x.SectionName, keyword)); foreach (var set in dsSet) { shProduct product = _product.FindByKey(set.ProductGuid); timkiem = new TimKiemNangCao(); timkiem.CategoryId = TheLoaiTimKiemNangCao.SetSanPham.GetHashCode(); timkiem.Category = "Sản phẩm"; timkiem.Name = product.ProductName + "- Set " + set.SectionName + keyword; timkiem.MetaTitle = product.MetaTitle + "-" + product.ProductId; timkiem.keyword = keyword; timkiem.CreatedDate = set.CreateDate; timkiem.Description = " Bộ sản phẩm có kết cấu và giá sản phẩm: Kích ..."; timkiem.ProductGuid = product.ProductGuid; ds.Add(timkiem); } // 4. Tìm kiếm trong bảng kích thước theo set shSizeService _size = new shSizeService(); IEnumerable <shSetSize> dsSize = _size.FindList().Where(x => TypeHelper.CompareString(x.SizeName, keyword)); foreach (var size in dsSize) { shProduct product = _product.FindByKey(size.ProductGuid); timkiem = new TimKiemNangCao(); timkiem.CategoryId = TheLoaiTimKiemNangCao.SetSanPham.GetHashCode(); timkiem.Category = "Sản phẩm"; timkiem.Name = product.ProductName + " - Kích thước: " + size.SizeName; timkiem.MetaTitle = product.MetaTitle + "-" + product.ProductId; timkiem.keyword = keyword; timkiem.CreatedDate = size.CreateDate; timkiem.Description = " Bộ sản phẩm có kết cấu và giá sản phẩm: Kích ..."; timkiem.ProductGuid = product.ProductGuid; ds.Add(timkiem); } // 2. Tìm kiếm trong bảng tin tức shNewService _new = new shNewService(); IEnumerable <shNew> dsNew = _new.FindList().Where(x => TypeHelper.CompareString(x.TitleNew, keyword)); foreach (var news in dsNew) { timkiem = new TimKiemNangCao(); timkiem.CategoryId = TheLoaiTimKiemNangCao.TinTuc.GetHashCode(); timkiem.Category = "Tin Tức"; timkiem.Name = news.TitleNew; timkiem.MetaTitle = news.MetaTitle + "-" + news.NewId; timkiem.keyword = keyword; timkiem.CreatedDate = news.CreatedDate; timkiem.Description = news.Summary; ds.Add(timkiem); } return(ds); }