/// <summary> /// 编辑新增页面 /// </summary> /// <returns></returns> public ActionResult ValueEdit() { int attrId = RequestInt("attrId"); if (attrId == 0) { return(LayerAlertErrorAndClose("属性有误!")); } Product_Attribute modAttr = Bll.BllProduct_Attribute.First(o => o.Id == attrId); if (modAttr == null) { LayerAlertErrorAndClose("属性有误!"); } //判断是否是文本 bool isString = false; if (modAttr.InputType == (int)Tools.Enums.ESite.AttrType.Text) { isString = true; } int id = RequestInt("id"); Product_AttributeSelect model = null; if (id > 0) { model = Bll.BllProduct_AttributeSelect.First(o => o.Id == id); if (model == null) { return(LayerAlertErrorAndClose("属性不存在!")); } } ViewBag.isString = isString; ViewBag.modAttr = modAttr; ViewBag.attrId = attrId; return(View(model)); }
public ActionResult ValueSave() { int id = RequestInt("id"); int attrId = RequestInt("attrId"); string itemName = RequestString("ItemName"); if (attrId == 0) { return(LayerAlertErrorAndClose("属性有误!")); } Product_Attribute modAttr = Bll.BllProduct_Attribute.First(o => o.Id == attrId); if (modAttr == null) { LayerAlertErrorAndClose("属性有误!"); } //判断是否是文本 if (modAttr.InputType == (int)Tools.Enums.ESite.AttrType.Text) { modAttr.DefaultValue = itemName; if (Bll.BllProduct_Attribute.Update(modAttr, o => o.Id == modAttr.Id) > 0) { return(LayerAlertSuccessAndRefreshPage("添加成功!")); } else { return(LayerAlertErrorAndClose("添加失败!")); } } else { Product_AttributeSelect mod = null; if (id > 0) { mod = Bll.BllProduct_AttributeSelect.First(o => o.Id == id); if (mod == null) { return(LayerAlertErrorAndClose("属性不存在!")); } mod.ItemName = itemName; if (Bll.BllProduct_AttributeSelect.Update(mod, o => o.Id == id) > 0) { return(LayerAlertSuccessAndRefreshPage("修改成功!")); } else { return(LayerAlertErrorAndClose("修改失败!")); } } else { mod = new Product_AttributeSelect(); mod.ItemName = itemName; mod.AttributeId = attrId; mod.Sequence = Bll.BllSys_Class <Product_AttributeSelect> .Instance().GetMaxSequence("AttributeID=" + attrId); if (Bll.BllProduct_AttributeSelect.Insert(mod) > 0) { return(LayerAlertSuccessAndRefreshPage("添加成功!")); } else { return(LayerAlertErrorAndClose("添加失败!")); } } } }