Пример #1
0
        public ResultModel Update(UserModel user, Model.CustomsClearance customsClearance, List<Model.CustomsDetail> details)
        {
            ResultModel result = new ResultModel();
            DAL.CustomsDetailDAL customsDetailDAL = new CustomsDetailDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = customsclearanceDAL.Get(user, customsClearance.CustomsId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.CustomsClearance customsClearanceResult = result.ReturnValue as Model.CustomsClearance;
                    if (customsClearanceResult == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取失败";
                        return result;
                    }

                    customsClearanceResult.Customser = user.EmpId;
                    customsClearanceResult.CustomsCorpId = customsClearance.CustomsCorpId;
                    customsClearanceResult.CustomsDate = DateTime.Now;
                    customsClearanceResult.CustomsName = 0;
                    customsClearanceResult.GrossWeight = customsClearance.GrossWeight;
                    customsClearanceResult.NetWeight = customsClearance.NetWeight;
                    customsClearanceResult.CurrencyId = customsClearance.CurrencyId;
                    customsClearanceResult.CustomsPrice = customsClearance.CustomsPrice;
                    customsClearanceResult.TariffRate = customsClearance.TariffRate;
                    customsClearanceResult.AddedValueRate = customsClearance.AddedValueRate;
                    customsClearanceResult.OtherFees = customsClearance.OtherFees;
                    customsClearanceResult.Memo = customsClearance.Memo;

                    result = customsclearanceDAL.Update(user, customsClearanceResult);
                    if (result.ResultStatus != 0)
                        return result;

                    result = customsDetailDAL.Load(user, customsClearance.CustomsId);
                    if (result.ResultStatus != 0)
                        return result;

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

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

                    if (details != null && details.Any())
                    {
                        foreach (Model.CustomsDetail detail in details)
                        {
                            detail.CustomsId = customsClearance.CustomsId;
                            result = customsDetailDAL.Insert(user, detail);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

                    if (result.ResultStatus == 0)
                        result.ReturnValue = customsClearance.CustomsId;

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

            return result;
        }
Пример #2
0
        public ResultModel Invalid(UserModel user, int customId)
        {
            ResultModel result = new ResultModel();
            DAL.CustomsDetailDAL customsDetailDAL = new CustomsDetailDAL();

            try
            {
                using (System.Transactions.TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = customsclearanceDAL.Get(user, customId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.CustomsClearance customsClearance = result.ReturnValue as Model.CustomsClearance;
                    if (customsClearance == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取数据出错";
                        return result;
                    }

                    result = customsclearanceDAL.Invalid(user, customsClearance);
                    if (result.ResultStatus != 0)
                        return result;

                    result = customsDetailDAL.Load(user, customId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.CustomsDetail> details = result.ReturnValue as List<Model.CustomsDetail>;
                    if (details == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取数据出错";
                        return result;
                    }

                    foreach (Model.CustomsDetail detail in details)
                    {
                        if (detail.DetailStatus == Common.StatusEnum.已生效)
                            detail.DetailStatus = Common.StatusEnum.已录入;

                        result = customsDetailDAL.Invalid(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

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

            return result;
        }