Example #1
0
        public override IModel CreateModel(SqlDataReader dr)
        {
            RecAllotDetail recallotdetail = new RecAllotDetail();

            int indexDetailId = dr.GetOrdinal("DetailId");
            recallotdetail.DetailId = Convert.ToInt32(dr[indexDetailId]);

            int indexRecId = dr.GetOrdinal("RecId");
            if (dr["RecId"] != DBNull.Value)
            {
                recallotdetail.RecId = Convert.ToInt32(dr[indexRecId]);
            }

            int indexAllotId = dr.GetOrdinal("AllotId");
            if (dr["AllotId"] != DBNull.Value)
            {
                recallotdetail.AllotId = Convert.ToInt32(dr[indexAllotId]);
            }

            int indexAllotBala = dr.GetOrdinal("AllotBala");
            if (dr["AllotBala"] != DBNull.Value)
            {
                recallotdetail.AllotBala = Convert.ToDecimal(dr[indexAllotBala]);
            }

            int indexDetailStatus = dr.GetOrdinal("DetailStatus");
            if (dr["DetailStatus"] != DBNull.Value)
            {
                recallotdetail.DetailStatus = (Common.StatusEnum)Convert.ToInt32(dr[indexDetailStatus]);
            }

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

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

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

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

            return recallotdetail;
        }
Example #2
0
        public ResultModel Load(UserModel user,int allotId,NFMT.Common.StatusEnum status = StatusEnum.已生效)
        {
            ResultModel result = new ResultModel();
            try
            {
                string cmdText = string.Format("select * from dbo.Fun_RecAllotDetail where AllotId = {0} and DetailStatus >={1}",allotId,(int)status);

                DataTable dt = SqlHelper.ExecuteDataTable(ConnectString, cmdText, null, CommandType.Text);

                List<RecAllotDetail> recAllotDetails = new List<RecAllotDetail>();

                foreach (DataRow dr in dt.Rows)
                {
                    RecAllotDetail recallotdetail = new RecAllotDetail();
                    recallotdetail.DetailId = Convert.ToInt32(dr["DetailId"]);

                    if (dr["RecId"] != DBNull.Value)
                    {
                        recallotdetail.RecId = Convert.ToInt32(dr["RecId"]);
                    }
                    if (dr["AllotId"] != DBNull.Value)
                    {
                        recallotdetail.AllotId = Convert.ToInt32(dr["AllotId"]);
                    }
                    if (dr["AllotBala"] != DBNull.Value)
                    {
                        recallotdetail.AllotBala = Convert.ToDecimal(dr["AllotBala"]);
                    }
                    if (dr["DetailStatus"] != DBNull.Value)
                    {
                        recallotdetail.DetailStatus = (Common.StatusEnum)Convert.ToInt32(dr["DetailStatus"]);
                    }
                    if (dr["CreatorId"] != DBNull.Value)
                    {
                        recallotdetail.CreatorId = Convert.ToInt32(dr["CreatorId"]);
                    }
                    if (dr["CreateTime"] != DBNull.Value)
                    {
                        recallotdetail.CreateTime = Convert.ToDateTime(dr["CreateTime"]);
                    }
                    if (dr["LastModifyId"] != DBNull.Value)
                    {
                        recallotdetail.LastModifyId = Convert.ToInt32(dr["LastModifyId"]);
                    }
                    if (dr["LastModifyTime"] != DBNull.Value)
                    {
                        recallotdetail.LastModifyTime = Convert.ToDateTime(dr["LastModifyTime"]);
                    }
                    recAllotDetails.Add(recallotdetail);
                }
                result.AffectCount = dt.Rows.Count;
                result.Message = "获取列表成功";
                result.ResultStatus = 0;
                result.ReturnValue = recAllotDetails;
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }

            return result;
        }