Esempio n. 1
0
        public ResultModel Complete(UserModel user, StockMoveApply stockMoveApply)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = this.Get(user, stockMoveApply.StockMoveApplyId);
                    stockMoveApply = result.ReturnValue as StockMoveApply;

                    if (stockMoveApply == null)
                    {
                        result.Message = "该数据不存在,不能完成";
                        return result;
                    }

                    NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
                    result = applyDAL.Get(user, stockMoveApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Operate.Model.Apply apply = result.ReturnValue as NFMT.Operate.Model.Apply;

                    if (apply.ApplyStatus != StatusEnum.已生效)
                    {
                        result.Message = "非已生效状态的数据不允许完成";
                        return result;
                    }

                    DAL.StockMoveDAL stockMoveDAL = new StockMoveDAL();
                    result = stockMoveDAL.GetStockMoveIdByApplyId(user, stockMoveApply.StockMoveApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    int stockMoveId = (int)result.ReturnValue;
                    result = stockMoveDAL.Get(user, stockMoveId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StockMove stockMove = result.ReturnValue as StockMove;
                    if (stockMove.Status != StatusEnum.已完成)
                    {
                        result.Message = "该申请对应的移库操作未完成,不能申请完成";
                        result.ResultStatus = -1;
                        return result;
                    }

                    result = applyDAL.Confirm(user, apply);
                    //result = stockmoveapplyDAL.Complete(user, stockMoveApply);

                    if (result.ResultStatus == 0)
                        scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    log.ErrorFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (log.IsInfoEnabled)
                    log.InfoFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }
Esempio n. 2
0
        public ResultModel StockMoveUpdateHandle(UserModel user, int stockMoveId, string memo)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    DAL.StockMoveDAL stockMoveDAL = new StockMoveDAL();
                    result = stockMoveDAL.Get(user, stockMoveId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StockMove stockMove = result.ReturnValue as Model.StockMove;

                    stockMove.MoveMemo = memo;
                    stockMove.MoveTime = DateTime.Now;
                    stockMove.Mover = user.EmpId;

                    stockMove.Status = StatusEnum.已录入;
                    result = stockMoveDAL.Update(user, stockMove);
                    if (result.ResultStatus != 0)
                        return result;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    log.ErrorFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (log.IsInfoEnabled)
                    log.InfoFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }