コード例 #1
0
        } // END ShowPageInfo

        protected void Update_Page(object sender, EventArgs e)
        {
            PAGESDB pages_db = new PAGESDB();

            bool   valid  = true;
            string pageid = Request.QueryString["page_id"];

            if (String.IsNullOrEmpty(pageid))
            {
                valid = false;
            }
            if (valid)
            {
                HTTP_Page new_page = new HTTP_Page();
                new_page.Set_http_title(page_title.Text);
                new_page.Set_http_body(page_body.Text);
                new_page.Set_http_publish(page_publish.Checked);

                try
                {
                    pages_db.UpdatePage(Int32.Parse(pageid), new_page);
                    Response.Redirect("ShowPage.aspx?page_id=" + pageid);
                } // END TRY
                catch
                {
                    valid = false;
                } // END CATCH
            }
            if (!valid)
            {
                edit_page.InnerHtml = "There was an error updating that page.";
            }

            ShowPageInfo(pages_db);
        } // END Update_Page
コード例 #2
0
        } // END DeletePage

        public void UpdatePage(int pageid, HTTP_Page new_page)
        {
            // SRC: CRUD Essentials, Christine Bittle
            // PURPOSE: HOW TO EDIT PAGE
            // STRING FORMATTING:
            string query = "UPDATE pages set page_title='{0}', page_body='{1}', page_published={2} WHERE page_id={3}";

            query = String.Format(query, new_page.Get_http_title(), new_page.Get_http_body(), new_page.Get_http_publish(), pageid);

            MySqlConnection Connect = new MySqlConnection(ConnectionString);
            MySqlCommand    cmd     = new MySqlCommand(query, Connect);

            try
            {
                Connect.Open();
                cmd.ExecuteNonQuery();
                Debug.WriteLine("Executed query " + query);
            } // END TRY
            catch (Exception ex)
            {
                Debug.WriteLine("Something went wrong in the UpdatePage method.");
                Debug.WriteLine(ex.ToString());
            } // END CATCH

            Connect.Close();
        } // END UpdatePage
コード例 #3
0
        protected void Add_Page(object sender, EventArgs e)
        {
            PAGESDB pages_db = new PAGESDB();

            HTTP_Page new_page = new HTTP_Page();

            new_page.Set_http_title(page_title.Text);
            new_page.Set_http_body(page_body.Text);
            new_page.Set_http_publish(page_publish.Checked);

            pages_db.AddPage(new_page);

            Response.Redirect("ListPages.aspx");
        } // END Add_Page
コード例 #4
0
        } // END UpdatePage

        public void AddPage(HTTP_Page new_page)
        {
            string query = "INSERT INTO pages (page_title, page_body, page_published) VALUES ('{0}', '{1}', {2})";

            query = String.Format(query, new_page.Get_http_title(), new_page.Get_http_body(), new_page.Get_http_publish());

            MySqlConnection Connect = new MySqlConnection(ConnectionString);
            MySqlCommand    cmd     = new MySqlCommand(query, Connect);

            try
            {
                Connect.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Something went wrong in the AddPage method.");
                Debug.WriteLine(ex.ToString());
            }
            Connect.Close();
        } // END AddPage