Пример #1
0
    protected void btnPostComment_Click(object sender, EventArgs e)
    {
        try
        {
            if (Session["user_id"] != null)
            {
                blog_commentsBO usercomment = new blog_commentsBO();

                //First : Post the comment

                usercomment.blog_id = id;
                usercomment.is_admin = false;
                usercomment.poster_id = Convert.ToInt32(Session["user_id"]);
                usercomment.comment = txtcomment.Value.ToString();

                blogviewer.BlogPostComments(usercomment);

                txtcomment.Value = "";

                // Second : Load the comments

                Listcomments();
            }
            else
            {
                Response.Write("<script type='text/javascript'> alert('Sign In First To Post Any Comments'); </script>");
            }
        }
        catch(Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
Пример #2
0
 public void BlogPostComments(blog_commentsBO blogComment)
 {
     try
     {
         userFunctions.BlogPostComments(blogComment);
     }
     catch
     {
         throw;
     }
 }
Пример #3
0
 public void BlogPostComments(blog_commentsBO blogComment)
 {
     try
     {
         userFunctions.BlogPostComments(blogComment);
     }
     catch
     {
         throw;
     }
 }
Пример #4
0
    public void BlogPostComments(blog_commentsBO blogComment)
    {
        try
        {
            if (newcon.State == ConnectionState.Closed)
            {
                newcon.Open();
            }

            Next_ID id = new Next_ID();

            blogComment.comment_id = id.incrementer("comment_id","blog_comments");
            blogComment.date_time_of_comment = System.DateTime.Now;

            String query = "insert into blog_comments values(@comment_id,@blog_id,@poster_id,@is_admin,@comment,@date_time_of_post)";
            command = new SqlCommand(query, newcon);

            command.Parameters.AddWithValue("@comment_id", blogComment.comment_id);
            command.Parameters.AddWithValue("@blog_id",blogComment.blog_id);
            command.Parameters.AddWithValue("@poster_id",blogComment.poster_id);
            command.Parameters.AddWithValue("@is_admin", Convert.ToInt32((blogComment.is_admin ? 1 : 0)));
            command.Parameters.AddWithValue("@comment",blogComment.comment.ToString());
            command.Parameters.AddWithValue("@date_time_of_post", blogComment.date_time_of_comment.ToString());

            command.ExecuteNonQuery();

            command.Dispose();

        }
        catch
        {
            throw;
        }
        finally
        {
            if (newcon.State == ConnectionState.Open)
            {
                newcon.Close();
            }
        }
    }
    public void BlogPostComments(blog_commentsBO blogComment)
    {
        try
        {
            if (newcon.State == ConnectionState.Closed)
            {
                newcon.Open();
            }

            Next_ID id = new Next_ID();

            blogComment.comment_id           = id.incrementer("comment_id", "blog_comments");
            blogComment.date_time_of_comment = System.DateTime.Now;

            String query = "insert into blog_comments values(@comment_id,@blog_id,@poster_id,@is_admin,@comment,@date_time_of_post)";
            command = new SqlCommand(query, newcon);

            command.Parameters.AddWithValue("@comment_id", blogComment.comment_id);
            command.Parameters.AddWithValue("@blog_id", blogComment.blog_id);
            command.Parameters.AddWithValue("@poster_id", blogComment.poster_id);
            command.Parameters.AddWithValue("@is_admin", Convert.ToInt32((blogComment.is_admin ? 1 : 0)));
            command.Parameters.AddWithValue("@comment", blogComment.comment.ToString());
            command.Parameters.AddWithValue("@date_time_of_post", blogComment.date_time_of_comment.ToString());

            command.ExecuteNonQuery();

            command.Dispose();
        }
        catch
        {
            throw;
        }
        finally
        {
            if (newcon.State == ConnectionState.Open)
            {
                newcon.Close();
            }
        }
    }
Пример #6
0
    protected void btnPostComment_Click(object sender, EventArgs e)
    {
        try
        {
            if (Session["user_id"] != null)
            {
                if (txtcomment.Value.Trim() != "")
                {
                    blog_commentsBO usercomment = new blog_commentsBO();

                    //First : Post the comment

                    usercomment.blog_id   = id;
                    usercomment.is_admin  = false;
                    usercomment.poster_id = Convert.ToInt32(Session["user_id"]);
                    usercomment.comment   = txtcomment.Value.ToString();

                    blogviewer.BlogPostComments(usercomment);

                    txtcomment.Value = "";

                    // Second : Load the comments

                    Listcomments();
                }
            }
            else
            {
                String loginStatus = "<script type='text/javascript'> alert('Sign In First To Post Any Comments'); </script>";
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "loginStatus", loginStatus, false);
            }
        }
        catch (Exception ex)
        {
            ErrorReportBAL error = new ErrorReportBAL();
            error.SendErrorReport("ViewPost.aspx", ex.ToString());
            //Response.Write("<script>alert('Some Error Occured \n Sorry for inconvenience');</script>");
        }
    }