public ActionResult ThemmoiTH(DONVILUHANH thuonghieu, HttpPostedFileBase fileupload) { if (fileupload == null) { ViewBag.Thongbao = "Vui lòng chọn ảnh bìa"; return(View()); } else { if (ModelState.IsValid) { var fileName = Path.GetFileName(fileupload.FileName); var path = Path.Combine(Server.MapPath("~/Img/ThuongHieu"), fileName); if (System.IO.File.Exists(path)) { ViewBag.Thongbao = "Hình ảnh đã tồn tại"; } else { fileupload.SaveAs(path); } thuonghieu.AnhDV = fileName; data.DONVILUHANHs.InsertOnSubmit(thuonghieu); data.SubmitChanges(); } } return(View()); }
public ActionResult DangnhapTH(FormCollection collection) { var tendn = collection["TenDN"]; var matkhau = collection["Matkhau"]; if (String.IsNullOrEmpty(tendn)) { ViewData["Loi1"] = "Ph?i nh?p tên dang nh?p"; } else if (String.IsNullOrEmpty(matkhau)) { ViewData["Loi2"] = "Ph?i nh?p m?t kh?u"; } else { DONVILUHANH th = data.DONVILUHANHs.SingleOrDefault(n => n.Taikhoan == tendn && n.MatKhau == matkhau); if (th != null) { ViewBag.Thongbao = "Ðang nh?p thành công"; Session["TaikhoanTH"] = th; Session["TentaikhoanTH"] = collection["TenDN"].ToString(); return(RedirectToAction("Index", "Guest")); } else { ViewBag.Thongbao = "Tên dang nh?p ho?c m?t kh?u sai"; } } return(View()); }
public ActionResult DangkyTH(FormCollection collection, DONVILUHANH th) { var tenth = collection["TenTH"]; var tendn = collection["TenDN"]; var matkhau = collection["MatKhau"]; var matkhaunl = collection["Matkhaunhaplai"]; var diachi = collection["DiaChi"]; var email = collection["Email"]; var dienthoai = collection["DienThoai"]; if (String.IsNullOrEmpty(tenth)) { ViewData["Loi1"] = "Vui lòng nh?p h? và tên"; } else if (String.IsNullOrEmpty(tendn)) { ViewData["Loi2"] = "Vui lòng nh?p tên tài kho?n"; } else if (String.IsNullOrEmpty(matkhau)) { ViewData["Loi3"] = "Vui lòng nh?p m?t kh?u"; } else if (String.IsNullOrEmpty(matkhaunl) || matkhau != matkhaunl) { ViewData["Loi4"] = "M?t kh?u không kh?p"; } else if (String.IsNullOrEmpty(email)) { ViewData["Loi5"] = "Vui lòng nh?p email"; } else if (String.IsNullOrEmpty(diachi)) { ViewData["Loi6"] = "Vui lòng nh?p d?a ch?"; } else if (String.IsNullOrEmpty(dienthoai)) { ViewData["Loi7"] = "Vui lòng nh?p di?n tho?i"; } else { th.TenDV = tenth; th.Taikhoan = tendn; th.MatKhau = matkhau; th.Email = email; th.DiaChi = diachi; th.DienThoai = dienthoai; data.DONVILUHANHs.InsertOnSubmit(th); data.SubmitChanges(); return(RedirectToAction("DangnhapTH")); } return(this.DangkyTH()); }
public ActionResult SuaTH(int id) { if (Session["Taikhoanadmin"] == null || Session["Taikhoanadmin"].ToString() == "") { return(RedirectToAction("Login", "Admin")); } DONVILUHANH thuonghieu = data.DONVILUHANHs.SingleOrDefault(n => n.MaTH == id); ViewBag.MaTH = thuonghieu.MaTH; if (thuonghieu == null) { Response.StatusCode = 404; return(null); } return(View(thuonghieu)); }
public ActionResult SuaTH(DONVILUHANH thuonghieu, HttpPostedFileBase fileUpload) { if (ModelState.IsValid) { DONVILUHANH th = data.DONVILUHANHs.SingleOrDefault(n => n.MaTH == thuonghieu.MaTH); th.TenDV = thuonghieu.TenDV; if (fileUpload != null) { var fileName = Path.GetFileName(fileUpload.FileName); var path = Path.Combine(Server.MapPath("~/Img/ThuongHieu"), fileName); fileUpload.SaveAs(path); th.AnhDV = fileName; } th.DienThoai = thuonghieu.DienThoai; UpdateModel(thuonghieu); data.SubmitChanges(); } return(RedirectToAction("ThuongHieu")); }
public ActionResult XacnhanxoaTH(int id) { var MaSP = (from sp in data.SANPHAMs where sp.MaTH == id select sp); foreach (var sp in MaSP) { data.SANPHAMs.DeleteOnSubmit(sp); } DONVILUHANH thuonghieu = data.DONVILUHANHs.SingleOrDefault(n => n.MaTH == id); ViewBag.MaTH = thuonghieu.MaTH; if (thuonghieu == null) { Response.StatusCode = 404; return(null); } data.DONVILUHANHs.DeleteOnSubmit(thuonghieu); data.SubmitChanges(); return(RedirectToAction("Thuonghieu")); }