Esempio n. 1
0
        public override IModel CreateModel(SqlDataReader dr)
        {
            Pledge pledge = new Pledge();

            int indexPledgeId = dr.GetOrdinal("PledgeId");
            pledge.PledgeId = Convert.ToInt32(dr[indexPledgeId]);

            int indexPledgeApplyId = dr.GetOrdinal("PledgeApplyId");
            if (dr["PledgeApplyId"] != DBNull.Value)
            {
                pledge.PledgeApplyId = Convert.ToInt32(dr[indexPledgeApplyId]);
            }

            int indexPledger = dr.GetOrdinal("Pledger");
            if (dr["Pledger"] != DBNull.Value)
            {
                pledge.Pledger = Convert.ToInt32(dr[indexPledger]);
            }

            int indexPledgeTime = dr.GetOrdinal("PledgeTime");
            if (dr["PledgeTime"] != DBNull.Value)
            {
                pledge.PledgeTime = Convert.ToDateTime(dr[indexPledgeTime]);
            }

            int indexPledgeBank = dr.GetOrdinal("PledgeBank");
            if (dr["PledgeBank"] != DBNull.Value)
            {
                pledge.PledgeBank = Convert.ToInt32(dr[indexPledgeBank]);
            }

            int indexMemo = dr.GetOrdinal("Memo");
            if (dr["Memo"] != DBNull.Value)
            {
                pledge.Memo = Convert.ToString(dr[indexMemo]);
            }

            int indexPledgeStatus = dr.GetOrdinal("PledgeStatus");
            if (dr["PledgeStatus"] != DBNull.Value)
            {
                pledge.PledgeStatus = (Common.StatusEnum)Convert.ToInt32(dr[indexPledgeStatus]);
            }

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

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

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

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

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

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

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

                    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.ApplyStatus != StatusEnum.已生效)
                    {
                        result.ResultStatus = -1;
                        result.Message = "非已生效状态的数据不允许完成";
                        return result;
                    }

                    DAL.PledgeDAL pledgeDAL = new PledgeDAL();
                    result = pledgeDAL.GetPledgeIdByApplyId(user, pledgeApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    if (!string.IsNullOrEmpty(result.ReturnValue.ToString()))
                    {
                        Model.Pledge pledge = new Pledge();
                        foreach (string s in result.ReturnValue.ToString().Split(','))
                        {
                            result = pledgeDAL.Get(user, Convert.ToInt32(s));
                            if (result.ResultStatus != 0)
                                return result;
                            pledge = result.ReturnValue as Model.Pledge;

                            if (pledge.Status != StatusEnum.已完成)
                            {
                                result.ResultStatus = -1;
                                result.Message = "该质押申请对应的质押并未全部完成";
                                return result;
                            }
                        }
                    }

                    result = applyDAL.Confirm(user, apply);

                    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;
        }
Esempio n. 3
0
        public override IModel CreateModel(DataRow dr)
        {
            Pledge pledge = new Pledge();

            pledge.PledgeId = Convert.ToInt32(dr["PledgeId"]);

            if (dr["PledgeApplyId"] != DBNull.Value)
            {
                pledge.PledgeApplyId = Convert.ToInt32(dr["PledgeApplyId"]);
            }

            if (dr["Pledger"] != DBNull.Value)
            {
                pledge.Pledger = Convert.ToInt32(dr["Pledger"]);
            }

            if (dr["PledgeTime"] != DBNull.Value)
            {
                pledge.PledgeTime = Convert.ToDateTime(dr["PledgeTime"]);
            }

            if (dr["PledgeBank"] != DBNull.Value)
            {
                pledge.PledgeBank = Convert.ToInt32(dr["PledgeBank"]);
            }

            if (dr["Memo"] != DBNull.Value)
            {
                pledge.Memo = Convert.ToString(dr["Memo"]);
            }

            if (dr["PledgeStatus"] != DBNull.Value)
            {
                pledge.PledgeStatus = (Common.StatusEnum)Convert.ToInt32(dr["PledgeStatus"]);
            }

            if (dr["CreatorId"] != DBNull.Value)
            {
                pledge.CreatorId = Convert.ToInt32(dr["CreatorId"]);
            }

            if (dr["CreateTime"] != DBNull.Value)
            {
                pledge.CreateTime = Convert.ToDateTime(dr["CreateTime"]);
            }

            if (dr["LastModifyId"] != DBNull.Value)
            {
                pledge.LastModifyId = Convert.ToInt32(dr["LastModifyId"]);
            }

            if (dr["LastModifyTime"] != DBNull.Value)
            {
                pledge.LastModifyTime = Convert.ToDateTime(dr["LastModifyTime"]);
            }

            return pledge;
        }