コード例 #1
0
        public ActionResult Delete(string ProjectIds)
        {
            ResultHelper objResult = null;

            try
            {
                using (LedDb db = new LedDb())
                {
                    if (ModelState.IsValid)
                    {
                        string[] Id     = ProjectIds.Split(',');
                        string   strMsg = string.Empty;
                        for (int i = 0; i < Id.Length; i++)
                        {
                            ProjectBll.DeleteAProject(int.Parse(Id[i]), out strMsg);
                        }
                        objResult = new ResultHelper()
                        {
                            Status = true,
                            Ret    = 0,
                            Obj    = ProjectIds,
                            Msg    = strMsg,
                            Desc   = strMsg
                        };
                        //StringBuilder strSql = new StringBuilder();
                        //strSql.AppendFormat(@"UPDATE ProjectInfo SET IsDel = 1 WHERE Id IN ({0})", ProjectIds);
                        //if (db.Database.ExecuteSqlCommand(strSql.ToString()) > 0)
                        //{

                        //    objResult = new ResultHelper()
                        //    {
                        //        Status = true,
                        //        Ret = 0,
                        //        Obj = ProjectIds,
                        //        Msg = "Delete Success!",
                        //        Desc = "Delete Success!"
                        //    };
                        //}
                        //else
                        //{
                        //    objResult = new ResultHelper()
                        //    {
                        //        Desc = "Delete Faile,please try again.",
                        //        Msg = "Delete Faile,please try again.",
                        //        Obj = null,
                        //        Ret = -1,
                        //        Status = false
                        //    };
                        //}
                    }
                    else
                    {
                        objResult = new ResultHelper()
                        {
                            Desc   = " Faile,please try again",
                            Msg    = " Faile,please try again",
                            Obj    = null,
                            Ret    = -1,
                            Status = false
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
            }
            return(Json(objResult));
        }