Exemple #1
0
        protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            //In-built paging implementation
            MainGridView.PageIndex = e.NewPageIndex;
            MainGridView.DataBind();

            if (ViewState[Prefix + "CurrentPageIndex"] == null)
            {
                ViewState.Add(Prefix + "CurrentPageIndex", e.NewPageIndex);
            }
            else
            {
                ViewState[Prefix + "CurrentPageIndex"] = e.NewPageIndex;
            }

            //Synchronize with custom paging
            oGridPagiation = new GridPagiation();

            dtGlobal = GetData();

            oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory);
            oGridPagiation.Changed           += oGridPagiation_Changed;
            oGridPagiation.PageIndexInSession = e.NewPageIndex;
            oGridPagiation.ManagePaging(dtGlobal);
        }
Exemple #2
0
        private void RetrieveRecords(StringCollection sc, ActionCommand cmd)
        {
            try
            {
                ShowSelectedRecords(sc, cmd);

                var dt1 = new DataTable();

                if (_getData != null)
                {
                    dt1 = _getData();
                }
                else
                {
                    dt1 = GetGroupedRecords();
                }

                MainGridView.DataSource = dt1;
                MainGridView.DataBind();

                oGridPagiation = new GridPagiation();
                oGridPagiation.Setup(plcPaging, litPagingSummary, dt1, MainGridView, Page);
                oGridPagiation.Changed += oGridPagiation_Changed;
                oGridPagiation.ManagePaging(dt1);

                numberedPager.Setup(dt1.Rows.Count, MainGridView);
                numberedPager.Changed += oGridPagiation_Changed;
            }
            catch (Exception ex)
            {
                var msg = "Deletion Error:";
                msg += ex.Message;
                throw new Exception(msg);
            }
        }
Exemple #3
0
        public void Setup(string tableName, GetDataDelegate getDataDelegate, GetColumnDelegate getColumnDelegate, bool pageLoad, bool isPaging)
        {
            lblHeader.Text = "Top " + tableName;
            if (ViewState[Prefix + "TableName"] == null)
            {
                ViewState.Add(Prefix + "TableName", tableName);
            }

            if (ViewState[Prefix + "TableName"] != null && !(ViewState[Prefix + "TableName"].ToString().Equals(tableName)))
            {
                ViewState[Prefix + "TableName"]        = tableName;
                ViewState[Prefix + "CurrentPageIndex"] = 0;
            }

            ViewState["TableName"] = tableName;
            //ViewState["IsTesting"] = SessionVariables.IsTesting;
            ViewState["PageLoad"] = pageLoad;

            _getColumnDelegate = getColumnDelegate;
            _getData           = getDataDelegate;

            dtGlobal = _getData();

            Sample(dtGlobal, HideData, SessionVariables.IsTesting);
            MainGridView.DataSource = dtGlobal;

            if (isPaging)
            {
                MainGridView.PageSize = DefaultRowCount;

                oGridPagiation = new GridPagiation();
                oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory);
                oGridPagiation.Changed += oGridPagiation_Changed;

                if (ViewState[Prefix + "CurrentPageIndex"] != null)
                {
                    oGridPagiation.PageIndexInSession = int.Parse(ViewState[Prefix + "CurrentPageIndex"].ToString());
                }

                oGridPagiation.ManagePaging(dtGlobal);
            }
            else
            {
                MainGridView.AllowPaging = isPaging;
            }
            MainGridView.DataBind();
        }
Exemple #4
0
        private void RefreshGrid()
        {
            if (ViewState[Prefix + "CurrentPageIndex"] != null)
            {
                MainGridView.PageIndex = int.Parse(ViewState[Prefix + "CurrentPageIndex"].ToString());
            }
            else
            {
                MainGridView.PageIndex = 0;
            }
            MainGridView.DataBind();

            oGridPagiation = new GridPagiation();
            dtGlobal       = GetData();
            oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory);
            oGridPagiation.Changed           += oGridPagiation_Changed;
            oGridPagiation.PageIndexInSession = MainGridView.PageIndex;
            oGridPagiation.ManagePaging(dtGlobal);
            if (ViewState[Prefix + "SortExpression"] != null && ViewState[Prefix + "SortDirection"] != null)
            {
                SortGridView(ViewState[Prefix + "SortExpression"].ToString(), ViewState[Prefix + "SortDirection"].ToString());
            }
        }
