Ejemplo n.º 1
0
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <returns>返回Json串</returns>
        public string Delete()
        {
            long id = Convert.ToInt64(System.Web.HttpContext.Current.Request.Params["id"]);              //主表主键

            FindedResults <ExpenseCategoryModel> expenseCategorys = ExpenseCategoryService.Find(t => t.PhId == id);

            if (expenseCategorys != null && expenseCategorys.Data.Count > 0)
            {
                string dm = expenseCategorys.Data[0].Dm;
                FindedResults <ProjectMstModel> findedResults1 = ProjectMstService.FindProjectMst(dm);
                FindedResults <BudgetMstModel>  findedResults2 = BudgetMstService.FindBudgetMst(dm);
                if (findedResults1 != null && findedResults1.Data.Count > 0)
                {
                    findedResults1.Status = ResponseStatus.Error;
                    findedResults1.Msg    = "当前类别已被引用,无法删除!";
                    return(DataConverterHelper.SerializeObject(findedResults1));
                }
                if (findedResults2 != null && findedResults2.Data.Count > 0)
                {
                    findedResults2.Status = ResponseStatus.Error;
                    findedResults2.Msg    = "当前类别已被引用,无法删除!";
                    return(DataConverterHelper.SerializeObject(findedResults2));
                }
            }

            var deletedresult = ExpenseCategoryService.Delete <System.Int64>(id);

            return(DataConverterHelper.SerializeObject(deletedresult));
        }
 public ActionResult Delete(int ID)
 {
     ex.Delete(ID);
     return(View());
 }