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

            try
            {
                NFMT.WareHouse.DAL.StockOutApplyDAL stockOutApplyDAL = new NFMT.WareHouse.DAL.StockOutApplyDAL();
                NFMT.WareHouse.DAL.StockOutApplyDetailDAL stockOutApplyDetailDAL = new NFMT.WareHouse.DAL.StockOutApplyDetailDAL();
                NFMT.Operate.DAL.ApplyDAL applyDAL = new NFMT.Operate.DAL.ApplyDAL();
                NFMT.WareHouse.DAL.StockExclusiveDAL stockExclusiveDAL = new NFMT.WareHouse.DAL.StockExclusiveDAL();

                //获取子合约出库申请
                result = stockOutApplyDAL.LoadBySubId(user, subId);
                if (result.ResultStatus != 0)
                    return result;

                List<NFMT.WareHouse.Model.StockOutApply> outApplies = result.ReturnValue as List<NFMT.WareHouse.Model.StockOutApply>;
                if (outApplies == null || outApplies.Count == 0)
                {
                    result.ResultStatus = -1;
                    result.Message = "获取出库申请失败";
                    return result;
                }

                foreach (NFMT.WareHouse.Model.StockOutApply outApply in outApplies)
                {
                    result = applyDAL.Get(user, outApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Operate.Model.Apply apply = result.ReturnValue as NFMT.Operate.Model.Apply;
                    if (apply == null || apply.ApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取主申请失败";
                        return result;
                    }

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

                    //获取出库申请明细
                    result = stockOutApplyDetailDAL.Load(user, outApply.StockOutApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<NFMT.WareHouse.Model.StockOutApplyDetail> details = result.ReturnValue as List<NFMT.WareHouse.Model.StockOutApplyDetail>;
                    if (details == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取出库申请明细失败";
                        return result;
                    }

                    foreach (NFMT.WareHouse.Model.StockOutApplyDetail detail in details)
                    {
                        detail.DetailStatus = StatusEnum.已录入;
                        result = stockOutApplyDetailDAL.Invalid(user, detail);
                        if (result.ResultStatus != 0)
                            return result;

                        //获取排他明细
                        result = stockExclusiveDAL.Get(user, apply.ApplyId, outApply.StockOutApplyId, detail.DetailId);
                        if (result.ResultStatus != 0)
                            return result;

                        NFMT.WareHouse.Model.StockExclusive stockExclusive = result.ReturnValue as NFMT.WareHouse.Model.StockExclusive;
                        if (stockExclusive == null || stockExclusive.ExclusiveId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "获取排他明细失败";
                            return result;
                        }

                        //作废排他明细
                        stockExclusive.ExclusiveStatus = StatusEnum.已录入;
                        result = stockExclusiveDAL.Invalid(user, stockExclusive);
                        if (result.ResultStatus != 0)
                            return result;
                    }
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Beispiel #2
0
        public ResultModel Invalid(UserModel user, int stockOutApplyId)
        {
            ResultModel result = new ResultModel();

            DAL.StockDAL stockDAL = new StockDAL();
            DAL.StockExclusiveDAL exclusiveDAL = new StockExclusiveDAL();
            DAL.StockOutApplyDAL outApplyDAL = new StockOutApplyDAL();
            Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            DAL.StockOutApplyDetailDAL detailDAL = new StockOutApplyDetailDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证出库申请
                    result = outApplyDAL.Get(user, stockOutApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StockOutApply outApply = result.ReturnValue as Model.StockOutApply;
                    if (outApply == null || outApply.StockOutApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "出库申请不存在";
                        return result;
                    }

                    //获取主申请实体
                    result = applyDAL.Get(user, outApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Operate.Model.Apply apply = result.ReturnValue as Operate.Model.Apply;
                    if (apply == null || apply.ApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "主申请不存在";
                        return result;
                    }

                    //获取申请明细
                    result = detailDAL.Load(user, outApply.StockOutApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<StockOutApplyDetail> details = result.ReturnValue as List<StockOutApplyDetail>;
                    if (details == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "申请明细获取失败";
                        return result;
                    }

                    //获取排他表数据
                    result = exclusiveDAL.Load(user, outApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<StockExclusive> exclusives = result.ReturnValue as List<StockExclusive>;
                    if (exclusives == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "排他明细获取失败";
                        return result;
                    }

                    //作废主申请
                    result = applyDAL.Invalid(user, apply);
                    if (result.ResultStatus != 0)
                        return result;
                    //作废申请明细
                    foreach (Model.StockOutApplyDetail detail in details)
                    {
                        detail.DetailStatus = StatusEnum.已录入;
                        result = detailDAL.Invalid(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }
                    //作废排他表
                    foreach (Model.StockExclusive exclusive in exclusives)
                    {
                        exclusive.ExclusiveStatus = StatusEnum.已录入;
                        result = exclusiveDAL.Invalid(user, exclusive);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
                return result;
            }

            return result;
        }