Esempio n. 1
0
        public ResultModel Invalid(UserModel user, int invoiceApplyId)
        {
            ResultModel result = new ResultModel();
            Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            DAL.InvoiceApplyDetailDAL invoiceApplyDetailDAL = new InvoiceApplyDetailDAL();

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

                    Model.InvoiceApply invoiceApply = result.ReturnValue as Model.InvoiceApply;
                    if (invoiceApply == null || invoiceApply.InvoiceApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票申请不存在";
                        return result;
                    }

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

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

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

                    //作废申请明细
                    foreach (Model.InvoiceApplyDetail detail in details)
                    {
                        if (detail.DetailStatus == StatusEnum.已生效)
                            detail.DetailStatus = StatusEnum.已录入;
                        result = invoiceApplyDetailDAL.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;
        }
Esempio n. 2
0
        public ResultModel Confirm(UserModel user, int invoiceApplyId)
        {
            ResultModel result = new ResultModel();
            Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            DAL.InvoiceApplyDetailDAL invoiceApplyDetailDAL = new InvoiceApplyDetailDAL();

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

                    Model.InvoiceApply invoiceApply = result.ReturnValue as Model.InvoiceApply;
                    if (invoiceApply == null || invoiceApply.InvoiceApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票申请不存在";
                        return result;
                    }

                    //验证主申请
                    result = applyDAL.Get(user, invoiceApply.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;
                    }

                    //验证是否执行完成 TODO

                    result = invoiceApplyDetailDAL.Load(user, invoiceApplyId);
                    if (result.ResultStatus != 0)
                        return result;

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

                    result = applyDAL.Confirm(user, apply);
                    if (result.ResultStatus != 0)
                        return result;

                    foreach (Model.InvoiceApplyDetail detail in details)
                    {
                        result = invoiceApplyDetailDAL.Confirm(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

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

            return result;
        }