public ActionResult OperateSave(Model.GoodsBasic model) { GESnapshotBll geBll = new GESnapshotBll(); GESnapshot ges = geBll.GetGesModel(model.ID, model.GESnapshot.GName); if (ges == null) { string isSale = ""; GoodsBasicBll bll = new GoodsBasicBll(); //可视分组 string hidGG = Request["hidGG"]; //属性规格 string hidGAV = HttpUtility.HtmlDecode(Request["hidGAV"]); int gcPid = int.Parse(Request["gClassP"]); int gcid = int.Parse(Request["gClass"]); Decimal lowerP = Decimal.Parse(Request["txtPriceLower"]); Decimal upperP = Decimal.Parse(Request["txtPriceUpper"]); string GEImg = Request["hidGEImg"]; model.GoodsClassID = gcid; if (model.RType == 2) { model.MinPrice = 0; model.MaxPrice = 0; } else { model.MinPrice = lowerP; model.MaxPrice = upperP; } model.BarCode = (model.BarCode == null) ? "" : model.BarCode; model.GModel = (model.GModel == null) ? "" : model.GModel; model.SaleNum = (model.SaleNum == null) ? 0 : model.SaleNum; model.CommentNum = (model.CommentNum == null) ? 0 : model.CommentNum; List <Hashtable> strGAV = JsonConvert.DeserializeObject <List <Hashtable> >(hidGAV); if (model.ID == 0) { isSale = "1"; model.IsSale = 1; model.Status = 0; model.EnterpriseID = LoginUser.UserBasic.EnterpriseID; model.AddTime = DateTime.Now; model.GESnapshot.IMG = GEImg; bll.AddGoods(model, gcPid, hidGG.Split(','), strGAV); } else { int gcp = 0; GoodsBasic updateModel = bll.GetModelByGBid(model.ID, out gcp, LoginUser.UserBasic.EnterpriseID); isSale = updateModel.IsSale.ToString(); model.IsSale = updateModel.IsSale; model.Status = updateModel.Status; model.EnterpriseID = updateModel.EnterpriseID; model.AddTime = updateModel.AddTime; model.Sorting = updateModel.Sorting; model.GESnapshot.AddTime = updateModel.GESnapshot.AddTime; model.GESnapshot.Status = updateModel.GESnapshot.Status; model.GESnapshot.GoodsBasicID = updateModel.GESnapshot.GoodsBasicID; model.GESnapshot.EnterpriseID = updateModel.GESnapshot.EnterpriseID; model.GESnapshot.IMG = GEImg; isSale = model.IsSale.ToString(); bll.UpdateGoods(model, gcPid, hidGG.Split(','), strGAV); } return(Json(new ReturnData <string>() { Status = true, Data = isSale })); } else { return(Json(new ReturnData <string>() { Status = false, Message = "该商品名称已被占用" })); } }
public ActionResult OperateSave(Model.GoodsBasic model) { GESnapshotBll geBll = new GESnapshotBll(); GESnapshot ges = geBll.GetGesModel(model.ID, model.GESnapshot.GName); if (ges == null) { string isSale = ""; GoodsBasicBll bll = new GoodsBasicBll(); //可视分组 string hidGG = Request["hidGG"]; //属性规格 string hidGAV = HttpUtility.HtmlDecode(Request["hidGAV"]); int gcPid = int.Parse(Request["gClassP"]); int gcid = int.Parse(Request["gClass"]); Decimal lowerP = Decimal.Parse(Request["txtPriceLower"]); Decimal upperP = Decimal.Parse(Request["txtPriceUpper"]); string GEImg = Request["hidGEImg"]; model.GoodsClassID = gcid; if (model.RType == 2) { model.MinPrice = 0; model.MaxPrice = 0; } else { model.MinPrice = lowerP; model.MaxPrice = upperP; } model.BarCode = (model.BarCode == null) ? "" : model.BarCode; model.GModel = (model.GModel == null) ? "" : model.GModel; model.SaleNum = (model.SaleNum == null) ? 0 : model.SaleNum; model.CommentNum = (model.CommentNum == null) ? 0 : model.CommentNum; List<Hashtable> strGAV = JsonConvert.DeserializeObject<List<Hashtable>>(hidGAV); if (model.ID == 0) { isSale = "1"; model.IsSale = 1; model.Status = 0; model.EnterpriseID = LoginUser.UserBasic.EnterpriseID; model.AddTime = DateTime.Now; model.GESnapshot.IMG = GEImg; bll.AddGoods(model, gcPid, hidGG.Split(','), strGAV); } else { int gcp = 0; GoodsBasic updateModel = bll.GetModelByGBid(model.ID, out gcp, LoginUser.UserBasic.EnterpriseID); isSale = updateModel.IsSale.ToString(); model.IsSale = updateModel.IsSale; model.Status = updateModel.Status; model.EnterpriseID = updateModel.EnterpriseID; model.AddTime = updateModel.AddTime; model.Sorting = updateModel.Sorting; model.GESnapshot.AddTime = updateModel.GESnapshot.AddTime; model.GESnapshot.Status = updateModel.GESnapshot.Status; model.GESnapshot.GoodsBasicID = updateModel.GESnapshot.GoodsBasicID; model.GESnapshot.EnterpriseID = updateModel.GESnapshot.EnterpriseID; model.GESnapshot.IMG = GEImg; isSale = model.IsSale.ToString(); bll.UpdateGoods(model, gcPid, hidGG.Split(','), strGAV); } return Json(new ReturnData<string>() { Status = true, Data = isSale }); } else { return Json(new ReturnData<string>() { Status = false, Message = "该商品名称已被占用" }); } }