Example #1
0
        public JsonResult Index(ShenQing entity)
        {
            SuggestionRes response = new SuggestionRes();

            #region 各种校验

            if (string.IsNullOrWhiteSpace(entity.BaoXiuRen))
            {
                response.errorCode = 2;
                return Json(response);
            }
            if (string.IsNullOrWhiteSpace(entity.LianXiDianHua))
            {
                response.errorCode = 3;
                return Json(response);
            }
            if (string.IsNullOrWhiteSpace(entity.MiaoShu))
            {
                response.errorCode = 4;
                return Json(response);
            }
            #endregion

            Account account = GetCurrentAccount();
            entity.HuiYuanId = account.Id;
            entity.BiaoShi = account.BiaoShi;
            entity.CreatePerson = account.PersonName;

            string returnValue = string.Empty;
            IChuLiBLL m_BLL = new ChuLiBLL();
            if (!m_BLL.CreateAndCopy(ref validationErrors, entity))
            {

                if (validationErrors != null && validationErrors.Count > 0)
                {
                    validationErrors.All(a =>
                    {
                        returnValue += a.ErrorMessage;
                        return true;
                    });
                }
                response.errorCode = 99;
                response.content = returnValue;
                return Json(response);
            }

            response.errorCode = 0;
            return Json(response);
        }
Example #2
0
 public ActionResult Edit(string id, ShenQing entity)
 {
     if (entity != null && ModelState.IsValid)
     {   //数据校验
     
         string currentPerson = GetCurrentPerson();                 
         //entity.UpdateTime = DateTime.Now;
         //entity.UpdatePerson = currentPerson;
                    
         string returnValue = string.Empty;   
         if (m_BLL.Edit(ref validationErrors, entity))
         {
             LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",维修申请信息的Id为" + id,"维修申请"
                 );//写入日志                           
             return Json(Suggestion.UpdateSucceed); //提示更新成功 
         }
         else
         { 
             if (validationErrors != null && validationErrors.Count > 0)
             {
                 validationErrors.All(a =>
                 {
                     returnValue += a.ErrorMessage;
                     return true;
                 });
             }
             LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",维修申请信息的Id为" + id + "," + returnValue, "维修申请"
                 );//写入日志                           
             return Json(Suggestion.UpdateFail  + returnValue); //提示更新失败
         }
     }
     return Json(Suggestion.UpdateFail + "请核对输入的数据的格式"); //提示输入的数据的格式不对               
   
 }
Example #3
0
 /// <summary>
 /// 创建一个维修申请
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="db">数据库上下文</param>
 /// <param name="entity">一个维修申请</param>
 /// <returns></returns>
 public bool Create(ref ValidationErrors validationErrors, ShenQing entity)
 {
     try
     {
         repository.Create(entity);
         return true;
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);                
     }
     return false;
 }
Example #4
0
        public ActionResult Create(ShenQing entity)
        {           
            if (entity != null && ModelState.IsValid)
            {
                string currentPerson = GetCurrentPerson();
                entity.CreateTime = DateTime.Now;
                entity.CreatePerson = currentPerson;
              
                entity.Id = Result.GetNewId();   
                string returnValue = string.Empty;
                if (m_BLL.Create(ref validationErrors, entity))
                {
                    LogClassModels.WriteServiceLog(Suggestion.InsertSucceed  + ",维修申请的信息的Id为" + entity.Id,"维修申请"
                        );//写入日志 
                    return Json(Suggestion.InsertSucceed);
                }
                else
                { 
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return true;
                        });
                    }
                    LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",维修申请的信息," + returnValue,"维修申请"
                        );//写入日志                      
                    return Json(Suggestion.InsertFail  + returnValue); //提示插入失败
                }
            }

            return Json(Suggestion.InsertFail + ",请核对输入的数据的格式"); //提示输入的数据的格式不对 
        }