Ejemplo n.º 1
0
 private void RetrieveRecords(StringCollection sc, Command cmd)
 {
     try
     {
         ShowSelectedRecords(sc, cmd);
         var dt1 = new DataTable();
         if (_getData != null)
         {
             dt1 = _getData();
             MainGridView.DataSource = dt1;
             MainGridView.DataBind();
         }
         oGridPagiation = new GridPagiation();
         oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dt1, MainGridView, Page, SettingCategory);
         oGridPagiation.Changed += oGridPagiation_Changed;
         oGridPagiation.ManagePaging(dt1);
     }
     catch (Exception ex)
     {
         string msg = "Deletion Error:";
         msg += ex.Message;
         throw new Exception(msg);
     }
     finally
     {
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="tableFolder"></param>
        /// <param name="primaryKey"></param>
        /// <param name="pageLoad"></param>
        /// <param name="getDataDelegate"></param>
        /// <param name="getColumnDelegate"></param>
        /// <param name="isPaging">flag for paging</param>
        public void Setup(string tableName, string tableFolder, string primaryKey, bool pageLoad, GetDataDelegate getDataDelegate, GetColumnDelegate getColumnDelegate, bool isPaging, bool isUpdateColumn = true, bool isDeleteColumn = true, string userPreferenceCategory = "")
        {
            _getData           = getDataDelegate;
            _getColumnDelegate = getColumnDelegate;

            ViewState["TableFolder"] = tableFolder;
            if (!string.IsNullOrEmpty(SessionVariables.ActiveTableName))
            {
                SessionVariables.ActiveTableName = tableName;
            }

            if (!string.IsNullOrEmpty(SessionVariables.ActiveTableName) && !(SessionVariables.ActiveTableName.Equals(tableName)))
            {
                SessionVariables.ActiveTableName = tableName;
            }
            if (CurrentPageIndex == null)
            {
                CurrentPageIndex = 0;
            }

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

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

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

                oGridPagiation = new GridPagiation();
                oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory);
                oGridPagiation.Changed += oGridPagiation_Changed;
                if (CurrentPageIndex != null)
                {
                    oGridPagiation.PageIndexInSession = CurrentPageIndex.Value;
                }
                oGridPagiation.ManagePaging(dtGlobal);
            }

            this.IsUpdateColumn = isUpdateColumn;
            this.IsDeleteColumn = isDeleteColumn;
        }
Ejemplo n.º 3
0
        protected void lnkfontlarger_Click(object sender, EventArgs e)
        {
            //griddiv.Style.Add("font-size", "16px");
            //MainGridView.CssClass = "largerfontgrid";
            MainGridView.DataBind();

            oGridPagiation = new GridPagiation();
            dtGlobal       = _getData();
            oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory);
            oGridPagiation.Changed += oGridPagiation_Changed;
            oGridPagiation.ManagePaging(dtGlobal);
            if (!string.IsNullOrEmpty(SessionVariables.SortExpression) && !string.IsNullOrEmpty(SessionVariables.SortDirection))
            {
                SortGridView(SessionVariables.SortExpression, SessionVariables.SortDirection);
            }
            //MainGridView.CssClass = "largerfontgrid";
        }
Ejemplo n.º 4
0
        protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            //In-built paging implementation
            MainGridView.PageIndex = e.NewPageIndex;
            MainGridView.DataBind();

            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);
            if (!string.IsNullOrEmpty(SessionVariables.SortExpression) && !string.IsNullOrEmpty(SessionVariables.SortDirection))
            {
                SortGridView(SessionVariables.SortExpression, SessionVariables.SortDirection);
            }
        }
Ejemplo n.º 5
0
        private void RefreshGrid()
        {
            if (CurrentPageIndex != null)
            {
                MainGridView.PageIndex = CurrentPageIndex.Value;
            }
            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 (!string.IsNullOrEmpty(SessionVariables.SortExpression) && !string.IsNullOrEmpty(SessionVariables.SortDirection))
            {
                SortGridView(SessionVariables.SortExpression, SessionVariables.SortDirection);
            }
        }
Ejemplo n.º 6
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       customizedSearch = CustomizedSearch;
            int       currentpage      = MainGridView.PageIndex;
            int       currentpagesize  = MainGridView.PageSize;
            int       totalnumofrows   = MainGridView.Rows.Count;
            DataTable dtlocal          = new DataTable();
            DataTable sortedtable      = new DataTable();
            DataTable 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)
            {
                dtGlobal = _getData();
            }
            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"))
            {
                string[] columns  = new string[dtGlobal.Columns.Count];
                Type[]   coltypes = new Type[dtGlobal.Columns.Count];
                int      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++)
                {
                    DataColumn dc = new DataColumn(columns[i], typeof(string));
                    sortedtable.Columns.Add(dc);
                    DataColumn dc2 = new DataColumn(columns[i], typeof(string));
                    dtlocal.Columns.Add(dc2);
                    DataColumn 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 (int 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, tableName, tableFolder, 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 (oGridPagiation != null)
                    {
                        oGridPagiation.RefreshGrid = false;
                        oGridPagiation.ManagePaging(dtGlobal);
                    }
                }
                disablemultipledelete(ViewState["TableName"].ToString());
                //if (disabledelete)
                //    disabledeletefunctionality();


                stylefkcolumns();
            }

            if (RadioButtonList1.SelectedItem.Value.Equals("FTSort"))
            {
                return(dv.ToTable(ViewState["TableName"].ToString()));
            }
            else
            {
                return(sortedtable);
            }
        }
Ejemplo n.º 7
0
        protected void chkSelectAll_CheckedChanged(object sender, EventArgs e)
        {
            int currentpage             = MainGridView.PageIndex;
            int currentpagesize         = MainGridView.PageSize;
            int totalnumofrows          = MainGridView.Rows.Count;
            var floor                   = (currentpage * currentpagesize);
            var ceil                    = ((currentpage * currentpagesize) + currentpagesize) - 1;
            StringCollection sc         = new StringCollection();
            string           id         = String.Empty;
            DataTable        dt1        = new DataTable();
            CheckBox         selectall  = (CheckBox)MainGridView.HeaderRow.Cells[0].FindControl("chkSelectAll");
            bool             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, lblCacheStatus, dt1, MainGridView, Page, SettingCategory);
            oGridPagiation.Changed += oGridPagiation_Changed;
            oGridPagiation.ManagePaging(dt1);
            selectall         = (CheckBox)MainGridView.HeaderRow.Cells[0].FindControl("chkSelectAll");
            selectall.Checked = chkchecked;
            //loop the GridView Rows
            int j = 0;

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

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

                    j++;
                }
            }
        }