protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var pageName = Request.QueryString["f"];
            Entities db = new Entities();
            var pageVariable = db.Variables.Single(x => x.Name == pageName);
            pageVariable.Value = rteBody.Text;
            db.SaveChanges();

            Response.Redirect(pageVariable.Name + ".aspx", true);
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Entities db = new Entities();

            string sFileName = Request.QueryString["cn"];
            var catalog = db.Catalogs.Single(x => x.Name == sFileName);
            catalog.Description = rteBody.Text;
            db.SaveChanges();

            Response.Redirect("Catalog.aspx?cn=" + sFileName, true);
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Entities db = new Entities();

            var passwordVariable = db.Variables.Single(x => x.Name == "Password");

            if (tbxCurrentPassword.Text == passwordVariable.Value)
            {
                passwordVariable.Value = tbxNewPassword.Text;
                db.SaveChanges();

                Response.Redirect("Default.aspx", true);
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Entities db = new Entities();

            if (Request.QueryString["a"] == "l")
            {
                if (!cbxDeleteCatalog1.Visible)
                {
                    var newCatalog = new Catalog
                    {
                        Name = tbxCatalogName1.Text,
                        URL = tbxCatalogURL1.Text,
                        Sleave = "Left",
                        ShowDescription = cbxShowDescription1.Checked
                    };
                    db.Catalogs.Add(newCatalog);
                    lbxCatalogs1.Items.Add(tbxCatalogName1.Text);
                }
                else
                {
                    if (cbxDeleteCatalog1.Checked)
                    {
                        int iIndex = lbxCatalogs1.SelectedIndex;
                        lbxCatalogs1.Items.RemoveAt(iIndex);
                        var catalog = db.Catalogs.Single(x => x.Name == tbxCatalogName1.Text);
                        db.Catalogs.Remove(catalog);
                    }
                    else
                    {
                        var catalog = db.Catalogs.Single(x => x.Name == lbxCatalogs1.SelectedItem.Text);
                        catalog.Name = tbxCatalogName1.Text;
                        catalog.URL = tbxCatalogURL1.Text;
                        catalog.ShowDescription = cbxShowDescription1.Checked;

                        int iIndex = lbxCatalogs1.SelectedIndex;
                        lbxCatalogs1.Items.RemoveAt(iIndex);
                        lbxCatalogs1.Items.Insert(iIndex, tbxCatalogName1.Text);
                    }
                }
                db.SaveChanges();
                imgRefresh1_Click(null, null);
            }
            else
            {
                if (!cbxDeleteCatalog2.Visible)
                {
                    var newCatalog = new Catalog
                    {
                        Name = tbxCatalogName2.Text,
                        URL = tbxCatalogURL2.Text,
                        Sleave = "Right",
                        ShowDescription = cbxShowDescription2.Checked
                    };
                    db.Catalogs.Add(newCatalog);
                    lbxCatalogs1.Items.Add(tbxCatalogName2.Text);
                }
                else
                {
                    if (cbxDeleteCatalog2.Checked)
                    {
                        int iIndex = lbxCatalogs2.SelectedIndex;
                        lbxCatalogs2.Items.RemoveAt(iIndex);
                        var catalog = db.Catalogs.Single(x => x.Name == tbxCatalogName2.Text);
                        db.Catalogs.Remove(catalog);
                    }
                    else
                    {
                        var catalog = db.Catalogs.Single(x => x.Name == lbxCatalogs2.SelectedItem.Text);
                        catalog.Name = tbxCatalogName2.Text;
                        catalog.URL = tbxCatalogURL2.Text;
                        catalog.ShowDescription = cbxShowDescription2.Checked;

                        int iIndex = lbxCatalogs2.SelectedIndex;
                        lbxCatalogs2.Items.RemoveAt(iIndex);
                        lbxCatalogs2.Items.Insert(iIndex, tbxCatalogName2.Text);
                    }
                }
                db.SaveChanges();
                imgRefresh2_Click(null, null);
            }
        }
 protected void imgRefresh2_Click(object sender, ImageClickEventArgs e)
 {
     Entities db = new Entities();
     var sleaveTitleVariable = db.Variables.Single(x => x.Name == "rightSleaveTitle");
     sleaveTitleVariable.Value = tbxListTitle2.Text;
     db.SaveChanges();
     Response.Redirect(Request.RawUrl, true);
 }