Пример #1
0
        public ResultModel Confirm(UserModel user, int customApplyId)
        {
            ResultModel result = new ResultModel();
            Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            DAL.CustomsApplyDetailDAL customsApplyDetailDAL = new CustomsApplyDetailDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证报关申请
                    result = customsclearanceapplyDAL.Get(user, customApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.CustomsClearanceApply customsClearanceApply = result.ReturnValue as Model.CustomsClearanceApply;
                    if (customsClearanceApply == null || customsClearanceApply.CustomsApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "报关申请不存在";
                        return result;
                    }

                    //验证主申请
                    result = applyDAL.Get(user, customsClearanceApply.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 = customsclearanceapplyDAL.CheckCustomCanConfirm(user, customsClearanceApply.CustomsApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Common.StatusEnum status = (Common.StatusEnum)result.ReturnValue;

                    //获取已生效报关申请明细
                    result = customsApplyDetailDAL.Load(user, customsClearanceApply.CustomsApplyId);
                    if (result.ResultStatus != 0)
                        return result;

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

                    //主申请更新状态至已完成
                    if (status == StatusEnum.已完成)
                        result = applyDAL.Confirm(user, apply);
                    else if (status == StatusEnum.部分完成)
                        result = applyDAL.PartiallyConfirm(user, apply);
                    else
                    {
                        result.ResultStatus = -1;
                        result.Message = "更新主申请状态失败";
                        return result;
                    }
                    if (result.ResultStatus != 0)
                        return result;

                    //报关申请明细更新状态至已完成
                    foreach (Model.CustomsApplyDetail detail in details)
                    {
                        //报关申请明细更新状态至已完成
                        result = customsApplyDetailDAL.Confirm(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

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

            return result;
        }
Пример #2
0
        public ResultModel Update(UserModel user, NFMT.Operate.Model.Apply apply, Model.CustomsClearanceApply customsClearanceApply, List<Model.CustomsApplyDetail> details)
        {
            ResultModel result = new ResultModel();
            NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            DAL.CustomsApplyDetailDAL customsApplyDetailDAL = new CustomsApplyDetailDAL();

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

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

                    applyResult.ApplyType = apply.ApplyType;
                    applyResult.EmpId = user.EmpId;
                    applyResult.ApplyTime = DateTime.Now;
                    applyResult.ApplyDept = apply.ApplyDept;
                    applyResult.ApplyDesc = apply.ApplyDesc;

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

                    result = customsclearanceapplyDAL.Get(user, customsClearanceApply.CustomsApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.WareHouse.Model.CustomsClearanceApply customsClearanceApplyResult = result.ReturnValue as NFMT.WareHouse.Model.CustomsClearanceApply;
                    if (customsClearanceApplyResult == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取数据失败";
                        return result;
                    }

                    customsClearanceApplyResult.ApplyId = customsClearanceApply.ApplyId;
                    customsClearanceApplyResult.AssetId = customsClearanceApply.AssetId;
                    customsClearanceApplyResult.GrossWeight = customsClearanceApply.GrossWeight;
                    customsClearanceApplyResult.NetWeight = customsClearanceApply.NetWeight;
                    customsClearanceApplyResult.UnitId = customsClearanceApply.UnitId;
                    customsClearanceApplyResult.OutCorpId = customsClearanceApply.OutCorpId;
                    customsClearanceApplyResult.InCorpId = customsClearanceApply.InCorpId;
                    customsClearanceApplyResult.CustomsCorpId = customsClearanceApply.CustomsCorpId;
                    customsClearanceApplyResult.CustomsPrice = customsClearanceApply.CustomsPrice;
                    customsClearanceApplyResult.CurrencyId = customsClearanceApply.CurrencyId;

                    customsClearanceApplyResult.Status = Common.StatusEnum.已录入;
                    result = customsclearanceapplyDAL.Update(user, customsClearanceApplyResult);
                    if (result.ResultStatus != 0)
                        return result;

                    result = customsApplyDetailDAL.Load(user, customsClearanceApply.CustomsApplyId);
                    if (result.ResultStatus != 0)
                        return result;

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

                    foreach (Model.CustomsApplyDetail detail in customsApplyDetails)
                    {
                        if (detail.DetailStatus == Common.StatusEnum.已生效)
                            detail.DetailStatus = Common.StatusEnum.已录入;
                        result = customsApplyDetailDAL.Invalid(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    if (details != null && details.Any())
                    {
                        foreach (Model.CustomsApplyDetail detail in details)
                        {
                            detail.CustomsApplyId = customsClearanceApply.CustomsApplyId;
                            result = customsApplyDetailDAL.Insert(user, detail);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }
                    if (result.ResultStatus == 0)
                        result.ReturnValue = customsClearanceApply.CustomsApplyId;
                    scope.Complete();
                }
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                result.ResultStatus = -1;
            }

            return result;
        }
Пример #3
0
        public ResultModel Create(UserModel user, NFMT.Operate.Model.Apply apply, Model.CustomsClearanceApply customsClearanceApply, List<Model.CustomsApplyDetail> details)
        {
            ResultModel result = new ResultModel();
            NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            DAL.CustomsApplyDetailDAL customsApplyDetailDAL = new CustomsApplyDetailDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = applyDAL.Insert(user, apply);
                    if (result.ResultStatus != 0)
                        return result;

                    int applyId = (int)result.ReturnValue;

                    customsClearanceApply.ApplyId = applyId;

                    result = customsclearanceapplyDAL.Insert(user, customsClearanceApply);
                    if (result.ResultStatus != 0)
                        return result;

                    int customsApplyId = (int)result.ReturnValue;

                    if (details != null && details.Any())
                    {
                        foreach (Model.CustomsApplyDetail detail in details)
                        {
                            detail.CustomsApplyId = customsApplyId;
                            result = customsApplyDetailDAL.Insert(user, detail);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

                    if (result.ResultStatus == 0)
                        result.ReturnValue = applyId;
                    scope.Complete();
                }
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                result.ResultStatus = -1;
            }

            return result;
        }
Пример #4
0
        public ResultModel Invalid(UserModel user, int customApplyId)
        {
            ResultModel result = new ResultModel();
            Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            DAL.CustomsApplyDetailDAL customsApplyDetailDAL = new CustomsApplyDetailDAL();

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

                    Model.CustomsClearanceApply customsClearanceApply = result.ReturnValue as Model.CustomsClearanceApply;
                    if (customsClearanceApply == null || customsClearanceApply.CustomsApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "报关申请不存在";
                        return result;
                    }

                    //获取主申请实体
                    result = applyDAL.Get(user, customsClearanceApply.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 = customsApplyDetailDAL.Load(user, customsClearanceApply.CustomsApplyId);
                    if (result.ResultStatus != 0)
                        return result;

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

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

                    //作废申请明细
                    foreach (Model.CustomsApplyDetail detail in details)
                    {
                        if (detail.DetailStatus == StatusEnum.已生效)
                            detail.DetailStatus = StatusEnum.已录入;
                        result = customsApplyDetailDAL.Invalid(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

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

            return result;
        }
Пример #5
0
        public ResultModel ConfirmCancel(UserModel user, int customApplyId)
        {
            ResultModel result = new ResultModel();
            DAL.CustomsApplyDetailDAL customsApplyDetailDAL = new CustomsApplyDetailDAL();
            Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证报关申请
                    result = customsclearanceapplyDAL.Get(user, customApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.CustomsClearanceApply customsClearanceApply = result.ReturnValue as Model.CustomsClearanceApply;
                    if (customsClearanceApply == null || customsClearanceApply.CustomsApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "报关申请不存在";
                        return result;
                    }

                    //验证主申请
                    result = applyDAL.Get(user, customsClearanceApply.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 = applyDAL.ConfirmCancel(user, apply);
                    if (result.ResultStatus != 0)
                        return result;

                    //报关申请明细,在已完成状态下的更新至已生效
                    //获取已关闭的明细
                    result = customsApplyDetailDAL.Load(user, customsClearanceApply.CustomsApplyId, Common.StatusEnum.已完成);
                    if (result.ResultStatus != 0)
                        return result;

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

                    foreach (Model.CustomsApplyDetail detail in details)
                    {
                        result = customsApplyDetailDAL.ConfirmCancel(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

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

            return result;
        }