Exemplo n.º 1
0
        protected void ShowPageInfo(HTTP_PAGEDB db)
        {
            //Our flag to know if the data can be shown or not
            bool valid = true;

            //Get the http_pageID from the query
            string http_pageID = Request.QueryString["http_pageID"];

            //if there is no id then user must have went to this page without a id
            if (String.IsNullOrEmpty(http_pageID))
            {
                valid = false;
            }

            //if there is a id on the page then
            if (valid)
            {
                //Get the HTTP_Page from the id we got
                HTTP_Page pageRecord = db.FindPage(Int32.Parse(http_pageID));
                //Show the data on the HTML
                pageID.InnerHtml            = pageRecord.GetID();
                pageTitle.Text              = pageRecord.GetTitle();
                pageContent.Text            = pageRecord.GetContent();
                pageDatePublished.InnerHtml = pageRecord.GetDate().ToString("MM/dd/yyyy");
            }

            //No id was found
            if (!valid)
            {
                http_page.InnerHtml = "There was an error finding that page.";
            }
        }
Exemplo n.º 2
0
        //if user clicks on the Delete button and confirm yes
        protected void DeletePage(object sender, EventArgs e)
        {
            //Our flag to know if the data can be deleted or not
            bool valid = true;

            //Get the http_pageID from the query
            string http_pageID = Request.QueryString["http_pageID"];

            //if there is no id then user must have went to this page without a id
            if (String.IsNullOrEmpty(http_pageID))
            {
                valid = false;
            }

            //Create our database object
            HTTP_PAGEDB db = new HTTP_PAGEDB();

            //if there is a id on the page then
            if (valid)
            {
                //Deleting the HTTP_Page from the system
                db.DeletePage(Int32.Parse(http_pageID));
                //Go back to the list of HTTP_Pages
                Response.Redirect("Manage_HTTP_Pages.aspx");
            }
        }
Exemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         //this connection instance is for showing data
         HTTP_PAGEDB db = new HTTP_PAGEDB();
         ShowPageInfo(db);
     }
 }
Exemplo n.º 4
0
        protected void ShowPageInfo(HTTP_PAGEDB db)
        {
            string query      = "SELECT * FROM http_pages";
            string SearchText = "";

            //if user submit then
            if (Page.IsPostBack)
            {
                SearchText = searchText.Text;
            }

            //Add a filter in the query
            if (SearchText != "")
            {
                query += " WHERE HTTPPAGETITLE LIKE \"%" + SearchText + "%\"";
                query += " OR HTTPPAGEDATE LIKE \"%" + SearchText + "%\"";
            }

            //Order Method
            query += " ORDER BY " + pageListOrder.SelectedValue.ToUpper();
            query += " " + pageListOrderDirection.SelectedValue.ToUpper();

            //Get the result of object (Result table from the query)
            List <HTTP_Page> pages = db.List_Query(query);

            //Clear the data right now
            resultTable.InnerHtml = "";

            //For each HTTP_Page in the result
            foreach (HTTP_Page row in pages)
            {
                //Show the particular HTTP_Page data on the HTML
                resultTable.InnerHtml += "<div class=\"flexContainer tableRow\">";
                resultTable.InnerHtml += "<div><a href=\"ShowHTTP_Page.aspx?http_pageID=" + row.GetID() + "\">" + row.GetTitle() + "</a></div>";
                resultTable.InnerHtml += "<div>" + row.GetDate().ToString("MM/dd/yyyy") + "</div>";
                resultTable.InnerHtml += "<div><a href=\"UpdateHTTP_Page.aspx?http_pageID=" + row.GetID() + "\">Edit</a></div>";

                //Attempts to make a delete button in the page
                //resultTable.InnerHtml += "<div><a href=\"\">Delete</a></div>";
                //resultTable.InnerHtml += "<div><asp:button ID=\"deleteButtonPage" + row.GetID() + "\" Text=\"Delete\" runat=\"server\" /></div>";
                //resultTable.InnerHtml += "<div><input runat=\"server\" Value=\"Delete\" type=\"button\" onclick=\"if (confirm(\"Are you sure want to delete this\")) {window.location.href=\"Manage_HTTP_Pages.aspx?http_pageID=" + row.GetID() + ";\"callback(DeletePage);}\" /></div>";
                //resultTable.InnerHtml += "<div><asp:Button runat=\"server\" Text=\"Delete\" OnClientClick = \"if(!confirm('Are you sure you want to delete this?')) return false;\" OnClick = \"DeletePage\" /></div>";

                //End of particular HTTP_Page
                resultTable.InnerHtml += "</div>";
            }
        }
Exemplo n.º 5
0
        //if the user clicks on the Update Page button
        protected void UpdatePage(object sender, EventArgs e)
        {
            //Create our database object
            HTTP_PAGEDB db = new HTTP_PAGEDB();

            //Our flag to know if the data can be obtained or not
            bool valid = true;

            //Get the http_pageID from the query
            string http_pageID = Request.QueryString["http_pageID"];

            //if there is no id then user must have went to this page without a id
            if (String.IsNullOrEmpty(http_pageID))
            {
                valid = false;
            }

            //if there is a id on the page then
            if (valid)
            {
                //Create a new HTTP_Page object
                HTTP_Page newPage = new HTTP_Page();

                //Set the necessary value in the HTTP_Page object that will get updated
                newPage.SetTitle(pageTitle.Text);
                newPage.SetContent(pageContent.Text);

                try
                {
                    //Update the HTTP_Page to the database
                    db.UpdatePage(Int32.Parse(http_pageID), newPage);
                    //Go back to the show page of this particular HTTP_Page we are updating
                    Response.Redirect("ShowHTTP_Page.aspx?http_pageID=" + http_pageID);
                }
                catch
                {
                    valid = false;
                }
            }

            //No id was found or failed to update
            if (!valid)
            {
                http_page.InnerHtml = "There was an error updating that page.";
            }
        }
Exemplo n.º 6
0
        //When user clicks on the Add Page button
        protected void AddPage(object sender, EventArgs e)
        {
            //Create connection
            HTTP_PAGEDB db = new HTTP_PAGEDB();

            //Create a new particular HTTP_Page
            HTTP_Page newPage = new HTTP_Page();

            //Set that page data
            newPage.SetTitle(pageTitle.Text);
            newPage.SetContent(pageContent.Text);
            newPage.SetDate(DateTime.Today);

            //Add the page to the database
            db.AddPage(newPage);

            //Go back to the list of HTTP_Pages
            Response.Redirect("Manage_HTTP_Pages.aspx");
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HTTP_PAGEDB db = new HTTP_PAGEDB();

            ShowPageInfo(db);
        }