public ActionResult Edit(System.Int64?id, string act) { Z01Product entity = null; long defaultBrandID = 0; if (id.HasValue && id > 0) { if (act == "detail") { if ((_crud & Zippy.SaaS.Entity.CRUD.Read) != Zippy.SaaS.Entity.CRUD.Read) { return(RedirectToAction("NoPermission", "Error")); } ViewData["VTitle"] = "查看产品信息"; ViewData["IsDetail"] = true; } else { if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update) { return(RedirectToAction("NoPermission", "Error")); } ViewData["VTitle"] = "修改产品信息"; } entity = Z01ProductHelper.Create(db, id.Value); defaultBrandID = entity.BrandID ?? 0; } else { if ((_crud & Zippy.SaaS.Entity.CRUD.Create) != Zippy.SaaS.Entity.CRUD.Create) { return(RedirectToAction("NoPermission", "Error")); } ViewData["VTitle"] = "新增产品"; entity = new Z01Product(); try { defaultBrandID = Request.Cookies["defaultBrandID"].Value.ToInt64(); } catch { } } ViewData["UnitIDOptions"] = Z01ProductHelper.GetUnitIDEntitiesHtmlOption(db, _tenant.TenantID.Value, entity.UnitID); ViewData["BrandIDOptions"] = Z01ProductHelper.GetBrandIDEntitiesHtmlOption(db, _tenant.TenantID.Value, defaultBrandID); ViewData["MoneyOptions"] = EAP.Logic.Bus.HtmlHelper.CurrencySelectOptions(db); string returnUrl = Request["ReturnUrl"]; if (returnUrl.IsNullOrEmpty()) { returnUrl = "/" + _ContollerName; } ViewData["ReturnUrl"] = returnUrl; return(View(entity)); }
public ActionResult Edit(System.Int64?id, Z01Product entity) { entity.ProductID = id; string formProductType = Request.Form["ProductType"]; entity.ProductType = formProductType.ToEnumInt32(); var ck_brandid = new System.Web.HttpCookie("defaultBrandID", (entity.BrandID ?? 0).ToString()); ck_brandid.Expires = DateTime.Now.AddMinutes(20); Response.SetCookie(ck_brandid); ValidateZ01Product(entity); if (!ModelState.IsValid) { ViewData["UnitIDOptions"] = Z01ProductHelper.GetUnitIDEntitiesHtmlOption(db, _tenant.TenantID.Value, entity.UnitID); ViewData["BrandIDOptions"] = Z01ProductHelper.GetBrandIDEntitiesHtmlOption(db, _tenant.TenantID.Value, entity.BrandID); ViewData["MoneyOptions"] = EAP.Logic.Bus.HtmlHelper.CurrencySelectOptions(db); return(View(entity)); } try { if (id.HasValue && id > 0) { if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update) { return(RedirectToAction("NoPermission", "Error")); } db.Update(entity); } else { if ((_crud & Zippy.SaaS.Entity.CRUD.Create) != Zippy.SaaS.Entity.CRUD.Create) { return(RedirectToAction("NoPermission", "Error")); } entity.ProductID = null; entity.TenantID = _tenant.TenantID; int pkid = db.Insert(entity); } return(Return()); } catch { return(View(entity)); } }