// // GET: /NhanVienCuaShop/Create public ActionResult Create() { if (Session["ID"] != null) { var model = new NhanVienCuaShop(); return PartialView("UpdateNhanVienCuaShop",model); } else { Session.Add("UrlRedirect", Url.AbsoluteAction("Create", "NhanVienCuaShop")); return RedirectToAction("LogOn", "Account"); } }
public ActionResult Create(FormCollection collection) { if (Session["ID"] != null) { var NVShop = new NhanVienCuaShop(); try { var sp = QLSRes.GetShopByAccount(int.Parse(Session["ID"].ToString())); if (TryUpdateModel(NVShop)) { IFormatProvider provider = new System.Globalization.CultureInfo("en-CA", true); String datetime = collection["NgaySinh"]; DateTime dt = DateTime.Parse(datetime, provider, System.Globalization.DateTimeStyles.NoCurrentDateDefault); NVShop.NgaySinh = dt; NVShop.ShopID = sp.QLSHOP_ID; NVShop.NgayTao = DateTime.Now; NVCSRes.Add(NVShop); NVCSRes.Save(); var models = NVCSRes.FindAllNhanVienCuaShop(sp.QLSHOP_ID); return Json(new { message = "Success", modelReturn = this.RenderPartialViewToString("Index", models) }, "text/html"); } return Json(new { message = "Validate", modelReturn = this.RenderPartialViewToString("UpdateNhanVienCuaShop", NVShop) }, "text/html"); } catch { return View(); } }else{ Session.Add("UrlRedirect", Url.AbsoluteAction("Create", "NhanVienCuaShop")); return RedirectToAction("LogOn", "Account"); } }
public void Delete(NhanVienCuaShop dm) { en.DeleteObject(dm); }
public void Add(NhanVienCuaShop dm) { en.AddObject("NhanVienCuaShop", dm); }