void cboLimit_SelectedIndexChanged(object sender, EventArgs e) { if (cboLimit.Enabled == false) { return; } _page = 0; try { PaginationModule _pm = this.ListofModule.Where(c => c.ModuleName == _currentModule).SingleOrDefault(); if (_pm != null) { if (_pm.PageLocked == true) { chkLocked_CheckedChanged(null, null); } } } catch (Exception) { } if (AfterLimitSelected != null) { AfterLimitSelected(this, new EventArgs()); } }
public static Dictionary <string, IModule> GetModules() { modules = new Dictionary <string, IModule>(); IModule filtersModule = new FiltersModule(); IModule sortingModule = new SortingModule(); IModule paginationModule = new PaginationModule(); modules.Add(filtersModule.ModuleName, filtersModule); modules.Add(sortingModule.ModuleName, sortingModule); modules.Add(paginationModule.ModuleName, paginationModule); return(modules); }
public void DontSetPaginationObject_WhenPaginationObjectInRequestIsNull() { // Arrange IModule paginationModule = new PaginationModule(); var requestJson = new ComboRequestJson() { Filters = new List <FilterObject>(), Pagination = null }; var settings = new ModulesSettings(); // Act var result = paginationModule.Initialize(requestJson, settings); // Assert Assert.IsNull(result.Pagination); }
public void ReturnNotNull_WhenPassingCorrectParameters() { // Arrange IModule paginationModule = new PaginationModule(); var requestJson = new ComboRequestJson() { Filters = new List <FilterObject>(), Pagination = new PaginationObject() }; var settings = new ModulesSettings(); // Act var result = paginationModule.Initialize(requestJson, settings); // Assert Assert.IsNotNull(result); }
private void chkLocked_CheckedChanged(object sender, EventArgs e) { if (chkLocked.Enabled == false) { return; } if (chkLocked.Checked == true) { try { PaginationModule _pm = this.ListofModule.Where(c => c.ModuleName == _currentModule).SingleOrDefault(); if (_pm != null) { ListofModule.Remove(_pm); } } catch (Exception) { } try { PaginationModule _new = new PaginationModule(); _new.ModuleName = _currentModule; _new.PageLocked = true; _new.Limit = cboLimit.Text; ListofModule.Add(_new); } catch (Exception) { } } else { try { PaginationModule _pm = this.ListofModule.Where(c => c.ModuleName == _currentModule).SingleOrDefault(); if (_pm != null) { ListofModule.Remove(_pm); } } catch (Exception) { } cboLimit.Enabled = false; cboLimit.Text = "100"; cboLimit.Enabled = true; } }
public void ReturnCorrectCollection_WhenPassingPaginationObject() { // Arrange IModule paginationModule = new PaginationModule(); var settings = new ModulesSettings { Pagination = new PaginationObject { Page = 2, PageSize = 2 } }; var collection = new List <Filter> { new Filter(), new Filter(), new Filter(), new Filter(), new Filter() }; // Act var result = paginationModule.ApplyExpression(collection, settings); // Assert Assert.AreEqual(2, result.Count()); }
public void GetData() { CheckForIllegalCrossThreadCalls = false; if (this.ListofModule != null) { try { PaginationModule _pm = this.ListofModule.Where(c => c.ModuleName == _currentModule).SingleOrDefault(); if (_pm != null) { if (_pm.PageLocked == true) { cboLimit.Enabled = false; chkLocked.Checked = true; cboLimit.Text = _pm.Limit; chkLocked.Enabled = false; chkLocked.Checked = true; chkLocked.Enabled = true; cboLimit.Enabled = true; } else if (_pm.PageLocked == false) { chkLocked.Enabled = false; chkLocked.Checked = false; chkLocked.Enabled = true; } } } catch (Exception) { chkLocked.Enabled = false; chkLocked.Checked = false; chkLocked.Enabled = true; } } else { chkLocked.Enabled = false; chkLocked.Checked = false; chkLocked.Enabled = true; } string _display = "Page {0} of {1}"; string _status = "Showing {0} to {1} of {2} entries"; string _cursearch = ""; if (_search == "" || _search == "''") { _cursearch = "''"; } else { _cursearch = "'%" + _search + "%'"; } long _limit = 0; if (cboLimit.Text != "ALL") { _limit = Convert.ToInt64(cboLimit.Text); } string _query = string.Format(_commandtext, (_cursearch == "''" ? _page : 0), _limit, _cursearch); DataTable _tb = new DataTable(); try { MySqlConnection _con = new MySqlConnection(ConnectionString); MySqlCommand _com = new MySqlCommand(_query, _con); MySqlDataAdapter _adp = new MySqlDataAdapter(_com); _com.CommandTimeout = 500; _adp.Fill(_tb); _con.Dispose(); _con = null; _com.Dispose(); _com = null; _adp.Dispose(); _adp = null; } catch (Exception) { } if (grid != null) { try { grid.DataSource = _tb; } catch (Exception) { } } if (cboLimit.Text != "ALL") { lblRecord.Text = "record per page"; flpPage.Visible = true; if (_tb.Columns.Contains("Total") && _tb.Rows.Count > 0) { _total = _tb.Rows[0].Field <long>("Total"); } long _recordfrom = (_page * _limit) + 1; long _recordto = (_recordfrom - 1) + _limit; decimal _temp = Convert.ToDecimal(_total) / Convert.ToDecimal(_limit); lblDisplay.Text = string.Format(_display, _page + 1, Math.Ceiling(_temp)); if (_page > Math.Ceiling(_temp)) { _page = _total; GetData(); return; } if (Math.Ceiling(_temp) == 1 || _page == Convert.ToInt32(Math.Ceiling(_temp)) - 1) { btnNext.Enabled = false; btnLast.Enabled = false; _recordto = _total; } else { btnNext.Enabled = true; btnLast.Enabled = true; } if (_page == 0) { btnFirst.Enabled = false; btnPrev.Enabled = false; } else { btnFirst.Enabled = true; btnPrev.Enabled = true; } if (_label != null) { _label.Text = _total == 0 ? "No record to display" : String.Format(_status, _recordfrom, _recordto, _total); _label.Width = 170; } this.Visible = (_total > 100); } else { if (_tb.Columns.Contains("Total") && _tb.Rows.Count > 0) { _total = _tb.Rows[0].Field <long>("Total"); } this.Visible = (_total > 100); lblRecord.Text = "record"; flpPage.Visible = false; } foreach (Column _col in grid.Cols) { if (_col.DataType != null) { if (_col.DataType.Name == typeof(System.DateTime).Name) { _col.Format = "yyyy-MM-dd"; _col.TextAlign = TextAlignEnum.CenterCenter; } } } if (grid.Cols.Contains("...")) { grid.Cols["..."].AllowResizing = false; grid.Cols["..."].AllowSorting = false; grid.Cols["..."].Width = 45; grid.Cols["..."].TextAlignFixed = TextAlignEnum.CenterCenter; } if (grid.Cols.Contains("Total")) { grid.Cols["Total"].Visible = false; } grid.Cols[0].Visible = false; grid.AllowFreezing = AllowFreezingEnum.None; grid.Cols.Frozen = 2; grid.AllowEditing = false; grid.AllowDelete = false; grid.AutoSizeCols(2, grid.Cols.Count - 1, 0); if (AfterDataLoaded != null) { AfterDataLoaded(this, new EventArgs()); } }