public JsonResult CreateInit() { int nextNoOfJournal = 0; int nextNoOfCategory = 0; if (!string.IsNullOrEmpty(Request.Form["journalId"]) && Request.Form["journalId"] != "0")//查询当前期刊下已有文章数量 { ArticleBLL articleBLL = new ArticleBLL(); List <SqlDbParameter> parms = new List <SqlDbParameter>(); SqlDbParameter parm = null; parm = new SqlDbParameter(); parm.ColumnName = "JournalId"; parm.ParameterName = "JournalId"; parm.ParameterValue = Request.Form["journalId"]; parm.ColumnType = DbType.Int32; parms.Add(parm); DataTable dt = articleBLL.GetArticleTotal(parms); //TODO 如果有文章被删除,就不能用这样的取号处理逻辑 if (dt.Rows.Count > 0) { nextNoOfJournal = int.Parse(dt.Rows[0]["TOTAL"].ToString()) + 1; } if (!string.IsNullOrEmpty(Request.Form["categoryId"]) && Request.Form["categoryId"] != "0") //查询当前期刊下当前类别的文章数量 { parm = new SqlDbParameter(); parm.ColumnName = "CategoryId"; parm.ParameterName = "CategoryId"; parm.ParameterValue = Request.Form["categoryId"]; parm.ColumnType = DbType.Int32; parms.Add(parm); DataTable dt2 = articleBLL.GetArticleTotal(parms); if (dt2.Rows.Count > 0) { nextNoOfCategory = int.Parse(dt2.Rows[0]["TOTAL"].ToString()) + 1; } } } if (nextNoOfJournal == 0) { nextNoOfJournal += 1; } if (nextNoOfCategory == 0) { nextNoOfCategory += 1; } return(Json(new { result = false, noOfJournal = nextNoOfJournal, noOfCategory = nextNoOfCategory }, JsonRequestBehavior.AllowGet)); }