private void BindData(int pageno, int sendtype) { NoticeQuery noticeQuery = new NoticeQuery(); noticeQuery.SortBy = "ID"; noticeQuery.SortOrder = SortAction.Desc; Globals.EntityCoding(noticeQuery, true); noticeQuery.PageIndex = pageno; noticeQuery.SendType = sendtype; noticeQuery.PageSize = this.pager.PageSize; noticeQuery.IsDistributor = new bool?(true); this.title = Globals.RequestQueryStr("title"); string text = Globals.RequestQueryStr("starttime"); string text2 = Globals.RequestQueryStr("endtime"); string text3 = Globals.RequestQueryStr("username"); string text4 = Globals.RequestQueryStr("state"); if (!string.IsNullOrEmpty(this.title)) { noticeQuery.Title = this.title; this.txtTitle.Text = this.title; } try { if (!string.IsNullOrEmpty(text)) { noticeQuery.StartTime = new System.DateTime?(System.DateTime.Parse(text)); this.calendarStartDate.Text = noticeQuery.StartTime.Value.ToString("yyyy-MM-dd"); } if (!string.IsNullOrEmpty(text2)) { noticeQuery.EndTime = new System.DateTime?(System.DateTime.Parse(text2)); this.calendarEndDate.Text = noticeQuery.EndTime.Value.ToString("yyyy-MM-dd"); } } catch { } if (!string.IsNullOrEmpty(text3)) { noticeQuery.Author = text3; this.txtUserName.Text = text3; } string a; if ((a = text4) != null && (a == "0" || a == "1")) { noticeQuery.IsPub = new int?(Globals.ToNum(text4)); this.ddlState.SelectedValue = text4; } noticeQuery.SortBy = "IsPub asc,AddTime"; DbQueryResult noticeRequest = NoticeHelper.GetNoticeRequest(noticeQuery); this.rptList.DataSource = noticeRequest.Data; this.rptList.DataBind(); int totalRecords = noticeRequest.TotalRecords; this.pager.TotalRecords = totalRecords; this.recordcount = totalRecords; if (this.pager.TotalRecords <= this.pager.PageSize) { this.pager.Visible = false; } }
public static DbQueryResult GetNoticeRequest(NoticeQuery query) { return(new NoticeDao().GetNoticeRequest(query)); }
private void BindData(int pageno, int sendtype) { string str5; NoticeQuery entity = new NoticeQuery { SortBy = "ID", SortOrder = SortAction.Desc }; Globals.EntityCoding(entity, true); entity.PageIndex = pageno; entity.SendType = sendtype; entity.PageSize = this.pager.PageSize; entity.IsDistributor = true; this.title = Globals.RequestQueryStr("title"); string str = Globals.RequestQueryStr("starttime"); string str2 = Globals.RequestQueryStr("endtime"); string str3 = Globals.RequestQueryStr("username"); string s = Globals.RequestQueryStr("state"); if (!string.IsNullOrEmpty(this.title)) { entity.Title = this.title; this.txtTitle.Text = this.title; } try { if (!string.IsNullOrEmpty(str)) { entity.StartTime = new DateTime?(DateTime.Parse(str)); this.calendarStartDate.Text = entity.StartTime.Value.ToString("yyyy-MM-dd"); } if (!string.IsNullOrEmpty(str2)) { entity.EndTime = new DateTime?(DateTime.Parse(str2)); this.calendarEndDate.Text = entity.EndTime.Value.ToString("yyyy-MM-dd"); } } catch { } if (!string.IsNullOrEmpty(str3)) { entity.Author = str3; this.txtUserName.Text = str3; } if (((str5 = s) != null) && ((str5 == "0") || (str5 == "1"))) { entity.IsPub = new int?(Globals.ToNum(s)); this.ddlState.SelectedValue = s; } entity.SortBy = "IsPub asc,AddTime"; DbQueryResult noticeRequest = NoticeHelper.GetNoticeRequest(entity); this.rptList.DataSource = noticeRequest.Data; this.rptList.DataBind(); int totalRecords = noticeRequest.TotalRecords; this.pager.TotalRecords = totalRecords; this.recordcount = totalRecords; if (this.pager.TotalRecords <= this.pager.PageSize) { this.pager.Visible = false; } }
public BaseListResponse <SPGetNotice_Result> Search([FromUri] NoticeQuery query) { return(categoryService.FilterNotice(query)); }
/// <summary> /// 获取通知列表 /// </summary> /// <returns></returns> public PageVM <NoticeVM> GetNoticeListPage(NoticeQuery query) { if (!query.PageIndex.HasValue) { query.PageIndex = 1; } if (!query.PageSize.HasValue) { query.PageSize = 10; } string sql = "select * from notice n where 1=1 "; if (!string.IsNullOrEmpty(query.KeyWord)) { sql += string.Format(" and n.title like '%{0}%' ", query.KeyWord); } sql += " order by n.InputTime DESC "; string pageSql = string.Format(" Limit {0},{1}", (query.PageIndex - 1) * query.PageSize, query.PageSize); using (var dbContext = new DbContext().ConnectionStringName(ConnectionUtil.connWXB, DbProviderTypes.MySql)) { //获取指定页数据 List <NoticeVM> list = dbContext.Sql(sql + pageSql).Query <NoticeVM, List <NoticeVM> >(reader => { var noVM = new NoticeVM() { ID = reader.AsInt("ID"), Title = reader.AsString("Title"), Content = reader.AsString("Content"), Inputer = reader.AsString("Inputer"), InputerID = reader.AsInt("InputerID") }; noVM.FeedBack = string.IsNullOrEmpty(reader["FeedBack"].ToString()) ? "" : reader.AsString("FeedBack"); noVM.FeedBacker = string.IsNullOrEmpty(reader["FeedBacker"].ToString()) ? "" : reader.AsString("FeedBacker"); if (!string.IsNullOrEmpty(reader["AttachmentUrl"].ToString())) { noVM.AttachmentUrl = reader.AsString("AttachmentUrl"); } if (!string.IsNullOrEmpty(reader["FeedBackerID"].ToString())) { noVM.FeedBackerID = reader.AsInt("FeedBackerID"); } if (!string.IsNullOrEmpty(reader["FeedBackTime"].ToString())) { noVM.FeedBackTime = Convert.ToDateTime(reader["FeedBackTime"]); noVM.FeedBackTimeStr = noVM.FeedBackTime.Value.ToString("yyyy-MM-dd"); } else { noVM.FeedBackTimeStr = string.Empty; } if (!string.IsNullOrEmpty(reader["InputTime"].ToString())) { noVM.InputTime = Convert.ToDateTime(reader["InputTime"]); noVM.InputTimeStr = noVM.InputTime.Value.ToString("yyyy-MM-dd"); } else { noVM.InputTimeStr = string.Empty; } return(noVM); }); list.ForEach(item => { if (!string.IsNullOrEmpty(item.AttachmentUrl)) { var arr = HttpUtility.UrlDecode(item.AttachmentUrl).Split('>'); item.FilePath = arr.Length > 0 ? arr[0] : string.Empty; item.FileName = arr.Length > 1 ? arr[1] : string.Empty; } else { item.FilePath = string.Empty; item.FileName = string.Empty; } }); //获取数据总数 int totalCount = dbContext.Sql(sql).Query().Count; //总页数 double totalPages = ((double)totalCount / query.PageSize.Value); PageVM <NoticeVM> pageVM = new PageVM <NoticeVM>(); pageVM.Data = list; pageVM.TotalCount = totalCount; pageVM.TotalPages = (int)Math.Ceiling(totalPages); pageVM.PageIndex = query.PageIndex; return(pageVM); } }
/// <summary> /// 通知查询 /// </summary> /// <param name="query"></param> /// <returns></returns> public QueryResult <Notice> Query(NoticeQuery query) { return(DataBase.Query(query)); }