/// <summary> /// 得到一个对象实体 /// </summary> public MyBookShop.Model.CheckEmail DataRowToModel(DataRow row) { MyBookShop.Model.CheckEmail model=new MyBookShop.Model.CheckEmail(); if (row != null) { if(row["Id"]!=null && row["Id"].ToString()!="") { model.Id=int.Parse(row["Id"].ToString()); } if(row["Actived"]!=null && row["Actived"].ToString()!="") { if((row["Actived"].ToString()=="1")||(row["Actived"].ToString().ToLower()=="true")) { model.Actived=true; } else { model.Actived=false; } } if(row["ActiveCode"]!=null) { model.ActiveCode=row["ActiveCode"].ToString(); } if(row["UserId"]!=null && row["UserId"].ToString()!="") { model.UserId=int.Parse(row["UserId"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public MyBookShop.Model.CheckEmail GetModel(int Id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 Id,Actived,ActiveCode,UserId from CheckEmail "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int,4) }; parameters[0].Value = Id; MyBookShop.Model.CheckEmail model=new MyBookShop.Model.CheckEmail(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }