public void AdminBlogDelete(blog_postBO blogInfo)
    {
        try
        {
            if (newcon.State == ConnectionState.Closed)
            {
                newcon.Open();
            }


            String query = "Delete from blog_post where blog_id = @bid";
            command = new SqlCommand(query, newcon);
            command.Parameters.AddWithValue("@bid", blogInfo.blog_id);
            command.ExecuteNonQuery();
        }
        catch
        {
            throw;
        }
        finally
        {
            if (newcon.State == ConnectionState.Open)
            {
                newcon.Close();
            }
        }
    }
示例#2
0
    public void AdminBlogDelete(blog_postBO blogInfo)
    {
        try
        {
            if (newcon.State == ConnectionState.Closed)
            {
                newcon.Open();
            }

            String query = "Delete from blog_post where blog_id = @bid";
            command = new SqlCommand(query, newcon);
            command.Parameters.AddWithValue("@bid", blogInfo.blog_id);
            command.ExecuteNonQuery();
        }
        catch
        {
            throw;
        }
        finally
        {
            if (newcon.State == ConnectionState.Open)
            {
                newcon.Close();
            }
        }
    }
示例#3
0
    public void AdminBlogEdit(blog_postBO nBlog)
    {
        try
        {
            if (newcon.State == ConnectionState.Closed)
            {
                newcon.Open();
            }

            String query = "Update blog_post set blog_title=@title,blog_content=@content where blog_id = @bid";
            command = new SqlCommand(query, newcon);

            command.Parameters.AddWithValue("@title", nBlog.blog_title.ToString());
            command.Parameters.AddWithValue("@content", nBlog.blog_content.ToString());
            command.Parameters.AddWithValue("@bid", nBlog.blog_id);

            command.ExecuteNonQuery();
            command.Dispose();
            newcon.Close();

        }
        catch
        {
            throw;
        }

        finally
        {
            if (newcon.State == ConnectionState.Open)
            {
                newcon.Close();
            }
        }
    }
    public void AdminBlogEdit(blog_postBO nBlog)
    {
        try
        {
            if (newcon.State == ConnectionState.Closed)
            {
                newcon.Open();
            }


            String query = "Update blog_post set blog_title=@title,blog_content=@content where blog_id = @bid";
            command = new SqlCommand(query, newcon);

            command.Parameters.AddWithValue("@title", nBlog.blog_title.ToString());
            command.Parameters.AddWithValue("@content", nBlog.blog_content.ToString());
            command.Parameters.AddWithValue("@bid", nBlog.blog_id);


            command.ExecuteNonQuery();
            command.Dispose();
            newcon.Close();
        }
        catch
        {
            throw;
        }

        finally
        {
            if (newcon.State == ConnectionState.Open)
            {
                newcon.Close();
            }
        }
    }
    public void UserPostNewBlog(blog_postBO nBlog)
    {
        try
        {
            Next_ID nid = new Next_ID();
            nBlog.blog_id = nid.incrementer("blog_id", "blog_post");

            if (newcon.State == ConnectionState.Closed)
            {
                newcon.Open();
            }



            int isadmin      = 0;
            int blog_checked = 0;;
            nBlog.date_time_of_post = System.DateTime.Now;


            if (nBlog.is_admin)
            {
                isadmin      = 1;
                blog_checked = 1;
            }
            else
            {
                isadmin      = 0;
                blog_checked = 0;
            }

            String query = "insert into blog_post(blog_id,blog_title,blog_content,poster_id,is_admin,date_time_of_post,blog_checked) values(@bid,@title,@content,@posterid,@isadmin,@datetime,@blog_checked)";
            command = new SqlCommand(query, newcon);

            command.Parameters.AddWithValue("@bid", nBlog.blog_id);
            command.Parameters.AddWithValue("@title", nBlog.blog_title.ToString());
            command.Parameters.AddWithValue("@content", nBlog.blog_content.ToString());
            command.Parameters.AddWithValue("@posterid", nBlog.poster_id);
            command.Parameters.AddWithValue("@isadmin", isadmin);
            command.Parameters.AddWithValue("@datetime", nBlog.date_time_of_post.ToString());
            command.Parameters.AddWithValue("@blog_checked", blog_checked);

            command.ExecuteNonQuery();
            command.Dispose();
            newcon.Close();
        }

        catch
        {
            throw;
        }
        finally
        {
            if (newcon.State == ConnectionState.Open)
            {
                newcon.Close();
            }
        }
    }
