protected void showpageinfo()
        {
            WebsiteDB dB   = new WebsiteDB();
            Boolean   flag = true;

            //get the pageid from the request and convert the string to int
            int pageid = Convert.ToInt32(Request.QueryString["pageid"]);

            //if the id that requested is null or is 0 set the flag to false
            if (pageid.Equals(null) || pageid.Equals(0))
            {
                flag = false;
            }

            //if the flag is true continue with the logic
            if (flag)
            {
                //find the webpage and set its values to the variables in the webpage class
                Webpage webpage = dB.FindWebPage(pageid);

                //get the data from the webpage class of the webpage requested
                //set the text boxes and the dropdown to the variables from the webpage class
                pagename.InnerText          = webpage.get_W_title();
                txtpage_title.Text          = webpage.get_W_title();
                txtpage_body.InnerText      = webpage.get_W_body();
                ddpage_author.SelectedValue = webpage.get_W_author();
            }
            //if false show the alert of the error
            else
            {
                alert.Visible = true;
                alert.Attributes.Add("class", "alert alert-danger");
                output.InnerHtml = "Error please go back home";
            }
        }
Exemplo n.º 2
0
        public void AddWebpage(Webpage webpage)
        {
            string query = "insert into pages(page_title,page_body,publish_author,publish_state,publish_date) values ('{0}','{1}','{2}','{3}','{4}')";

            query = String.Format(query, webpage.get_W_title(), webpage.get_W_body(), webpage.get_W_author(), webpage.get_W_publish_state(), webpage.get_W_publish_date());

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

            try
            {
                sqlCon.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Check the AddWebpage()");
                Debug.WriteLine(ex.ToString());
            }

            sqlCon.Close();
        }
Exemplo n.º 3
0
        public void UpdateWebpage(int pageid, Webpage webpage)
        {
            string query = "update pages set page_title='{0}', page_body='{1}', publish_author='{2}' where page_id = " + pageid;

            query = String.Format(query, webpage.get_W_title(), webpage.get_W_body(), webpage.get_W_author());

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

            try
            {
                sqlCon.Open();
                cmd.ExecuteNonQuery();
                Debug.WriteLine("Executed query " + query);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Check the UpdateWebpage()");
                Debug.WriteLine(ex.ToString());
            }

            sqlCon.Close();
        }