Example #1
0
        public ResultModel GetStockMoveApplyByApplyId(UserModel user, int applyId)
        {
            ResultModel result = new ResultModel();

            SqlDataReader dr = null;
            try
            {
                string sql = string.Format("select * from dbo.St_StockMoveApply where ApplyId = {0}", applyId);
                dr = SqlHelper.ExecuteReader(ConnectString, CommandType.Text, sql, null);

                Model.StockMoveApply model = new StockMoveApply();

                if (dr.Read())
                {
                    model = CreateModel(dr) as StockMoveApply;

                    result.AffectCount = 1;
                    result.Message = "读取成功";
                    result.ResultStatus = 0;
                    result.ReturnValue = model;
                }
                else
                {
                    result.Message = "读取失败或无数据";
                    result.AffectCount = 0;
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }
            finally
            {
                if (dr != null)
                    dr.Dispose();
            }
            return result;
        }
Example #2
0
        public override IModel CreateModel(SqlDataReader dr)
        {
            StockMoveApply stockmoveapply = new StockMoveApply();

            int indexStockMoveApplyId = dr.GetOrdinal("StockMoveApplyId");
            stockmoveapply.StockMoveApplyId = Convert.ToInt32(dr[indexStockMoveApplyId]);

            int indexApplyId = dr.GetOrdinal("ApplyId");
            if (dr["ApplyId"] != DBNull.Value)
            {
                stockmoveapply.ApplyId = Convert.ToInt32(dr[indexApplyId]);
            }

            int indexCreatorId = dr.GetOrdinal("CreatorId");
            if (dr["CreatorId"] != DBNull.Value)
            {
                stockmoveapply.CreatorId = Convert.ToInt32(dr[indexCreatorId]);
            }

            int indexCreateTime = dr.GetOrdinal("CreateTime");
            if (dr["CreateTime"] != DBNull.Value)
            {
                stockmoveapply.CreateTime = Convert.ToDateTime(dr[indexCreateTime]);
            }

            int indexLastModifyId = dr.GetOrdinal("LastModifyId");
            if (dr["LastModifyId"] != DBNull.Value)
            {
                stockmoveapply.LastModifyId = Convert.ToInt32(dr[indexLastModifyId]);
            }

            int indexLastModifyTime = dr.GetOrdinal("LastModifyTime");
            if (dr["LastModifyTime"] != DBNull.Value)
            {
                stockmoveapply.LastModifyTime = Convert.ToDateTime(dr[indexLastModifyTime]);
            }

            return stockmoveapply;
        }
Example #3
0
        public ResultModel Complete(UserModel user, StockMoveApply stockMoveApply)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = this.Get(user, stockMoveApply.StockMoveApplyId);
                    stockMoveApply = result.ReturnValue as StockMoveApply;

                    if (stockMoveApply == null)
                    {
                        result.Message = "该数据不存在,不能完成";
                        return result;
                    }

                    NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
                    result = applyDAL.Get(user, stockMoveApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Operate.Model.Apply apply = result.ReturnValue as NFMT.Operate.Model.Apply;

                    if (apply.ApplyStatus != StatusEnum.已生效)
                    {
                        result.Message = "非已生效状态的数据不允许完成";
                        return result;
                    }

                    DAL.StockMoveDAL stockMoveDAL = new StockMoveDAL();
                    result = stockMoveDAL.GetStockMoveIdByApplyId(user, stockMoveApply.StockMoveApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    int stockMoveId = (int)result.ReturnValue;
                    result = stockMoveDAL.Get(user, stockMoveId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StockMove stockMove = result.ReturnValue as StockMove;
                    if (stockMove.Status != StatusEnum.已完成)
                    {
                        result.Message = "该申请对应的移库操作未完成,不能申请完成";
                        result.ResultStatus = -1;
                        return result;
                    }

                    result = applyDAL.Confirm(user, apply);
                    //result = stockmoveapplyDAL.Complete(user, stockMoveApply);

                    if (result.ResultStatus == 0)
                        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;
        }