예제 #1
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);
            }
        }
예제 #2
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);
        }
예제 #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();
        }
예제 #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());
            }
        }
예제 #5
0
        private DataTable SortGridView(string sortExpression, string sortDirection)
        {
            var tableFolder  = ViewState["TableFolder"].ToString();
            var tableName    = ViewState["TableName"].ToString();
            var primaryKeyId = ViewState["PrimaryKey"].ToString();
            //var isTesting = (bool)(ViewState["IsTesting"]);
            var currentpage     = MainGridView.PageIndex;
            var currentpagesize = MainGridView.PageSize;
            var totalnumofrows  = MainGridView.Rows.Count;
            var dtlocal         = new DataTable();
            var sortedtable     = new DataTable();
            var dtlocal2        = new DataTable();

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

            if (ceil > dtGlobal.Rows.Count)
            {
                ceil = dtGlobal.Rows.Count - 1;
            }

            if (ViewState["SessionUpdated"] != null)
            {
                dtGlobal = GetData();
            }
            else
            {
                dtGlobal = GetDataSet(tableName);
            }

            //Extract Sort Info from Session
            if (ViewState[Prefix + "SortExpression"] != null)
            {
                if (dtGlobal.Columns.Contains(ViewState[Prefix + "SortExpression"].ToString()))
                {
                    sortExpression = ViewState[Prefix + "SortExpression"].ToString();
                }
            }
            if (ViewState[Prefix + "SortDirection"] != null)
            {
                sortDirection = ViewState[Prefix + "SortDirection"].ToString();
            }
            else
            {
                if (sortDirection.Equals("Ascending"))
                {
                    sortDirection = "ASC";
                }
                else
                {
                    sortDirection = "DESC";
                }
            }


            var columns  = new string[dtGlobal.Columns.Count];
            var coltypes = new Type[dtGlobal.Columns.Count];
            var cnt      = 0;

            //create Data Table objects
            foreach (DataColumn column in dtGlobal.Columns)
            {
                columns[cnt]  = column.ColumnName;
                coltypes[cnt] = column.GetType();
                cnt++;
            }


            dtlocal.Clear();
            dtlocal.Reset();
            for (var i = 0; i < columns.Length; i++)
            {
                var dc = new DataColumn(columns[i], typeof(string));
                sortedtable.Columns.Add(dc);
                var dc2 = new DataColumn(columns[i], typeof(string));
                dtlocal.Columns.Add(dc2);
                var dc3 = new DataColumn(columns[i], typeof(string));
                dtlocal2.Columns.Add(dc3);
            }

            //Load dtlocal with current rows in view
            for (var i = floor; i <= ceil; i++)
            {
                if (dtGlobal.Rows.Count >= ceil && i < dtGlobal.Rows.Count)
                {
                    dtlocal.ImportRow(dtGlobal.Rows[i]);
                }
            }

            //sort current rows in view
            if (!string.IsNullOrEmpty(sortExpression))
            {
                dtlocal2 = SortDataTable(dtlocal, sortExpression, sortDirection);
            }

            //rebuild the datatable with sorted rows in view and rest of the rows
            for (var i = 0; i < dtGlobal.Rows.Count; i++)
            {
                if (i == floor)
                {
                    for (var j = 0; j <= dtlocal2.Rows.Count - 1; j++)
                    {
                        if (dtlocal2.Rows[j] != null)
                        {
                            sortedtable.ImportRow(dtlocal2.Rows[j]);
                        }
                        else
                        {
                            sortedtable.ImportRow(dtGlobal.Rows[j]);
                        }
                    }
                    i = ceil + 1;
                }
                if (i < dtGlobal.Rows.Count)
                {
                    sortedtable.ImportRow(dtGlobal.Rows[i]);
                }
            }

            // fix this name ..
            Sample(dtGlobal, primaryKeyId, HideData, SessionVariables.IsTesting);

            var dv = dtGlobal.DefaultView;


            // if blank, only should really be the first time
            // then we don't want to appened the sort instruction
            if (!string.IsNullOrEmpty(sortExpression) && dtGlobal.Columns.Contains(sortExpression))
            {
                dv.Sort = sortExpression + " " + sortDirection;
                //System.Diagnostics.Debug.WriteLine(dv.Sort);
            }

            //Bind data based on the sort selection
            if (!skipgridreload)
            {
                //if (RadioButtonList1.SelectedItem.Value.Equals("FTSort"))
                //{
                MainGridView.DataSource = dv;
                MainGridView.DataBind();
                //}
                //else
                //{
                //    MainGridView.DataSource = sortedtable;
                //    MainGridView.DataBind();
                //}
                if (MainGridView.AllowPaging)
                {
                    if (ViewState[Prefix + "CurrentPageIndex"] != null)
                    {
                        oGridPagiation.PageIndexInSession = int.Parse(ViewState[Prefix + "CurrentPageIndex"].ToString());
                    }
                    oGridPagiation.RefreshGrid = false;
                    oGridPagiation.ManagePaging(dtGlobal);
                }
            }
            //if (RadioButtonList1.SelectedItem.Value.Equals("FTSort"))
            //{
            return(dv.ToTable(ViewState["TableName"].ToString()));
            //}
            //else
            //{
            //    return sortedtable;
            //}
        }
예제 #6
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();
        }
예제 #7
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();
        }
예제 #8
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");
            }
        }
