/// <summary> /// 修改保存 /// </summary> /// <returns></returns> public ActionResult UpdateGoodsChop() { string styMy = "fail"; try { B_GoodsChopList JJ = new B_GoodsChopList(); JJ.GoodsChopID = Convert.ToInt32(Request.Form["GoodsChopID"]); JJ.GoodsChopName = Request.Form["GoodsChopName"]; JJ.SpellCod = Request.Form["SpellCod"]; JJ.GoodsChopCode = Request.Form["GoodsChopCode"]; JJ.RegisteredAddress = Request.Form["RegisteredAddress"]; JJ.DiplomaValid = Convert.ToDateTime(Request.Form["DiplomaValid"]); JJ.RegisteredDiploma = Request.Form["RegisteredDiploma"]; MyModels.Entry(JJ).State = System.Data.Entity.EntityState.Modified; MyModels.SaveChanges(); styMy = "success"; } catch (Exception e) { Console.WriteLine(e); } return(Json(styMy, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 生成商标代码 /// </summary> /// <returns></returns> public ActionResult SelectGoodsChopCode() { string strGoodsChopCode = ""; var listDep = (from tbDmp in MyModels.B_GoodsChopList orderby tbDmp.GoodsChopCode select tbDmp).ToList(); if (listDep.Count > 0) { int count = listDep.Count; B_GoodsChopList modelDep = listDep[count - 1]; int intCode = Convert.ToInt32(modelDep.GoodsChopCode.Substring(2, 5)); intCode++; strGoodsChopCode = intCode.ToString(); for (int i = 0; i < 4; i++) { strGoodsChopCode = strGoodsChopCode.Length < 4 ? "0" + strGoodsChopCode : strGoodsChopCode; } strGoodsChopCode = "SB" + strGoodsChopCode; } else { strGoodsChopCode = "SB0001"; } return(Json(strGoodsChopCode, JsonRequestBehavior.AllowGet)); //return View(); }
/// <summary> /// 新增保存 /// </summary> /// <returns></returns> public ActionResult btnInsert(B_GoodsChopList pwGoodsChop) { string strMsg = "fali"; try { //判断数据是否已经存在 int oldGoodsMoneyRuleRows = (from tbGoodsMoneyRule in MyModels.B_GoodsChopList where tbGoodsMoneyRule.GoodsChopCode == pwGoodsChop.GoodsChopCode select tbGoodsMoneyRule).Count(); if (oldGoodsMoneyRuleRows == 0) { B_GoodsChopList JJ = new B_GoodsChopList(); JJ.GoodsChopName = Request.Form["GoodsChopName"]; JJ.SpellCod = Request.Form["SpellCod"]; JJ.GoodsChopCode = Request.Form["GoodsChopCode"]; JJ.RegisteredAddress = Request.Form["RegisteredAddress"]; JJ.DiplomaValid = Convert.ToDateTime(Request.Form["DiplomaValid"]); JJ.RegisteredDiploma = Request.Form["RegisteredDiploma"]; JJ.Proprietor = Request.Form["Proprietor"]; JJ.AgentCondition = Request.Form["AgentCondition"]; JJ.TrademarkRankID = Convert.ToInt32(Request.Form["TrademarkRankID"]); JJ.TrademarkStatusID = Convert.ToInt32(Request.Form["TrademarkStatusID"]); JJ.TrademarkLocalID = Convert.ToInt32(Request.Form["TrademarkLocalID"]); if (JJ.GoodsChopName != null && JJ.SpellCod != null && JJ.GoodsChopCode != null && JJ.RegisteredAddress != null && JJ.RegisteredDiploma != null && JJ.DiplomaValid != null && JJ.Proprietor != null && JJ.AgentCondition != null && JJ.TrademarkRankID != null && JJ.TrademarkStatusID != null && JJ.TrademarkLocalID != null) { MyModels.B_GoodsChopList.Add(JJ); MyModels.SaveChanges(); return(Json("success", JsonRequestBehavior.AllowGet)); } else { return(Json("fail", JsonRequestBehavior.AllowGet)); } } else { strMsg = "exsit"; } } catch (Exception e) { Console.WriteLine(e); } return(Json(strMsg, JsonRequestBehavior.AllowGet)); }