示例#6
0
 public void AdminBlogDelete(blog_postBO blogInfo)
 {
     try
     {
         adminfunction.AdminBlogDelete(blogInfo);
     }
     catch
     {
         throw;
     }
 }
示例#7
0
 public void UserPostNewBlog(blog_postBO nBlog)
 {
     try
     {
         userFunctions.UserPostNewBlog(nBlog);
     }
     catch
     {
         throw;
     }
 }
 public void AdminBlogDelete(blog_postBO blogInfo)
 {
     try
     {
         adminfunction.AdminBlogDelete(blogInfo);
     }
     catch
     {
         throw;
     }
 }
 public void AdminPostBlog(blog_postBO nblog)
 {
     try
     {
         adminfunction.AdminPostBlog(nblog);
     }
     catch
     {
         throw;
     }
 }
    public blog_postBO AdminBlogViewer(int blog_id)
    {
        blog_postBO blog = new blog_postBO();

        try
        {
            if (newcon.State == ConnectionState.Closed)
            {
                newcon.Open();
            }


            String query = "Select * from blog_post where blog_id = @bid";
            command = new SqlCommand(query, newcon);
            command.Parameters.AddWithValue("@bid", blog_id);

            reader = command.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                {
                    blog.blog_id           = Convert.ToInt32(reader[0]);
                    blog.blog_title        = reader[1].ToString();
                    blog.blog_content      = reader[2].ToString();
                    blog.poster_id         = Convert.ToInt32(reader[3]);
                    blog.is_admin          = (Convert.ToInt16(reader[4]) == 1) ? true : false;
                    blog.date_time_of_post = Convert.ToDateTime(reader[5]);
                    blog.blog_checked      = (Convert.ToInt16(reader[7]) == 1) ? true : false;
                }
            }
            else
            {
                blog = null;
            }

            command.Dispose();
            reader.Dispose();

            return(blog);
        }
        catch
        {
            throw;
        }
        finally
        {
            if (newcon.State == ConnectionState.Open)
            {
                newcon.Close();
            }
        }
    }
    public void AdminBlogEdit(blog_postBO nBlog)
    {
        try
        {
            adminfunction.AdminBlogEdit(nBlog);
        }

        catch
        {
            throw;
        }
    }
示例#12
0
    public void AdminBlogEdit(blog_postBO nBlog)
    {
        try
           {
           adminfunction.AdminBlogEdit(nBlog);
           }

           catch
           {
           throw;
           }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["admin_id"] == null)
        {
            Response.Redirect("AdminLogin.aspx");
        }
        else
        {
            if (!(Page.IsPostBack))
            {
                if (Request.QueryString["id"] == null)
                {
                    Response.Redirect("~/Admin/AdminBlog.aspx");
                }

                else
                {
                    try
                    {
                        blog = blogviewer.AdminBlogViewer(Convert.ToInt32(Request.QueryString["id"]));

                        if (blog == null)
                        {
                            Response.Write("Sorry, But the blog is not present");
                        }
                        else
                        {
                            div_blog_title.InnerText     = Server.HtmlDecode(blog.blog_title.ToString());
                            div_blog_date_time.InnerText = Server.HtmlDecode((blog.date_time_of_post).ToLongDateString());
                            spn_posterName.InnerText     = Server.HtmlDecode((blogviewer.AdminName(blog.poster_id)).ToString()); //getting the admin name from admin_id
                            spn_timeOfPost.InnerText     = Server.HtmlDecode(blog.date_time_of_post.ToShortTimeString());


                            if (blog.blog_checked == true)
                            {
                                div_blog_body.InnerHtml = Server.HtmlDecode(blog.blog_content.ToString());
                                blog_checked            = true;
                            }
                            else if (blog.blog_checked == false)
                            {
                                div_blog_body.InnerHtml = "<center><h3>This Blog is not posted yet, awaiting for admin to check it </h3></center>" + Server.HtmlDecode(blog.blog_content.ToString());
                                btnEdit.Text            = "POST";
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Response.Write("Error Ocured : " + ex.ToString());
                    }
                }
            }
        }
    }
示例#14
0
 protected void lbtnDelete_Command(object sender, CommandEventArgs e)
 {
     try
     {
         blog_postBO blogInfo = new blog_postBO();
         blogInfo.blog_id = Convert.ToInt32(e.CommandArgument.ToString());
         newpostlister.AdminBlogDelete(blogInfo);
         Response.Redirect("~/Admin/NewPostRequest.aspx");
     }
     catch (Exception ex)
     {
         Response.Write("Error Occured : " + ex.ToString());
     }
 }
示例#15
0
    protected void lbtnDelete_Click(object sender, CommandEventArgs e)
    {
        try
        {

            blog_postBO blogInfo = new blog_postBO();
            blogInfo.blog_id = Convert.ToInt32(e.CommandArgument.ToString());
            adminBlogFunctions.AdminBlogDelete(blogInfo);
            Response.Redirect("~/Admin/AdminBlog.aspx");
        }
        catch (Exception ex)
        {
            Response.Write("Error Occured : " + ex.ToString());
        }
    }
示例#16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["admin_id"] == null)
        {
            Response.Redirect("AdminLogin.aspx");
        }
        else
        {
            if (!(Page.IsPostBack))
            {

                if (Request.QueryString["id"] == null)
                {
                    Response.Redirect("~/Admin/AdminBlog.aspx");
                }

                else
                {

                    try
                    {
                        blog = blogviewer.AdminBlogViewer(Convert.ToInt32(Request.QueryString["id"]));

                        if (blog == null)
                        {
                            Response.Write("Sorry, But the blog is not present");
                        }
                        else
                        {

                            div_blog_title.InnerText = Server.HtmlDecode(blog.blog_title.ToString());
                            div_blog_date_time.InnerText = Server.HtmlDecode((blog.date_time_of_post).ToLongDateString());
                            div_blog_body.InnerHtml = Server.HtmlDecode(blog.blog_content.ToString());
                            spn_posterName.InnerText = Server.HtmlDecode((blogviewer.AdminName(blog.poster_id)).ToString());   //getting the admin name from admin_id
                            spn_timeOfPost.InnerText = Server.HtmlDecode(blog.date_time_of_post.ToShortTimeString());

                        }
                    }
                    catch (Exception ex)
                    {
                        Response.Write("Error Ocured : " + ex.ToString());
                    }

                }
            }
        }
    }