예제 #9
0
        private DataTable SortGridView(string sortExpression, string sortDirection)
        {
            var tableName        = ViewState["TableName"].ToString();
            var primaryKeyId     = ViewState["PrimaryKey"].ToString();
            var isTesting        = (bool)(ViewState["IsTesting"]);
            var customizedSearch = CustomizedSearch;

            var currentpage     = MainGridView.PageIndex;
            var currentpagesize = MainGridView.PageSize;
            var totalnumofrows  = MainGridView.Rows.Count;

            var dtlocal     = new DataTable();
            var sortedtable = new DataTable();
            var dtlocal2    = new DataTable();

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

            if (ceil > dtGlobal.Rows.Count)
            {
                ceil = dtGlobal.Rows.Count - 1;
            }

            if (customizedSearch && ViewState["SessionUpdated"] != null)
            {
                if (_getData != null)
                {
                    dtGlobal = _getData();
                }
                else
                {
                    dtGlobal = GetGroupedRecords();
                }
            }
            else
            {
                dtGlobal = GetDataSet(tableName);
            }

            //Extract Sort Info from Session

            if (!string.IsNullOrEmpty(SessionVariables.SortExpression))
            {
                if (dtGlobal.Columns.Contains(SessionVariables.SortExpression))
                {
                    sortExpression = SessionVariables.SortExpression;
                }
            }

            if (!string.IsNullOrEmpty(SessionVariables.SortDirection))
            {
                sortDirection = SessionVariables.SortDirection;
            }
            else
            {
                if (sortDirection.Equals("Ascending"))
                {
                    sortDirection = "ASC";
                }
                else
                {
                    sortDirection = "DESC";
                }
            }

            //Check which sort is selected
            //If View Sort is selected
            if (RadioButtonList1.SelectedItem.Value.Equals("VSort"))
            {
                var columns  = new string[dtGlobal.Columns.Count];
                var coltypes = new Type[dtGlobal.Columns.Count];

                var cnt = 0;

                //create Data Table objects
                foreach (DataColumn column in dtGlobal.Columns)
                {
                    columns[cnt]  = column.ColumnName;
                    coltypes[cnt] = column.GetType();
                    cnt++;
                }

                dtlocal.Clear();
                dtlocal.Reset();

                for (var i = 0; i < columns.Length; i++)
                {
                    var dc = new DataColumn(columns[i], typeof(string));
                    sortedtable.Columns.Add(dc);

                    var dc2 = new DataColumn(columns[i], typeof(string));
                    dtlocal.Columns.Add(dc2);

                    var dc3 = new DataColumn(columns[i], typeof(string));
                    dtlocal2.Columns.Add(dc3);
                }

                //Load dtlocal with current rows in view
                for (var i = floor; i <= ceil; i++)
                {
                    if (dtGlobal.Rows.Count >= ceil && i < dtGlobal.Rows.Count)
                    {
                        dtlocal.ImportRow(dtGlobal.Rows[i]);
                    }
                }

                //sort current rows in view
                if (!string.IsNullOrEmpty(sortExpression))
                {
                    dtlocal2 = ListHelperSort.SortDataTable(dtlocal, sortExpression, sortDirection);
                }

                //rebuild the datatable with sorted rows in view and rest of the rows
                for (var i = 0; i < dtGlobal.Rows.Count; i++)
                {
                    if (i == floor)
                    {
                        for (var j = 0; j <= dtlocal2.Rows.Count - 1; j++)
                        {
                            if (dtlocal2.Rows[j] != null)
                            {
                                sortedtable.ImportRow(dtlocal2.Rows[j]);
                            }
                            else
                            {
                                sortedtable.ImportRow(dtGlobal.Rows[j]);
                            }
                        }

                        i = ceil + 1;
                    }

                    if (i < dtGlobal.Rows.Count)
                    {
                        sortedtable.ImportRow(dtGlobal.Rows[i]);
                    }
                }
            }

            // fix this name ..
            BindColumns(dtGlobal, tableName, primaryKeyId, HideData, isTesting);

            var dv = dtGlobal.DefaultView;

            // if blank, only should really be the first time
            // then we don't want to appened the sort instruction
            if (!string.IsNullOrEmpty(sortExpression) && dtGlobal.Columns.Contains(sortExpression))
            {
                dv.Sort = sortExpression + " " + sortDirection;
                //System.Diagnostics.Debug.WriteLine(dv.Sort);
            }

            //Bind data based on the sort selection
            if (!skipgridreload)
            {
                if (RadioButtonList1.SelectedItem.Value.Equals("FTSort"))
                {
                    MainGridView.DataSource = dv;
                    MainGridView.DataBind();
                }
                else
                {
                    MainGridView.DataSource = sortedtable;
                    MainGridView.DataBind();
                }

                CurrentPageIndex = MainGridView.PageIndex;
                if (MainGridView.AllowPaging)
                {
                    numberedPager.Setup(dtGlobal.Rows.Count, MainGridView);
                    numberedPager.CurrentIndex = CurrentPageIndex.Value;
                    numberedPager.CreateNumberedPagingControl();
                    if (oGridPagiation != null)
                    {
                        oGridPagiation.refreshgrid = false;
                        oGridPagiation.ManagePaging(dtGlobal);
                    }
                }
                DisableMultipleDelete(ViewState["TableName"].ToString());
                //if (disabledelete)
                //    disabledeletefunctionality();

                //stylefkcolumns();
                if (!string.IsNullOrEmpty(FieldConfigurationMode))
                {
                    ListHelper.StyleDataRows(MainGridView, ViewState, int.Parse(FieldConfigurationMode));
                }
                else
                {
                    ListHelper.StyleDataRows(MainGridView, ViewState, -1);
                }
            }

            if (RadioButtonList1.SelectedItem.Value.Equals("FTSort"))
            {
                return(dv.ToTable(ViewState["TableName"].ToString()));
            }
            else
            {
                return(sortedtable);
            }
        }