/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.roles DataRowToModel(DataRow row) { Maticsoft.Model.roles model=new Maticsoft.Model.roles(); if (row != null) { if(row["roleid"]!=null && row["roleid"].ToString()!="") { model.roleid=int.Parse(row["roleid"].ToString()); } if(row["roleno"]!=null) { model.roleno=row["roleno"].ToString(); } if(row["rolename"]!=null) { model.rolename=row["rolename"].ToString(); } if(row["beizhu"]!=null) { model.beizhu=row["beizhu"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.roles GetModel(int roleid) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 roleid,roleno,rolename,beizhu from roles "); strSql.Append(" where roleid=@roleid"); SqlParameter[] parameters = { new SqlParameter("@roleid", SqlDbType.Int,4) }; parameters[0].Value = roleid; Maticsoft.Model.roles model=new Maticsoft.Model.roles(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }