/// <summary> /// 分页获取供求收藏信息列表 /// </summary> /// <param name="pageSize">每页显示条数</param> /// <param name="pageIndex">当前页码</param> /// <param name="recordCount">总记录数</param> /// <param name="CompanyId">公司编号 =""返回全部</param> /// <param name="UserId">用户编号 =""返回全部</param> /// <returns></returns> public virtual IList <EyouSoft.Model.CommunityStructure.ExchangeFavor> GetList(int pageSize, int pageIndex, ref int recordCount, string CompanyId, string UserId) { IList <EyouSoft.Model.CommunityStructure.ExchangeFavor> list = new List <EyouSoft.Model.CommunityStructure.ExchangeFavor>(); string tableName = "tbl_ExchangeFavor"; StringBuilder fields = new StringBuilder("ID,ExchangeId,(select ExchangeTitle from tbl_ExchangeList where ID=tbl_ExchangeFavor.ExchangeId) as ExchangeTitle"); fields.Append(",(select TopicClassID from tbl_ExchangeList where ID=tbl_ExchangeFavor.ExchangeId) as TopicClassID"); fields.Append(",(select ExchangeTagId from tbl_ExchangeList where ID=tbl_ExchangeFavor.ExchangeId) as ExchangeTagId"); fields.Append(",(select ProvinceId from tbl_ExchangeList where ID=tbl_ExchangeFavor.ExchangeId) as ProvinceId"); fields.Append(",(select WriteBackCount from tbl_ExchangeList where ID=tbl_ExchangeFavor.ExchangeId) as WriteBackCount"); fields.Append(",(select IssueTime from tbl_ExchangeList where ID=tbl_ExchangeFavor.ExchangeId) as IssueTime"); string primaryKey = "ID"; string OrderByString = " ID DESC"; #region 生成查询条件 StringBuilder strWhere = new StringBuilder(" 1=1 "); if (!string.IsNullOrEmpty(CompanyId)) { strWhere.AppendFormat(" and CompanyId='{0}' ", CompanyId); } if (!string.IsNullOrEmpty(UserId)) { strWhere.AppendFormat(" and OperatorId='{0}' ", UserId); } #endregion using (IDataReader dr = DbHelper.ExecuteReader(this._database, pageSize, pageIndex, ref recordCount, tableName, primaryKey, fields.ToString(), strWhere.ToString(), OrderByString)) { while (dr.Read()) { EyouSoft.Model.CommunityStructure.ExchangeFavor model = new EyouSoft.Model.CommunityStructure.ExchangeFavor(); model.ID = dr.GetInt32(0); model.ExchangeId = dr.IsDBNull(1) ? string.Empty : dr.GetString(1); model.ExchangeTitle = dr.IsDBNull(2) ? string.Empty : dr.GetString(2); if (!dr.IsDBNull(3)) { model.TopicClassID = (EyouSoft.Model.CommunityStructure.ExchangeType) int.Parse(dr.GetByte(3).ToString()); } if (!dr.IsDBNull(4)) { model.ExchangeTag = (EyouSoft.Model.CommunityStructure.ExchangeTag) int.Parse(dr.GetByte(4).ToString()); } model.ProvinceId = dr.IsDBNull(5) ? 0 : dr.GetInt32(5); model.WriteBackCount = dr.IsDBNull(6) ? 0 : dr.GetInt32(6); model.IssueTime = dr.IsDBNull(7) ? DateTime.MaxValue : dr.GetDateTime(7); list.Add(model); model = null; } } return(list); }
/// <summary> /// 数据绑定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void rpt_HasSupplyFavorites_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { EyouSoft.Model.CommunityStructure.ExchangeFavor model = (EyouSoft.Model.CommunityStructure.ExchangeFavor)e.Item.DataItem; Literal ltrExchangeTag = (Literal)e.Item.FindControl("ltrExchangeTag"); if (ltrExchangeTag != null) { if (model.ExchangeTagHtml != null) { ltrExchangeTag.Text = model.ExchangeTagHtml.TagHTML;// string.Format("<div class=\"gqbiaoqian{0}\">{1}</div>", (int)model.ExchangeTag, model.ExchangeTag); } } } }