/// <summary> /// 添加/修改 /// </summary> public ActionResult ProductImgEdit(Model.ProductImgBase imgbase) { bool result = false; string Message = ""; Model.ProductImgBase imodel = new Model.ProductImgBase(); try { if (Request.Form["texOtype"] == "add") { string hfpid = Request.Form["hfPId"];//1|1 skuid pid int skuid = int.Parse(hfpid.Split('|')[0]); imgbase.pi_Url = Request.Form["FileInputEId"].ToString(); ViewData["LogoUrl"] = imgbase.pi_Url; imgbase.sku_ID = skuid; imgbase.pi_IsDel = false; imgbase.pi_StatusCode = 0; var imodellist = pingbll.GetModelList(" sku_Id=" + skuid + " and pi_Type=1 and pi_isDel=0"); if (Request.Form["ImgType"] == "chose") { return Content(DWZUtil.GetResultJson("300", "请选择图片类别!!", "", "", "")); } else if (int.Parse(Request.Form["ImgType"]) == 1 && imodellist.Count > 0) { return Content(DWZUtil.GetResultJson("300", "该商品已设置封面图片,请选择其他类别!!", "", "", "")); } else { if (Request.Form["ImgType"] == "1") { imgbase.pi_Type = true; } else { imgbase.pi_Type = false; } } result = pingbll.Add(imgbase); } else { string pids = Request.Form["attrValue"]; string hfpid = Request.Form["hfPId"];//2|1|2 m["pi_ID"]|@item["sku_ID"]|@item["pi_Type" int skuid = int.Parse(hfpid.Split('|')[1]); int piid = int.Parse(hfpid.Split('|')[0]); //bool pitype = bool.Parse(hfpid.Split('|')[2]); Model.ProductImgBase newimg = pingbll.GetModel(piid); newimg.pi_Url = Request.Form["FileInputEId"].ToString(); var imodellist = pingbll.GetModelList(" sku_Id=" + skuid + " and pi_Type=1 and pi_isDel=0"); if (Request.Form["ImgType"] == "chose") { return Content(DWZUtil.GetResultJson("300", "请选择图片类别!!", "", "", "")); } else if (int.Parse(Request.Form["ImgType"]) == 1 && imodellist.Count > 0 && imodellist[0].pi_ID != newimg.pi_ID) { return Content(DWZUtil.GetResultJson("300", "该商品已设置封面图片,请选择其他类别!!", "", "", "")); } else { if (Request.Form["ImgType"] == "1") { newimg.pi_Type = true; } else { newimg.pi_Type=false; } } result = pingbll.Update(newimg); } if (result) { return Content(DWZUtil.GetAjaxTodoJson("200", "保存成功!!", "", "forward", "closeCurrent", "pimgBox", "")); // return Content(DWZUtil.GetResultJson("200", "操作成功!!", "w_商品图册", "", "closeCurrent")); } else { return Content(DWZUtil.GetResultJson("300", "保存失败!!", "", "", "")); } } catch { Message = "程序异常,保存失败"; return Content(DWZUtil.GetResultJson("300", "保存失败!!", "", "", "")); } }
public ActionResult ProductImgEdit() { Model.ProductImgBase pimodel = new Model.ProductImgBase(); this.ViewData["texOtype"] = RequestBase.GetString("otype"); ViewData["hf_luj"] = ConfigurationManager.AppSettings["SaveImage"];//图片的存储路径 BindControl bc = new BindControl(); ViewData["IsHasFunRole"] = Rolemanager.IsHasFunRole(EmployeeBase.e_ID, "001001001");//是否拥有管理的权限 List<SelectListItem> ImgType = new List<SelectListItem> { new SelectListItem { Text = "请选择", Value = "chose" }, new SelectListItem { Text = "封面", Value = "1" }, new SelectListItem { Text = "非封面", Value = "0" } }; ViewData["ImgType"] = new SelectList(ImgType, "Value", "Text"); if (RequestBase.GetString("otype") == "modify") { string ids = RequestBase.GetString("dli_id"); ViewData["hfPId"] = ids; int piid = int.Parse(ids.Split('|')[0]);//图片ID int skuid = int.Parse(ids.Split('|')[1]); bool typeid = bool.Parse(ids.Split('|')[2]);//图片类别 pimodel = pingbll.GetModel(piid); ViewData["LogoUrl"] = pimodel.pi_Url; if (bool.Parse(ids.Split('|')[2])) { ViewData["ImgType"] = new SelectList(ImgType, "Value", "Text",1); } else { ViewData["ImgType"] = new SelectList(ImgType, "Value", "Text", 0); } return View(pimodel); } else { string pids = RequestBase.GetString("dli_id"); ViewData["hfPId"] = pids; return View(); } }