private void RegisterToolbarSettings()
        {
            Telerik.Web.UI.RadToolBarButton btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideFinished");
            if (btn != null)
            {
                Session["HideFinished"] = btn.Checked;
            }

            btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("Separations");
            if (btn != null)
            {
                Session["SelectedAllSeps"] = btn.Checked;
            }

            btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideApproved");
            if (btn != null)
            {
                Session["HideApproved"] = btn.Checked;
            }

            btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideCommon");
            if (btn != null)
            {
                Session["HideCommon"] = btn.Checked;
            }

            btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("ShowCopies");
            if (btn != null)
            {
                Session["SelectedAllCopies"] = btn.Checked;
            }
        }
        private void ReBind()
        {
            Telerik.Web.UI.RadToolBarButton btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideFinished");
            if (btn != null)
            {
                Session["HideFinished"] = btn.Checked;
            }

            SetScreenSize();

            GetFilteredGrid();
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            if ((string)Session["UserName"] == null)
            {
                Response.Redirect("~/SessionTimeout.htm");
            }

            if ((string)Session["UserName"] == "")
            {
                Response.Redirect("/Denied.htm");
            }



            Telerik.Web.UI.RadToolBarButton btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideFinished");
            if (btn != null)
            {
                Session["HideFinished"] = btn.Checked;
            }

            if (!this.IsPostBack)
            {
                SetLanguage();
                SetAccess();
            }

            SetScreenSize();

            if (!this.IsPostBack)
            {
                lblError.Text = "";
                GetFilteredGrid();
            }


            //  SetToolbarLabel();

            SetRefreshheader();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((string)Session["UserName"] == null)
            {
                Response.Redirect("~/SessionTimeout.htm");
            }

            if ((string)Session["UserName"] == "")
            {
                Response.Redirect("/Denied.htm");
            }

            Session["SelectedSeps"] = null;
            SetScreenSize();

            if (!this.IsPostBack)
            {
                Telerik.Web.UI.RadToolBarButton btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideFinished");
                if (btn != null)
                {
                    btn.Checked = (bool)Session["HideFinished"];
                }

                btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("Separations");
                if (btn != null)
                {
                    btn.Checked = (bool)Session["SelectedAllSeps"];
                }

                btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideApproved");
                if (btn != null)
                {
                    btn.Checked = (bool)Session["HideApproved"];
                }

                btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideCommon");
                if (btn != null)
                {
                    btn.Checked = (bool)Session["HideCommon"];
                }

                btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("Reimage");
                if (btn != null)
                {
                    btn.Visible = (bool)Session["MayReimage"] || (bool)Session["IsAdmin"];
                }

                btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideCopies");
                if (btn != null)
                {
                    btn.Checked = (bool)Session["SelectedAllCopies"];
                }

                SetLanguage();

                SetAccess();

                // Defaults
                ViewState["HideEditionColumn"]       = false;
                ViewState["HideSectiontionColumn"]   = false;
                ViewState["DataSortExpression"]      = "";
                ViewState["MasterSetColumn"]         = 1;
                ViewState["SetColumn"]               = 1;
                ViewState["FlatSeparationColumn"]    = 1;
                ViewState["FlatSeparationSetColumn"] = 1;
                ViewState["DefColumnOrder"]          = (string)Application["ColumnOrder"];

                ViewState["SectionColumn"] = 1;
                ViewState["EditionColumn"] = 1;

                ViewState["ActiveColumn"]  = 50;
                ViewState["PrioColumn"]    = 50;
                ViewState["ColorColumn"]   = 1;
                Session["TableSelectMode"] = "Page";


                lblError.Text = "";
                ReBind();
            }

            //Loop through all windows in the WindowManager.Windows collection
            foreach (Telerik.Web.UI.RadWindow win in RadWindowManager1.Windows)
            {
                //Set whether the first window will be visible on page load
                win.VisibleOnPageLoad = false;
            }


            if (HiddenReturendFromPopup.Value == "1")
            {
                HiddenReturendFromPopup.Value = "0";
                ReBind();
            }

            SetRefreshheader();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((string)Session["UserName"] == null)
            {
                Response.Redirect("~/SessionTimeout.htm");
            }

            if ((string)Session["UserName"] == "")
            {
                Response.Redirect("/Denied.htm");
            }

            if (!this.IsPostBack)
            {
                Telerik.Web.UI.RadToolBarButton btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideFinished");
                if (btn != null)
                {
                    btn.Checked = (bool)Session["HideFinished"];
                }

                btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("Separations");
                if (btn != null)
                {
                    btn.Checked = (bool)Session["SelectedAllSeps"];
                }

                btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideApproved");
                if (btn != null)
                {
                    btn.Checked = (bool)Session["HideApproved"];
                }

                btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideCommon");
                if (btn != null)
                {
                    btn.Checked = (bool)Session["HideCommon"];
                }

                btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("Reimage");
                if (btn != null)
                {
                    btn.Visible = (bool)Session["MayReimage"] || (bool)Session["IsAdmin"];
                }

                btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideCopies");
                if (btn != null)
                {
                    btn.Checked = (bool)Session["SelectedAllCopies"];
                }
            }

            Session["SelectedSeps"] = null;

            ImageC = System.Drawing.Image.FromFile(Request.MapPath(Request.ApplicationPath) + "/Images/colorC.gif");
            ImageM = System.Drawing.Image.FromFile(Request.MapPath(Request.ApplicationPath) + "/Images/colorM.gif");
            ImageY = System.Drawing.Image.FromFile(Request.MapPath(Request.ApplicationPath) + "/Images/colorY.gif");
            ImageK = System.Drawing.Image.FromFile(Request.MapPath(Request.ApplicationPath) + "/Images/colorK.gif");
            ImageS = System.Drawing.Image.FromFile(Request.MapPath(Request.ApplicationPath) + "/Images/colorS.gif");

            if (!this.IsPostBack)
            {
                SetLanguage();
                SetAccess();

                // Defaults
                ViewState["HideEditionColumn"]       = false;
                ViewState["HideSectiontionColumn"]   = false;
                ViewState["DataSortExpression"]      = "";
                ViewState["MasterSetColumn"]         = 1;
                ViewState["SetColumn"]               = 1;
                ViewState["FlatSeparationColumn"]    = 1;
                ViewState["FlatSeparationSetColumn"] = 1;
                ViewState["DefColumnOrder"]          = (string)Application["ColumnOrder"];

                ViewState["SectionColumn"] = 1;
                ViewState["EditionColumn"] = 1;

                ViewState["ActiveColumn"]  = 50;
                ViewState["PrioColumn"]    = 50;
                ViewState["ColorColumn"]   = 1;
                Session["TableSelectMode"] = "Page";
            }

            SetScreenSize();

            if (!this.IsPostBack)
            {
                lblError.Text = "";
                ReBind();
            }

            SetRefreshheader();
        }
        private void ReBind()
        {
            Response.ContentEncoding              = Encoding.GetEncoding((string)Session["encoding"]);
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture((string)Session["language"]);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo((string)Session["language"]);
            ImageC = System.Drawing.Image.FromFile(Request.MapPath(Request.ApplicationPath) + "/Images/colorC.gif");
            ImageM = System.Drawing.Image.FromFile(Request.MapPath(Request.ApplicationPath) + "/Images/colorM.gif");
            ImageY = System.Drawing.Image.FromFile(Request.MapPath(Request.ApplicationPath) + "/Images/colorY.gif");
            ImageK = System.Drawing.Image.FromFile(Request.MapPath(Request.ApplicationPath) + "/Images/colorK.gif");
            ImageS = System.Drawing.Image.FromFile(Request.MapPath(Request.ApplicationPath) + "/Images/colorS.gif");

            if ((string)Session["SelectedPublication"] == "")
            {
                lblChooseProduct.Visible = true;
                return;
            }
            lblChooseProduct.Visible = false;

            Telerik.Web.UI.RadToolBarButton btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideFinished");
            if (btn != null)
            {
                Session["HideFinished"] = btn.Checked;
            }

            btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("Separations");
            if (btn != null)
            {
                Session["SelectedAllSeps"] = btn.Checked;
            }

            btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideApproved");
            if (btn != null)
            {
                Session["HideApproved"] = btn.Checked;
            }

            btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("HideCommon");
            if (btn != null)
            {
                Session["HideCommon"] = btn.Checked;
            }

            btn = (Telerik.Web.UI.RadToolBarButton)RadToolBar1.FindItemByValue("ShowCopies");
            if (btn != null)
            {
                Session["SelectedAllCopies"] = btn.Checked;
            }



            CCDBaccess db = new CCDBaccess();

            string    errmsg = "";
            DataTable tbl    = null;

            if ((bool)Session["SelectedAllSeps"])
            {
                tbl = db.GetTablePageSeparationCollection(false, (bool)Session["SelectedAllCopies"], out errmsg);
            }
            else
            {
                tbl = db.GetTablePageCollection(false, (bool)Session["SelectedAllCopies"], out errmsg);
            }

            if (tbl != null)
            {
                lblError.Text = "";
                ViewState["MasterSetColumn"]         = tbl.Columns["MasterCopySeparationSet"].Ordinal + 1;
                ViewState["FlatSeparationColumn"]    = tbl.Columns["FlatSeparation"].Ordinal + 1;
                ViewState["FlatSeparationSetColumn"] = tbl.Columns["FlatSeparationSet"].Ordinal + 1;
                ViewState["PrioColumn"]     = tbl.Columns["Priority"].Ordinal + 1;
                ViewState["ColorColumn"]    = tbl.Columns["Color"].Ordinal + 1;
                ViewState["ActiveColumn"]   = tbl.Columns["Active"].Ordinal + 1;
                ViewState["SetColumn"]      = tbl.Columns["SeparationSet"].Ordinal + 1;
                ViewState["TemplateColumn"] = tbl.Columns["Template"].Ordinal + 1;
                ViewState["EditionColumn"]  = tbl.Columns["Edition"].Ordinal + 1;
                ViewState["SectionColumn"]  = tbl.Columns["Section"].Ordinal + 1;

                string s = " ";
                foreach (DataColumn col in tbl.Columns)
                {
                    if (s != "")
                    {
                        s += ",";
                    }
                    s += col.ColumnName;
                }

                ViewState["DefColumnOrder"] = s;

                if ((string)ViewState["DataSortExpression"] != "")
                {
                    DataView dv1 = new DataView(tbl, "", (string)ViewState["DataSortExpression"], DataViewRowState.CurrentRows);
                    DataGrid1.DataSource = dv1;
                }
                else
                {
                    DataGrid1.DataSource = tbl.DefaultView;
                }
                DataView dv = (DataView)DataGrid1.DataSource;
                // string translatedSectionName = "Section";
                //string translatedEditionName = "Edition";
                foreach (DataColumn col in dv.Table.Columns)
                {
                    string ss = Global.rm.GetString("txt" + col.ColumnName);
                    if (ss != null && ss != "" && ss != " ")
                    {
                        /*     if (col.ColumnName == "Section")
                         *       translatedSectionName = ss;
                         *   if (col.ColumnName == "Edition")
                         *       translatedEditionName = ss;      */
                        col.Caption = ss;
                    }
                }

                List <string> uniqueSections = new List <string>();
                List <string> uniqueEditions = new List <string>();

                foreach (DataRow row in tbl.Rows)
                {
                    s = (string)row["Section"];
                    if (uniqueSections.Contains(s) == false)
                    {
                        uniqueSections.Add(s);
                    }
                    s = (string)row["Edition"];
                    if (uniqueEditions.Contains(s) == false)
                    {
                        uniqueEditions.Add(s);
                    }
                }

                ViewState["HideEditionColumn"] = uniqueEditions.Count < 2;
                ViewState["HideSectionColumn"] = uniqueSections.Count < 2;


                DataGrid1.DataBind();
            }
            else
            {
                lblError.Text = errmsg;
            }
        }