コード例 #1
0
        protected void ShowPageInfo(htmldb db)
        {
            bool   valid   = true;
            string html_id = Request.QueryString["html_id"];

            if (String.IsNullOrEmpty(html_id))
            {
                valid = false;
            }

            if (valid)
            {
                HTTP_Page page_record = db.Find_Page(Int32.Parse(html_id));

                html_tag_title.InnerHtml = page_record.GetPageTitle();
                html_tag_desc.InnerHtml  = page_record.GetPageBody();
            }
            else
            {
                valid = false;
            }

            if (!valid)
            {
                html_element.InnerHtml = "There is an error finding a page.";
            }
        }
コード例 #2
0
        protected void Update_Page(object sender, EventArgs e)
        {
            htmldb db = new htmldb();

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

            if (String.IsNullOrEmpty(html_id))
            {
                valid = false;
            }
            if (valid)
            {
                HTTP_Page new_page = new HTTP_Page();

                new_page.SetPageTitle(html_tag.Text);
                new_page.SetPageBody(html_body.Text);

                try
                {
                    db.UpdatePage(Int32.Parse(html_id), new_page);
                    Response.Redirect("view_Page.aspx?html_id=" + html_id);
                }
                catch
                {
                    valid = false;
                }
            }

            if (!valid)
            {
                update_element.InnerHtml = "There was an error updating the page.";
            }
        }
コード例 #3
0
        public HTTP_Page Find_Page(int html_id)
        {
            MySqlConnection Connect = new MySqlConnection(ConnectionString);

            HTTP_Page result_page = new HTTP_Page();

            try
            {
                string query = "select * from html where html_tags_id = " + html_id;
                Debug.WriteLine("Connection Initialized...");

                Connect.Open();

                MySqlCommand cmd = new MySqlCommand(query, Connect);

                MySqlDataReader resultset = cmd.ExecuteReader();

                List <HTTP_Page> pages = new List <HTTP_Page>();

                while (resultset.Read())
                {
                    HTTP_Page currentpage = new HTTP_Page();


                    for (int i = 0; i < resultset.FieldCount; i++)
                    {
                        string key   = resultset.GetName(i);
                        string value = resultset.GetString(i);
                        Debug.WriteLine("Attempting to transfer " + key + " data of " + value);

                        switch (key)
                        {
                        case "html_tags_title":
                            currentpage.SetPageTitle(value);
                            break;

                        case "html_tags_body":
                            currentpage.SetPageBody(value);
                            break;
                        }
                    }

                    pages.Add(currentpage);
                }

                result_page = pages[0];
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Something went wrong in the find Page method!");
                Debug.WriteLine(ex.ToString());
            }

            Connect.Close();
            Debug.WriteLine("Database Connection Terminated.");

            return(result_page);
        }
コード例 #4
0
        protected void Add_Page(object sender, EventArgs e)
        {
            htmldb db = new htmldb();

            HTTP_Page new_page = new HTTP_Page();

            new_page.SetPageTitle(html_title.Text);
            new_page.SetPageBody(html_body.Text);

            db.Add_Page(new_page);

            Response.Redirect("list_pages.aspx");
        }
コード例 #5
0
        public void Add_Page(HTTP_Page new_page)
        {
            string query = "insert into html (html_tags_title, html_tags_body) values ('{0}','{1}')";

            query = String.Format(query, new_page.GetPageTitle(), new_page.GetPageBody());

            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 Add_Page Method!");
                Debug.WriteLine(ex.ToString());
            }

            Connect.Close();
        }
コード例 #6
0
        protected void ShowPageInfo(htmldb db)
        {
            bool   valid   = true;
            string html_id = Request.QueryString["html_id"];

            if (String.IsNullOrEmpty(html_id))
            {
                valid = false;
            }

            if (valid)
            {
                HTTP_Page page_record = db.Find_Page(Int32.Parse(html_id));
                html_tag.Text  = page_record.GetPageTitle();
                html_body.Text = page_record.GetPageBody();
            }


            if (!valid)
            {
                update_element.InnerHtml = html_id;
            }
        }
コード例 #7
0
        public void UpdatePage(int html_id, HTTP_Page new_page)
        {
            string query = "update html set html_tags_title='{0}', html_tags_body='{1}' where html_tags_id={2}";

            query = String.Format(query, new_page.GetPageTitle(), new_page.GetPageBody(), html_id);

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

            try
            {
                Connect.Open();
                cmd.ExecuteNonQuery();
                Debug.WriteLine("Executed query " + query);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Something went wrong in the Update_Page Method!");
                Debug.WriteLine(ex.ToString());
            }

            Connect.Close();
        }