public ActionResult Entrance() { ViewBag.cates = new ProductBLL().GetParentCates(); MediaBLL mediaBLL = new MediaBLL(); MediaObj mediaObj = mediaBLL.GetMedia(1); ViewBag.media1 = mediaObj; mediaObj = mediaBLL.GetMedia(2); ViewBag.media2 = mediaObj; mediaObj = mediaBLL.GetMedia(3); ViewBag.media3 = mediaObj; return(View()); }
public ActionResult Products() { if (!AppData.IsManagerLogin) { return(Redirect("/Manage/Error/1.html")); } if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 17)) { return(Redirect("/Manage/Error/2.html")); } MediaBLL mediaBLL = new MediaBLL(); ViewBag.media15 = mediaBLL.GetMedia(15); ViewBag.media16 = mediaBLL.GetMedia(16); ViewBag.media17 = mediaBLL.GetMedia(17); ViewBag.media18 = mediaBLL.GetMedia(18); ViewBag.media19 = mediaBLL.GetMedia(19); ViewBag.media20 = mediaBLL.GetMedia(20); ViewBag.media21 = mediaBLL.GetMedia(21); ViewBag.media22 = mediaBLL.GetMedia(22); ViewBag.media23 = mediaBLL.GetMedia(23); ViewBag.media24 = mediaBLL.GetMedia(24); ViewBag.media25 = mediaBLL.GetMedia(25); ViewBag.media26 = mediaBLL.GetMedia(26); ViewBag.media27 = mediaBLL.GetMedia(27); ViewBag.media28 = mediaBLL.GetMedia(28); ViewBag.media29 = mediaBLL.GetMedia(29); ViewBag.media30 = mediaBLL.GetMedia(30); ViewBag.media31 = mediaBLL.GetMedia(31); ViewBag.media32 = mediaBLL.GetMedia(32); ViewBag.media33 = mediaBLL.GetMedia(33); ViewBag.media34 = mediaBLL.GetMedia(34); ViewBag.media35 = mediaBLL.GetMedia(35); return(View()); }
public ActionResult Upload() { ViewBag.success = false; if (!AppData.IsManagerLogin) { ViewBag.msg = "抱歉,您未登录后台或会话已过期!"; return(View()); } if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 1601)) { ViewBag.msg = "您没有执行该操作的权限!"; return(View()); } HttpPostedFileBase pic = Request.Files.Count == 0 ? null : Request.Files[0]; int mediaID = string.IsNullOrEmpty(Request.Form["id"]) ? 0 : int.Parse(Request.Form["id"]); if (pic != null && !string.IsNullOrEmpty(pic.FileName)) { int type = string.IsNullOrEmpty(Request.Form["type"]) ? 0 : int.Parse(Request.Form["type"]); string ext = Path.GetExtension(pic.FileName); if (type == 0) { if (!Regex.IsMatch(ext, @"^\.(gif|jpg|jpeg|png)$", RegexOptions.IgnoreCase)) { ViewBag.msg = "上传的图片格式不合要求,请上传gif,png,jpg格式的图片"; return(View()); } } else if (type == 1) { if (!Regex.IsMatch(ext, @"^\.(mp3|wma)$", RegexOptions.IgnoreCase)) { ViewBag.msg = "上传的图片格式不合要求,请上传mp3,wma格式的文件"; return(View()); } } string dirPath = Config.MediaPath + @"\Media"; if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } MediaBLL mediaBLL = new MediaBLL(); MediaObj mediaObj = mediaBLL.GetMedia(mediaID); if (mediaObj != null) { System.IO.File.Delete(Config.MediaPath + mediaObj.SavePath); } else { mediaObj = new MediaObj(); mediaObj.MediaID = mediaID; } string newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff") + ext; string savePath = Path.Combine(dirPath, newFileName); mediaObj.SavePath = @"\Media\" + newFileName; mediaObj.Src = "/Media/" + newFileName; mediaObj.Description = Request.Form["desc"]; mediaObj.Url = Request.Form["url"]; mediaObj.Content = Request.Form["content"]; mediaBLL.SetMedia(mediaObj); pic.SaveAs(savePath); ViewBag.success = true; return(View()); } else if (mediaID != 0) { MediaBLL mediaBLL = new MediaBLL(); MediaObj mediaObj = mediaBLL.GetMedia(mediaID); mediaObj.Description = Request.Form["desc"]; mediaObj.Url = Request.Form["url"]; mediaObj.Content = Request.Form["content"]; mediaBLL.SetMedia(mediaObj); ViewBag.success = true; return(View()); } else { ViewBag.msg = "请您选择一张图片上传"; return(View()); } }
public ActionResult Index() { if (!AppData.IsManagerLogin) { return(Redirect("/Manage/Error/1.html")); } if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 16)) { return(Redirect("/Manage/Error/2.html")); } MediaBLL mediaBLL = new MediaBLL(); MediaObj mediaObj = mediaBLL.GetMedia(1); ViewBag.media1 = mediaObj; mediaObj = mediaBLL.GetMedia(2); ViewBag.media2 = mediaObj; mediaObj = mediaBLL.GetMedia(3); ViewBag.media3 = mediaObj; mediaObj = mediaBLL.GetMedia(4); ViewBag.media4 = mediaObj; mediaObj = mediaBLL.GetMedia(5); ViewBag.media5 = mediaObj; mediaObj = mediaBLL.GetMedia(6); ViewBag.media6 = mediaObj; mediaObj = mediaBLL.GetMedia(7); ViewBag.media7 = mediaObj; mediaObj = mediaBLL.GetMedia(8); ViewBag.media8 = mediaObj; mediaObj = mediaBLL.GetMedia(9); ViewBag.media9 = mediaObj; mediaObj = mediaBLL.GetMedia(10); ViewBag.media10 = mediaObj; mediaObj = mediaBLL.GetMedia(11); ViewBag.media11 = mediaObj; mediaObj = mediaBLL.GetMedia(12); ViewBag.media12 = mediaObj; mediaObj = mediaBLL.GetMedia(13); ViewBag.media13 = mediaObj; mediaObj = mediaBLL.GetMedia(14); ViewBag.media14 = mediaObj; return(View()); }
public ActionResult Index() { MediaBLL mediaBLL = new MediaBLL(); IDictionary <int, MediaObj> flash = new Dictionary <int, MediaObj>(); flash.Add(4, mediaBLL.GetMedia(4)); flash.Add(5, mediaBLL.GetMedia(5)); flash.Add(6, mediaBLL.GetMedia(6)); flash.Add(7, mediaBLL.GetMedia(7)); flash.Add(8, mediaBLL.GetMedia(8)); flash.Add(9, mediaBLL.GetMedia(9)); flash.Add(10, mediaBLL.GetMedia(10)); flash.Add(11, mediaBLL.GetMedia(11)); flash.Add(12, mediaBLL.GetMedia(12)); flash.Add(13, mediaBLL.GetMedia(13)); flash.Add(14, mediaBLL.GetMedia(14)); ViewBag.flash = flash; return(View()); }
public ActionResult Cates(string id) { int cateID; int startPage; if (id.IndexOf('_') == -1) { cateID = int.Parse(id); startPage = 1; } else { string[] strId = id.Split('_'); cateID = int.Parse(strId[0]); startPage = int.Parse(strId[1]); } ViewBag.page = startPage; MediaBLL mediaBLL = new MediaBLL(); IDictionary <int, MediaObj> flash = new Dictionary <int, MediaObj>(); flash.Add(32, mediaBLL.GetMedia(32)); flash.Add(33, mediaBLL.GetMedia(33)); flash.Add(34, mediaBLL.GetMedia(34)); flash.Add(35, mediaBLL.GetMedia(35)); ViewBag.flash = flash; ProductBLL productBLL = new ProductBLL(); IList <ProductCateObj> productCateList = new List <ProductCateObj>(); ProductCateObj productCateObj = productBLL.GetProductCateByCateID(cateID); ViewBag.cates = productCateObj; while (productCateObj != null) { productCateObj = productBLL.GetProductCateByCateID(productCateObj.ParentID); if (productCateObj == null) { break; } else { productCateList.Add(productCateObj); } } StringBuilder sb = new StringBuilder(); for (int i = productCateList.Count - 1; i >= 0; i--) { sb.Append(">") .Append("<a href='/list/") .Append(productCateList[i].CategoryID) .Append(".html'>") .Append(productCateList[i].CategoryName) .Append("</a>"); } ViewBag.current = new MvcHtmlString(sb.ToString()); ViewBag.allCates = productBLL.GetProductCates(); Validation vld = new Validation(false); int sort = vld.GetInt("sort"); string price = vld.Get("price"); decimal priceFrom = 0; decimal priceTo = 0; if (!string.IsNullOrEmpty(price)) { string[] p = price.Split('-'); priceFrom = decimal.Parse(p[0]); priceTo = decimal.Parse(p[1]); } string sortField; bool isAsc; switch (sort) { case 1: sortField = "Price"; isAsc = true; break; case 2: sortField = "ProductID"; isAsc = false; break; case 4: sortField = "SellNum"; isAsc = false; break; case 5: sortField = "Price"; isAsc = false; break; default: sortField = "Products.Sort"; isAsc = false; break; } ViewBag.sort = sort; ViewBag.price = price; int pageSize = 24; int total; ViewBag.data = productBLL.GetProducts(cateID, null, priceFrom, priceTo, -1, -1, -1, -1, startPage, pageSize, out total, 1, sortField, isAsc); ViewBag.pageSize = pageSize; ViewBag.total = total; ViewBag.totalPages = total % pageSize == 0 ? total / pageSize : (total / pageSize + 1); int totalRecommends; ViewBag.recommends = productBLL.GetProducts(0, null, 0, 0, -1, -1, 1, -1, 1, 10, out totalRecommends); ViewBag.onSaleProducts = WriteProducts(productBLL.GetProducts(0, null, 0, 0, -1, 1, -1, -1, 1, 5, out total)); ViewBag.newProducts = WriteProducts(productBLL.GetProducts(0, null, 0, 0, 1, -1, -1, -1, 1, 20, out total), 5); return(View()); }
public ActionResult Index() { int total; MediaBLL mediaBLL = new MediaBLL(); IDictionary <int, MediaObj> flash = new Dictionary <int, MediaObj>(); flash.Add(15, mediaBLL.GetMedia(15)); flash.Add(16, mediaBLL.GetMedia(16)); flash.Add(17, mediaBLL.GetMedia(17)); flash.Add(18, mediaBLL.GetMedia(18)); flash.Add(19, mediaBLL.GetMedia(19)); flash.Add(20, mediaBLL.GetMedia(20)); flash.Add(21, mediaBLL.GetMedia(21)); flash.Add(22, mediaBLL.GetMedia(22)); flash.Add(23, mediaBLL.GetMedia(23)); flash.Add(24, mediaBLL.GetMedia(24)); flash.Add(25, mediaBLL.GetMedia(25)); flash.Add(26, mediaBLL.GetMedia(26)); flash.Add(27, mediaBLL.GetMedia(27)); flash.Add(28, mediaBLL.GetMedia(28)); flash.Add(29, mediaBLL.GetMedia(29)); flash.Add(30, mediaBLL.GetMedia(30)); flash.Add(31, mediaBLL.GetMedia(31)); ViewBag.flash = flash; ProductBLL productBLL = new ProductBLL(); JsonArray cates = productBLL.GetProductCatesByParentID(0); ViewBag.cates = cates; ViewBag.cate1 = WriteProducts(productBLL.GetProducts((int)cates[0]["categoryID"], null, 0, 0, -1, -1, -1, -1, 1, 3, out total)); ViewBag.cate2 = WriteProducts(productBLL.GetProducts((int)cates[1]["categoryID"], null, 0, 0, -1, -1, -1, -1, 1, 2, out total)); ViewBag.cate3 = WriteProducts(productBLL.GetProducts((int)cates[2]["categoryID"], null, 0, 0, -1, -1, -1, -1, 1, 6, out total)); ViewBag.cate4 = WriteProducts(productBLL.GetProducts((int)cates[3]["categoryID"], null, 0, 0, -1, -1, -1, -1, 1, 6, out total)); ViewBag.cate5 = WriteProducts(productBLL.GetProducts((int)cates[4]["categoryID"], null, 0, 0, -1, -1, -1, -1, 1, 6, out total)); ViewBag.cate6 = WriteProducts(productBLL.GetProducts((int)cates[5]["categoryID"], null, 0, 0, -1, -1, -1, -1, 1, 6, out total)); ViewBag.cate7 = WriteProducts(productBLL.GetProducts((int)cates[6]["categoryID"], null, 0, 0, -1, -1, -1, -1, 1, 6, out total)); ViewBag.onSaleProducts = WriteProducts(productBLL.GetProducts(0, null, 0, 0, -1, 1, -1, -1, 1, 4, out total)); ViewBag.newProducts = WriteProducts(productBLL.GetProducts(0, null, 0, 0, 1, -1, -1, -1, 1, 3, out total)); return(View()); }