public JsonResult AddPastureFodder(string fodderName, string quantity, string price, string sysFodderID) { string Msg; PastureFodder p = new PastureFodder(); p.FodderName = fodderName; p.IsCurrent = true; double result; if (Double.TryParse(quantity, out result)) { p.Quantity = result; if (Double.TryParse(price, out result)) { p.Price = result; int rr; if (Int32.TryParse(sysFodderID, out rr)) { p.SysFodderID = rr; p.PastureID = UserBLL.Instance.CurrentUser.Pasture.ID; FodderBLL fBLL = new FodderBLL(); int temp = fBLL.InsertPastureFodder(p); Msg = temp == 1 ? "成功添加牧场饲料!" : "未添加成功!"; } else { Msg = "标准饲料选择错!"; } } else { Msg = "价格输入错!"; } } else { Msg = "饲料数量输入错!"; } return(Json(new { Msg = Msg }, JsonRequestBehavior.AllowGet)); }