public DbQueryResult Query(VoteSearch query) { StringBuilder builder = new StringBuilder("1=1 "); if (query.status != VoteStatus.All) { if (query.status == VoteStatus.In) { builder.AppendFormat("and [StartDate] <= '{0}' and [EndDate] >= '{0}'", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } else if (query.status == VoteStatus.End) { builder.AppendFormat("and [EndDate] < '{0}'", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } else if (query.status == VoteStatus.unBegin) { builder.AppendFormat("and [StartDate] > '{0}'", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } } if (!string.IsNullOrEmpty(query.Name)) { builder.AppendFormat("and VoteName like '%{0}%' ", query.Name); } return(DataHelper.PagingByRownumber(query.PageIndex, query.PageSize, query.SortBy, query.SortOrder, query.IsCount, "Hishop_Votes", "VoteId", builder.ToString(), "*")); }
private void CountTotal() { VoteSearch query = new VoteSearch { IsCount = true, PageIndex = this.pager.PageIndex, PageSize = this.pager.PageSize, SortBy = "VoteId", SortOrder = SortAction.Desc, status = VoteStatus.In }; DbQueryResult result = VoteHelper.Query(query); this.lblIn.Text = (result.Data != null) ? result.TotalRecords.ToString() : "0"; query.status = VoteStatus.End; result = VoteHelper.Query(query); this.lblEnd.Text = (result.Data != null) ? result.TotalRecords.ToString() : "0"; query.status = VoteStatus.unBegin; result = VoteHelper.Query(query); this.lblUnBegin.Text = (result.Data != null) ? result.TotalRecords.ToString() : "0"; }
private void CountTotal() { VoteSearch voteSearch = new VoteSearch(); voteSearch.status = this.status; voteSearch.IsCount = true; voteSearch.PageIndex = this.pager.PageIndex; voteSearch.PageSize = this.pager.PageSize; voteSearch.SortBy = "VoteId"; voteSearch.SortOrder = SortAction.Desc; voteSearch.status = VoteStatus.In; DbQueryResult dbQueryResult = VoteHelper.Query(voteSearch); this.lblIn.Text = ((dbQueryResult.Data != null) ? dbQueryResult.TotalRecords.ToString() : "0"); voteSearch.status = VoteStatus.End; dbQueryResult = VoteHelper.Query(voteSearch); this.lblEnd.Text = ((dbQueryResult.Data != null) ? dbQueryResult.TotalRecords.ToString() : "0"); voteSearch.status = VoteStatus.unBegin; dbQueryResult = VoteHelper.Query(voteSearch); this.lblUnBegin.Text = ((dbQueryResult.Data != null) ? dbQueryResult.TotalRecords.ToString() : "0"); }
public static DbQueryResult Query(VoteSearch query) { return(_vote.Query(query)); }
public Task <ActionResult <List <VoteView> > > GetVotesAsync([FromQuery] VoteSearch search) { return(ThrowToAction(() => service.SearchAsync(search, GetRequesterNoFail()))); }
private void BindData() { string str = this.txt_name.Text.Trim(); VoteSearch query = new VoteSearch { status = this.status, IsCount = true, PageIndex = this.pager.PageIndex, PageSize = this.pager.PageSize, SortBy = "VoteId", SortOrder = SortAction.Desc, Name = str }; DbQueryResult result = VoteHelper.Query(query); DataTable data = (DataTable)result.Data; if (data != null) { data.Columns.Add("sStatus"); data.Columns.Add("sType"); data.Columns.Add("sAttend"); string str2 = ""; if (data.Rows.Count > 0) { foreach (DataRow row in data.Rows) { DateTime time = DateTime.Parse(row["startDate"].ToString()); DateTime time2 = DateTime.Parse(row["endDate"].ToString()); bool flag = bool.Parse(row["IsMultiCheck"].ToString()); int num = int.Parse(row["voteId"].ToString()); if (time > DateTime.Now) { row["sStatus"] = "未开始"; } else if (time2 < DateTime.Now) { row["sStatus"] = "已结束"; } else { row["sStatus"] = "进行中"; } if (flag) { row["sType"] = "多选"; } else { row["sType"] = "单选"; } row["sAttend"] = VoteHelper.GetVoteAttends((long)num); str2 = str2 + ", " + num.ToString(); } if (str2.Length > 1) { str2 = str2.Substring(1); } } } this.grdDate.DataSource = data; this.grdDate.DataBind(); this.pager.TotalRecords = result.TotalRecords; this.CountTotal(); }
public static DbQueryResult Query(VoteSearch query) { return(new VoteDao().Query(query)); }