/// <summary> /// 得到一个对象实体 /// </summary> public Gymnasium_APP.Model.MemberInfoModel DataRowToModel(DataRow row) { Gymnasium_APP.Model.MemberInfoModel model=new Gymnasium_APP.Model.MemberInfoModel(); if (row != null) { if(row["MemberID"]!=null && row["MemberID"].ToString()!="") { model.MemberID=int.Parse(row["MemberID"].ToString()); } if(row["CardID"]!=null) { model.CardID=row["CardID"].ToString(); } if(row["Mail"]!=null) { model.Mail=row["Mail"].ToString(); } if(row["CardType"]!=null) { model.CardType=row["CardType"].ToString(); } if(row["IDCardType"]!=null) { model.IDCardType=row["IDCardType"].ToString(); } if(row["Name"]!=null) { model.Name=row["Name"].ToString(); } if(row["IDCard"]!=null) { model.IDCard=row["IDCard"].ToString(); } if(row["Sex"]!=null) { model.Sex=row["Sex"].ToString(); } if(row["StartTime"]!=null) { model.StartTime=row["StartTime"].ToString(); } if(row["Birthday"]!=null) { model.Birthday=row["Birthday"].ToString(); } if(row["EndTime"]!=null) { model.EndTime=row["EndTime"].ToString(); } if(row["Phone"]!=null) { model.Phone=row["Phone"].ToString(); } if(row["Count"]!=null) { model.Count=row["Count"].ToString(); } if(row["Unit"]!=null) { model.Unit=row["Unit"].ToString(); } if(row["AddTime"]!=null) { model.AddTime=row["AddTime"].ToString(); } if(row["AddUserName"]!=null) { model.AddUserName=row["AddUserName"].ToString(); } if(row["Photo"]!=null && row["Photo"].ToString()!="") { model.Photo=(byte[])row["Photo"]; } if(row["InfoType"]!=null) { model.InfoType=row["InfoType"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Gymnasium_APP.Model.MemberInfoModel GetModel(int MemberID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 MemberID,CardID,Mail,CardType,IDCardType,Name,IDCard,Sex,StartTime,Birthday,EndTime,Phone,Count,Unit,AddTime,AddUserName,Photo,InfoType from MemberInfo "); strSql.Append(" where MemberID=@MemberID"); SqlParameter[] parameters = { new SqlParameter("@MemberID", SqlDbType.Int,4) }; parameters[0].Value = MemberID; Gymnasium_APP.Model.MemberInfoModel model=new Gymnasium_APP.Model.MemberInfoModel(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }