public ActionResult Xoa(int id) { GIAYCHUNGTHUC gcthuc = db.GIAYCHUNGTHUCs.Find(id); if (gcthuc != null) { db.GIAYCHUNGTHUCs.Remove(gcthuc); db.SaveChanges(); int id_hs = (int)Session["id_hsDetail"]; Session["chuyenTab"] = 8; return(RedirectToAction("DetailChung", "HocSinh", new { id = id_hs })); } return(View()); }
public JsonResult CapNhatGCT() { if (System.Web.HttpContext.Current.Request.Files.AllKeys.Any()) { var file = Request.Files["HelpSectionFile"]; //lưu tên file var fileName = Path.GetFileName(file.FileName); //lưu đường dẫn var path = Path.Combine(Server.MapPath("~/Content/filePDF"), fileName); // file is uploaded var type = file.ContentType; if (System.IO.File.Exists(path)) { ViewBag.Thongbao = "File đã tồn tại"; } else { if (type == "application/docx" || type == "application/pdf") { file.SaveAs(path); } } Session["file"] = fileName; int id_HS = (int)Session["id_hsDetail"]; if (id_HS != null) { GIAYCHUNGTHUC giay = new GIAYCHUNGTHUC(); giay.Anh = fileName; giay.TenGiay = fileName; giay.id_HSHS = id_HS; db.GIAYCHUNGTHUCs.Add(giay); db.SaveChanges(); } return(Json(fileName, JsonRequestBehavior.AllowGet)); } Session["file"] = null; return(Json("Khong", JsonRequestBehavior.AllowGet)); }