protected void Update_Page(object sender, EventArgs e)
        {
            PageDB db     = new PageDB();
            bool   valid  = true;
            string pageid = Request.QueryString["pageid"];

            if (String.IsNullOrEmpty(pageid))
            {
                valid = false;
            }
            if (valid)
            {
                Debug.WriteLine("grab the info from here");
                Page_Class new_page = new Page_Class();
                //this is way to set the data
                new_page.SetTitle(pageTitle.Text);
                new_page.SetBody(page_body.Text);
                new_page.SetAuthorNumber(author_number.Text);

                //now want this value into the database
                try
                {
                    db.UpdatePage(Int32.Parse(pageid), new_page);
                    Response.Redirect("Details_of_page.aspx?pageid=" + pageid);
                }
                catch
                {
                }
            }
            if (!valid)
            {
                Debug.WriteLine("ERRORRRRRRRRRRRRRR" + pageid);
            }
        }
        protected void ShowPageInfo(PageDB db)
        {
            Debug.WriteLine("i am trying to show the page");
            bool   valid  = true;
            string pageid = Request.QueryString["pageid"];

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

            Debug.WriteLine("the page validitiy is " + valid + " and the page id is " + pageid);
            if (valid)
            {
                Page_Class page_record = db.FindPage(Int32.Parse(pageid));

                page_header_title.InnerHtml += page_record.GetTitle();
                page_title.InnerHtml        += page_record.GetTitle();
                page_body.InnerHtml         += page_record.GetBody();
                author_number.InnerHtml     += page_record.GetAuthorNumber();
                created_date.InnerHtml      += page_record.GetCreatedDate().ToString("yyyy/mm/dd");
            }

            if (!valid)
            {
            }
        }
예제 #3
0
        public void AddPage(Page_Class new_http_page)
        {
            string query = "insert into HTTP_PAGE(TITLE,BODY,AUTHOR_ID,CREATED_DATE) VALUES ('{0}','{1}','{2}','{3}')";

            //UPPER STRING FOR QUERY AND VALUES IN CURLY BRACES TO REFER THESE VALUES;
            query = String.Format(query, new_http_page.GetTitle(), new_http_page.GetBody(), new_http_page.GetAuthorNumber(), new_http_page.GetCreatedDate().ToString("yyyy/mm/dd"));

            //now for sql connection
            MySqlConnection Connect = new MySqlConnection(ConnectionString);
            MySqlCommand    cmd     = new MySqlCommand(query, Connect);

            try
            {
                Connect.Open();
                cmd.ExecuteNonQuery();
                //here excute non query for creating updating and delete
                //other then this we are using excute reder for read the things
            }
            catch (Exception ex)
            {
                Debug.WriteLine("something is wrong here");
                Debug.WriteLine(ex.ToString());
            }
            Connect.Close();
        }
        protected void Add_Page(object sender, EventArgs e)
        {
            //the above add_page is related to our onclick funcion
            //firstly access from db
            PageDB db = new PageDB();

            //create a new page
            //here this page class is  to refer the class which we created;
            Page_Class new_http_page = new Page_Class();

            //set that student data now
            new_http_page.SetTitle(page_title.Text);
            new_http_page.SetBody(page_body.Text);
            new_http_page.SetAuthorNumber(author_number.Text);
            new_http_page.SetCreatedDate(DateTime.Now);

            //now this new page created to our database
            db.AddPage(new_http_page);
            //this add page is related to our db add page.

            Response.Redirect("HTTP_Page.aspx");
        }
예제 #5
0
        public void UpdatePage(int pageid, Page_Class new_page)
        {
            string query = "update HTTP_PAGE set TITLE='{0}', BODY='{1}',AUTHOR_ID='{2}' WHERE PAGE_ID='{3}' ";

            query = String.Format(query, new_page.GetTitle(), new_page.GetBody(), new_page.GetAuthorNumber(), pageid);

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

            try
            {
                Connect.Open();
                cmd.ExecuteNonQuery();
                Debug.WriteLine("Excueted query " + query);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("something went wrong in update method");
                Debug.WriteLine(ex.ToString());
            }
            Connect.Close();
        }
        //this is function for show the information in our filed so that they can update it/

        protected void ShowPageInfo(PageDB db)
        {
            bool   valid  = true;
            string pageid = Request.QueryString["pageid"];

            if (String.IsNullOrEmpty(pageid))
            {
                valid = false;
            }
            if (valid)
            {
                Page_Class page_record = db.FindPage(Int32.Parse(pageid));

                page_title.InnerHtml += page_record.GetTitle();
                pageTitle.Text       += page_record.GetTitle();
                page_body.Text       += page_record.GetBody();
                author_number.Text   += page_record.GetAuthorNumber();
            }

            if (!valid)
            {
                Debug.WriteLine("may b check here" + pageid);
            }
        }
예제 #7
0
        //here because we define the class thats why we mention here
        //otherwise we have to use dictionary method.
        public Page_Class FindPage(int pageid)
        {
            MySqlConnection Connect = new MySqlConnection(ConnectionString);

            Page_Class page_result = new Page_Class();

            try
            {
                string query = "select PAGE_ID,TITLE, BODY, concat(first_name, ' ', last_name) as AUTHOR_NAME, CREATED_DATE from HTTP_PAGE join AUTHOR ON HTTP_PAGE.AUTHOR_ID = AUTHOR.AUTHOR_ID where PAGE_ID =" + pageid;
                Debug.WriteLine("connection initialized!!! i am trying to find a page with id " + pageid);

                Connect.Open();

                MySqlCommand cmd = new MySqlCommand(query, Connect);

                MySqlDataReader resultset = cmd.ExecuteReader();

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

                while (resultset.Read())
                {
                    //info we stored for single vlaue
                    Page_Class currenthttp_page = new Page_Class();

                    for (int i = 0; i < resultset.FieldCount; i++)
                    {
                        string name  = resultset.GetName(i);
                        string value = resultset.GetString(i);

                        Debug.WriteLine("Attempting to transfer " + name + "data of" + value);

                        switch (name)
                        {
                        case "TITLE":
                            currenthttp_page.SetTitle(value);
                            break;

                        case "BODY":
                            currenthttp_page.SetBody(value);
                            break;

                        case "AUTHOR_NAME":
                            currenthttp_page.SetAuthorNumber(value);
                            break;

                        case "CREATED_DATE":
                            currenthttp_page.SetCreatedDate(DateTime.Parse(value));
                            break;
                        }
                    }
                    HTTP_Page.Add(currenthttp_page);
                }
                page_result = HTTP_Page[0];
            }
            catch (Exception ex)
            {
                Debug.WriteLine("something went wrong for this  page");
                Debug.WriteLine(ex.ToString());
            }
            Connect.Close();
            Debug.WriteLine("Database terminated!!!");

            return(page_result);
        }