public void Refresh(StyleGuide.API api, Int32 pPageNo) { StyleGuide.PagingInfo pgInf = null; if (pPageNo > 0) { pgInf = new StyleGuide.PagingInfo(); pgInf.RecordsPerPage = REC_PER_PAGE; pgInf.CurrentPage = pPageNo; } StyleGuide.SgCategories.Categories cats = null; if (!string.IsNullOrWhiteSpace(tbSearch.Text)) { if (this.rbSearchOpt.SelectedItem.Value == "C") { cats = api.getAllCategoriesNameContains(tbSearch.Text, pgInf); } else { cats = api.getAllCategoriesNameStartsWith(tbSearch.Text, pgInf); } } else { cats = api.getAllCategories(pgInf); } this.gvCatList.DataSource = cats; this.gvCatList.DataBind(); SetPaging(cats, (pPageNo == -1 ? true : false)); }
public void Refresh(StyleGuide.API api, Int32 pPageNo, string searchText = null) { StyleGuide.PagingInfo pgInf = null; if (pPageNo > 0) { pgInf = new StyleGuide.PagingInfo(); pgInf.RecordsPerPage = REC_PER_PAGE; pgInf.CurrentPage = pPageNo; } if (searchText != null) { tbSearch.Text = searchText; } StyleGuide.SgEntities.Entities ents = null; if (!string.IsNullOrWhiteSpace(tbSearch.Text)) { if (tbSearch.Text.StartsWith("{ID}")) { string temp = tbSearch.Text.Replace("{ID}", ""); if (StyleGuideUI.App_Code.SgCommon.IsNumeric(temp)) { long entID = Convert.ToInt64(temp); StyleGuide.SgEntities.Entity ent = null; ent = api.getEntityByID(entID); ents = new StyleGuide.SgEntities.Entities(); ents.Add(ent); } else { ents = api.getAllEntities(pgInf); } } else { if (this.rbSearchOpt.SelectedItem.Value == "C") { ents = api.getAllEntitiesNameContains(tbSearch.Text, pgInf); } else { ents = api.getAllEntitiesNameStartsWith(tbSearch.Text, pgInf); } } } else { ents = api.getAllEntities(pgInf); } this.gvEntList.DataSource = ents; this.gvEntList.DataBind(); SetPaging(ents, (pPageNo == -1 ? true : false)); }
protected void btNew_Click(object sender, EventArgs e) { StyleGuide.API api = new StyleGuide.API(); try { this.tbSearch.Text = ""; btSave_Click(this.btSave, null); Refresh(api, UcPaging1.TotalPages); StyleGuide.PagingInfo pgInf = null; if (this.UcPaging1.CurrentPage > 0) { pgInf = new StyleGuide.PagingInfo(); pgInf.RecordsPerPage = REC_PER_PAGE; pgInf.CurrentPage = this.UcPaging1.TotalPages; } StyleGuide.SgCategories.Categories cats = api.getAllCategories(pgInf); if (cats == null) { cats = new StyleGuide.SgCategories.Categories(); } StyleGuide.SgCategories.Category cat = new StyleGuide.SgCategories.Category(); cat.ID = -1; cat.Name = "New "; cats.Add(cat); this.gvCatList.DataSource = cats; this.gvCatList.DataBind(); SetPaging(cats, true); } catch (Exception ex) { ShowErrorMessage("Error on CreateNew(). " + ex.Message); } finally { api.Dispose(); } }