Esempio n. 1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     int published=0;
     if (drpPublish.SelectedIndex == 0)
         published = 1;
     else
         published = 0;
     Page_class page = new Page_class(txtTitle.Text.Replace("'", "''"), published);
     page.SavePage(txtContent.Text.Replace("'", "''"));
 }
Esempio n. 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
         return;
     string pageid = Request.QueryString["pageid"];
     page = Page_class.GetPagebyID(pageid);
     globaldata.PageContents = Page_class.GetTextofPage(page.pageName);
     txtTitle.Text = globaldata.PageContents[1];
     txtContent.Text = globaldata.PageContents[3];
     if (page.published == 1)
         drpPublish.SelectedIndex = 0;
     else
         drpPublish.SelectedIndex = 1;
     txtSelectedIndex.Text = drpPublish.SelectedIndex.ToString();
 }
Esempio n. 3
0
        //read pages from db function
        public static List <Page_class> ReadPagesFromDB()
        {
            SqlConnection     con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["globaldb"].ConnectionString);
            string            q1   = "select * from pages where published=1";
            SqlCommand        com1 = new SqlCommand(q1, con1);
            SqlDataReader     rdr;
            Page_class        page;
            List <Page_class> pages = new List <Page_class>();

            con1.Open();
            rdr = com1.ExecuteReader();
            while (rdr.Read())
            {
                page             = new Page_class();
                page.pageId      = Convert.ToInt32(rdr["PageID"]);
                page.pageName    = rdr["PageName"].ToString();
                page.displayName = rdr["DisplayName"].ToString();
                page.pageURL     = rdr["pageURL"].ToString();
                if (rdr["DateCreated"] != DBNull.Value)
                {
                    page.dateCreated = Convert.ToDateTime(rdr["DateCreated"]);
                }
                if (rdr["DateModified"] != DBNull.Value)
                {
                    page.dateModified = Convert.ToDateTime(rdr["DateModified"]);
                }
                if (rdr["DatePublished"] != DBNull.Value)
                {
                    page.datePublished = Convert.ToDateTime(rdr["DatePublished"]);
                }
                page.published = Convert.ToInt32(rdr["Published"]);
                page.authorId  = Convert.ToInt32(rdr["Published"]);
                pages.Add(page);
            }
            con1.Close();
            return(pages);
        }
Esempio n. 4
0
        //get page by id for editing
        public static Page_class GetPagebyID(string pageid)
        {
            Page_class    page = new Page_class();
            SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["globaldb"].ConnectionString);
            string        q1   = "select * from PAGES where PageID=" + pageid;
            SqlCommand    com1 = new SqlCommand(q1, con1);
            SqlDataReader rdr;

            con1.Open();
            rdr = com1.ExecuteReader();
            while (rdr.Read())
            {
                page.pageId        = Convert.ToInt32(pageid);
                page.pageName      = rdr["PageName"].ToString();
                page.displayName   = rdr["DisplayName"].ToString();
                page.dateCreated   = Convert.ToDateTime(rdr["DateCreated"]);
                page.dateModified  = Convert.ToDateTime(rdr["DateModified"]);
                page.datePublished = Convert.ToDateTime(rdr["DatePublished"]);
                page.published     = Convert.ToInt32(rdr["Published"]);
                page.authorId      = Convert.ToInt32(rdr["AuthorId"]);
            }
            con1.Close();
            return(page);
        }
Esempio n. 5
0
        //get page by id for editing
        public static Page_class GetPagebyID(string pageid)
        {
            Page_class page = new Page_class();
            SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["globaldb"].ConnectionString);
            string q1 = "select * from PAGES where PageID=" + pageid;
            SqlCommand com1 = new SqlCommand(q1, con1);
            SqlDataReader rdr;
            con1.Open();
            rdr = com1.ExecuteReader();
            while (rdr.Read())
            {
                page.pageId = Convert.ToInt32(pageid);
                page.pageName = rdr["PageName"].ToString();
                page.displayName = rdr["DisplayName"].ToString();
                page.dateCreated = Convert.ToDateTime(rdr["DateCreated"]);
                page.dateModified = Convert.ToDateTime(rdr["DateModified"]);
                page.datePublished = Convert.ToDateTime(rdr["DatePublished"]);
                page.published = Convert.ToInt32(rdr["Published"]);
                page.authorId = Convert.ToInt32(rdr["AuthorId"]);

            }
            con1.Close();
            return page;
        }
Esempio n. 6
0
 //read pages from db function
 public static List<Page_class> ReadPagesFromDB()
 {
     SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["globaldb"].ConnectionString);
     string q1 = "select * from pages where published=1";
     SqlCommand com1 = new SqlCommand(q1, con1);
     SqlDataReader rdr;
     Page_class page;
     List<Page_class> pages = new List<Page_class>();
     con1.Open();
     rdr = com1.ExecuteReader();
     while (rdr.Read())
     {
         page = new Page_class();
         page.pageId = Convert.ToInt32(rdr["PageID"]);
         page.pageName = rdr["PageName"].ToString();
         page.displayName = rdr["DisplayName"].ToString();
         page.pageURL = rdr["pageURL"].ToString();
         if(rdr["DateCreated"] != DBNull.Value)
             page.dateCreated = Convert.ToDateTime(rdr["DateCreated"]);
         if (rdr["DateModified"] != DBNull.Value)
             page.dateModified = Convert.ToDateTime(rdr["DateModified"]);
         if (rdr["DatePublished"] != DBNull.Value)
             page.datePublished = Convert.ToDateTime(rdr["DatePublished"]);
         page.published = Convert.ToInt32(rdr["Published"]);
         page.authorId = Convert.ToInt32(rdr["Published"]);
         pages.Add(page);
     }
     con1.Close();
     return pages;
 }