/// <summary> /// 对象实体绑定数据 /// </summary> public VAN_OA.Model.EFrom.A_ProInfo ReaderBind(IDataReader dataReader) { VAN_OA.Model.EFrom.A_ProInfo model = new VAN_OA.Model.EFrom.A_ProInfo(); object ojb; ojb = dataReader["pro_Id"]; if (ojb != null && ojb != DBNull.Value) { model.pro_Id = (int)ojb; } model.pro_Type = dataReader["pro_Type"].ToString(); ojb = dataReader["cou"]; if (ojb != null && ojb != DBNull.Value) { if (Convert.ToInt32(ojb) > 0) { model.IfIDS = true; } else { model.IfIDS = false; } } return(model); }
/// <summary> /// 获得数据列表(比DataSet效率高,推荐使用) /// </summary> public List <VAN_OA.Model.EFrom.A_ProInfo> GetListArrayByRoleIds(string roleIds) { StringBuilder strSql = new StringBuilder(); strSql.AppendFormat(@"select distinct A_ProInfo.pro_Id,A_ProInfo.pro_Type,a_Role_Id from A_ProInfo left join A_ProInfos on A_ProInfo.pro_Id=A_ProInfos.pro_Id where a_Role_Id in ({0}) ", roleIds); List <VAN_OA.Model.EFrom.A_ProInfo> list = new List <VAN_OA.Model.EFrom.A_ProInfo>(); using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlCommand objCommand = new SqlCommand(strSql.ToString(), conn); using (SqlDataReader dataReader = objCommand.ExecuteReader()) { while (dataReader.Read()) { VAN_OA.Model.EFrom.A_ProInfo model = new VAN_OA.Model.EFrom.A_ProInfo(); object ojb; ojb = dataReader["pro_Id"]; if (ojb != null && ojb != DBNull.Value) { model.pro_Id = (int)ojb; } model.pro_Type = dataReader["pro_Type"].ToString(); model.RoleId = Convert.ToInt32(dataReader["a_Role_Id"]); list.Add(model); } } } return(list); }