private void tabPage_Search( string kw, string modelName, DataFileInfoSelectTop info, TabPageCustom page, ListViewModelItem grid, Label lbl_PageCurrent, Label lbl_PageTotal, Label lbl_TotalRecord) { //grid.DataSource = null; string predicate = ""; if (string.IsNullOrEmpty(kw)) { page.SearchRequest = null; page.SearchResult = null; page.PageCurrent = 1; lbl_PageCurrent.Text = page.PageCurrent.ToString(); int countPage = (int)(info.TotalRecord / selectTop) + (info.TotalRecord % selectTop == 0 ? 0 : 1); lbl_PageTotal.Text = countPage.ToString(); lbl_TotalRecord.Text = "Records: " + info.DataSelectTop.Count.ToString() + " / " + info.TotalRecord.ToString() + " "; grid.SetDataBinding(info.Fields, info.DataSelectTop); } else { StringBuilder wh_Contain = new StringBuilder(); for (int k = 0; k < info.Fields.Length; k++) { var dp = info.Fields[k]; wh_Contain.Append(dp.Name + (dp.Type.Name == "String" ? string.Empty : ".ToString()") + ".Contains(@0) "); if (k < info.Fields.Length - 1) { wh_Contain.Append(" || "); } } List <object> lp = new List <object>(); predicate = wh_Contain.ToString(); lp.Add(kw); SearchRequest sr = new SearchRequest(selectTop, 1, predicate, lp.Count == 0 ? null : lp.ToArray()); SearchResult rs = db.Search(modelName, sr); page.SearchRequest = sr; page.SearchResult = rs; if (rs != null) { page.PageCurrent = rs.PageNumber; lbl_PageCurrent.Text = page.PageCurrent.ToString(); int countPage = (int)(rs.Total / selectTop) + (rs.Total % selectTop == 0 ? 0 : 1); lbl_PageTotal.Text = countPage.ToString(); lbl_TotalRecord.Text = "Records: " + rs.IDs.Length.ToString() + " / " + info.TotalRecord.ToString() + " "; grid.SetDataBinding(info.Fields, (IList)rs.Message); } } }
private void tabPage_Next( string modelName, DataFileInfoSelectTop info, TabPageCustom page, ListViewModelItem grid, Label lbl_PageCurrent, Label lbl_PageTotal, Label lbl_TotalRecord) { SearchRequest sr = page.SearchRequest; SearchResult rs = page.SearchResult; if (sr == null) { int PageNumber = page.PageCurrent + 1; if (PageNumber > int.Parse(lbl_PageTotal.Text)) { return; } page.PageCurrent = PageNumber; lbl_PageCurrent.Text = page.PageCurrent.ToString(); grid.SetDataBinding(info.Fields, db.GetSelectPage(modelName, PageNumber, selectTop)); } else { sr.PageNumber = sr.PageNumber + 1; if (sr.PageNumber > int.Parse(lbl_PageTotal.Text)) { return; } rs = db.Search(modelName, sr); page.SearchRequest = sr; page.SearchResult = rs; if (rs != null) { page.PageCurrent = rs.PageNumber; lbl_PageCurrent.Text = page.PageCurrent.ToString(); lbl_TotalRecord.Text = "Records: " + rs.IDs.Length.ToString() + " / " + info.TotalRecord.ToString() + " "; grid.SetDataBinding(info.Fields, (IList)rs.Message); } } }