Beispiel #1
0
        protected void ShowPageInfo(PagesCMSDB db)
        {
            bool   valid     = true;
            string pagecmsid = Request.QueryString["pagecmsid"];

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


            if (valid)
            {
                PageCMS pagecms_record = db.FindPageCMS(Int32.Parse(pagecmsid));

                pagecms_title.Text = pagecms_record.GetCMStitle();
                pagecms_body.Text  = pagecms_record.GetCMSbody();
            }

            //if not valid
            if (!valid)
            {
                PageUpdateCMS.InnerHtml = "There was an error finding that page.";
            }
        }
Beispiel #2
0
        protected void ShowPageInfo(PagesCMSDB db)
        {   //Debug.WriteLine allows to check for errors in the Debug Output window easier
            Debug.WriteLine("I am trying to show a page");
            bool   valid     = true;
            string pagecmsid = Request.QueryString["pagecmsid"];

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


            if (valid)
            {
                //finds page title and body info and displays it
                PageCMS page_record = db.FindPageCMS(Int32.Parse(pagecmsid));

                Debug.WriteLine("the page is " + page_record.GetCMStitle());
                page_title.InnerHtml = page_record.GetCMStitle();
                page_body.InnerHtml  = page_record.GetCMSbody();
            }
            else
            {
                valid = false;
            }


            if (!valid)
            {   //displays if the user goes to the page directly and not from
                //the list page
                pagecms.InnerHtml = "There was an error finding that page.";
            }
        }
Beispiel #3
0
        protected void Update_PageCMS(object sender, EventArgs e)
        {
            PagesCMSDB db = new PagesCMSDB();

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

            if (String.IsNullOrEmpty(pagecmsid))
            {
                valid = false;
            }
            if (valid)
            {
                PageCMS new_pagecms = new PageCMS();
                //sets page data
                new_pagecms.SetCMStitle(pagecms_title.Text);
                new_pagecms.SetCMSbody(pagecms_body.Text);

                //updates page in the database
                try
                {
                    db.UpdatePageCMS(Int32.Parse(pagecmsid), new_pagecms);
                    Response.Redirect("ShowPageCMS.aspx?pagecmsid=" + pagecmsid);
                }
                catch
                {
                    valid = false;
                }
            }

            if (!valid)
            {   //if not valid
                PageUpdateCMS.InnerHtml = "There was an error updating that page.";
            }
        }
Beispiel #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //Only show the data when the user visits the page for the first time
     //HAVE TO MAKE SURE WE PUT
     if (!Page.IsPostBack)
     {
         //this connection instance is for showing data
         PagesCMSDB db = new PagesCMSDB();
         ShowPageInfo(db);
     }
 }
        protected void ListFeaturedPageCMS(PagesCMSDB db)
        {
            //query to select all of pages from table
            string query = " SELECT * from pagecmsinfo ";
            List <Dictionary <String, String> > rs = db.List_Query(query);

            foreach (Dictionary <String, String> row in rs)
            {   //displays the page titles using user control
                //string stores pagecmsid to be used later
                string pagecmsid = row["pagecmsid"];
                //show all pages on page
                //grab page using pagecmsid url, then grab the pagecmsid from the string we did above then show the page title - seperated by |
                featured_pagecms.InnerHtml += "<a href=\"ShowPageCMS.aspx?pagecmsid=" + pagecmsid + "\">" + row["pagecmstitle"] + " | " + "</a>";
            }
        }
        protected void Add_PageCMS(object sender, EventArgs e)
        {
            //creates a  connection
            PagesCMSDB db = new PagesCMSDB();

            //creates a new page
            PageCMS new_pagecms = new PageCMS();

            //sets the page data
            new_pagecms.SetCMStitle(page_title.Text);
            new_pagecms.SetCMSbody(page_body.Text);


            //adds the page to the database
            db.AddPageCMS(new_pagecms);


            Response.Redirect("ListPageCMS.aspx");
        }
Beispiel #7
0
        protected void Delete_PageCMS(object sender, EventArgs e)
        {
            bool   valid     = true;
            string pagecmsid = Request.QueryString["pagecmsid"];

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

            PagesCMSDB db = new PagesCMSDB();

            //deleting the page from the system
            if (valid)
            {
                db.DeletePageCMS(Int32.Parse(pagecmsid));
                Response.Redirect("ListPageCMS.aspx");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            pagecms_result.InnerHtml = "";

            string searchkey = "";

            if (Page.IsPostBack)
            {
                searchkey = pagecms_search.Text;
            }
            // query for MySQL to search for page title from database
            string query = "select * from pagecmsinfo";

            if (searchkey != "")
            {   //annying little space between the " and WHERE was making it not work.
                //ahhhh so annoying. I have to remember that c# is very case sensitive and
                //a strongly typed language. Have to really be careful.
                query += " where pagecmstitle like '%" + searchkey + "%' ";
            }
            //displays query result
            sql_searcher.InnerHtml = query;

            //lists pages populated from database
            var db = new PagesCMSDB();
            List <Dictionary <String, String> > rs = db.List_Query(query);

            foreach (Dictionary <String, String> row in rs)
            {
                pagecms_result.InnerHtml += "<div class=\"listitem\">";

                string pagecmsid = row["pagecmsid"];

                string pagecmstitle = row["pagecmstitle"];
                pagecms_result.InnerHtml += "<div class=\"col2\"><a href=\"ShowPageCMS.aspx?pagecmsid=" + pagecmsid + "\">" + pagecmstitle + "</a></div>";

                string pagecmsbody = row["pagecmsbody"];
                pagecms_result.InnerHtml += "<div class=\"col2last\">" + pagecmsbody + "</div>";

                pagecms_result.InnerHtml += "</div>";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            PagesCMSDB db = new PagesCMSDB();

            ListFeaturedPageCMS(db);
        }
Beispiel #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PagesCMSDB db = new PagesCMSDB();

            ShowPageInfo(db);
        }