public ActionResult Details(System.Int64 id) { if ((_crud & Zippy.SaaS.Entity.CRUD.Read) != Zippy.SaaS.Entity.CRUD.Read) { return(RedirectToAction("NoPermission", "Error")); } Z01Product entity = Z01ProductHelper.Create(db, id); return(View(entity)); }
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 Index(int?PageIndex, int?PageSize, string qTitle, string qBrief, string qModel1, string qModel2, long?qBrandID, DateTime?qCreateDateStart, DateTime?qCreateDateEnd, long?qCateID, int?qStatus, int?orderCol) { if ((_crud & Zippy.SaaS.Entity.CRUD.Read) != Zippy.SaaS.Entity.CRUD.Read) { return(RedirectToAction("NoPermission", "Error")); } System.Text.StringBuilder sbMenu = new System.Text.StringBuilder(); if ((_crud & Zippy.SaaS.Entity.CRUD.Create) == Zippy.SaaS.Entity.CRUD.Create) { sbMenu.AppendLine("<a href='/" + _ContollerName + "/Edit?ReturnUrl=" + System.Web.HttpUtility.UrlEncode("/" + _ContollerName + "/?PageSize=" + PageSize) + "' class='btn img'><i class='icon i_create'></i>添加<b></b></a>"); } sbMenu.AppendLine("<a href='javascript:;' class='btn img' id='bReload'><i class='icon i_refresh'></i>刷新<b></b></a>"); ViewData["TopMenu"] = sbMenu.ToString(); ViewData.Add("db", db); ViewData.Add("PageSize", PageSize ?? 20); int currentPageSize = PageSize ?? 20; int currentPageIndex = PageIndex ?? 1; //throw new Exception(qTitle); Hashtable hs = new Hashtable(); hs.Add("qTitle", qTitle); hs.Add("qBrief", qBrief); hs.Add("qCreateDateStart", qCreateDateStart); hs.Add("qCreateDateEnd", qCreateDateEnd); hs.Add("qCateID", qCateID); hs.Add("qModel1", qModel1); hs.Add("qModel2", qModel2); hs.Add("qBrandID", qBrandID); hs.Add("qStatus", qStatus); PaginatedList <Z01Product> result = Z01ProductHelper.Query(db, _tenant.TenantID.Value, currentPageSize, currentPageIndex, hs, orderCol); result.QueryParameters = hs; ViewData.Add("xcateid", qCateID); ViewData.Add("xbrandid", qBrandID); var brands = db.Take <Z01Brand>("1=1 order by Title"); ViewBag.brands = brands; ViewBag.categories = EAP.Logic.Z01.Helper.GetProductCategories(_tenant.TenantID.Value); return(View(result)); }
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)); } }