public ActionResult SanPhamDM(int?id, int curPage = 1) { if (id.HasValue == false) { return(RedirectToAction("Index", "Home")); } using (var ctx = new QLShopRuouEntities()) { List <chitietSP> list; var query = ctx.chitietSPs.Where(c => c.sanpham.maloaiSP == id).ToList(); ViewBag.tenloaiSP = ctx.loaiSPs.Where(c => c.maloaiSP == id).Select(c => c.tenloaiSP).FirstOrDefault(); int n = query.Count(); int nPages = n / 4; if (n % 4 > 0) { nPages++; } ViewBag.nPages = nPages; ViewBag.curPage = curPage; ViewBag.nextPage = curPage + 1; ViewBag.prevPage = curPage - 1; if (n == 0) { ViewBag.sl = 0; } int nSkip = (curPage - 1) * 4; list = query.OrderBy(c => c.maSP) .Skip(nSkip).Take(4) .ToList(); return(View(list)); } }
public ActionResult partialnhaSX() { using (var ctx = new QLShopRuouEntities()) { List <nhasanxuat> list = ctx.nhasanxuats.OrderBy(c => c.tenNSX).ToList(); return(PartialView(list)); } }
public ActionResult partialloaiSP() { using (var ctx = new QLShopRuouEntities()) { List <loaiSP> list = ctx.loaiSPs.OrderBy(c => c.tenloaiSP).ToList(); return(PartialView(list)); } }
public ActionResult PartialBanner() { using (var c = new QLShopRuouEntities()) { List <hinhanh> list = c.hinhanhs.ToList(); return(PartialView(list)); } }
public ActionResult DangKy(RegisterModel model) { taikhoan tk = new taikhoan { tk = model.UID, matKhau = Helpers.StringUtils.Md5(model.PWD), hoTen = model.Fullname, email = model.Email, ngaySinh = Convert.ToDateTime(model.Birthday), ltk = 2, }; using (var ctx = new QLShopRuouEntities()) { ctx.taikhoans.Add(tk); ctx.SaveChanges(); } return(View()); }
public static bool Islogged() { if ((int)HttpContext.Current.Session["IsLogin"] == 1) { return(true); } if (HttpContext.Current.Response.Cookies["Username"] != null) { string username = HttpContext.Current.Response.Cookies["Username"].Value; using (QLShopRuouEntities ctx = new QLShopRuouEntities()) { taikhoan user = ctx.taikhoans.Where(t => t.tk == username).FirstOrDefault(); if (user != null) { HttpContext.Current.Session["IsLogin"] = 1; HttpContext.Current.Session["CurUser"] = user; return(true); } } } return(false); }
public ActionResult Login(Login u) { using (QLShopRuouEntities ctx = new QLShopRuouEntities()) { string umd5 = Helpers.StringUtils.Md5(u.pass); taikhoan user = ctx.taikhoans.Where(t => t.tk == u.user && t.matKhau == umd5).FirstOrDefault(); if (user == null) { ViewBag.error = "Thông tin đăng nhập không đúng"; return(View(u)); } else { Session["IsLogin"] = 1; Session["CurUser"] = user; if (u.remember) { Response.Cookies["Username"].Value = user.tk; Response.Cookies["Username"].Expires = DateTime.Now.AddDays(1); } return(RedirectToAction("Index", "Home")); } } }