public ActionResult Delete(int id) { if (Session["TaiKhoan"].ToString() == "admin") { donghoDataContext db = new donghoDataContext(); var query = from dh in db.DONGHOs join th in db.THUONGHIEUs on dh.MaTH equals th.MaTH join km in db.KHUYENMAIs on dh.MaKM equals km.MaKM join nsx in db.NHASANXUATs on dh.MaNSX equals nsx.MaNSX join bh in db.BAOHANHs on dh.TGBH equals bh.TGBH where dh.MaSP == id select new DH() { MaSP = dh.MaSP, TenSP = dh.TenSP, GiaSP = dh.GiaSP, Ngaycapnhat = dh.Ngaycapnhat, Soluongton = dh.Soluongton, KM = km.HinhThucKM, TH = th.TenTH, NSX = nsx.TenNSX, img = dh.img, HTBH = bh.HinhThucBH }; return(View(query.Single())); } return(RedirectToAction("Index", "Home")); }
public ActionResult Delete(string id) { donghoDataContext db = new donghoDataContext(); var query = from kh in db.KHACHHANGs where kh.CMND == id select kh; return(View(query.Single())); }
public ActionResult Detail(int id) { donghoDataContext db = new donghoDataContext(); var query = from dh in db.DONGHOs where dh.MaSP == id select dh; return(View(query.Single())); }
// GET: SanPham public ActionResult Index(int id, int?page) { int pageSize = 3; int pageNum = (page ?? 1); donghoDataContext db = new donghoDataContext(); var query = from dh in db.DONGHOs where dh.MaTH == id select dh; return(View(query.ToPagedList(pageNum, pageSize))); }
public ActionResult SPCungTH(int id, int MaTH, int?page) { int pageSize = 4; int pageNum = (page ?? 1); donghoDataContext db = new donghoDataContext(); ViewData["MaSP"] = id; var query = from dh in db.DONGHOs where dh.MaTH == MaTH && dh.MaSP != id select dh; return(PartialView(query.ToPagedList(pageNum, pageSize))); }
public ActionResult DangKy(FormCollection f) { if (f["cmnd"].Length != 9 && f["cmnd"].Length != 12) { ViewData["L1"] = "Vui lòng nhập đúng CMND"; return(View()); } KHACHHANG k = new KHACHHANG(); PHANQUYEN p = new PHANQUYEN(); donghoDataContext db = new donghoDataContext(); var query = from kh in db.KHACHHANGs where kh.CMND == f["cmnd"].ToString() select kh; if (query.ToList().Count != 0) { ViewData["L1"] = "Tài Khoản đã tồn tại"; return(View()); } k.CMND = f["cmnd"]; if (string.Compare(f["gioitinh"], "nam") == 0) { k.GioiTinh = false; } else { k.GioiTinh = true; } k.TenKH = f["hoten"]; k.Ngaysinh = DateTime.Parse(f["ngaysinh"]); k.Email = f["email"]; k.TrangThai = true; if (string.Compare(f["pass"], f["xnpass"]) != 0) { ViewData["L3"] = "Mật khẩu không trùng khớp"; return(View()); } p.TrangThai = true; p.TaiKhoan = f["cmnd"]; p.PassWord = EncryptMD5.MD5Hash(f["pass"]); p.MaCN = 2; db.PHANQUYENs.InsertOnSubmit(p); db.KHACHHANGs.InsertOnSubmit(k); db.SubmitChanges(); return(RedirectToAction("Login", "Home")); }
public ActionResult SuaKH(FormCollection f) { donghoDataContext db = new donghoDataContext(); KHACHHANG khachhang = db.KHACHHANGs.First(m => m.CMND == f["CMND"]); if (ModelState.IsValid) { var a = f["Ngaysinh"]; khachhang.TenKH = f["TenKH"]; if (!string.IsNullOrEmpty(f["Ngaysinh"])) { khachhang.Ngaysinh = DateTime.Parse(f["Ngaysinh"].ToString()); } khachhang.GioiTinh = Convert.ToBoolean(f["GioiTinh"]); khachhang.Email = f["Email"]; UpdateModel(khachhang); db.SubmitChanges(); } return(RedirectToAction("Index", "Home")); }