//bấm nút xóa trong trang thanh toán public ActionResult Remove(int proId) { var c = Session["cart"] as ClientCart; c = CSDLQLBH.RemoveCartItem(c, proId); return(RedirectToAction("Detail", "Cart")); }
//bấm nút cập nhật trong trang thanh toán public ActionResult Update(int proId, int quantity) { var c = Session["cart"] as ClientCart; c = CSDLQLBH.UpdateCartItem(c, proId, quantity); return(RedirectToAction("Detail", "Cart")); }
//kiểm tra captch //Lưu thông tin đăng kí vào CSDL public ActionResult Register(UserRegisting user) { if (!ModelState.IsValid) { // TODO: Captcha validation failed, show error message ViewBag.ErrorMsg = "Incorrect CAPTCHA code!"; } else { // TODO: Captcha validation passed, proceed with protected action var u = new ClientUser { f_Username = user.Username, f_Password = Ulti.Md5Hash(user.Password), f_Name = user.Name, f_Email = user.Email, f_DOB = DateTime.ParseExact(user.DOB, "d/m/yyyy", null) }; CSDLQLBH.InsertUser(u); Session["Registered"] = 1; return(RedirectToAction("Login", "Account")); } return(View()); }
public ActionResult Update(ClientOrder order) { var or = CSDLQLBH.GetSingleOrder(order.OrderID); or.SttID = order.SttID; CSDLQLBH.UpdateOrders(or); return(RedirectToAction("Index")); }
public ActionResult Update(ClientCategory category) { var cat = CSDLQLBH.GetSingleCategory(category.CatID); cat.CatName = category.CatName; CSDLQLBH.UpdateCategory(cat); return(RedirectToAction("Index")); }
public ActionResult Update(ClientProducer producer) { var prod = CSDLQLBH.GetSingleProducer(producer.ProducerID); prod.ProducerName = producer.ProducerName; CSDLQLBH.UpdateProducer(prod); return(RedirectToAction("Index")); }
public ActionResult Update(int id) { var listStt = CSDLQLBH.GetStatuses().ToList(); var order = CSDLQLBH.GetSingleOrder(id); var list = new SelectList(listStt, "SttID", "SttName", order.SttID); ViewBag.Loai = list; return(View(order)); }
// GET: ManageProduct/Delete public ActionResult Delete(int id) { var pD = CSDLQLBH.GetSingleProduct(id); if (pD != null) { CSDLQLBH.RemoveProduct(id); } Ulti.DeleteProductImgs(id, Server.MapPath("~")); return(RedirectToAction("Index")); }
public ActionResult UpdateProfile() { var ui = Session["Logged"] as ClientUserInfo; var u = new ClientUser(); u = CSDLQLBH.UserGetSingleByUserName(ui.Username); ui.FullInfo = u; return(View(ui)); }
//bấm nút mua sẽ thêm vào được giỏ hàng public ActionResult AddCIFromIndex(int proId) { if (Session["cart"] == null) { Session["cart"] = new ClientCart(); } var c = Session["cart"] as ClientCart; c = CSDLQLBH.InsertCartItem(c, proId); return(RedirectToAction("Index", "Home")); }
//bấm nút mua sẽ thêm vào được giỏ hàng public ActionResult AddCIFromListProduct(int proId, int catId, int page) { if (Session["cart"] == null) { Session["cart"] = new ClientCart(); } var c = Session["cart"] as ClientCart; c = CSDLQLBH.InsertCartItem(c, proId); return(RedirectToAction("GetListByCategory", "Product", new { id = catId, page = page })); }
public ActionResult Add(int proId, int quantity) { if (Session["cart"] == null) { Session["cart"] = new ClientCart(); } var c = Session["cart"] as ClientCart; c = CSDLQLBH.InsertCartItem(c, proId, quantity); return(RedirectToAction("Detail", "Product", new { id = proId })); }
public ActionResult GetListProduct(decimal?PriceMin, decimal?PriceMax, int?CatID, int?ProducerID, int page = 1) { ViewBag.PriceMin = PriceMin; ViewBag.PriceMax = PriceMax; ViewBag.CatID = CatID; ViewBag.ProducerID = ProducerID; var List = CSDLQLBH.GetProducts(); var ListProduct = List.ToList(); if (PriceMin != null) { ListProduct = List.Where(p => p.Price > PriceMin).ToList(); } if (PriceMax != null) { ListProduct = ListProduct.Where(p => p.Price < PriceMax).ToList(); } if (CatID != null) { ListProduct = ListProduct.Where(p => p.CatID == CatID).ToList(); } if (ProducerID != null) { ListProduct = ListProduct.Where(p => p.ProducerID == ProducerID).ToList(); } int totalP = ListProduct.Count(); int nPage = totalP / nPerPage + (totalP % nPerPage > 0 ? 1 : 0); if (page < 1) { page = 1; } if (page > nPage) { page = nPage; } ViewBag.totalPage = nPage; ViewBag.curPage = page; ListProduct = ListProduct.OrderBy(p => p.ProID) .Skip((page - 1) * nPerPage) .Take(nPerPage) .ToList(); return(View("SearchNangCao", ListProduct)); }
// GET: Search public ActionResult SearchProduct(string keyword, int page = 1) { ViewBag.Keyword = keyword; List <ClientProduct> listPro = new List <ClientProduct>(); Dictionary <string, object> result = CSDLQLBH.GetPagedProducts(keyword: keyword, page: page, pageSize: nPerPage); ViewBag.totalPage = result["totalPage"]; ViewBag.curPage = result["curPage"]; listPro = result["Collection"] as List <ClientProduct>; return(View("Search", listPro)); }
public ActionResult Detail(int?id) { if (!id.HasValue) { return(RedirectToAction("Index", "Home")); } var product = CSDLQLBH.GetSingleProduct(id); List <ClientComment> listCom = CSDLQLBH.GetCommentsByProduct(product.ProID).ToList(); if (listCom != null) { ViewBag.ListComment = listCom; } return(View(product)); }
public ActionResult AddComment(int?proId, string uName, string content, string dayCM) { ClientUser u = CSDLQLBH.GetUsers(filter: "f_Username = "******"Detail", "Product", new { id = proId })); }
public ActionResult GetListByCategorySX(int?id, int page = 1) { if (!id.HasValue) { return(RedirectToAction("Index", "Home")); } Dictionary <string, object> result = CSDLQLBH.GetPagedProducts(filter: "ProducerID =" + id, page: page, pageSize: nPerPage); ViewBag.totalPage = result["totalPage"]; ViewBag.curPage = result["curPage"]; ViewBag.cId = id; var l = result["Collection"] as List <ClientProduct>; return(View("ListByCategory", l)); }
//bấm nút thanh toán, nó sẽ lưu vào csdl và giỏ hàng sẽ trở về số 0 public ActionResult Checkout(decimal totalPrice) { var c = Session["cart"] as ClientCart; var ui = Session["Logged"] as ClientUserInfo; var user = CSDLQLBH.UserGetSingleByUserName(ui.Username); var order = new ClientOrder { OrderDate = DateTime.Now, User = user, Total = totalPrice, }; var totalOrders = CSDLQLBH.GetOrders().ToList().Count; if (totalOrders == 0) { order.OrderID = 1; } CSDLQLBH.InsertOrders(order); decimal amount = 0; foreach (var ci in c.Items) { var p = CSDLQLBH.GetSingleProduct(ci.Product.ProID); amount = (decimal)p.Price * ci.Quantity; var od = new ClientOrderDetail { Order = order, Product = p, Quantity = ci.Quantity, Price = (decimal)p.Price, Amount = amount }; CSDLQLBH.InsertOrderDetail(od); p.Quantity -= ci.Quantity; CSDLQLBH.UpdateProduct(p); } c = CSDLQLBH.Checkout(c); Session["CheckOut"] = 1; return(RedirectToAction("Detail", "Cart")); }
public ActionResult Add(ClientProduct p, HttpPostedFile imgLg, HttpPostedFile imgSm) { //khi hai ô này rỗng if (p.TinyDes == null) { p.TinyDes = string.Empty; } if (p.FullDesRaw == null) { p.FullDesRaw = string.Empty; } p.FullDes = p.FullDesRaw; p.View = 0; //lưu thông tin p = CSDLQLBH.InsertProduct(p); Ulti.SaveProductImgs((int)p.ProID, Server.MapPath("~"), imgLg, imgSm); return(RedirectToAction("Index")); }
public ActionResult UpdateProfile(ClientUserInfo ui) { if (!ModelState.IsValid) { // TODO: Captcha validation failed, show error message ViewBag.ErrorMsg = "Incorrect CAPTCHA code!"; } else { ClientUser u = ui.FullInfo; u.f_Password = Ulti.Md5Hash(ui.Password); CSDLQLBH.UpdateUser(u.f_ID, u); Session["Updated"] = 1; Session["Logged"] = null; Session["cart"] = null; Response.Cookies["UserId"].Expires = DateTime.Now.AddDays(-1); return(RedirectToAction("Login", "Account")); } return(View()); }
public ActionResult Login(ClientUserInfo ui) { var pass = Ulti.Md5Hash(ui.Password); var user = CSDLQLBH.Login(ui); if (user != null) { if (user.Permission == "Customer") { Session["Logged"] = ui; Session["Updated"] = null; Response.Cookies["UserId"].Value = user.FullInfo.f_ID.ToString(); Response.Cookies["UserId"].Expires = DateTime.Now.AddDays(7); return(RedirectToAction("Index", "Home")); } else { //them chuc nang admin ui.Permission = user.Permission; //cookie Session["Logged"] = ui; Session["Updated"] = null; Response.Cookies["UserId"].Value = user.FullInfo.f_ID.ToString(); Response.Cookies["UserId"].Expires = DateTime.Now.AddDays(7); return(RedirectToAction("Index", "ManageProduct"));// trả về trang Index nếu đã nhập đúng thông tin } } else { ViewBag.ErrorMsg = "Thông tin đăng nhập chưa đúng"; } return(View()); }
// GET: ManagerCat/Update public ActionResult Update(int id) { var cat = CSDLQLBH.GetSingleCategory(id); return(View(cat)); }
// GET: ManagerCat/Delete public ActionResult Delete(int id) { CSDLQLBH.RemoveCategory(id); return(RedirectToAction("Index")); }
public ActionResult Add(ClientCategory c) { //lưu thông tin CSDLQLBH.InsertCategory(c); return(RedirectToAction("Index")); }
// GET: ManagerCat public ActionResult Index() { var l = CSDLQLBH.GetCategories().ToList(); return(View(l)); }
// GET: Home public ActionResult Index() { var l = CSDLQLBH.GetProducts().ToList(); return(View(l)); }
public ActionResult GetListProducer() { var l1 = CSDLQLBH.GetProducers().ToList(); return(PartialView("_PartialListProducer", l1)); }
//sản phẩm cùng nhà sản xuất public ActionResult ProductAsProducer(int producerID, int proID) { var l = CSDLQLBH.GetProducts(filter: "ProducerID = " + producerID + " and ProID != " + proID).Take(5).ToList(); return(PartialView("ProductAsProducer", l)); }
//sản phẩm cùng loại public ActionResult ProductTheSame(int catID, int proID) { var l = CSDLQLBH.GetProducts(filter: "CatID = " + catID + " and ProID != " + proID).Take(6).ToList(); return(PartialView("ProductTheSame", l)); }
public ActionResult RateProductIndex(int?proId, int?rateId, int?rate) { var p = CSDLQLBH.GetRatingsByProduct(proId).FirstOrDefault(); if (p != null) { switch (rateId) { case 1: if (rate == 1) { p.One += 1; } else { p.One -= 1; } break; case 2: if (rate == 1) { p.Two += 1; } else { p.Two -= 1; } break; case 3: if (rate == 1) { p.Three += 1; } else { p.Three -= 1; } break; case 4: if (rate == 1) { p.Four += 1; } else { p.Four -= 1; } break; case 5: if (rate == 1) { p.Five += 1; } else { p.Five -= 1; } break; } p.Rate = ((p.One * 1) + (p.Two * 2) + (p.Three * 3) + (p.Four * 4) + (p.Five * 5)) / (p.One + p.Two + p.Three + p.Four + p.Five); CSDLQLBH.UpdateRating(p); } else { ClientRating ra = new ClientRating { ProID = proId, One = 0, Two = 0, Three = 0, Four = 0, Five = 0 }; switch (rateId) { case 1: ra.One = rate; break; case 2: ra.Two = rate; break; case 3: ra.Three = rate; break; case 4: ra.Four = rate; break; case 5: ra.Five = rate; break; } ra.Rate = ((ra.One * 1) + (ra.Two * 2) + (ra.Three * 3) + (ra.Four * 4) + (ra.Five * 5)) / (ra.One + ra.Two + ra.Three + ra.Four + ra.Five); CSDLQLBH.InsertRating(ra); } return(RedirectToAction("Index", "Home")); }