コード例 #1
0
ファイル: PostView.aspx.cs プロジェクト: nksherani/EJASCMS
        protected void Page_Load(object sender, EventArgs e)
        {
            postid = Convert.ToInt32(Request.QueryString["postid"]);
            if (postid == 0)
                v = new Post();
            else
                v=Post.LoadPostbyId(postid);

            Ncomments = v.GetNComments(1, 20);
        }
コード例 #2
0
ファイル: NewPostbyDB.aspx.cs プロジェクト: nksherani/EJASCMS
 protected void Button1_Click(object sender, EventArgs e)
 {
     List<string> categories = new List<string>();
     foreach (ListItem item in lstCategories.Items)
     {
         if (item.Selected)
         {
             categories.Add(item.Text);
         }
     }
     int published;
     if (drpPublish.SelectedIndex == 0)
         published = 1;
     else
         published = 0;
     post = new Post(txtTitle.Text.Replace("'", "''"), txtContent.Text.Replace("'", "''"), published, categories, txtNewTags.Text.Replace("'", "''"));
     if (post.published == 1)
         posted = true;
 }
コード例 #3
0
ファイル: EditPost.aspx.cs プロジェクト: nksherani/EJASCMS
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
                return;
            txtToggleValue.Text = "";
            populateCategoryList();
            postid = Request.QueryString["postid"].ToString();
            //postid = "21";
            post = Post.LoadPostbyIdAll(Convert.ToInt32(postid));
            txtTitle.Text = post.title;
            txtContent.Text = post.content;
            if (post.published == 0)
                drpPublish.SelectedIndex = 1;
            else
                drpPublish.SelectedIndex = 0;
            //populating multiselect list from db
            for(int i = 0; i < lstCategories.Items.Count; i++)
            {
                if((post.categories.Find(x=>x.categoryName==lstCategories.Items[i].Text)!=null))
                    lstCategories.Items[i].Selected = true;
            }
            int count = 0;
            foreach(var tag in post.tags)
            {
                if(count!=0)
                txtNewTags.Text += ",";
                txtNewTags.Text += tag.tag;
                count++;

            }
            if (drpPublish.SelectedItem.Text == "Yes")
                txtToggle.Text = "0";
            else
                txtToggle.Text = "1";
        }
コード例 #4
0
ファイル: Post.cs プロジェクト: nksherani/EJASCMS
 //gettagsofthispost
 public List<Tag> GetTags(Post post)
 {
     SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["globaldb"].ConnectionString);
     List<Tag> lstTags = new List<Tag>();
     string q1 = "select tag from tags where pagepostID =" + post.postId;
     SqlCommand com1 = new SqlCommand(q1, con1);
     //List<int> catIDs = new List<int>();
     con1.Open();
     SqlDataReader rdr = com1.ExecuteReader();
     while (rdr.Read())
     {
         lstTags.Add(new Tag(rdr["tag"].ToString(),post.postId));
     }
     con1.Close();
     tags = lstTags;
     return lstTags;
 }
コード例 #5
0
ファイル: Post.cs プロジェクト: nksherani/EJASCMS
        //getcategoriesofthispost
        public List<Category> GetCategories(Post post)
        {
            SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["globaldb"].ConnectionString);
            List<Category> lstCategories = new List<Category>();
            string q1 = "select categoryId from postCategories where postID =" + post.postId;
            SqlCommand com1 = new SqlCommand(q1, con1);
            List<int> catIDs = new List<int>();
            con1.Open();
            SqlDataReader rdr = com1.ExecuteReader();
            while (rdr.Read())
            {
                catIDs.Add(Convert.ToInt32(rdr[0]));
            }
            con1.Close();
            foreach(var v in catIDs)
            {
                q1 = "select * from categories where id=" + v;
                com1 = new SqlCommand(q1, con1);
                con1.Open();
                rdr = com1.ExecuteReader();
                while (rdr.Read())
                {
                    lstCategories.Add(new Category(Convert.ToInt32(rdr[0]), rdr[1].ToString(), rdr[2].ToString()));
                }
                con1.Close();

            }
            categories = lstCategories;
            return lstCategories;
        }
