Esempio n. 1
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;
        }
Esempio n. 2
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. 3
0
        public ResultModel StockMoveCreateHandle(UserModel user, int stockMoveApplyId, string memo)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    Model.StockMove stockMove = new StockMove()
                    {
                        StockMoveApplyId = stockMoveApplyId,
                        Mover = user.EmpId,
                        MoveTime = DateTime.Now,
                        MoveMemo = memo,
                    };

                    DAL.StockMoveDAL stockMoveDAL = new StockMoveDAL();
                    result = stockmoveDAL.Insert(user, stockMove);
                    if (result.ResultStatus != 0)
                        return result;

                    int stockMoveId = (int)result.ReturnValue;

                    DAL.StockMoveApplyDetailDAL stockMoveApplyDetailDAL = new StockMoveApplyDetailDAL();
                    result = stockMoveApplyDetailDAL.Load(user, stockMoveApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.StockMoveApplyDetail> details = result.ReturnValue as List<Model.StockMoveApplyDetail>;
                    if (details == null || !details.Any())
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取失败";
                        return result;
                    }

                    DAL.StockMoveDetailDAL stockMoveDetailDAL = new StockMoveDetailDAL();
                    foreach (Model.StockMoveApplyDetail stockMoveApplyDetail in details)
                    {
                        result = stockMoveDetailDAL.Insert(user, new StockMoveDetail()
                        {
                            StockMoveId = stockMoveId,
                            MoveDetailStatus = StatusEnum.已生效,
                            StockId = stockMoveApplyDetail.StockId,
                            PaperNo = stockMoveApplyDetail.PaperNo,
                            DeliverPlaceId = stockMoveApplyDetail.DeliverPlaceId
                        });

                        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;
        }