示例#17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["viewBlog_id"] == null)
        {
            Response.Redirect("~/Blog.aspx");
        }

        else
        {
            try
            {
                id = Convert.ToInt32(Convert.ToInt32(Session["viewBlog_id"]));
                //Session["viewBlog_id"] = null;
                blog = blogviewer.UserBlogViewer(id);

                if (blog == null)
                {
                    div_blog_title.InnerText = "Sorry, But the blog is not present";
                }
                else
                {
                    div_blog_title.InnerText     = Server.HtmlDecode(blog.blog_title.ToString());
                    div_blog_date_time.InnerText = Server.HtmlDecode((blog.date_time_of_post).ToLongDateString());
                    div_blog_body.InnerHtml      = Server.HtmlDecode(blog.blog_content.ToString());
                    spn_posterName.InnerText     = Server.HtmlDecode((blogviewer.UserNameFetch(blog.poster_id)).ToString()); //getting the admin name from admin_id
                    spn_timeOfPost.InnerText     = Server.HtmlDecode(blog.date_time_of_post.ToShortTimeString());


                    //lading the comments
                    Listcomments();


                    if (!(Page.IsPostBack))
                    {
                        blogviewer.SetBlogViewCount(Convert.ToInt32(Session["viewBlog_id"]));
                    }
                }
            }

            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>");
            }
        }
    }
