Esempio n. 1
0
        public ResultModel Close(UserModel user, int repoId)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (System.Transactions.TransactionScope scope = new TransactionScope())
                {
                    //获取回购
                    result = this.repoDAL.Get(user, repoId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.Repo repo = result.ReturnValue as Model.Repo;
                    if (repo == null || repo.RepoId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "回购不存在";
                        return result;
                    }

                    //回购关闭
                    result = this.repoDAL.Close(user, repo);
                    if (result.ResultStatus != 0)
                        return result;

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

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

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

                    foreach (Model.RepoDetail detail in details)
                    {
                        //明细关闭
                        result = repoDetailDAL.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.UpdateStockStatusToPrevious(user, stock, StockStatusEnum.质押库存);
                        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 Close(UserModel user, int stockOutId)
        {
            ResultModel result = new ResultModel();

            try
            {
                StockOutDetailDAL stockOutDetailDAL = new StockOutDetailDAL();
                StockOutApplyDAL applyDAL = new StockOutApplyDAL();
                StockLogDAL stockLogDAL = new StockLogDAL();
                StockDAL stockDAL = new StockDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证出库
                    result = stockoutDAL.Get(user, stockOutId);
                    if (result.ResultStatus != 0)
                        return result;

                    StockOut resultObj = result.ReturnValue as StockOut;
                    if (resultObj == null || resultObj.StockOutId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "该数据不存在,不能进行执行完成操作";
                        return result;
                    }

                    //关闭出库
                    result = stockoutDAL.Close(user, resultObj);
                    if (result.ResultStatus != 0)
                        return result;

                    //加载对应出库申请
                    result = applyDAL.Get(user, resultObj.StockOutApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    StockOutApply apply = result.ReturnValue as StockOutApply;
                    if (apply == null || apply.StockOutApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "对应出库申请加载失败";
                        return result;
                    }

                    //加载明细
                    result = stockOutDetailDAL.Load(user, resultObj.StockOutId);
                    if (result.ResultStatus != 0)
                        return result;

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

                    foreach (StockOutDetail detail in details)
                    {
                        //关闭明细
                        result = stockOutDetailDAL.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, stockLog.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;
                        }

                        if (stock.StockStatus == StockStatusEnum.预售库存)
                        {
                            result = stockDAL.UpdateStockStatusToPrevious(user, stock);
                            if (result.ResultStatus != 0)
                                return result;
                        }

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

            return result;
        }
Esempio n. 3
0
        /// <summary>
        /// 数据撤返
        /// </summary>
        /// <param name="user">当前操作用户</param>
        /// <param name="pledge">Pledge对象</param>
        /// <returns></returns>
        public ResultModel GoBack(UserModel user, int pledgeId)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = this.Get(user, pledgeId);
                    if (result.ResultStatus != 0)
                        return result;
                    Model.Pledge pledge = result.ReturnValue as Pledge;

                    if (pledge == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "该数据不存在,不能撤返";
                        return result;
                    }

                    if (pledge.Status != StatusEnum.待审核 && pledge.Status != StatusEnum.已生效)
                    {
                        result.ResultStatus = -1;
                        result.Message = "非待审核或已生效状态的数据不允许撤返";
                        return result;
                    }

                    //获取质押申请实体
                    DAL.PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL();
                    result = pledgeApplyDAL.Get(user, pledge.PledgeApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.PledgeApply pledgeApply = result.ReturnValue as Model.PledgeApply;

                    //获取申请实体
                    NFMT.Operate.DAL.ApplyDAL applyDAl = new Operate.DAL.ApplyDAL();
                    result = applyDAl.Get(user, pledgeApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Operate.Model.Apply apply = result.ReturnValue as NFMT.Operate.Model.Apply;
                    if (apply.Status == Common.StatusEnum.已关闭 || apply.Status == Common.StatusEnum.已完成)
                    {
                        result.ResultStatus = -1;
                        result.Message = "质押对应的申请已完成或已关闭,不能进行撤返操作";
                        return result;
                    }

                    result = pledgeDAL.Goback(user, pledge);
                    if (result.ResultStatus != 0)
                        return result;

                    if (pledge.Status == StatusEnum.待审核)
                    {
                        //同步工作流状态
                        NFMT.WorkFlow.BLL.DataSourceBLL dataSourceBLL = new WorkFlow.BLL.DataSourceBLL();
                        result = dataSourceBLL.SynchronousStatus(user, pledge);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    NFMT.WareHouse.DAL.PledgeDetialDAL pledgeDetialDAL = new DAL.PledgeDetialDAL();
                    result = pledgeDetialDAL.GetStockId(user, pledgeId);
                    if (result.ResultStatus != 0)
                        return result;

                    if (!string.IsNullOrEmpty(result.ReturnValue.ToString()))
                    {
                        NFMT.WareHouse.DAL.StockDAL stockDAL = new StockDAL();
                        NFMT.WareHouse.DAL.StockNameDAL stockNameDAL = new StockNameDAL();
                        NFMT.WareHouse.DAL.StockLogDAL stockLogDAL = new StockLogDAL();

                        NFMT.WareHouse.Model.StockName stockName = new StockName();
                        NFMT.WareHouse.Model.Stock stock = new Stock();
                        NFMT.WareHouse.Model.StockLog stockLog = new StockLog();

                        foreach (string s in result.ReturnValue.ToString().Split(','))
                        {
                            result = stockDAL.Get(user, Convert.ToInt32(s));
                            if (result.ResultStatus != 0)
                                return result;
                            stock = result.ReturnValue as Model.Stock;

                            result = stockNameDAL.Get(user, stock.StockNameId);
                            if (result.ResultStatus != 0)
                                return result;
                            stockName = result.ReturnValue as Model.StockName;

                            ////创建stockLog对象
                            //stockLog = new StockLog()
                            //{
                            //    StockId = stock.StockId,
                            //    StockNameId = stock.StockNameId,
                            //    RefNo = stockName.RefNo,
                            //    //LogDirection =
                            //    LogType = LogEnum.质押冲销,
                            //    //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_Pledge",
                            //    SourceId = pledgeId
                            //};

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

                            result = stockDAL.UpdateStockStatusToPrevious(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;
        }
Esempio n. 4
0
        public ResultModel Close(UserModel user, int pledgeId)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (System.Transactions.TransactionScope scope = new TransactionScope())
                {
                    //获取质押
                    result = this.pledgeDAL.Get(user, pledgeId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.Pledge pledge = result.ReturnValue as Model.Pledge;
                    if (pledge == null || pledge.PledgeId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "质押不存在";
                        return result;
                    }

                    //质押关闭
                    result = this.pledgeDAL.Close(user, pledge);
                    if (result.ResultStatus != 0)
                        return result;

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

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

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

                    foreach (Model.PledgeDetial detail in details)
                    {
                        //明细关闭
                        result = pledgeDetialDAL.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;
                        }

                        if (stock.PreStatus == StockStatusEnum.质押库存)
                            stock.PreStatus = StockStatusEnum.在库正常;

                        result = stockDAL.UpdateStockStatusToPrevious(user, stock);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }

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

            return result;
        }
Esempio n. 5
0
        public ResultModel Complete(UserModel user, int stockMoveId)
        {
            ResultModel result = new ResultModel();

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

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

                    result = stockmoveDAL.Complete(user, stockmove);
                    if (result.ResultStatus != 0)
                        return result;

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

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

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

                    foreach (Model.StockMoveDetail detail in details)
                    {
                        //明细完成
                        result = stockMoveDetailDAL.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;
                        }

                        result = stockDAL.UpdateStockStatusToPrevious(user, stock, StockStatusEnum.在库正常);
                        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;
        }