Exemple #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;
        }
Exemple #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;
        }
Exemple #3
0
        //报关审核生效	   流水操作:写入 流水类型:报关 流水状态:已生效    库存操作:更新 库存状态:预报关库存
        public ResultModel Audit(UserModel user, NFMT.WorkFlow.Model.DataSource dataSource, bool isPass)
        {
            ResultModel result = new ResultModel();

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

                    Model.CustomsClearance customsClearance = result.ReturnValue as Model.CustomsClearance;
                    if (customsClearance == null || customsClearance.CustomsId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "报关不存在";
                        return result;
                    }

                    //审核,修改数据状态
                    result = this.customsclearanceDAL.Audit(user, customsClearance, isPass);
                    if (result.ResultStatus != 0)
                        return result;

                    //审核通过
                    if (isPass)
                    {
                        //加载已生效明细
                        DAL.CustomsDetailDAL customsDetailDAL = new CustomsDetailDAL();
                        result = customsDetailDAL.Load(user, customsClearance.CustomsId, StatusEnum.已生效);
                        if (result.ResultStatus != 0)
                            return result;

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

                        DAL.StockDAL stockDAL = new StockDAL();
                        DAL.StockNameDAL stockNameDAL = new StockNameDAL();
                        DAL.StockLogDAL stockLogDAL = new StockLogDAL();
                        Model.Stock stock = null;
                        Model.StockName stockName = null;
                        Model.StockLog stockLog = null;

                        foreach (Model.CustomsDetail detail in details)
                        {
                            //获取库存
                            result = stockDAL.Get(user, detail.StockId);
                            if (result.ResultStatus != 0)
                                return result;

                            stock = result.ReturnValue as Model.Stock;
                            if (stock == null)
                            {
                                result.ResultStatus = -1;
                                result.Message = "获取库存失败";
                                return result;
                            }

                            //获取业务单号
                            result = stockNameDAL.Get(user, stock.StockNameId);
                            if (result.ResultStatus != 0)
                                return result;

                            stockName = result.ReturnValue as Model.StockName;
                            if (stockName == null)
                            {
                                result.ResultStatus = -1;
                                result.Message = "获取业务单号失败";
                                return result;
                            }

                            //创建库存流水
                            stockLog = new StockLog()
                            {
                                StockId = stock.StockId,
                                StockNameId = stock.StockNameId,
                                RefNo = stockName.RefNo,
                                LogDirection = (int)LogDirectionEnum.Out,
                                LogType = (int)LogTypeEnum.报关,
                                //ContractId =
                                //SubContractId =
                                LogDate = DateTime.Now,
                                OpPerson = user.EmpId,
                                Bundles = stock.Bundles,
                                GrossAmount = stock.GrossAmount,
                                NetAmount = stock.NetAmount,
                                MUId = stock.UintId,
                                BrandId = stock.BrandId,
                                DeliverPlaceId = stock.DeliverPlaceId,
                                PaperNo = stock.PaperNo,
                                PaperHolder = stock.PaperHolder,
                                CardNo = stock.CardNo,
                                Memo = stock.Memo,
                                LogStatus = StatusEnum.已生效,
                                LogSourceBase = "NFMT",
                                LogSource = "dbo.St_CustomsClearance",
                                SourceId = customsClearance.CustomsId
                            };

                            result = stockLogDAL.Insert(user, stockLog);
                            if (result.ResultStatus != 0)
                                return result;

                            int stockLogId = 0;
                            if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out stockLogId) || stockLogId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "流水添加失败";
                                return result;
                            }

                            //将库存流水Id反向更新到明细表中
                            detail.StockLogId = stockLogId;
                            result = customsDetailDAL.Update(user, detail);
                            if (result.ResultStatus != 0)
                                return result;

                            //更新库存状态
                            result = stockDAL.UpdateStockStatus(stock, StockStatusEnum.预报关库存);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

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

            return result;
        }
