Exemplo n.º 1
0
    public static ForumUserCommentbyEst getoneForumCommentbyID(string forumcommentID)
    {
        ForumUserCommentbyEst fu = new ForumUserCommentbyEst();

        try
        {
            SqlCommand command = new SqlCommand("Select * from ForumUserCommentbyEst where forumcommentID=@forumcommentID");
            command.Parameters.AddWithValue("@forumcommentID", forumcommentID);
            command.Connection = connection;
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                fu.forumcommentID = reader["forumcommentID"].ToString();
                AForumUser onef = AForumUserDB.getForumUserbyID(reader["forumID"].ToString());
                fu.forumID  = onef;
                fu.comments = reader["comments"].ToString();
                Establishment u = EstablishmentDB.getEstablishmentByID(reader["commentby"].ToString());
                fu.commentby = u;
                fu.date      = Convert.ToDateTime(reader["date"]);
                fu.status    = reader["status"].ToString();
            }
            reader.Close();
        }
        finally
        {
            connection.Close();
        }
        return(fu);
    }
Exemplo n.º 2
0
    public static List <ForumUserCommentbyEst> getAlloneForumAllComment()
    {
        List <ForumUserCommentbyEst> fulists = new List <ForumUserCommentbyEst>();

        try
        {
            SqlCommand command = new SqlCommand("Select * from ForumUserCommentbyEst");
            command.Connection = connection;
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                ForumUserCommentbyEst fu = new ForumUserCommentbyEst();

                fu.forumcommentID = reader["forumcommentID"].ToString();
                AForumUser onef = AForumUserDB.getForumUserbyID(reader["forumID"].ToString());
                fu.forumID  = onef;
                fu.comments = reader["comments"].ToString();
                Establishment u = EstablishmentDB.getEstablishmentByID(reader["commentby"].ToString());
                fu.commentby = u;
                fu.date      = Convert.ToDateTime(reader["date"]);
                fu.status    = reader["status"].ToString();
                fulists.Add(fu);
            }
            reader.Close();
        }
        finally
        {
            connection.Close();
        }
        return(fulists);
    }
Exemplo n.º 3
0
 protected void gvUser_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     allflist          = AForumUserDB.getAllForumUser();
     gvUser.PageIndex  = e.NewPageIndex;
     gvUser.DataSource = allflist;
     gvUser.DataBind();
 }
Exemplo n.º 4
0
    protected void gvUser_SelectedIndexChanged1(object sender, EventArgs e)
    {
        List <tempcomment> tclist = new List <tempcomment>();

        Panel1.Visible = true;
        allflist       = AForumUserDB.getAllForumUser();
        AForumUser fu = allflist[gvUser.PageSize * gvUser.PageIndex + gvUser.SelectedIndex];

        Session["forumID"]   = fu.forumID;
        gvUser.SelectedIndex = -1;
        lbltitle.Text        = fu.Title;
        lblmessage.Text      = fu.message;
        lblUser.Text         = fu.userID.username;
        lblDate.Text         = string.Format("{0:dd/MM/yyyy}", fu.date);

        List <ForumUserCommentbyEst>  fuce = ForumUserCommentbyEstDB.getoneForumAllCommentbyID(fu.forumID);
        List <ForumUserCommentbyUser> fucu = ForumUserCommentbyUserDB.getoneForumAllCommentbyID(fu.forumID);

        foreach (ForumUserCommentbyEst f in fuce)
        {
            tempcomment tc = new tempcomment();
            tc.comentID  = f.forumcommentID;
            tc.comment   = f.comments;
            tc.commentby = f.commentby.Name.ToString();
            tc.time      = f.date;
            tc.status    = f.status;
            tc.timeshow  = datesub(f.date);
            tclist.Add(tc);
        }

        foreach (ForumUserCommentbyUser g in fucu)
        {
            tempcomment tc = new tempcomment();
            tc.comentID  = g.forumcommentID;
            tc.comment   = g.comments;
            tc.commentby = g.commentby.username.ToString();
            tc.time      = g.date;
            tc.status    = g.status;
            tc.timeshow  = datesub(g.date);
            tclist.Add(tc);
        }

        if (tclist.Count == 0)
        {
            lblNotFound.Visible = true;
        }
        else
        {
            tclist = tclist.OrderBy(x => x.time).ToList();
            tclist.Reverse();
            lblNotFound.Visible  = false;
            GridView1.DataSource = tclist;
            GridView1.DataBind();
        }
    }
Exemplo n.º 5
0
    protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlFBChoose.SelectedIndex == 0)
        {
            panelEst.Visible    = false;
            panelUser.Visible   = false;
            Panel1.Visible      = false;
            lblSelectError.Text = "";
        }

        else if (ddlFBChoose.SelectedIndex == 1)
        {
            allflist = AForumUserDB.getAllForumUser();

            if (allflist.Count == 0)
            {
                lblSelectError.Text = "Sorry there is no forum by User found in the moment!";
                panelUser.Visible   = false;
                panelEst.Visible    = false;
            }
            else
            {
                panelUser.Visible = true;
                panelEst.Visible  = false;
                Panel1.Visible    = false;
                gvUser.DataSource = allflist;
                gvUser.DataBind();
                lblSelectError.Text = "The are " + allflist.Count + " Forum posted by Users found!";
                Session["u"]        = "user";
                Session["e"]        = null;
            }
        }
        else
        {
            allelist = ForumEstablishmentsDB.getAllForumEstablishment();

            if (allelist.Count == 0)
            {
                lblSelectError.Text = "Sorry there is no forum by Establishment found in the moment!";
                panelUser.Visible   = false;
                panelEst.Visible    = false;
            }
            else
            {
                panelUser.Visible = false;
                panelEst.Visible  = true;
                Panel1.Visible    = false;
                gvEst.DataSource  = allelist;
                gvEst.DataBind();
                lblSelectError.Text = "The are " + allelist.Count + " Forum posted by Establishment found!";
                Session["u"]        = null;
                Session["e"]        = "est";
            }
        }
    }
Exemplo n.º 6
0
    protected void gvUser_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        allflist = AForumUserDB.getAllForumUser();
        AForumUser af = allflist[gvUser.PageSize * gvUser.PageIndex + e.RowIndex];

        if (af.status == "allow")
        {
            af.status = "ban";
        }
        else
        {
            af.status = "allow";
        }
        AForumUserDB.updateUserForum(af);
        allflist          = AForumUserDB.getAllForumUser();
        gvUser.DataSource = allflist;
        gvUser.DataBind();
    }