Exemple #5
0
        public void Setup(int systemEntityId, int entityKey, string UserPreferenceCategory = "")
        {
            var tableName  = "AuditHistory";
            var primaryKey = "AuditHistoryId";
            var isPaging   = true;

            SystemEntityTypeId = systemEntityId;
            EntityKey          = entityKey;
            Prefix             = entityKey.ToString();

            var userPreferenceCategory = UserPreferenceCategory;

            if (string.IsNullOrEmpty(userPreferenceCategory))
            {
                userPreferenceCategory = tableName;
            }

            SetViewState();

            var userGrouping = PerferenceUtility.GetUserPreferenceByKey(ApplicationCommon.HistoryAdvancedModeGroupingKey, userPreferenceCategory);

            if (userGrouping == "timeinterval")
            {
                AdvancedModeGrouping = GridViewAdvancedModeGrouping.TimeInterval;
                txtInterval.Text     = Convert.ToString(ConvertTimeIntervalInMinute(PerferenceUtility.GetUserPreferenceByKeyAsInt(ApplicationCommon.HistoryAdvancedModeIntervalKey)));
                drpAdvancedModeGrouping.SelectedValue = "timeinterval";
                dynIntervalMode.Visible = true;
            }
            else
            {
                dynIntervalMode.Visible = false;
                if (userGrouping == "auditaction")
                {
                    AdvancedModeGrouping = GridViewAdvancedModeGrouping.AuditAction;
                    drpAdvancedModeGrouping.SelectedValue = "auditaction";
                }
                else if (userGrouping == "actionby")
                {
                    AdvancedModeGrouping = GridViewAdvancedModeGrouping.ActionByAndAuditAction;
                    drpAdvancedModeGrouping.SelectedValue = "actionby";
                }
            }


            dtGlobal = GetData();

            Sample(dtGlobal, primaryKey, HideData, SessionVariables.IsTesting);
            MainGridView.DataSource = dtGlobal;

            if (isPaging)
            {
                MainGridView.PageSize = SessionVariables.DefaultRowCount;

                oGridPagiation = new GridPagiation();
                oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory);
                oGridPagiation.Changed += oGridPagiation_Changed;

                if (ViewState[Prefix + "CurrentPageIndex"] != null)
                {
                    oGridPagiation.PageIndexInSession = int.Parse(ViewState[Prefix + "CurrentPageIndex"].ToString());
                }

                oGridPagiation.ManagePaging(dtGlobal);
            }
            else
            {
                MainGridView.AllowPaging = isPaging;
            }
            MainGridView.DataBind();
        }
Exemple #6
0
        public void Setup(
            string tableName, string tableFolder, string primaryKey, bool pageLoad
            , GetDataDelegate getDataDelegate, GetColumnDelegate getColumnDelegate
            , bool isPaging, int entityKey, string UserPreferenceCategory = "")
        {
            EntityKey = entityKey;
            Prefix    = entityKey.ToString();

            _getData                 = getDataDelegate;
            _getColumnDelegate       = getColumnDelegate;
            ViewState["TableFolder"] = tableFolder;
            ViewState["TableName"]   = tableName;

            var userPreferenceCategory = UserPreferenceCategory;

            if (string.IsNullOrEmpty(userPreferenceCategory))
            {
                userPreferenceCategory = tableName;
            }

            if (ViewState[Prefix + "TableName"] == null)
            {
                ViewState.Add(Prefix + "TableName", tableName);
            }

            if (ViewState[Prefix + "TableName"] != null && !(ViewState[Prefix + "TableName"].ToString().Equals(tableName)))
            {
                ViewState[Prefix + "TableName"]        = tableName;
                ViewState[Prefix + "CurrentPageIndex"] = 0;
            }

            ViewState["TableName"]  = tableName;
            ViewState["PrimaryKey"] = primaryKey;
            //ViewState["IsTesting"] = SessionVariables.IsTesting;
            ViewState["PageLoad"] = pageLoad;

            dtGlobal = GetData();

            Sample(dtGlobal, primaryKey, HideData, SessionVariables.IsTesting);
            MainGridView.DataSource = dtGlobal;

            if (isPaging)
            {
                MainGridView.PageSize = DefaultRowCount;

                oGridPagiation = new GridPagiation();
                oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory);
                oGridPagiation.Changed += oGridPagiation_Changed;

                if (ViewState[Prefix + "CurrentPageIndex"] != null)
                {
                    oGridPagiation.PageIndexInSession = int.Parse(ViewState[Prefix + "CurrentPageIndex"].ToString());
                }

                oGridPagiation.ManagePaging(dtGlobal);
            }
            else
            {
                MainGridView.AllowPaging = isPaging;
            }

            MainGridView.DataBind();
        }
