Example #1
0
        /// <summary>
        /// 修改数据
        /// </summary>
        public AjaxResult Update(TbSupplier model)
        {
            if (model == null)
            {
                return(AjaxResult.Warning("参数错误"));
            }
            //验证是否可操作
            var anyRet = AnyInfo(model.ID);

            if (anyRet.state != ResultType.success.ToString())
            {
                return(anyRet);
            }
            try
            {
                var count = Repository <TbSupplier> .Update(model, p => p.ID == model.ID);

                if (count > 0)
                {
                    return(AjaxResult.Success());
                }
                return(AjaxResult.Error("操作失败"));
            }
            catch (Exception ex)
            {
                return(AjaxResult.Error(ex.ToString()));
            }
        }
Example #2
0
 public ActionResult SubmitForm(TbSupplier param, string type)
 {
     try
     {
         if (type == "add")
         {
             var data = _supplier.Insert(param);
             return(Content(data.ToJson()));
         }
         else
         {
             var data = _supplier.Update(param);
             return(Content(data.ToJson()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #3
0
        /// <summary>
        /// 新增数据
        /// </summary>
        public AjaxResult Insert(TbSupplier model)
        {
            if (model == null)
            {
                return(AjaxResult.Warning("参数错误"));
            }
            model.InsertUserCode = OperatorProvider.Provider.CurrentUser.UserCode;
            try
            {
                var count = Repository <TbSupplier> .Insert(model);

                if (count > 0)
                {
                    return(AjaxResult.Success());
                }
                return(AjaxResult.Error("操作失败"));
            }
            catch (Exception ex)
            {
                return(AjaxResult.Error(ex.ToString()));
            }
        }