public ActionResult LoginIndex(tblUser tblusers, tblHistoryLogin tblhistorylogin) { string pass = EncryptandDecrypt.Encrypt(tblusers.Password); var list = db.tblUsers.Where(p => p.UserName == tblusers.UserName && p.Password == pass && p.Active == true).ToList(); if (list.Count > 0) { var userCookie = new HttpCookie("Username"); var id = list[0].id.ToString(CultureInfo.InvariantCulture); var username = list[0].UserName; var fullname = list[0].FullName; userCookie.Values["UserID"] = id; userCookie.Values["FullName"] = Server.HtmlEncode(fullname.Trim()); userCookie.Values["fullname"] = fullname; userCookie.Values["UserName"] = Server.UrlEncode(username.Trim()); userCookie.Values["username"] = username; tblhistorylogin.FullName = fullname; tblhistorylogin.Task = "Login hệ thống"; tblhistorylogin.idUser = int.Parse(id); tblhistorylogin.DateCreate = DateTime.Now; tblhistorylogin.Active = true; db.tblHistoryLogins.Add(tblhistorylogin); db.SaveChanges(); userCookie.Expires = DateTime.Now.AddHours(22); Response.Cookies.Add(userCookie); Session["Count"] = ""; return(Redirect("/Productad/Index")); } else { ViewBag.Note = "Tài khoản của bạn nhập không đúng, kiểm tra lại tên đăng nhập hoặc mật khẩu. Có thể tài khoản bị khóa !"; return(View()); } }
public ActionResult Index(FormCollection colletion) { tblContact tblcontact = new tblContact(); tblcontact.Name = colletion["txtName"]; tblcontact.Mobile = colletion["txtMobile"]; tblcontact.Address = colletion["txtAddress"]; tblcontact.Email = colletion["txtEmail"]; tblcontact.Content = colletion["txtDescription"]; db.tblContacts.Add(tblcontact); db.SaveChanges(); ViewBag.favicon = " <link href=\"" + db.TblConfigs.First().Favicon + "\" rel=\"icon\" type=\"image/x-icon\" />"; ViewBag.status = "<script>$(document).ready(function(){ alert('Bạn đã liên hệ thành công. Vui lòng Check Mail để biết chi tiết !') });</script>"; return(View()); }
public ActionResult Index(TblConfig TblConfig, int id = 1) { if (ModelState.IsValid) { TblConfig.ID = id; #region [Updatehistory] Updatehistoty.UpdateHistory("Config Website", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString()); #endregion db.Entry(TblConfig).State = EntityState.Modified; db.SaveChanges(); Session["Thongbao"] = "<div class=\"alert alert-info\">Bạn cập nhật thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(RedirectToAction("Index")); } return(View(TblConfig)); }
public static void UpdateHistory(string task, string FullName, string UserID) { KangaroochinhhangContext db = new KangaroochinhhangContext(); tblHistoryLogin tblhistorylogin = new tblHistoryLogin(); tblhistorylogin.FullName = FullName; tblhistorylogin.Task = task; tblhistorylogin.idUser = int.Parse(UserID); tblhistorylogin.DateCreate = DateTime.Now; tblhistorylogin.Active = true; db.tblHistoryLogins.Add(tblhistorylogin); db.SaveChanges(); }
public ActionResult Edit(tblMap tblmaps, FormCollection collection) { if (ModelState.IsValid) { string idUser = Request.Cookies["Username"].Values["UserID"]; tblmaps.UserID = int.Parse(idUser); tblmaps.DateCreate = DateTime.Now; int id = int.Parse(collection["idMaps"]); tblmaps.id = id; db.Entry(tblmaps).State = EntityState.Modified; db.SaveChanges(); #region [Updatehistory] Updatehistoty.UpdateHistory("Update Maps", Request.Cookies["Username"].Values["Username"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString()); #endregion } return(View(tblmaps)); }
// GET: Manufacturesad public ActionResult Index(string idCate, FormCollection collection) { if ((Request.Cookies["Username"] == null)) { return(RedirectToAction("LoginIndex", "Login")); } if (ClsCheckRole.CheckQuyen(8, 0, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { var menuModel = db.tblGroupImages.Where(m => m.Active == true).OrderBy(m => m.id).ToList(); carlist.Clear(); foreach (var item in menuModel) { carlist.Add(new SelectListItem { Text = item.Name, Value = item.id.ToString() }); } if (idCate != "") { ViewBag.drMenu = new SelectList(carlist, "Value", "Text", idCate); ViewBag.idCate = idCate; ViewBag.idMenu = idCate; } else { ViewBag.drMenu = carlist; } if (collection["btnDelete"] != null) { foreach (string key in Request.Form.Keys) { var checkbox = ""; if (key.StartsWith("chk_")) { checkbox = Request.Form["" + key]; if (checkbox != "false") { if (ClsCheckRole.CheckQuyen(9, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { int id = Convert.ToInt32(key.Remove(0, 4)); var tblimages = db.tblImages.Find(id); db.tblImages.Remove(tblimages); db.SaveChanges(); } else { return(Redirect("/Users/Erro")); } } } } //dsd } if (Session["Thongbao"] != null && Session["Thongbao"] != "") { ViewBag.thongbao = Session["Thongbao"].ToString(); Session["Thongbao"] = ""; } return(View()); } else { return(Redirect("/Users/Erro")); } }
public ActionResult Index(int?page, string id, FormCollection collection) { if ((Request.Cookies["Username"] == null)) { return(RedirectToAction("LoginIndex", "Login")); } if (ClsCheckRole.CheckQuyen(10, 0, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { var LitsHotline = db.tblHotlines.ToList(); const int pageSize = 20; var pageNumber = (page ?? 1); // Thiết lập phân trang var ship = new PagedListRenderOptions { DisplayLinkToFirstPage = PagedListDisplayMode.Always, DisplayLinkToLastPage = PagedListDisplayMode.Always, DisplayLinkToPreviousPage = PagedListDisplayMode.Always, DisplayLinkToNextPage = PagedListDisplayMode.Always, DisplayLinkToIndividualPages = true, DisplayPageCountAndCurrentLocation = false, MaximumPageNumbersToDisplay = 5, DisplayEllipsesWhenNotShowingAllPageNumbers = true, EllipsesFormat = "…", LinkToFirstPageFormat = "Trang đầu", LinkToPreviousPageFormat = "«", LinkToIndividualPageFormat = "{0}", LinkToNextPageFormat = "»", LinkToLastPageFormat = "Trang cuối", PageCountAndCurrentLocationFormat = "Page {0} of {1}.", ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}.", FunctionToDisplayEachPageNumber = null, ClassToApplyToFirstListItemInPager = null, ClassToApplyToLastListItemInPager = null, ContainerDivClasses = new[] { "pagination-container" }, UlElementClasses = new[] { "pagination" }, LiElementClasses = Enumerable.Empty <string>() }; ViewBag.ship = ship; if (Session["Thongbao"] != null && Session["Thongbao"] != "") { ViewBag.thongbao = Session["Thongbao"].ToString(); Session["Thongbao"] = ""; } if (collection["btnDelete"] != null) { foreach (string key in Request.Form.Keys) { var checkbox = ""; if (key.StartsWith("chk_")) { checkbox = Request.Form["" + key]; if (checkbox != "false") { if (ClsCheckRole.CheckQuyen(10, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { int ids = Convert.ToInt32(key.Remove(0, 4)); tblHotline tblhotline = db.tblHotlines.Find(ids); db.tblHotlines.Remove(tblhotline); db.SaveChanges(); return(RedirectToAction("Index")); } else { return(Redirect("/Users/Erro")); } } } } } return(View(LitsHotline.ToPagedList(pageNumber, pageSize))); } else { return(Redirect("/Users/Erro")); } }
public ActionResult Index(FormCollection collection) { if (collection["btnSend"] != null) { string nName = collection["txtName"]; string nAddress = collection["txtAddress"]; string nMobile = collection["txtMobile"]; string nEmail = collection["txtEmail"]; string nContent = collection["txtContent"]; string ararurl = Request.Url.ToString(); var listurl = ararurl.Split('/'); string urlhomes = ""; for (int i = 0; i < listurl.Length - 2; i++) { if (i > 0) { urlhomes += "/" + listurl[i]; } else { urlhomes += listurl[i]; } } tblContact tblcontact = new tblContact(); tblcontact.Name = nName; tblcontact.Address = nAddress; tblcontact.Mobile = nMobile; tblcontact.Email = nEmail; tblcontact.Content = nContent; db.tblContacts.Add(tblcontact); db.SaveChanges(); var config = db.TblConfigs.First(); var fromAddress = config.UserEmail; string fromPassword = config.PassEmail; var toAddress = config.Email; string subject = "Bạn có liên hệ mới từ " + urlhomes + ""; string chuoihtml = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Thông tin đơn hàng</title></head><body style=\"background:#f2f2f2; font-family:Arial, Helvetica, sans-serif\"><div style=\"width:750px; height:auto; margin:5px auto; background:#FFF; border-radius:5px; overflow:hidden\">"; chuoihtml += "<div style=\"width:100%; height:40px; float:left; margin:0px; background:#1c7fc4\"><span style=\"font-size:14px; line-height:40px; color:#FFF; margin:auto 20px; float:left\">" + DateTime.Now.Date + "</span><span style=\"font-size:14px; line-height:40px; float:right; margin:auto 20px; color:#FFF; text-transform:uppercase\">Hotline : " + config.HotlineIN + "</span></div>"; chuoihtml += "<div style=\"width:100%; height:auto; float:left; margin:0px\"><div style=\"width:35%; height:100%; margin:0px; float:left\"><a href=\"/\" title=\"\"><img src=\"" + urlhomes + "" + config.Logo + "\" alt=\"Logo\" style=\"margin:8px; display:block; max-height:95% \" /></a></div><div style=\"width:60%; height:100%; float:right; margin:0px; text-align:right\"><span style=\"font-size:18px; margin:20px 5px 5px 5px; display:block; color:#ff5a00; text-transform:uppercase\">" + config.Name + "</span><span style=\"display:block; margin:5px; color:#515151; font-size:13px; text-transform:uppercase\">Lớn nhất - Chính hãng - Giá rẻ nhất việt nam</span> </div> </div>"; chuoihtml += "<span style=\"text-align:center; margin:10px auto; font-size:20px; color:#000; font-weight:bold; text-transform:uppercase; display:block\">Thông tin Liên hệ</span>"; chuoihtml += " <div style=\"width:90%; height:auto; margin:10px auto; background:#f2f2f2; padding:15px\">"; chuoihtml += "<p style=\"font-size:14px; color:#464646; margin:5px 20px\">Thông tin liên hệ từ website : <span style=\"color:#1c7fc4\">" + urlhomes + "</span></p>"; chuoihtml += "<p style=\"font-size:14px; color:#464646; margin:5px 20px\">Ngày gửi liên hệ : <span style=\"color:#1c7fc4\">Vào lúc " + DateTime.Now.Hour + " giờ " + DateTime.Now.Minute + " phút ( ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year + ") </span></p>"; chuoihtml += "<div style=\" width:100%; margin:15px 0px\">"; chuoihtml += "<div style=\"width:100%; height:auto; float:left; margin:0px; border:1px solid #d5d5d5\">"; chuoihtml += "<div style=\" width:100%; height:30px; float:left; background:#1c7fc4; font-size:12px; color:#FFF; text-indent:15px; line-height:30px\"> Thông tin người gửi </div>"; chuoihtml += "<div style=\"width:100%; height:auto; float:left\">"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Họ và tên :<span style=\"font-weight:bold\"> " + nName + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Địa chỉ :<span style=\"font-weight:bold\"> " + nAddress + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Điện thoại :<span style=\"font-weight:bold\"> " + nMobile + " </span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Email :<span style=\"font-weight:bold\">" + nEmail + "</span></p>"; chuoihtml += "<div style=\"width:90%; height:auto; margin:10px auto; border:1px solid #d5d5d5\">"; chuoihtml += "<div style=\" width:100%; height:30px; float:left; background:#1c7fc4; font-size:12px; color:#FFF; text-indent:15px; line-height:30px\"> Nội dung </div>"; chuoihtml += " <div style=\"width:100%; height:auto; float:left\">"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px; font-weight:bold; color:#F00\"> - " + nContent + "</p>"; chuoihtml += "</div>"; chuoihtml += "</div>"; chuoihtml += "</div>"; chuoihtml += "<div style=\"width:100%; height:auto; float:left; margin:0px\">"; chuoihtml += "<hr style=\"width:80%; height:1px; background:#d8d8d8; margin:20px auto 10px auto\" />"; chuoihtml += "<p style=\"font-size:12px; text-align:center; margin:5px 5px\">" + config.Address + "</p>"; chuoihtml += "<p style=\"font-size:12px; text-align:center; margin:5px 5px\">Điện thoại : " + config.MobileIN + " - " + config.HotlineIN + "</p>"; chuoihtml += " <p style=\"font-size:12px; text-align:center; margin:5px 5px; color:#ff7800\">Thời gian mở cửa : Từ 7h30 đến 18h30 hàng ngày (làm cả thứ 7, chủ nhật). Khách hàng đến trực tiếp xem hàng giảm thêm giá.</p>"; chuoihtml += "</div>"; chuoihtml += "<div style=\"clear:both\"></div>"; chuoihtml += " </div>"; chuoihtml += " <div style=\"width:100%; height:40px; float:left; margin:0px; background:#1c7fc4\">"; chuoihtml += "<span style=\"font-size:12px; text-align:center; color:#FFF; line-height:40px; display:block\">Copyright (c) 2002 – 2015 SONHA VIET NAM. All Rights Reserved</span>"; chuoihtml += " </div>"; chuoihtml += "</div>"; chuoihtml += "</body>"; chuoihtml += "</html>"; string body = chuoihtml; var smtp = new System.Net.Mail.SmtpClient(); { smtp.Host = config.Host; smtp.Port = int.Parse(config.Port.ToString()); smtp.EnableSsl = true; smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtp.Credentials = new NetworkCredential(fromAddress, fromPassword); smtp.Timeout = int.Parse(config.Timeout.ToString()); } using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body, IsBodyHtml = true, }) { smtp.Send(message); } Session["Status"] = "<script>$(document).ready(function(){ alert('Bạn đã đặt hàng thành công !') });</script>"; return(RedirectToAction("Index")); } return(View()); }
public ActionResult newsDetail(string tag) { tblNew tblnews = db.tblNews.First(p => p.Tag == tag); int id = tblnews.id; int idmenu = int.Parse(tblnews.idCate.ToString()); tblGroupNew groupNews = db.tblGroupNews.First(p => p.id == idmenu); ViewBag.menuName = groupNews.Name; ViewBag.tagMenuName = groupNews.Tag; var listId = db.tblConnectManuToNews.Where(p => p.idNews == id).Select(p => p.idManu).Take(1).ToList(); Session["idManu"] = ""; int idManu = int.Parse(listId[0].Value.ToString()); var manufactures = db.SelectListItem.Find(idManu); ViewBag.manuName = manufactures.Name; ViewBag.color = manufactures.Color; Session["idManu"] = idManu; if (tblnews.Style == true) { ViewBag.style = "width:100% !important; margin:0px"; ViewBag.style1 = "display:none"; } ViewBag.Title = "<title>" + tblnews.Title + "</title>"; ViewBag.Description = "<meta name=\"description\" content=\"" + tblnews.Description + "\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"" + tblnews.Keyword + "\" /> "; ViewBag.dcTitle = "<meta name=\"DC.title\" content=\"" + tblnews.Title + "\" />"; if (tblnews.Meta != null && tblnews.Meta != "") { int phut = DateTime.Now.Minute * 2; ViewBag.refresh = "<meta http-equiv=\"refresh\" content=\"" + phut + "; url=" + tblnews.Meta + "\">"; } ViewBag.dcDescription = "<meta name=\"DC.description\" content=\"" + tblnews.Description + "\" />"; string meta = ""; ViewBag.canonical = "<link rel=\"canonical\" href=\"http://Kangaroochinhhang.com/3/" + StringClass.NameToTag(tag) + "\" />"; meta += "<meta itemprop=\"name\" content=\"" + tblnews.Name + "\" />"; meta += "<meta itemprop=\"url\" content=\"" + Request.Url.ToString() + "\" />"; meta += "<meta itemprop=\"description\" content=\"" + tblnews.Description + "\" />"; meta += "<meta itemprop=\"image\" content=\"http://Kangaroochinhhang.com" + tblnews.Images + "\" />"; meta += "<meta property=\"og:title\" content=\"" + tblnews.Title + "\" />"; meta += "<meta property=\"og:type\" content=\"product\" />"; meta += "<meta property=\"og:url\" content=\"" + Request.Url.ToString() + "\" />"; meta += "<meta property=\"og:image\" content=\"http://Kangaroochinhhang.com" + tblnews.Images + "\" />"; meta += "<meta property=\"og:site_name\" content=\"http://Kangaroochinhhang.com\" />"; meta += "<meta property=\"og:description\" content=\"" + tblnews.Description + "\" />"; meta += "<meta property=\"fb:admins\" content=\"\" />"; ViewBag.Meta = meta; StringBuilder schame = new StringBuilder(); schame.Append("<script type=\"application/ld+json\">"); schame.Append("{"); schame.Append("\"@context\": \"http://schema.org\","); schame.Append("\"@type\": \"NewsArticle\","); schame.Append("\"headline\": \"" + tblnews.Description + "\","); schame.Append(" \"datePublished\": \"" + tblnews.DateCreate + "\","); schame.Append("\"image\": ["); schame.Append(" \"" + tblnews.Images + "\""); schame.Append(" ]"); schame.Append("}"); schame.Append("</script> "); ViewBag.schame = schame.ToString(); int iduser = int.Parse(tblnews.idUser.ToString()); ViewBag.user = db.tblUsers.First(p => p.id == iduser).UserName; string tab = tblnews.Tabs; string Tabsnews = ""; if (tab != null) { string[] mang = tab.Split(','); for (int i = 0; i < mang.Length; i++) { Tabsnews += " <a href=\"/TagNews/" + StringClass.NameToTag(mang[i]) + "\" title=\"" + mang[i] + "\">" + mang[i] + "</a>"; } ViewBag.tags = Tabsnews; } StringBuilder result = new StringBuilder(); var listIdNews = db.tblConnectManuToNews.Where(p => listId.Contains(p.idManu)).Select(p => p.idNews).ToList(); var listnews = db.tblNews.Where(p => listIdNews.Contains(p.id) && p.Active == true && p.id != id).OrderByDescending(p => p.DateCreate).Take(5).ToList(); if (listnews.Count > 0) { for (int j = 0; j < listnews.Count; j++) { result.Append(" <li><a href=\"/3/" + listnews[j].Tag + "\" title=\"" + listnews[j].Name + "\"><i class=\"fa fa-angle-right\" aria-hidden=\"true\"></i> " + listnews[j].Name + "</a><span>"); result.Append(" <i class=\"fa fa-clock-o\" aria-hidden=\"true\"></i> Viết ngày : " + listnews[j].DateCreate + " </span><li>"); } } ViewBag.result = result.ToString(); ViewBag.favicon = " <link href=\"" + manufactures.Favicon + "\" rel=\"icon\" type=\"image/x-icon\" />"; ViewBag.nUrl = "<ol itemscope itemtype=\"http://schema.org/BreadcrumbList\"> <li itemprop=\"itemListElement\" itemscope itemtype=\"http://schema.org/ListItem\"> <a itemprop=\"item\" href=\"http://Kangaroochinhhang.com\"> <span itemprop=\"name\">Trang chủ</span></a> <meta itemprop=\"position\" content=\"1\" /> </li> ›" + Urlnews(idmenu) + "</ol>"; int visit = int.Parse(tblnews.Visit.ToString()); if (visit > 0) { tblnews.Visit = tblnews.Visit + 1; db.SaveChanges(); } else { tblnews.Visit = tblnews.Visit + 1; db.SaveChanges(); } return(View(tblnews)); }
public ActionResult Index(int?page, string text, string idCate, string pageSizes, FormCollection collection) { if ((Request.Cookies["Username"] == null)) { return(RedirectToAction("LoginIndex", "Login")); } if (ClsCheckRole.CheckQuyen(5, 0, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { #region [Load Menu] var pro = db.tblGroupNews.OrderByDescending(p => p.Ord).Take(1).ToList(); var menuModel = db.tblGroupNews.Where(m => m.ParentID == null).OrderBy(m => m.id).ToList(); carlist.Clear(); string strReturn = "---"; foreach (var item in menuModel) { carlist.Add(new SelectListItem { Text = item.Name, Value = item.id.ToString() }); StringClass.DropDownListNews(item.id, carlist, strReturn); strReturn = "---"; } if (idCate != "") { ViewBag.drMenu = new SelectList(carlist, "Value", "Text", idCate); ViewBag.idCate = idCate; ViewBag.idMenu = idCate; } else { ViewBag.drMenu = carlist; } #endregion if (Session["Thongbao"] != null && Session["Thongbao"] != "") { ViewBag.thongbao = Session["Thongbao"].ToString(); Session["Thongbao"] = ""; } if (collection["btnDelete"] != null) { foreach (string key in Request.Form.Keys) { var checkbox = ""; if (key.StartsWith("chk_")) { checkbox = Request.Form["" + key]; if (checkbox != "false") { if (ClsCheckRole.CheckQuyen(5, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { int id = Convert.ToInt32(key.Remove(0, 4)); tblNew tblnews = db.tblNews.Find(id); int ord = int.Parse(tblnews.Ord.ToString()); int idCates = int.Parse(tblnews.idCate.ToString()); var kiemtra = db.tblNews.Where(p => p.Ord > ord && p.idCate == idCates).ToList(); if (kiemtra.Count > 0) { var ListNews = db.tblNews.Where(p => p.Ord > ord && p.idCate == idCates).ToList(); for (int i = 0; i < ListNews.Count; i++) { int idp = int.Parse(ListNews[i].id.ToString()); var NewsUpdate = db.tblNews.Find(idp); NewsUpdate.Ord = NewsUpdate.Ord - 1; db.SaveChanges(); } } db.tblNews.Remove(tblnews); db.SaveChanges(); clsSitemap.DeteleSitemap(id.ToString(), "News"); } else { return(Redirect("/Users/Erro")); } } } } //dsd } return(View()); } else { return(Redirect("/Users/Erro")); } }
// GET: Manufacturesad public ActionResult Index(string idCate, FormCollection collection) { if ((Request.Cookies["Username"] == null)) { return(RedirectToAction("LoginIndex", "Login")); } if (ClsCheckRole.CheckQuyen(8, 0, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { var menuModel = db.tblGroupProducts.Where(m => m.ParentID == null).OrderBy(m => m.id).ToList(); carlist.Clear(); string strReturn = "---"; foreach (var item in menuModel) { carlist.Add(new SelectListItem { Text = item.Name, Value = item.id.ToString() }); StringClass.DropDownListFor(item.id, carlist, strReturn); strReturn = "---"; } if (idCate != "") { ViewBag.drMenu = new SelectList(carlist, "Value", "Text", idCate); ViewBag.idCate = idCate; ViewBag.idMenu = idCate; } else { ViewBag.drMenu = carlist; } if (collection["btnDelete"] != null) { foreach (string key in Request.Form.Keys) { var checkbox = ""; if (key.StartsWith("chk_")) { checkbox = Request.Form["" + key]; if (checkbox != "false") { if (ClsCheckRole.CheckQuyen(7, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { int id = Convert.ToInt32(key.Remove(0, 4)); var tblManu = db.SelectListItem.Find(id); db.SelectListItem.Remove(tblManu); db.SaveChanges(); var ListManu = db.tblConnectManuProducts.Where(p => p.idManu == id).ToList(); for (int i = 0; i < ListManu.Count; i++) { db.tblConnectManuProducts.Remove(ListManu[i]); db.SaveChanges(); } clsSitemap.DeteleSitemap(id.ToString(), "Manufactures"); } else { return(Redirect("/Users/Erro")); } } } } //dsd } if (Session["Thongbao"] != null && Session["Thongbao"] != "") { ViewBag.thongbao = Session["Thongbao"].ToString(); Session["Thongbao"] = ""; } return(View()); } else { return(Redirect("/Users/Erro")); } }
public ActionResult Command(FormCollection collection) { tblRegister register = new tblRegister(); register.Name = collection["txtName"]; register.Mobile = collection["txtMobile"]; register.Address = collection["txtAddress"]; register.Email = collection["txtEmail"]; if (collection["txtDatemua"] != null) { register.DateTimebyy = DateTime.Parse(collection["txtDatemua"]); } else { register.DateTimebyy = DateTime.Now; } if (collection["txtDatethay"] != null) { register.DateTime = DateTime.Parse(collection["txtDatethay"]); } else { register.DateTime = DateTime.Now; } db.tblRegisters.Add(register); db.SaveChanges(); foreach (string key in Request.Form) { var checkbox = ""; if (key.StartsWith("chk_")) { checkbox = Request.Form["" + key]; if (checkbox != "false") { Int32 idll = Convert.ToInt32(key.Remove(0, 4)); int idkh = int.Parse(db.tblRegisters.OrderByDescending(p => p.id).ToList()[0].id.ToString()); tblConnectLoiloc clloiloc = new tblConnectLoiloc(); clloiloc.idkh = idkh; clloiloc.idll = idll; db.tblConnectLoilocs.Add(clloiloc); db.SaveChanges(); } } } TblConfig config = db.TblConfigs.First(); var fromAddress = config.UserEmail; var toAddress = config.Email; var MaxRigister = db.tblRegisters.OrderByDescending(p => p.id).Take(1).ToList(); string fromPassword = config.PassEmail; string ararurl = Request.Url.ToString(); var listurl = ararurl.Split('/'); string urlhomes = ""; for (int i = 0; i < listurl.Length - 2; i++) { if (i > 0) { urlhomes += "/" + listurl[i]; } else { urlhomes += listurl[i]; } } int Makh = int.Parse(MaxRigister[0].id.ToString()); string subject = "Đăng ký thay lõi lọc nước thành công"; string chuoihtml = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Thông tin đơn hàng</title></head><body style=\"background:#f2f2f2; font-family:Arial, Helvetica, sans-serif\"><div style=\"width:750px; height:auto; margin:5px auto; background:#FFF; border-radius:5px; overflow:hidden\">"; chuoihtml += "<div style=\"width:100%; height:40px; float:left; margin:0px; background:#1c7fc4\"><span style=\"font-size:14px; line-height:40px; color:#FFF; margin:auto 20px; float:left\">" + DateTime.Now.Date + "</span><span style=\"font-size:14px; line-height:40px; float:right; margin:auto 20px; color:#FFF; text-transform:uppercase\">Hotline : " + config.HotlineIN + "</span></div>"; chuoihtml += "<div style=\"width:100%; height:auto; float:left; margin:0px\"><div style=\"width:35%; height:100%; margin:0px; float:left\"><a href=\"/\" title=\"\"><img src=\"" + urlhomes + "" + config.Logo + "\" alt=\"Logo\" style=\"margin:8px; display:block; max-height:95% \" /></a></div><div style=\"width:60%; height:100%; float:right; margin:0px; text-align:right\"><span style=\"font-size:18px; margin:20px 5px 5px 5px; display:block; color:#ff5a00; text-transform:uppercase\">" + config.Name + "</span><span style=\"display:block; margin:5px; color:#515151; font-size:13px; text-transform:uppercase\">Lớn nhất - Chính hãng - Giá rẻ nhất việt nam</span> </div> </div>"; chuoihtml += "<span style=\"text-align:center; margin:10px auto; font-size:20px; color:#000; font-weight:bold; text-transform:uppercase; display:block\">Thông tin dăng ký</span>"; chuoihtml += " <div style=\"width:90%; height:auto; margin:10px auto; background:#f2f2f2; padding:15px\">"; chuoihtml += "<p style=\"font-size:14px; color:#464646; margin:5px 20px\">Website đăng ký : <span style=\"color:#1c7fc4\">" + urlhomes + "</span></p>"; chuoihtml += "<p style=\"font-size:14px; color:#464646; margin:5px 20px\">Ngày đăng ký : <span style=\"color:#1c7fc4\">Vào lúc " + DateTime.Now.Hour + " giờ " + DateTime.Now.Minute + " phút ( ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year + ") </span></p>"; chuoihtml += "<p style=\"font-size:14px; color:#464646; margin:5px 20px\">Mã khách hàng : <span style=\"color:#1c7fc4\">" + Makh + " </span></p>"; chuoihtml += "<div style=\" width:100%; margin:15px 0px\">"; chuoihtml += "<div style=\"width:90%; height:auto; float:left; margin:0px; border:1px solid #d5d5d5\">"; chuoihtml += "<div style=\" width:100%; height:30px; float:left; background:#1c7fc4; font-size:12px; color:#FFF; text-indent:15px; line-height:30px\"> Thông tin đăng ký </div>"; chuoihtml += "<div style=\"width:100%; height:auto; float:left\">"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Họ và tên :<span style=\"font-weight:bold\"> " + collection["txtName"] + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Địa chỉ :<span style=\"font-weight:bold\"> " + collection["txtAddress"] + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Điện thoại :<span style=\"font-weight:bold\"> " + collection["txtMobile"] + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Email :<span style=\"font-weight:bold\">" + collection["txtEmail"] + "</span></p>"; chuoihtml += "</div>"; chuoihtml += "</div>"; chuoihtml += "</div>"; chuoihtml += "<div style=\"width:100%; height:auto; float:left; margin:0px\">"; chuoihtml += "<hr style=\"width:80%; height:1px; background:#d8d8d8; margin:20px auto 10px auto\" />"; chuoihtml += "<p style=\"font-size:12px; text-align:center; margin:5px 5px\">" + config.Address + "</p>"; chuoihtml += "<p style=\"font-size:12px; text-align:center; margin:5px 5px\">Điện thoại : " + config.MobileIN + " - " + config.HotlineIN + "</p>"; chuoihtml += " <p style=\"font-size:12px; text-align:center; margin:5px 5px; color:#ff7800\">Thời gian mở cửa : Từ 7h30 đến 18h30 hàng ngày (làm cả thứ 7, chủ nhật). Hãy liên hệ để được giảm giá.</p>"; chuoihtml += "</div>"; chuoihtml += "<div style=\"clear:both\"></div>"; chuoihtml += " </div>"; chuoihtml += " <div style=\"width:100%; height:40px; float:left; margin:0px; background:#1c7fc4\">"; chuoihtml += "<span style=\"font-size:12px; text-align:center; color:#FFF; line-height:40px; display:block\">Copyright (c) 2002 – 2015 VINCOM VIET NAM. All Rights Reserved</span>"; chuoihtml += " </div>"; chuoihtml += "</div>"; chuoihtml += "</body>"; chuoihtml += "</html>"; string body = chuoihtml; var smtp = new System.Net.Mail.SmtpClient(); { smtp.Host = config.Host; smtp.Port = int.Parse(config.Port.ToString()); smtp.EnableSsl = true; smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtp.Credentials = new NetworkCredential(fromAddress, fromPassword); smtp.Timeout = int.Parse(config.Timeout.ToString()); } using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body, IsBodyHtml = true, }) { smtp.Send(message); } string emails = collection["txtEmail"]; using (var messages = new MailMessage(fromAddress, emails) { Subject = subject, Body = body, IsBodyHtml = true, }) { smtp.Send(messages); } Session["Register"] = "<script>$(document).ready(function(){ alert('Bạn đã đăng ký thành công !') });</script>"; return(Redirect("/")); }
// GET: InfoCriteria public ActionResult Index(string id, FormCollection collection) { if ((Request.Cookies["Username"] == null)) { return(RedirectToAction("LoginIndex", "Login")); } if (ClsCheckRole.CheckQuyen(6, 0, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { var ListCriteria = db.tblInfoCriterias.OrderBy(m => m.Ord).ToList(); var menuModel = db.tblGroupProducts.Where(m => m.ParentID == null).OrderBy(m => m.id).ToList(); carlists.Clear(); string strReturn = "---"; foreach (var item in menuModel) { carlists.Add(new SelectListItem { Text = item.Name, Value = item.id.ToString() }); StringClass.DropDownListFor(item.id, carlists, strReturn); strReturn = "---"; } if (id != "") { ViewBag.drMenu = carlists; ViewBag.idCate = id; ViewBag.idMenu = id; } else { ViewBag.drMenu = carlists; } if (collection["btnDelete"] != null) { foreach (string key in Request.Form.Keys) { var checkbox = ""; if (key.StartsWith("chk_")) { checkbox = Request.Form["" + key]; if (checkbox != "false") { if (ClsCheckRole.CheckQuyen(6, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { int ids = Convert.ToInt32(key.Remove(0, 4)); tblInfoCriteria tblcriteria = db.tblInfoCriterias.Find(ids); db.tblInfoCriterias.Remove(tblcriteria); db.SaveChanges(); } else { return(Redirect("/Users/Erro")); } } } } //dsd } if (Session["Thongbao"] != null && Session["Thongbao"] != "") { ViewBag.thongbao = Session["Thongbao"].ToString(); Session["Thongbao"] = ""; } return(View()); } else { return(Redirect("/Users/Erro")); } }
public ActionResult ProductDetail(string tag) { tblProduct ProductDetail = db.tblProducts.First(p => p.Tag == tag); int idmenu = int.Parse(ProductDetail.idCate.ToString()); tblGroupProduct groupProduct = db.tblGroupProducts.First(p => p.id == idmenu); ViewBag.Nhomsp = groupProduct.Name; ViewBag.favicon = " <link href=\"" + groupProduct.Favicon + "\" rel=\"icon\" type=\"image/x-icon\" />"; var ListManu = db.tblConnectManuProducts.Where(p => p.idCate == idmenu).Take(1).ToList(); if (ListManu.Count > 0) { int idManu = int.Parse(ListManu[0].idManu.ToString()); ViewBag.Manu = "<li><span>Thương hiệu : " + db.SelectListItem.Find(idManu).Name + "</span></li>"; ViewBag.Manufactures = db.SelectListItem.Find(idManu).Name; } ViewBag.Title = "<title>" + ProductDetail.Title + "</title>"; ViewBag.Description = "<meta name=\"description\" content=\"" + ProductDetail.Description + "\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"" + ProductDetail.Keyword + "\" /> "; ViewBag.imageog = "<meta property=\"og:image\" content=\"" + ProductDetail.ImageLinkDetail + "\"/>"; ViewBag.titleog = "<meta property=\"og:title\" content=\"" + ProductDetail.Title + "\"/> "; ViewBag.site_nameog = "<meta property=\"og:site_name\" content=\"" + ProductDetail.Name + "\"/> "; ViewBag.urlog = "<meta property=\"og:url\" content=\"" + Request.Url.ToString() + "\"/> "; ViewBag.descriptionog = "<meta property=\"og:description\" content=\"" + ProductDetail.Description + "\" />"; ViewBag.nUrl = "<ol itemscope itemtype=\"http://schema.org/BreadcrumbList\"> <li itemprop=\"itemListElement\" itemscope itemtype=\"http://schema.org/ListItem\"> <a itemprop=\"item\" href=\"http://Kangaroochinhhang.com\"> <span itemprop=\"name\">Trang chủ</span></a> <meta itemprop=\"position\" content=\"1\" /> </li> ›" + UrlProduct(groupProduct.id) + "</ol> "; ViewBag.canonical = "<link rel=\"canonical\" href=\"http://Kangaroochinhhang.com/1/" + ProductDetail.Tag + "\" />"; StringBuilder schame = new StringBuilder(); schame.Append("<script type=\"application/ld+json\">"); schame.Append("{"); schame.Append("\"@context\": \"http://schema.org\","); schame.Append("\"@type\": \"ProductArticle\","); schame.Append("\"headline\": \"" + ProductDetail.Description + "\","); schame.Append(" \"datePublished\": \"" + ProductDetail.DateCreate + "\","); schame.Append("\"image\": ["); schame.Append(" \"" + ProductDetail.ImageLinkThumb + "\""); schame.Append(" ]"); schame.Append("}"); schame.Append("</script> "); ViewBag.schame = schame.ToString(); int visit = int.Parse(ProductDetail.Visit.ToString()); if (visit > 0) { ProductDetail.Visit = ProductDetail.Visit + 1; db.SaveChanges(); } else { ProductDetail.Visit = ProductDetail.Visit + 1; db.SaveChanges(); } string chuoilienquan = ""; var listProductlq = db.tblProducts.Where(p => p.Active == true && p.idCate == idmenu && p.Tag != tag).OrderByDescending(p => p.id).Take(8).ToList(); for (int i = 0; i < listProductlq.Count; i++) { chuoilienquan += "<div class=\"Tear_1\">"; chuoilienquan += "<div class=\"img\">"; chuoilienquan += "<div class=\"content_img\"><a href=\"/1/" + listProductlq[i].Tag + "\" title=\"" + listProductlq[i].Name + "\"><img src=\"" + listProductlq[i].ImageLinkThumb + "\" alt=\"" + listProductlq[i].Name + "\" /></a></div>"; chuoilienquan += "<div class=\"detail\">"; chuoilienquan += "<span class=\"title\">" + listProductlq[i].Name + "</span>"; chuoilienquan += "<p>" + listProductlq[i].Info + "</p>"; chuoilienquan += "<a href=\"/1/" + listProductlq[i].Tag + "\" title=\"" + listProductlq[i].Name + "\">Xem tiếp</a>"; chuoilienquan += "</div>"; chuoilienquan += "</div>"; chuoilienquan += "<h3><a href=\"/1/" + listProductlq[i].Tag + "\" class=\"Name\" title=\"" + listProductlq[i].Name + "\">" + listProductlq[i].Name + "</a></h3>"; chuoilienquan += "<span class=\"Price\">Giá : " + string.Format("{0:#,#}", listProductlq[i].Price) + " đ</span>"; chuoilienquan += "<span class=\"PriceSale\"><img /> " + string.Format("{0:#,#}", listProductlq[i].PriceSale) + " đ</span>"; chuoilienquan += "</div>"; } ViewBag.chuoilienquan = chuoilienquan; int id = ProductDetail.id; var listProductTags = db.tblProductTags.Where(p => p.idp == id).ToList(); StringBuilder resultTag = new StringBuilder(); for (int i = 0; i < listProductTags.Count; i++) { resultTag.Append("<h3> <a href=\"/Tabs/" + listProductTags[i].Tag + "\" title=\"" + listProductTags[i].Name + "\">" + listProductTags[i].Name + "</a></h3>"); } ViewBag.chuoitab = resultTag.ToString(); return(View(ProductDetail)); }
public ActionResult productDetail(string tag) { tblProduct ProductDetail = db.tblProducts.First(p => p.Tag == tag); int id = ProductDetail.id; int idmenu = int.Parse(ProductDetail.idCate.ToString()); tblGroupProduct groupProduct = db.tblGroupProducts.First(p => p.id == idmenu); ViewBag.Nhomsp = groupProduct.Name; var listId = db.tblConnectManuProducts.Where(p => p.idCate == idmenu).Select(p => p.idManu).Take(1).ToList(); Session["idManu"] = ""; int idManu = int.Parse(listId[0].Value.ToString()); var manufactures = db.SelectListItem.Find(idManu); ViewBag.manuName = manufactures.Name; ViewBag.color = manufactures.Color; ViewBag.color1 = manufactures.Color1; ViewBag.color3 = manufactures.Color2; ViewBag.imageGenuine = manufactures.imageGenuine; Session["idManu"] = idManu; ViewBag.Manu = "<li><span>Thương hiệu : " + manufactures.Name + "</span></li>"; ViewBag.Manufactures = db.SelectListItem.Find(idManu).Name; ViewBag.favicon = " <link href=\"" + manufactures.Favicon + "\" rel=\"icon\" type=\"image/x-icon\" />"; ViewBag.Title = "<title>" + ProductDetail.Title + "</title>"; ViewBag.Description = "<meta name=\"description\" content=\"" + ProductDetail.Description + "\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"" + ProductDetail.Keyword + "\" /> "; ViewBag.imageog = "<meta property=\"og:image\" content=\"http://Kangaroochinhhang.com" + ProductDetail.ImageLinkThumb + "\"/>"; ViewBag.titleog = "<meta property=\"og:title\" content=\"" + ProductDetail.Title + "\"/> "; ViewBag.site_nameog = "<meta property=\"og:site_name\" content=\"" + ProductDetail.Name + "\"/> "; ViewBag.urlog = "<meta property=\"og:url\" content=\"" + Request.Url.ToString() + "\"/> "; ViewBag.descriptionog = "<meta property=\"og:description\" content=\"" + ProductDetail.Description + "\" />"; ViewBag.nUrl = "<ol itemscope itemtype=\"http://schema.org/BreadcrumbList\"> <li itemprop=\"itemListElement\" itemscope itemtype=\"http://schema.org/ListItem\"> <a itemprop=\"item\" href=\"http://Kangaroochinhhang.com\"> <span itemprop=\"name\">Trang chủ</span></a> <meta itemprop=\"position\" content=\"1\" /> </li> ›" + UrlProduct(groupProduct.id) + "</ol> "; ViewBag.canonical = "<link rel=\"canonical\" href=\"http://Kangaroochinhhang.com/1/" + ProductDetail.Tag + "\" />"; StringBuilder schame = new StringBuilder(); schame.Append("<script type=\"application/ld+json\">"); schame.Append("{"); schame.Append("\"@context\": \"http://schema.org\","); schame.Append("\"@type\": \"ProductArticle\","); schame.Append("\"headline\": \"" + ProductDetail.Description + "\","); schame.Append(" \"datePublished\": \"" + ProductDetail.DateCreate + "\","); schame.Append("\"image\": ["); schame.Append(" \"" + ProductDetail.ImageLinkThumb + "\""); schame.Append(" ]"); schame.Append("}"); schame.Append("</script> "); ViewBag.schame = schame.ToString(); var ListGroupCri = db.tblGroupCriterias.Where(p => p.idCate == idmenu).Select(p => p.idCri).ToList(); var ListCri = db.tblCriterias.Where(p => ListGroupCri.Contains(p.id) && p.Active == true).OrderBy(p => p.Ord).ToList(); StringBuilder chuoi = new StringBuilder(); #region [Lọc thuộc tính] for (int i = 0; i < ListCri.Count; i++) { int idCre = int.Parse(ListCri[i].id.ToString()); var ListCr = (from a in db.tblConnectCriterias join b in db.tblInfoCriterias on a.idCre equals b.id where a.idpd == id && b.idCri == idCre && b.Active == true select new { b.Name, b.Url, b.Ord }).OrderBy(p => p.Ord).ToList(); if (ListCr.Count > 0) { chuoi.Append("<tr>"); chuoi.Append("<td>" + ListCri[i].Name + "</td>"); chuoi.Append("<td>"); int dem = 0; string num = ""; if (ListCr.Count > 1) { num = "⊹ "; } foreach (var item in ListCr) { if (item.Url != null && item.Url != "") { chuoi.Append("<a href=\"" + item.Url + "\" title=\"" + item.Name + "\">"); if (dem == 1) { chuoi.Append(num + item.Name); } else { chuoi.Append(num + item.Name); } dem = 1; chuoi.Append("</a>"); } else { if (dem == 1) { chuoi.Append(num + item.Name + "</br> "); } else { chuoi.Append(num + item.Name + "</br> "); } dem = 1; } } chuoi.Append("</td>"); chuoi.Append(" </tr>"); } } ViewBag.chuoi = chuoi.ToString(); int visit = int.Parse(ProductDetail.Visit.ToString()); if (visit > 0) { ProductDetail.Visit = ProductDetail.Visit + 1; db.SaveChanges(); } else { ProductDetail.Visit = ProductDetail.Visit + 1; db.SaveChanges(); } var listImages = db.tblImageProducts.Where(p => p.idProduct == id).ToList(); StringBuilder chuoiimages = new StringBuilder(); if (listImages.Count > 0) { chuoiimages.Append("<li class=\"getImg" + ProductDetail.id + "\"><a href=\"javascript:;\" onclick=\"javascript:return getImage('" + ProductDetail.ImageLinkDetail + "', 'getImg" + ProductDetail.id + "')\" title=\"" + ProductDetail.Name + "\"><img src=\"" + ProductDetail.ImageLinkDetail + "\" alt=\"" + ProductDetail.Name + "\" /></a></li>"); for (int i = 0; i < listImages.Count; i++) { chuoiimages.Append("<li class=\"getImg" + listImages[i].id + "\"><a href=\"javascript:;\" onclick=\"javascript:return getImage('" + listImages[i].Images + "', 'getImg" + listImages[i].id + "')\" title=\"" + ProductDetail.Name + "\"><img src=\"" + listImages[i].Images + "\" alt=\"" + ProductDetail.Name + "\" /></a></li>"); } } ViewBag.chuoiimages = chuoiimages; ViewBag.hotline = db.TblConfigs.First().HotlineIN; //load root StringBuilder chuoitag = new StringBuilder(); if (ProductDetail.Tabs != null) { string Chuoi = ProductDetail.Tabs; string[] Mang = Chuoi.Split(','); List <int> araylist = new List <int>(); for (int i = 0; i < Mang.Length; i++) { string tagsp = StringClass.NameToTag(Mang[i]); chuoitag.Append("<a href=\"/tabs/" + tagsp + "\" title=\"" + Mang[i] + "\">" + Mang[i] + "</a>"); } } ViewBag.chuoitag = chuoitag; StringBuilder result = new StringBuilder(); result.Append("<div class=\"tearListProduct\">"); result.Append("<div class=\"contentListProductContent\">"); var listProduct = db.tblProducts.Where(p => p.Active == true && p.idCate == idmenu && p.Tag != tag).Take(6).OrderBy(p => p.Ord).ToList(); for (int j = 0; j < listProduct.Count; j++) { result.Append("<div class=\"tear\">"); result.Append("<div class=\"contentTear\">"); float price = float.Parse(listProduct[j].Price.ToString()); float pricesale = float.Parse(listProduct[j].PriceSale.ToString()); float phantram = 100 - ((pricesale * 100) / price); result.Append(" <div class=\"sale\">" + Convert.ToInt32(phantram) + "%</div>"); result.Append("<div class=\"img\">"); result.Append("<a href=\"/1/" + listProduct[j].Tag + "\" title=\"" + listProduct[j].Name + "\"><img src=\"" + listProduct[j].ImageLinkThumb + "\" alt=\"" + listProduct[j].Name + "\" /></a>"); result.Append(" </div>"); result.Append("<a href=\"/1/" + listProduct[j].Tag + "\" title=\"" + listProduct[j].Name + "\" class=\"name\">" + listProduct[j].Name + "</a>"); result.Append("<div class=\"boxItem\">"); result.Append("<div class=\"boxPrice\">"); result.Append("<span class=\"priceSale\">" + string.Format("{0:#,#}", listProduct[j].PriceSale) + "đ</span>"); result.Append("<span class=\"price\">" + string.Format("{0:#,#}", listProduct[j].Price) + "đ</span>"); result.Append("</div>"); result.Append("<div class=\"boxSale\">"); result.Append("<a href=\"\" title=\"\"></a>"); result.Append("</div>"); result.Append("</div>"); result.Append(" </div>"); result.Append("</div>"); } result.Append("</div>"); result.Append("</div>"); ViewBag.resultLienquan = result.ToString(); #endregion return(View(ProductDetail)); }
public ActionResult Command(FormCollection collection, string tag) { if (collection["btnorder"] != null) { try { string Name = collection["Name"]; string Address = collection["Address"]; string DateByy = collection["DateByy"]; string Mobile = collection["Mobile"]; string Mobiles = collection["Mobiles"]; string Email = collection["Email"]; string Name1 = collection["Name1"]; string Address1 = collection["Address"]; string Mobile1 = collection["Mobile1"]; string Mobile1s = collection["Mobile1s"]; string Email1 = collection["Email1"]; string rdtt = collection["rdtt"]; string rdvc = collection["rdvc"]; string NameCP = collection["NameCP"]; string AddressCP = collection["AddressCP"]; string MST = collection["MST"]; string Description = collection["Description"]; var Sopping = (clsGiohang)Session["giohang"]; tblOrder order = new tblOrder(); order.Name = Name; order.Name1 = Name1; order.Address = Address; order.Address1 = Address1; order.DateByy = DateTime.Now; order.Mobile = Mobile; order.Mobile1 = Mobile1; order.Mobiles = Mobiles; order.Mobile1s = Mobile1s; order.TypePay = int.Parse(rdtt); order.Email1 = Email1; order.Email = Email; order.NameCP = NameCP; order.AddressCP = AddressCP; order.MST = MST; order.TypePay = int.Parse(rdtt); order.TypeTransport = int.Parse(rdvc); order.Status = false; order.Description = Description; order.Active = true; tblOrderDetail orderdetail = new tblOrderDetail(); var MaxOrd = db.tblOrders.OrderByDescending(p => p.id).Take(1).ToList(); int idOrder = 1; if (MaxOrd.Count > 0) { idOrder = MaxOrd[0].id; } for (int i = 0; i < Sopping.CartItem.Count; i++) { orderdetail.idProduct = Sopping.CartItem[i].id; orderdetail.Name = Sopping.CartItem[i].Name; orderdetail.Price = Sopping.CartItem[i].Price; orderdetail.Quantily = Sopping.CartItem[i].Ord; orderdetail.SumPrice = Sopping.CartItem[i].SumPrice; orderdetail.idOrder = idOrder; db.tblOrderDetails.Add(orderdetail); db.SaveChanges(); } TblConfig config = db.TblConfigs.First(); var fromAddress = config.UserEmail; var toAddress = config.Email; var orders = db.tblOrders.OrderByDescending(p => p.id).Take(1).ToList(); string fromPassword = config.PassEmail; string ararurl = Request.Url.ToString(); var listurl = ararurl.Split('/'); string urlhomes = ""; for (int i = 0; i < listurl.Length - 2; i++) { if (i > 0) { urlhomes += "/" + listurl[i]; } else { urlhomes += listurl[i]; } } order.Tolar = Sopping.CartTotal; db.tblOrders.Add(order); db.SaveChanges(); string subject = "Đơn hàng mới từ " + urlhomes + ""; string chuoihtml = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Thông tin đơn hàng</title></head><body style=\"background:#f2f2f2; font-family:Arial, Helvetica, sans-serif\"><div style=\"width:750px; height:auto; margin:5px auto; background:#FFF; border-radius:5px; overflow:hidden\">"; chuoihtml += "<div style=\"width:100%; height:40px; float:left; margin:0px; background:#1c7fc4\"><span style=\"font-size:14px; line-height:40px; color:#FFF; margin:auto 20px; float:left\">" + DateTime.Now.Date + "</span><span style=\"font-size:14px; line-height:40px; float:right; margin:auto 20px; color:#FFF; text-transform:uppercase\">Hotline : " + config.HotlineIN + "</span></div>"; chuoihtml += "<div style=\"width:100%; height:auto; float:left; margin:0px\"><div style=\"width:35%; height:100%; margin:0px; float:left\"><a href=\"/\" title=\"\"><img src=\"" + urlhomes + "" + config.Logo + "\" alt=\"Logo\" style=\"margin:8px; display:block; max-height:95% \" /></a></div><div style=\"width:60%; height:100%; float:right; margin:0px; text-align:right\"><span style=\"font-size:18px; margin:20px 5px 5px 5px; display:block; color:#ff5a00; text-transform:uppercase\">" + config.Name + "</span><span style=\"display:block; margin:5px; color:#515151; font-size:13px; text-transform:uppercase\">Lớn nhất - Chính hãng - Giá rẻ nhất việt nam</span> </div> </div>"; chuoihtml += "<span style=\"text-align:center; margin:10px auto; font-size:20px; color:#000; font-weight:bold; text-transform:uppercase; display:block\">Thông tin đơn hàng</span>"; chuoihtml += " <div style=\"width:90%; height:auto; margin:10px auto; background:#f2f2f2; padding:15px\">"; chuoihtml += "<p style=\"font-size:14px; color:#464646; margin:5px 20px\">Đơn hàng từ website : <span style=\"color:#1c7fc4\">" + urlhomes + "</span></p>"; chuoihtml += "<p style=\"font-size:14px; color:#464646; margin:5px 20px\">Ngày gửi đơn hàng : <span style=\"color:#1c7fc4\">Vào lúc " + DateTime.Now.Hour + " giờ " + DateTime.Now.Minute + " phút ( ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year + ") </span></p>"; chuoihtml += "<p style=\"font-size:14px; color:#464646; margin:5px 20px\">Mã đơn hàng : <span style=\"color:#1c7fc4\">" + idOrder + " </span></p>"; chuoihtml += "<p style=\"font-size:14px; color:#1b1b1b; margin:5px 20px; text-decoration:underline; text-transform:uppercase\">Danh sách sản phẩm : </p>"; chuoihtml += "<table style=\"width:100%; height:auto; margin:10px auto; background:#FFF; border:1px\" border=\"0\">"; chuoihtml += " <tr style=\" background:#1c7fc4; color:#FFF; text-align:center; line-height:25px; font-size:12px\">"; chuoihtml += "<td>STT</td>"; chuoihtml += "<td>Tên sản phẩm</td>"; chuoihtml += "<td>Đơn giá (vnđ)</td>"; chuoihtml += "<td>Số lượng</td>"; chuoihtml += "<td>Thành tiền (vnđ)</td>"; chuoihtml += "</tr>"; for (int i = 0; i < Sopping.CartItem.Count; i++) { chuoihtml += "<tr style=\"line-height:20px; font-size:13px; color:#000; text-indent:5px; border-bottom:1px dashed #cecece; margin:1px 0px;\">"; chuoihtml += "<td style=\"text-align:center; width:7%\">" + i + "</td>"; chuoihtml += "<td style=\"width:45%\">" + Sopping.CartItem[i].Name + "</td>"; int gia = Convert.ToInt32(Sopping.CartItem[i].Price.ToString()); chuoihtml += "<td style=\"text-align:center; width:15%\">" + gia.ToString().Replace(",", "") + "</td>"; chuoihtml += "<td style=\"text-align:center; width:10%\">" + Sopping.CartItem[i].Ord + "</td>"; float thanhtien = Sopping.CartItem[i].Price * Sopping.CartItem[i].Ord; chuoihtml += "<td style=\"text-align:center; font-weight:bold\">" + thanhtien.ToString().Replace(",", "") + "</td>"; chuoihtml += " </tr>"; } chuoihtml += "<tr style=\"font-size:12px; font-weight:bold\">"; chuoihtml += "<td colspan=\"4\" style=\"text-align:right\">Tổng giá trị đơn hàng : </td>"; chuoihtml += "<td style=\"font-size:14px; color:#F00\">" + Sopping.CartTotal + " vnđ</td>"; chuoihtml += " </tr>"; chuoihtml += "</table>"; chuoihtml += "<div style=\" width:100%; margin:15px 0px\">"; chuoihtml += "<div style=\"width:100%; height:auto; float:left; margin:0px; border:1px solid #d5d5d5\">"; chuoihtml += "<div style=\" width:100%; height:30px; float:left; background:#1c7fc4; font-size:12px; color:#FFF; text-indent:15px; line-height:30px\"> Thông tin người gửi </div>"; chuoihtml += "<div style=\"width:100%; height:auto; float:left\">"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Họ và tên :<span style=\"font-weight:bold\"> " + Name + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Địa chỉ :<span style=\"font-weight:bold\"> " + Address + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Điện thoại :<span style=\"font-weight:bold\"> " + Mobile + " - " + Mobiles + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Email :<span style=\"font-weight:bold\">" + Email + "</span></p>"; if (rdtt == "1") { chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Hình thức thanh toán :<span style=\"font-weight:bold\">Chuyển hàng thu tiền tại nhà</span></p>"; } if (rdtt == "2") { chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Hình thức thanh toán :<span style=\"font-weight:bold\">Nhận hàng và thanh toán tại Kangaroochinhhang</span></p>"; } if (rdtt == "3") { chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Hình thức thanh toán :<span style=\"font-weight:bold\">Chuyển khoản ATM & Ngân hàng</span></p>"; } if (rdtt == "4") { chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Hình thức thanh toán :<span style=\"font-weight:bold\">Thanh toán visa, mastercard</span></p>"; } if (rdvc == "1") { chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Thời gian giao hàng :<span style=\"font-weight:bold\">Bất kể giờ nào</span></p>"; } if (rdvc == "2") { chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Thời gian giao hàng :<span style=\"font-weight:bold\">Trong giờ hàng chính</span></p>"; } if (rdvc == "3") { chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Thời gian giao hàng :<span style=\"font-weight:bold\">Ngoài giờ hành chính</span></p>"; } chuoihtml += "</div>"; chuoihtml += "</div>"; if (Name1 != null) { chuoihtml += "<div style=\" width:100%; height:30px; float:left; background:#1c7fc4; font-size:12px; color:#FFF; text-indent:15px; line-height:30px\"> Người nhận hàng </div>"; chuoihtml += "<div style=\"width:100%; height:auto; float:left\">"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Họ và tên :<span style=\"font-weight:bold\"> " + Name1 + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Địa chỉ :<span style=\"font-weight:bold\"> " + Address1 + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Điện thoại :<span style=\"font-weight:bold\"> " + Mobile1 + " - " + Mobile1s + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Email :<span style=\"font-weight:bold\">" + Email1 + "</span></p>"; chuoihtml += "</div>"; chuoihtml += "</div>"; } if (NameCP != null) { chuoihtml += "<div style=\" width:100%; height:30px; float:left; background:#1c7fc4; font-size:12px; color:#FFF; text-indent:15px; line-height:30px\"> Thông tin yêu cầu hóa đơn </div>"; chuoihtml += "<div style=\"width:100%; height:auto; float:left\">"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Tên công ty :<span style=\"font-weight:bold\"> " + NameCP + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Địa chỉ :<span style=\"font-weight:bold\"> " + AddressCP + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">MST:<span style=\"font-weight:bold\"> " + MST + "</span></p>"; chuoihtml += "</div>"; chuoihtml += "</div>"; } chuoihtml += "<div style=\"width:90%; height:auto; margin:10px auto; border:1px solid #d5d5d5\">"; chuoihtml += "<div style=\" width:100%; height:30px; float:left; background:#1c7fc4; font-size:12px; color:#FFF; text-indent:15px; line-height:30px\"> Yêu cầu của người gửi </div>"; chuoihtml += " <div style=\"width:100%; height:auto; float:left\">"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px; font-weight:bold; color:#F00\"> - " + Description + "</p>"; chuoihtml += "</div>"; chuoihtml += "</div>"; var listo = db.tblOrders.OrderByDescending(p => p.id).Take(1).ToList(); chuoihtml += " <a href=\"" + urlhomes + "/Orderad/ActiveOrder?id=" + listo[0].id + "\" title=\"\" style=\"padding:5px; color:#FFF; background:#F00; display:inline-block; text-align:center; margin:10px auto\">Đã check thông tin >></a>"; chuoihtml += "</div>"; chuoihtml += "<div style=\"width:100%; height:auto; float:left; margin:0px\">"; chuoihtml += "<hr style=\"width:80%; height:1px; background:#d8d8d8; margin:20px auto 10px auto\" />"; chuoihtml += "<p style=\"font-size:12px; text-align:center; margin:5px 5px\">" + config.Address + "</p>"; chuoihtml += "<p style=\"font-size:12px; text-align:center; margin:5px 5px\">Điện thoại : " + config.MobileIN + " - " + config.HotlineIN + "</p>"; chuoihtml += " <p style=\"font-size:12px; text-align:center; margin:5px 5px; color:#ff7800\">Thời gian mở cửa : Từ 7h30 đến 18h30 hàng ngày (làm cả thứ 7, chủ nhật). Khách hàng đến trực tiếp xem hàng giảm thêm giá.</p>"; chuoihtml += "</div>"; chuoihtml += "<div style=\"clear:both\"></div>"; chuoihtml += " </div>"; chuoihtml += " <div style=\"width:100%; height:40px; float:left; margin:0px; background:#1c7fc4\">"; chuoihtml += "<span style=\"font-size:12px; text-align:center; color:#FFF; line-height:40px; display:block\">Copyright (c) 2002 – 2015 Kangaroochinhhang VIET NAM. All Rights Reserved</span>"; chuoihtml += " </div>"; chuoihtml += "</div>"; chuoihtml += "</body>"; chuoihtml += "</html>"; string body = chuoihtml; var smtp = new System.Net.Mail.SmtpClient(); { smtp.Host = config.Host; smtp.Port = int.Parse(config.Port.ToString()); smtp.EnableSsl = true; smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtp.Credentials = new NetworkCredential(fromAddress, fromPassword); smtp.Timeout = int.Parse(config.Timeout.ToString()); } using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body, IsBodyHtml = true, }) { smtp.Send(message); } Session["Status"] = "<script>$(document).ready(function(){ alert('Bạn đã đặt hàng thành công !') });</script>"; return(RedirectToAction("Success")); } catch (Exception ex) { Session["Status"] = "<script>$(document).ready(function(){ alert('Bạn đã đặt hàng không thành công " + ex.Message + "!') });</script>"; return(RedirectToAction("OrderIndex")); } } return(RedirectToAction("OrderIndex")); }