Beispiel #1
0
        public ResultModel StockMoveApplyInvalid(UserModel user, int stockMoveApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //获取移库申请
                    NFMT.WareHouse.DAL.StockMoveApplyDAL stockMoveApplyDAL = new StockMoveApplyDAL();
                    result = stockMoveApplyDAL.Get(user, stockMoveApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.WareHouse.Model.StockMoveApply StockMoveApply = result.ReturnValue as NFMT.WareHouse.Model.StockMoveApply;

                    //获取申请主表
                    NFMT.Operate.BLL.ApplyBLL applyBLL = new Operate.BLL.ApplyBLL();
                    result = applyBLL.Get(user, StockMoveApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

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

                    //作废申请主表
                    result = applyBLL.Invalid(user, apply);
                    if (result.ResultStatus != 0)
                        return result;

                    //作废移库申请明细
                    NFMT.WareHouse.DAL.StockMoveApplyDetailDAL stockMoveApplyDetailDAL = new StockMoveApplyDetailDAL();
                    result = stockMoveApplyDetailDAL.Invalid(user, stockMoveApplyId, string.Empty);
                    if (result.ResultStatus != 0)
                        return result;

                    //NFMT.WareHouse.DAL.StockExclusiveDAL stockExclusiveDAL = new StockExclusiveDAL();
                    //result = stockExclusiveDAL.Invalid(user, apply.ApplyId, stockMoveApplyId, string.Empty);
                    //if (result.ResultStatus != 0)
                    //    return result;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Message = string.Format("操作失败,{0}", ex.Message);
                result.ResultStatus = -1;
            }
            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;
        }
Beispiel #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="user"></param>
        /// <param name="apply"></param>
        /// <param name="stockMoveApply"></param>
        /// <param name="stockMoveApplyDetails"></param>
        /// <returns></returns>
        public ResultModel StockMoveApplyCreateHandle(UserModel user, NFMT.Operate.Model.Apply apply, List<Model.StockMoveApplyDetail> stockMoveApplyDetails)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //写入申请主表
                    NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
                    result = applyDAL.Insert(user, apply);
                    if (result.ResultStatus != 0)
                        return result;

                    int applyId = (int)result.ReturnValue;

                    //写入移库申请表
                    NFMT.WareHouse.DAL.StockMoveApplyDAL stockMoveApplyDAL = new StockMoveApplyDAL();
                    result = stockMoveApplyDAL.Insert(user, new Model.StockMoveApply()
                    {
                        ApplyId = applyId
                    });
                    if (result.ResultStatus != 0)
                        return result;

                    int stockMoveApplyId = (int)result.ReturnValue;

                    //写入移库申请明细表
                    NFMT.WareHouse.DAL.StockMoveApplyDetailDAL detailDAL = new StockMoveApplyDetailDAL();
                    foreach (Model.StockMoveApplyDetail detail in stockMoveApplyDetails)
                    {
                        detail.StockMoveApplyId = stockMoveApplyId;
                        result = detailDAL.Insert(user, detail);
                        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;
        }