public ActionResult Delete(int id) { AjaxResult result = new AjaxResult(); try { GreenFactoryClass entity = m_FTISService.GetGreenFactoryClassById(id); //檢查底下的GreenFactory數量 IDictionary <string, string> conditions = new Dictionary <string, string>(); conditions.Add("GreenFactoryClassId", id.ToString()); int subsCount = m_FTISService.GetGreenFactoryCount(conditions); if (subsCount > 0) { return(this.Json(new AjaxResult(AjaxResultStatus.Fail, string.Format("{0}底下尚有綠色工廠,不可刪除。", entity.Name)))); } m_FTISService.DeleteGreenFactoryClass(entity); result.ErrorCode = AjaxResultStatus.Success; result.Message = string.Format("{0}刪除成功", entity.Name); } catch (Exception ex) { result.ErrorCode = AjaxResultStatus.Exception; result.Message = ex.Message; } return(this.Json(result)); }