示例#18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["admin_id"] == null)
        {
            Response.Redirect("AdminLogin.aspx");
        }
        else
        {
        if (!(Page.IsPostBack))
        {

            if (Request.QueryString["id"] == null)
            {
                Response.Redirect("~/Admin/AdminBlog.aspx");
            }

            else
            {

                try
                {
                    blog = blogedit.AdminBlogViewer(Convert.ToInt32(Request.QueryString["id"]));

                    if (blog == null)
                    {
                        Response.Write("Sorry, But the blog is not present");
                    }
                    else
                    {
                        txtBlogTitle.Value = Server.HtmlDecode(blog.blog_title.ToString());
                        div_blog_body.InnerHtml = Server.HtmlDecode(blog.blog_content.ToString());
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("Error Ocured : " + ex.ToString());
                }

            }
        }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["admin_id"] == null)
        {
            Response.Redirect("AdminLogin.aspx");
        }
        else
        {
            if (!(Page.IsPostBack))
            {
                if (Request.QueryString["id"] == null)
                {
                    Response.Redirect("~/Admin/AdminBlog.aspx");
                }

                else
                {
                    try
                    {
                        blog = blogedit.AdminBlogViewer(Convert.ToInt32(Request.QueryString["id"]));

                        if (blog == null)
                        {
                            Response.Write("Sorry, But the blog is not present");
                        }
                        else
                        {
                            txtBlogTitle.Value      = Server.HtmlDecode(blog.blog_title.ToString());
                            div_blog_body.InnerHtml = Server.HtmlDecode(blog.blog_content.ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        Response.Write("Error Ocured : " + ex.ToString());
                    }
                }
            }
        }
    }
示例#20
0
    public void AdminPostBlog(blog_postBO nBlog)
    {
        try
        {
            Next_ID nid = new Next_ID();
            nBlog.blog_id = nid.incrementer("blog_id", "blog_post");

            if (newcon.State == ConnectionState.Closed)
            {
                newcon.Open();
            }

            int isadmin = 0;

            nBlog.date_time_of_post = System.DateTime.Now;

            if (nBlog.is_admin)
            {
                isadmin = 1;
            }
            else
            {
                isadmin = 0;
            }

            String query = "insert into blog_post values(@bid,@title,@content,@posterid,@isadmin,@datetime)";
            command = new SqlCommand(query, newcon);

            command.Parameters.AddWithValue("@bid",nBlog.blog_id);
            command.Parameters.AddWithValue("@title", nBlog.blog_title.ToString());
            command.Parameters.AddWithValue("@content", nBlog.blog_content.ToString());
            command.Parameters.AddWithValue("@posterid",nBlog.poster_id);
            command.Parameters.AddWithValue("@isadmin",isadmin);
            command.Parameters.AddWithValue("@datetime", nBlog.date_time_of_post.ToString());

            command.ExecuteNonQuery();
            command.Dispose();
            newcon.Close();
        }

        catch
        {
            throw;
        }
        finally
        {
            if (newcon.State == ConnectionState.Open)
            {
                newcon.Close();
            }
        }
    }
示例#21
0
    public blog_postBO UserBlogViewer(int blog_id)
    {
        blog_postBO blog = new blog_postBO();
        try
        {
            if (newcon.State == ConnectionState.Closed)
            {
                newcon.Open();
            }

            String query = "Select * from blog_post where blog_id = @bid";
            command = new SqlCommand(query, newcon);
            command.Parameters.AddWithValue("@bid", blog_id);

            reader = command.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                {
                    blog.blog_id = Convert.ToInt32(reader[0]);
                    blog.blog_title = reader[1].ToString();
                    blog.blog_content = reader[2].ToString();
                    blog.poster_id = Convert.ToInt32(reader[3]);
                    blog.is_admin = (Convert.ToInt16(reader[4]) == 1) ? true : false;
                    blog.date_time_of_post = Convert.ToDateTime(reader[5]);
                }
            }
            else
            {
                blog = null;
            }

            command.Dispose();
            reader.Dispose();

            return blog;
        }
        catch
        {
            throw;
        }
        finally
        {
            if (newcon.State == ConnectionState.Open)
            {
                newcon.Close();
            }
        }
    }
示例#22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] == null)
        {
            Response.Redirect("~/HopeInTomorrow/Blog.aspx");
        }

        else
        {

            try
            {
                id = Convert.ToInt32(Request.QueryString["id"]);
                blog = blogviewer.UserBlogViewer(id);

                if (blog == null)
                {
                    div_blog_title.InnerText ="Sorry, But the blog is not present";
                }
                else
                {

                    div_blog_title.InnerText = Server.HtmlDecode(blog.blog_title.ToString());
                    div_blog_date_time.InnerText = Server.HtmlDecode((blog.date_time_of_post).ToLongDateString());
                    div_blog_body.InnerHtml = Server.HtmlDecode(blog.blog_content.ToString());
                    spn_posterName.InnerText = Server.HtmlDecode((blogviewer.UserNameFetch(blog.poster_id)).ToString());   //getting the admin name from admin_id
                    spn_timeOfPost.InnerText = Server.HtmlDecode(blog.date_time_of_post.ToShortTimeString());

                    //lading the comments
                    Listcomments();

                }
            }
            catch (Exception ex)
            {
                Response.Write("Error Ocured : " + ex.ToString());
            }

        }
    }
示例#23
0
    public void AdminPostBlog(blog_postBO nblog)
    {
        try
           {
           adminfunction.AdminPostBlog(nblog);

           }
           catch
           {
           throw;
           }
    }