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