Exemple #7
0
        protected void chkSelectAll_CheckedChanged(object sender, EventArgs e)
        {
            var currentpage     = int.Parse(CurrentPageIndex.ToString());
            var currentpagesize = MainGridView.PageSize;
            //var totalnumofrows = MainGridView.Rows.Count;

            var floor = (currentpage * currentpagesize);
            var ceil  = ((currentpage * currentpagesize) + currentpagesize) - 1;

            //var sc = new StringCollection();
            //var id = string.Empty;

            var dt1 = new DataTable();

            var selectall  = SelectAllCheckBox;
            var chkchecked = selectall.Checked;

            if (!string.IsNullOrEmpty(SessionVariables.SortExpression) && !string.IsNullOrEmpty(SessionVariables.SortDirection))
            {
                skipgridreload = true;
                dt1            = SortGridView(SessionVariables.SortExpression, SessionVariables.SortDirection);
                skipgridreload = false;
            }
            else
            {
                dt1 = dtGlobal;
            }

            MainGridView.DataSource = dt1;
            MainGridView.DataBind();

            oGridPagiation = new GridPagiation();
            oGridPagiation.Setup(plcPaging, litPagingSummary, dt1, MainGridView, Page);
            oGridPagiation.Changed += oGridPagiation_Changed;
            oGridPagiation.ManagePaging(dt1);

            numberedPager.Setup(dt1.Rows.Count, MainGridView);
            numberedPager.Changed += oGridPagiation_Changed;

            ListHelper.AddCheckBox(MainGridView);

            SelectAllCheckBox.Checked = chkchecked;



            //loop the GridView Rows
            var j = 0;

            for (var i = floor; i <= ceil; i++)
            {
                if (j < MainGridView.Rows.Count)
                {
                    var cb = (CheckBox)MainGridView.Rows[j].Cells[0].FindControl("CheckBox1");                     //find the CheckBox

                    if (cb == null)
                    {
                        for (var k = 0; k < MainGridView.Rows[j].Cells[0].Controls.Count; k++)
                        {
                            if (MainGridView.Rows[j].Cells[0].Controls[k].ID.Equals("CheckBox1"))
                            {
                                cb = (CheckBox)MainGridView.Rows[j].Cells[0].Controls[k];
                            }
                        }
                    }

                    if (cb != null && SelectAllCheckBox != null)
                    {
                        if (SelectAllCheckBox.Checked)
                        {
                            if (!cb.Checked)
                            {
                                cb.Checked = true;                                 // add the id to be deleted in the StringCollection
                            }
                        }
                        else
                        {
                            if (cb.Checked)
                            {
                                cb.Checked = false;
                            }
                        }
                    }

                    j++;
                }
            }

            if (SelectAllCheckBox.Checked)
            {
                ButtonDelete.Enabled       = true;
                ButtonUpdate.Enabled       = true;
                ButtonDetails.Enabled      = true;
                ButtonCommonUpdate.Enabled = true;
                ButtonInlineUpdate.Enabled = true;

                ButtonDetails.Style.Add("background-color", "#B40404");
                ButtonDelete.Style.Add("background-color", "#B40404");
                ButtonUpdate.Style.Add("background-color", "#B40404");
                ButtonCommonUpdate.Style.Add("background-color", "#B40404");
                ButtonInlineUpdate.Style.Add("background-color", "#B40404");

                //ButtonDetails.Style.Add("display",""); //below 3 lines added to make the Delete, Details, Update buttons visible.
                //ButtonUpdate.Style.Add("display", "");
                //ButtonDelete.Style.Add("display", "");
            }
            else
            {
                ButtonDelete.Enabled       = false;
                ButtonUpdate.Enabled       = false;
                ButtonDetails.Enabled      = false;
                ButtonCommonUpdate.Enabled = false;
                ButtonInlineUpdate.Enabled = false;

                ButtonDetails.Style.Add("background-color", "#808080");
                ButtonDelete.Style.Add("background-color", "#808080");
                ButtonUpdate.Style.Add("background-color", "#808080");
                ButtonCommonUpdate.Style.Add("background-color", "#808080");
                ButtonInlineUpdate.Style.Add("background-color", "#808080");


                //ButtonDetails.Style.Add("display", "none");//below 3 lines added to make the Delete, Details, Update buttons invisible.
                //ButtonUpdate.Style.Add("display", "none");
                //ButtonDelete.Style.Add("display", "none");
            }
        }