Exemple #4
0
        public ResultModel CompleteCancel(UserModel user, int customId)
        {
            ResultModel result = new ResultModel();

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

                    Model.CustomsClearance customsClearance = result.ReturnValue as CustomsClearance;
                    if (customsClearance == null)
                    {
                        result.Message = "该数据不存在,不能完成";
                        result.ResultStatus = -1;
                        return result;
                    }

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

                    //获取所有已生效的明细
                    DAL.CustomsDetailDAL customsDetailDAL = new CustomsDetailDAL();
                    result = customsDetailDAL.Load(user, customId, StatusEnum.已完成);
                    if (result.ResultStatus != 0)
                        return result;

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

                    DAL.StockLogDAL stockLogDAL = new StockLogDAL();
                    DAL.StockDAL stockDAL = new StockDAL();

                    foreach (Model.CustomsDetail detail in details)
                    {
                        //明细完成
                        result = customsDetailDAL.CompleteCancel(user, detail);
                        if (result.ResultStatus != 0)
                            return result;

                        //获取报关流水
                        result = stockLogDAL.Get(user, detail.StockLogId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.StockLog stockLog = result.ReturnValue as Model.StockLog;
                        if (stockLog == null || stockLog.StockLogId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "报关流水获取失败";
                            return result;
                        }

                        //完成报关流水
                        result = stockLogDAL.CompleteCancel(user, stockLog);
                        if (result.ResultStatus != 0)
                            return result;

                        //获取库存
                        result = stockDAL.Get(user, detail.StockId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.Stock stock = result.ReturnValue as Model.Stock;
                        if (stock == null || stock.StockId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "库存获取失败";
                            return result;
                        }

                        stock.StockStatus = StockStatusEnum.预报关库存;
                        stock.CustomsType = NFMT.Data.DetailProvider.Details(Data.StyleEnum.CustomType)["OutsideCustom"].StyleDetailId;//关外
                        result = stockDAL.Update(user, stock);
                        if (result.ResultStatus != 0)
                            return result;
                    }

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

            return result;
        }
Exemple #5
0
        public ResultModel Complete(UserModel user, int customId)
        {
            ResultModel result = new ResultModel();

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

                    Model.CustomsClearance customsClearance = result.ReturnValue as CustomsClearance;
                    if (customsClearance == null)
                    {
                        result.Message = "该数据不存在,不能完成";
                        return result;
                    }

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

                    //获取所有已生效的明细
                    DAL.CustomsDetailDAL customsDetailDAL = new CustomsDetailDAL();
                    result = customsDetailDAL.Load(user, customId, StatusEnum.已生效);
                    if (result.ResultStatus != 0)
                        return result;

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

                    DAL.StockLogDAL stockLogDAL = new StockLogDAL();
                    DAL.StockDAL stockDAL = new StockDAL();

                    foreach (Model.CustomsDetail detail in details)
                    {
                        //明细完成
                        result = customsDetailDAL.Complete(user, detail);
                        if (result.ResultStatus != 0)
                            return result;

                        //获取报关流水
                        result = stockLogDAL.Get(user, detail.StockLogId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.StockLog stockLog = result.ReturnValue as Model.StockLog;
                        if (stockLog == null || stockLog.StockLogId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "报关流水获取失败";
                            return result;
                        }

                        //完成报关流水
                        result = stockLogDAL.Complete(user, stockLog);
                        if (result.ResultStatus != 0)
                            return result;

                        //获取库存
                        result = stockDAL.Get(user, detail.StockId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.Stock stock = result.ReturnValue as Model.Stock;
                        if (stock == null || stock.StockId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "库存获取失败";
                            return result;
                        }

                        stock.StockStatus = (int)stock.PreStatus == 0 ? StockStatusEnum.在库正常 : stock.PreStatus;
                        stock.CustomsType = NFMT.Data.DetailProvider.Details(Data.StyleEnum.CustomType)["InsideCustom"].StyleDetailId;//关内
                        result = stockDAL.Update(user, stock);
                        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;
        }
Exemple #6
0
        public ResultModel Close(UserModel user, int customId)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (System.Transactions.TransactionScope scope = new TransactionScope())
                {
                    //获取报关
                    result = this.customsclearanceDAL.Get(user, customId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.CustomsClearance customsClearance = result.ReturnValue as Model.CustomsClearance;
                    if (customsClearance == null || customsClearance.CustomsId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "报关不存在";
                        return result;
                    }

                    //报关关闭
                    result = this.customsclearanceDAL.Close(user, customsClearance);
                    if (result.ResultStatus != 0)
                        return result;

                    //获取所有已完成的明细
                    DAL.CustomsDetailDAL customsDetailDAL = new CustomsDetailDAL();
                    result = customsDetailDAL.Load(user, customId, StatusEnum.已生效);
                    if (result.ResultStatus != 0)
                        return result;

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

                    DAL.StockLogDAL stockLogDAL = new StockLogDAL();
                    DAL.StockDAL stockDAL = new StockDAL();

                    foreach (Model.CustomsDetail detail in details)
                    {
                        //明细关闭
                        result = customsDetailDAL.Close(user, detail);
                        if (result.ResultStatus != 0)
                            return result;

                        //获取报关流水
                        result = stockLogDAL.Get(user, detail.StockLogId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.StockLog stockLog = result.ReturnValue as Model.StockLog;
                        if (stockLog == null || stockLog.StockLogId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "报关流水获取失败";
                            return result;
                        }

                        //完成报关流水
                        result = stockLogDAL.Close(user, stockLog);
                        if (result.ResultStatus != 0)
                            return result;

                        //获取库存
                        result = stockDAL.Get(user, detail.StockId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.Stock stock = result.ReturnValue as Model.Stock;
                        if (stock == null || stock.StockId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "库存获取失败";
                            return result;
                        }

                        result = stockDAL.UpdateStockStatusDirect(stock, StockStatusEnum.在库正常);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }

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

            return result;
        }