Example #1
0
        /// <summary>
        /// 新增数据
        /// </summary>
        public AjaxResult Insert(TbProblemOrder model, List <TbProblemOrderItem> items)
        {
            if (model == null)
            {
                return(AjaxResult.Warning("参数错误"));
            }
            model.InsertUserCode = OperatorProvider.Provider.CurrentUser.UserCode;
            model.Examinestatus  = "未发起";
            model.RevokeStatus   = "未撤销";
            try
            {
                using (DbTrans trans = Db.Context.BeginTransaction())
                {
                    //添加信息
                    Repository <TbProblemOrder> .Insert(trans, model);

                    //添加明细信息
                    Repository <TbProblemOrderItem> .Insert(trans, items);

                    trans.Commit();
                    return(AjaxResult.Success());
                }
            }
            catch (Exception ex)
            {
                return(AjaxResult.Error());
            }
        }
Example #2
0
        /// <summary>
        /// 修改数据
        /// </summary>
        public AjaxResult Update(TbProblemOrder model, List <TbProblemOrderItem> items)
        {
            if (model == null)
            {
                return(AjaxResult.Warning("参数错误"));
            }
            var anyRet = AnyInfo(model.ID);

            if (anyRet.state != ResultType.success.ToString())
            {
                return(anyRet);
            }
            try
            {
                using (DbTrans trans = Db.Context.BeginTransaction())//使用事务
                {
                    //修改信息
                    Repository <TbProblemOrder> .Update(trans, model, p => p.ID == model.ID);

                    if (items.Count > 0)
                    {
                        //删除历史明细信息
                        Repository <TbProblemOrderItem> .Delete(trans, p => p.ProblemOrderCode == model.ProblemOrderCode);

                        //添加明细信息
                        Repository <TbProblemOrderItem> .Insert(trans, items);
                    }
                    trans.Commit();//提交事务

                    return(AjaxResult.Success());
                }
            }
            catch (Exception ex)
            {
                return(AjaxResult.Error(ex.ToString()));
            }
        }