Esempio n. 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="user"></param>
        /// <param name="apply"></param>
        /// <param name="stockMoveApply"></param>
        /// <param name="stockIds"></param>
        /// <returns></returns>
        public ResultModel StockMoveApplyUpdateHandle(UserModel user, NFMT.Operate.Model.Apply apply, List<Model.StockMoveApplyDetail> details, int stockMoveApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
                    result = applyDAL.Get(user, apply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Operate.Model.Apply applyRes = result.ReturnValue as NFMT.Operate.Model.Apply;
                    if (applyRes == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取失败";
                        return result;
                    }

                    applyRes.ApplyCorp = apply.ApplyCorp;
                    applyRes.EmpId = user.EmpId;
                    applyRes.ApplyTime = DateTime.Now;
                    applyRes.ApplyDept = apply.ApplyDept;
                    applyRes.ApplyDesc = apply.ApplyDesc;

                    result = applyDAL.Update(user, applyRes);
                    if (result.ResultStatus != 0)
                        return result;

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

                    foreach (Model.StockMoveApplyDetail detail in details)
                    {
                        detail.StockMoveApplyId = stockMoveApplyId;
                        result = stockMoveApplyDetailDAL.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;
        }
Esempio n. 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;
        }