public ActionResult Detail(string tag) { string chuoi = ""; string chuoilink = ""; string image = ""; string imagethumb = ""; string Cart = ""; int category = 0; int proId = 0; string baohanh = ""; string noibat = ""; string chitiet = ""; string thanhtoan = ""; string canhbao = ""; string khuyenmai = ""; string fb = ""; var pro = (from p in data.Products where p.Tag == tag select p).ToList(); if (pro.Count > 0) { proId = pro[0].Id; data.sp_Product_Update(proId, pro[0].Name, pro[0].Tag, pro[0].Image, pro[0].Description, pro[0].Weight, pro[0].ChatLieu, pro[0].Status, pro[0].Detail, pro[0].SpTon, pro[0].Count, (pro[0].View + 1), pro[0].Like, pro[0].IdCategory, pro[0].Date, pro[0].Index, pro[0].Priority, pro[0].Keyword, pro[0].Title, pro[0].Content, pro[0].Ord, pro[0].Active, pro[0].PriceRetail, pro[0].PricePromotion, pro[0].Num, pro[0].Noibat, pro[0].Baohanh, pro[0].Giamgia); data.SaveChanges(); category = pro[0].IdCategory; var cate = (from p in data.GroupProducts where p.Id == category select p).ToList(); if (cate.Count > 0) { chuoilink = "<li class='Last'><a href='/danh-muc/" + cate[0].Tag + "'>" + cate[0].Name + "</a></li>"; } cate.Clear(); cate = null; ViewBag.link = chuoilink; int g = 0; if (pro[0].Num != null) { g = int.Parse(pro[0].Num.ToString()); } chuoi += "<input type=\"hidden\" id=\"item_id\" value=\"" + pro[0].Id + "\">"; imagethumb += "<li class='active' rel='1'><img src=\"" + pro[0].Image + "\" alt=\"" + pro[0].Name + "\" title=\"Click to enlarge\" /></li>"; //if (g == 0) //{ image += "<a href=\"" + pro[0].Image + "\" class=\"highslide\" rel=\"position: 'inside' , showTitle: false\" id=\"zoom1\" style=\"position: relative; display: block;\" onclick=\"return hs.expand(this)\"><img src=\"" + pro[0].Image + "\" alt=\"" + pro[0].Name + "\" /></a>"; //} //else //{ // image += "<a href=\"" + pro[0].Image + "\" class=\"highslide\" rel=\"position: 'inside' , showTitle: false\" id=\"zoom1\" style=\"position: relative; display: block;\" onclick=\"return hs.expand(this)\"><img src=\"" + pro[0].Image + "\" alt=\"" + pro[0].Name + "\" /></a>"; //} chuoi += "<input type=\"hidden\" id=\"item_id\" value=\"" + pro[0].Id + "\" />"; chuoi += "<p id=\"titPro\">" + pro[0].Name + "</p>"; chuoi += "<p>Mã SP: <span class=\"value\">" + pro[0].Code + "</span></p>"; chuoi += "<div class=\"divInfo\">"; if (g > 0) { //chuoi += "<p><span class=\"txtw80\">Tình trạng:</span><span class=\"stock\">Còn hàng</span></p>"; if ((pro[0].PricePromotion / pro[0].PriceRetail) * 100 < 100) { chuoi += "<p><span id=\"valBanle-cu\">Giá cũ: " + StringClass.Format_Price(pro[0].PriceRetail.ToString()) + "đ</span></p>"; chuoi += "<p>Giá bán: <span id=\"valBanle\"> " + StringClass.Format_Price(pro[0].PricePromotion.ToString()) + "đ</span></p>"; } else { chuoi += "<p>Giá: <span id=\"valBanle\"> " + StringClass.Format_Price(pro[0].PricePromotion.ToString()) + "đ</span></p>"; } } else { //chuoi += "<p><span class=\"txtw80\">Tình trạng:</span><span class=\"nostock\">Hết hàng</span></p>"; chuoi += "<p>Giá bán: <span id=\"valBanle\">" + StringClass.Format_Price(pro[0].PricePromotion.ToString()) + "đ</span></p>"; } //chuoi += "<span class=\"lblProduct\"> </span>"; chuoi += "</div>"; int pid = pro[0].Id; var proimages = (from im in data.ProImages where im.IdPro == pid select im).ToList(); int k = 2; for (int j = 0; j < proimages.Count; j++) { if (proimages.Count > 1) { imagethumb += "<li class='active' rel='" + (k + j) + "'><img src=\"" + proimages[j].Image + "\" alt=\"" + pro[0].Name + "\" /></li>"; } image += "<a href=\"" + proimages[j].Image + "\" class=\"highslide\" onclick=\"return hs.expand(this)\"><img src=\"" + proimages[j].Image + "\" alt=\"" + pro[0].Name + "\" /></a>"; } if (g > 0) { Cart += "<p id=\"Cart\"><a id=\"btnAddCart\" href=\"javascript:;\" class=\"btnBuyNow add-to-cart\" title=\"Thêm sản phẩm này vào giỏ hàng\"><span id=\"txt\"></span></a><a id=\"btnAddCart\" title=\"Mua ngay\" href=\"javascript:;\" class=\"btnAddCart\" rel=\"/Home/checkout\"><span id=\"txt1\">Mua ngay</span></a></p>"; } else { Cart += "<p id=\"Cart\"><a id=\"btnAddCart\" href=\"javascript:;\" class=\"btnBuyNow Disabled\" title=\"Thêm sản phẩm này vào giỏ hàng\"><span id=\"txt\"></span></a><a id=\"btnAddCart\" title=\"Mua ngay\" href=\"javascript:;\" class=\"btnAddCart Disabled\" rel=\"/Home/checkout\"><span id=\"txt1\">Mua ngay</span></a></p>"; } chitiet = pro[0].Content; noibat = pro[0].Noibat; int idcate = pro[0].IdCategory; var bh = data.GroupProducts.Find(idcate); baohanh = bh.BaoHanh; // bao hanh #region [Title, Keyword, Deskription] string t = pro[0].Title; string tt = pro[0].Description; string ttt = pro[0].Keyword; if (pro[0].Title != null && pro[0].Title.Length > 0) { ViewBag.tit = pro[0].Title; } else { ViewBag.tit = pro[0].Name; } if (pro[0].Description != null && pro[0].Description.Length > 0) { ViewBag.des = pro[0].Description; } else { ViewBag.des = pro[0].Name; } if (pro[0].Keyword != null && pro[0].Keyword.Length > 0) { ViewBag.key = pro[0].Keyword; } else { ViewBag.key = pro[0].Name; } #endregion ViewBag.cart = Cart; proimages.Clear(); proimages = null; fb += "<div class=\"fb-like\" style=\"margin-top: 15px; padding-bottom: 3px\" data-href=\"" + Request.Url.ToString() + "\" data-send=\"true\" data-max-width=\"950\" data-show-faces=\"true\"></div>"; fb += "<div class=\"fb-comments\" style=\"margin-top: 15px\" data-href=\"" + Request.Url.ToString() + "\" data-max-width=\"950\" data-num-posts=\"5\"></div>"; #region [Sản phẩm cùng loại] string chuoicungloai = ""; var list = (from p in data.Products where p.Active == true && p.IdCategory == category && p.Tag != tag orderby p.Ord ascending select p).Take(21).ToList(); for (int i = 0; i < list.Count; i++) { //if (i % 3 != 0) //{ // chuoicungloai += "<li class=\"other\">"; //} //else //{ // chuoicungloai += "<li class=\"right\">"; //} //chuoicungloai += "<div class=\"imagespro\"><a href=\"/thong-tin/" + list[i].Tag + "\" title=\"" + list[i].Name + "\"><img src=\"" + list[i].Image + "\" alt=\"" + list[i].Name + "\" title=\"" + list[i].Name + "\"/></a></div>"; // chuoicungloai += "<div>"; // if (list[i].Code != null && list[i].Code != "") // { // chuoicungloai += "<p class=\"gia_cu\">" + list[i].Code + " đ</p>"; // } // else // { // chuoicungloai += "<p class=\"gia_cu\">No size</p>"; // } // if (list[i].PricePromotion == 0) // { // chuoicungloai += "<p class=\"gia_sp\">Giá: Vui lòng liên hệ</p>"; // } // else // { // chuoicungloai += "<p class=\"gia_sp\">Giá: " + os.os.Format_Price(list[i].PricePromotion.ToString()) + " đ</p>"; // } // chuoicungloai += "</div>"; // chuoicungloai += "<p class=\"sp_code\"><a href=\"/thong-tin/" + list[i].Tag + "\">" + list[i].Name + "</a></p>"; //chuoicungloai += "</li>"; if (i % 3 != 0) { chuoicungloai += "<li class=\"other\">"; chuoicungloai += "<div class=\"imagespro\"><a href=\"/thong-tin/" + list[i].Tag + "\" title=\"" + list[i].Name + "\"><img src=\"" + list[i].Image + "\" alt=\"" + list[i].Name + "\" title=\"" + list[i].Name + "\"/></a></div>"; if ((list[i].PricePromotion / list[i].PriceRetail) * 100 < 100) { chuoicungloai += "<div>"; if (list[i].Code != null && list[i].Code != "") { chuoicungloai += "<p class=\"sp_code\">Mã SP: " + list[i].Code + "</p>"; } else { chuoicungloai += "<p class=\"sp_code\">No size</p>"; } if (list[i].PricePromotion == 0) { chuoicungloai += "<p class=\"gia_sp\">Giá: Vui lòng liên hệ</p>"; } else { chuoicungloai += "<p class=\"gia_cu\">Giá cũ: " + os.os.Format_Price(list[i].PriceRetail.ToString()) + "đ</p>"; chuoicungloai += "<p class=\"gia_sp\">Giá bán: " + os.os.Format_Price(list[i].PricePromotion.ToString()) + "đ</p>"; } chuoicungloai += "</div>"; chuoicungloai += "<p class=\"sp_name\"><a href=\"/thong-tin/" + list[i].Tag + "\"> " + list[i].Name + "</a></p>"; chuoicungloai += "<div class=\"giamgia\">"; chuoicungloai += "<span class=\"discount-label\">Giảm</span>"; chuoicungloai += "<span class=\"discount-value\">" + onsoft.Models.StringClass.Round(double.Parse((100 - (list[i].PricePromotion / list[i].PriceRetail) * 100).ToString()), 2) + "%</span>"; chuoicungloai += "</div>"; } else { chuoicungloai += "<div>"; if (list[i].Code != null && list[i].Code != "") { chuoicungloai += "<p class=\"sp_code\">Mã SP: " + list[i].Code + "</p>"; } else { chuoicungloai += "<p class=\"sp_code\">No size</p>"; } if (list[i].PricePromotion == 0) { chuoicungloai += "<p class=\"gia_sp\">Giá: Vui lòng liên hệ</p>"; } else { chuoicungloai += "<p class=\"gia_sp\">Giá bán: " + os.os.Format_Price(list[i].PricePromotion.ToString()) + "đ</p>"; } chuoicungloai += "</div>"; chuoicungloai += "<p class=\"sp_name\"><a href=\"/thong-tin/" + list[i].Tag + "\">" + list[i].Name + "</a></p>"; } chuoicungloai += "</li>"; } else { chuoicungloai += "<li class=\"right\">"; chuoicungloai += "<div class=\"imagespro\"><a href=\"/thong-tin/" + list[i].Tag + "\" title=\"list[i].Name\"><img src=\"" + list[i].Image + "\" alt=\"" + list[i].Name + "\" title=\"" + list[i].Name + "\"/></a></div>"; chuoicungloai += "<div>"; if (list[i].Code != null && list[i].Code != "") { chuoicungloai += "<p class=\"sp_code\">Mã SP: " + list[i].Code + "</p>"; } else { chuoicungloai += "<p class=\"sp_code\">No size</p>"; } if (list[i].PricePromotion == 0) { chuoicungloai += "<p class=\"gia_sp\">Giá: Vui lòng liên hệ</p>"; } else { chuoicungloai += "<p class=\"gia_sp\">Giá bán: " + os.os.Format_Price(list[i].PricePromotion.ToString()) + "đ</p>"; } chuoicungloai += "</div>"; chuoicungloai += "<p class=\"sp_name\"><a href=\"/thong-tin/" + list[i].Tag + "\">" + list[i].Name + "</a></p>"; chuoicungloai += "</li>"; } } ViewBag.cungloai = chuoicungloai; list.Clear(); list = null; #endregion #region [Sản phẩm nhiều người mua] string chuoinhieu = ""; var listnn = (from p in data.v_Product_DescTotalNumber select p).Take(20).ToList(); for (int e = 0; e < listnn.Count; e++) { chuoinhieu += "<li>"; chuoinhieu += "<a href=\"/dong-ho/" + listnn[e].Tag + "\"><img src=\"" + listnn[e].Image + "\" /></a>"; chuoinhieu += "<a href=\"/dong-ho/" + listnn[e].Tag + "\">" + listnn[e].Name + "</a>"; if ((listnn[e].PricePromotion / listnn[e].PriceRetail) * 100 < 100) { chuoinhieu += "<p><span>" + os.os.Format_Price(listnn[e].PriceRetail.ToString()) + "đ</span></p>"; chuoinhieu += "<p>" + os.os.Format_Price(listnn[e].PricePromotion.ToString()) + "đ</p>"; } else { chuoinhieu += "<p>" + os.os.Format_Price(listnn[e].PricePromotion.ToString()) + "đ</p>"; } chuoinhieu += "</li>"; } ViewBag.nhieu = chuoinhieu; listnn.Clear(); listnn = null; #endregion } ViewBag.images = image; ViewBag.imagethumb = imagethumb; ViewBag.pro = chuoi; pro.Clear(); pro = null; #region [Hiển thị thông tin các Tab] var listconf = data.Configs.ToList(); if (listconf.Count > 0) { thanhtoan = listconf[0].Thanhtoan; canhbao = listconf[0].Canhbao; khuyenmai = listconf[0].Helpsize; } listconf.Clear(); listconf = null; string chuoitab_head = ""; string chuoitab_content = ""; if (chitiet != null && chitiet != "") { chuoitab_head += "<li><a href=\"#tabs-1\">Thông tin sản phẩm</a></li>"; chuoitab_content += "<div id=\"tabs-1\"><p>" + chitiet + " " + canhbao + "</p></div>"; } if (noibat != null && noibat != "") { chuoitab_head += "<li><a href=\"#tabs-2\">Ưu điểm nổi bật</a></li>"; chuoitab_content += "<div id=\"tabs-2\"><p>" + noibat + "</p></div>"; } if (baohanh != null && baohanh != "") { chuoitab_head += "<li><a href=\"#tabs-3\">Thông tin bảo hành</a></li>"; chuoitab_content += "<div id=\"tabs-3\"><p>" + baohanh + "</p></div>"; } if (thanhtoan != null && thanhtoan != "") { chuoitab_head += "<li><a href=\"#tabs-4\">Phương thức thanh toán</a></li>"; chuoitab_content += "<div id=\"tabs-4\"><p>" + thanhtoan + "</p></div>"; } //if (canhbao != null && canhbao != "") //{ // chuoitab_head += "<li><a href=\"#tabs-5\">Cảnh báo</a></li>"; // chuoitab_content += "<div id=\"tabs-5\"><p>" + canhbao + "</p></div>"; //} if (khuyenmai != null && khuyenmai != "") { chuoitab_head += "<li><a href=\"#tabs-6\">Khuyến mại</a></li>"; chuoitab_content += "<div id=\"tabs-6\"><p>" + khuyenmai + "</p></div>"; } chuoitab_head += "<li><a href=\"#tabs-7\">Bình luận đánh giá</a></li>"; chuoitab_content += "<div id=\"tabs-7\"><p>" + fb + "</p></div>"; ViewBag.tabhead = chuoitab_head; ViewBag.tabcontent = chuoitab_content; #endregion #region [Hỗ trợ trực tuyến] string chuoisp = ""; string chuoi_tel = ""; string chuoi_hotline = ""; string chuoi_mobile = ""; var listsp = data.Supports.ToList(); if (listsp.Count > 0) { for (int i = 0; i < listsp.Count; i++) { if (listsp[i].Type == 0) { chuoisp += "<p><a href=\"ymsgr:sendim?" + listsp[i].Nick + "\" title=\"" + listsp[i].Name + "\"><img alt=\"" + listsp[i].Name + "\" src=\"http://opi.yahoo.com/online?u=" + listsp[i].Nick + "&m=g&t=1\" border=\"0\" align=\"middle\"></a></p>"; } else if (listsp[i].Type == 1) { chuoisp += "<p><a href=\"skype:" + listsp[i].Nick + "?chat\"><img src=\"HTTP://MYSTATUS.SKYPE.COM/smallclassic/" + listsp[i].Nick + "\" title=\"" + listsp[i].Name + "\"></a></p>"; } else if (listsp[i].Type == 2) { chuoi_hotline += "<p><a href=\"#\" class=\"hl\" title=\"" + listsp[i].Name + "\"></a><span>HOTLINE: " + listsp[i].Tel + "</span></p>"; } else if (listsp[i].Type == 3) { chuoi_tel += "<p><a href=\"#\" class=\"cel\" title=\"" + listsp[i].Name + "\"></a>" + listsp[i].Tel + "</p>"; } else if (listsp[i].Type == 4) { chuoi_mobile += "<p><a href=\"#\" class=\"mob\" title=\"" + listsp[i].Name + "\"></a>" + listsp[i].Tel + "</p>"; } } chuoisp = chuoisp + chuoi_tel + chuoi_mobile + chuoi_hotline; } ViewBag.support = chuoisp; #endregion //#region[view drop Colors] //var procolor = data.ProColors.Where(n => n.IdPro == proId).ToList(); //List<DropDownList> listcolor = new List<DropDownList>(); //listcolor.Add(new DropDownList { value = "0", text = "Như ảnh" }); //if (procolor.Count > 0) //{ // List<DropDownList> listcolor1 = new List<DropDownList>(); // for (int k = 0; k < procolor.Count; k++) // { // int clId=procolor[k].IdColor; // var color = data.Colors.Where(n => n.Id == clId).ToList(); // for (int i = 0; i < color.Count; i++) // { // string sid=color[i].Id.ToString(); // string sname=color[i].Name.ToString(); // listcolor1.Add(new DropDownList { value = "" + sid + "", text = "" + sname + "" }); // //ViewBag.color = new SelectList(color, "Id", "Name"); // } // } // ViewBag.color = new SelectList(listcolor1, "value", "text"); //} //else //{ // ViewBag.color = new SelectList(listcolor, "value", "text"); //} //#endregion //#region[view drop Sizes] //var prosize = data.ProSizes.Where(n => n.IdPro == proId).ToList(); //List<DropDownList> listsize = new List<DropDownList>(); //listsize.Add(new DropDownList { value = "0", text = "Freesize" }); //if (prosize.Count > 0) //{ // List<DropDownList> listsize1 = new List<DropDownList>(); // for (int s = 0; s < prosize.Count; s++) // { // int szId = prosize[s].IdSize; // var size = data.Sizes.Where(n => n.Id == szId).ToList(); // for (int i = 0; i < size.Count; i++) // { // string sid = size[i].Id.ToString(); // string sname = size[i].Name.ToString(); // listsize1.Add(new DropDownList { value = "" + sid + "", text = "" + sname + "" }); // //ViewBag.sizes = new SelectList(size, "Id", "Name"); // } // } // ViewBag.size = new SelectList(listsize1, "value", "text"); //} //else //{ // ViewBag.size = new SelectList(listsize, "value", "text"); //} //#endregion return(View()); }