コード例 #6
0
ファイル: Post.cs プロジェクト: nksherani/EJASCMS
        //search word is post content
        public static List<Post> SearchPostContentbyWord( string query)
        {
            Post post;
            List<Post> posts = new List<Post>();
            string q1 = "select * from Posts_View where postContent like '%" + query + "%'";
            SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["globaldb"].ConnectionString);
            SqlCommand com1 = new SqlCommand(q1, con1);
            SqlDataReader rdr;
            con1.Open();
            rdr = com1.ExecuteReader();

            while (rdr.Read())
            {
                string title = rdr["postTitle"].ToString();
                string content = rdr["postContent"].ToString();
                string Author = rdr["FirstName"].ToString();
                DateTime dtc = Convert.ToDateTime(rdr["dateCreated"]);
                DateTime dtm = Convert.ToDateTime(rdr["dateModified"]);
                DateTime dtp = Convert.ToDateTime(rdr["datePublished"]);
                int AuthorID = Convert.ToInt32(rdr["authorId"]);
                int postID = Convert.ToInt32(rdr["PostId"]);
                int published = Convert.ToInt32(rdr["Published"]); ;
                post = new Post(postID, title, content, dtc, dtm, published, dtp, AuthorID, Author);
                posts.Add(post);
            }
            con1.Close();
            return posts;
        }
コード例 #7
0
ファイル: Post.cs プロジェクト: nksherani/EJASCMS
 public static Post LoadPostbyIdAll(int N)
 {
     SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["globaldb"].ConnectionString);
     //N++;
     string q1 = "select * from Posts_View where postID =" + N;
     SqlCommand com1 = new SqlCommand(q1, con1);
     con1.Open();
     SqlDataReader rdr = com1.ExecuteReader();
     Post post = new Post();
     while (rdr.Read())
     {
         string title = rdr["postTitle"].ToString();
         string content = rdr["postContent"].ToString();
         string Author = rdr["FirstName"].ToString();
         DateTime dtc = Convert.ToDateTime(rdr["dateCreated"]);
         DateTime dtm = Convert.ToDateTime(rdr["dateModified"]);
         DateTime dtp = Convert.ToDateTime(rdr["datePublished"]);
         int AuthorID = Convert.ToInt32(rdr["authorId"]);
         int postID = Convert.ToInt32(rdr["PostId"]);
         int published = Convert.ToInt32(rdr["Published"]); ;
         post = new Post(postID, title, content, dtc, dtm, published, dtp, AuthorID, Author);
         //NPosts.Add(post);
     }
     con1.Close();
     return post;
 }
コード例 #8
0
ファイル: Post.cs プロジェクト: nksherani/EJASCMS
 public static List<Post> LoadNextNPosts(int i,int N)
 {
     SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["globaldb"].ConnectionString);
     N = N + i;
     string q1 = "select * from Posts_View where published=1 and postID between "+i+" and " + N;
     SqlCommand com1 = new SqlCommand(q1, con1);
     con1.Open();
     SqlDataReader rdr = com1.ExecuteReader();
     List<Post> NPosts = new List<Post>();
     while (rdr.Read())
     {
         string title = rdr["postTitle"].ToString();
         string content = rdr["postContent"].ToString();
         DateTime dtc = Convert.ToDateTime(rdr["dateCreated"]);
         DateTime dtm = Convert.ToDateTime(rdr["dateModified"]);
         DateTime dtp = Convert.ToDateTime(rdr["datePublished"]);
         int AuthorID = Convert.ToInt32(rdr["authorId"]);
         int postID = Convert.ToInt32(rdr["PostId"]);
         string Author = rdr["FirstName"].ToString();
         int published = 1;
         Post post = new Post(postID, title, content, dtc, dtm, published, dtp, AuthorID,Author);
         NPosts.Add(post);
     }
     con1.Close();
     return NPosts;
 }
コード例 #9
0
ファイル: Post.cs プロジェクト: nksherani/EJASCMS
        //load nposts of a tag
        public static List<Post> GetNPostsbyTag(int initial, int length, string tag)
        {
            SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["globaldb"].ConnectionString);
            string q1 = "select P.* from Posts_View P, Tags T where P.PostId=T.PagePostId and tag='" + tag+"'";
            SqlDataReader rdr;
            SqlCommand com1 = new SqlCommand(q1, con1);
            con1.Open();
            rdr = com1.ExecuteReader();
            Post thread;
            List<Post> NThreads = new List<Post>();
            int n = 1;
            while (rdr.Read())
            {
                thread = new Post();
                thread.postId = Convert.ToInt32(rdr["postId"]);
                thread.title = rdr["postTitle"].ToString();
                thread.content = rdr["postContent"].ToString();
                thread.dateCreated = Convert.ToDateTime(rdr["dateCreated"]);
                thread.dateModified = Convert.ToDateTime(rdr["dateModified"]);
                thread.datePublished = Convert.ToDateTime(rdr["datePublished"]);
                thread.published = 1;
                thread.AuthorId = Convert.ToInt32(rdr["AuthorId"]);
                thread.Author = rdr["FirstName"].ToString();

                if (n >= initial && n <= initial + length - 1)//improve efficiency
                    NThreads.Add(thread);
                n++;
            }
            con1.Close();
            return NThreads;
        }