Esempio n. 1
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();
        }
    }
    protected void btnSumbit_Click(object sender, EventArgs e)
    {
        if (tbxComment.Text == "")
        {
            lbloutput.Text = "The Comment field cannot be blank.";
            return;
        }
        else
        {
            lbloutput.Text = "";

            if (Session["hyper1"].ToString() == "1")
            {
                ForumUser             fu  = ForumUserDB.getForumUserbyID(Session["hyper"].ToString());
                Establishment         es  = (Establishment)Session["establishment"];
                ForumUserCommentbyEst fue = new ForumUserCommentbyEst(fu, tbxComment.Text, es, System.DateTime.Now, "allow");
                int num = ForumUserCommentbyEstDB.insertForumCommentUser(fue);
                if (num != 1)
                {
                    lbloutput.Text = "Fail to comment!";
                    return;
                }
                else
                {
                    Response.Redirect("ForumCommentE.aspx", true);
                }
            }
            else
            {
                ForumEstablishment   fe  = ForumEstablishmentDB.getForumEstbyID(Session["hyper1"].ToString());
                Establishment        es  = (Establishment)Session["establishment"];
                ForumEstCommentbyEst fee = new ForumEstCommentbyEst(fe, tbxComment.Text, es, System.DateTime.Now, "allow");
                int num = ForumEstCommentbyEstDB.insertForumCommentEst(fee);
                if (num != 1)
                {
                    lbloutput.Text = "Fail to comment!";
                    return;
                }
                else
                {
                    Response.Redirect("ForumCommentE.aspx", true);
                }
            }
        }
    }
Esempio n. 3
0
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string id = GridView1.SelectedRow.Cells[0].Text;
        int    enumber = 0, unumber = 0;

        if (ddlFBChoose.SelectedIndex == 1)
        {
            List <ForumUserCommentbyEst>  uelist = ForumUserCommentbyEstDB.getAlloneForumAllComment();
            List <ForumUserCommentbyUser> uulist = ForumUserCommentbyUserDB.getalloneForumAllComment();
            foreach (ForumUserCommentbyEst ue in uelist)
            {
                if (ue.forumcommentID == id)
                {
                    ufound  = true;
                    unumber = 1;
                    break;
                }
                else
                {
                    efound = false;
                }
            }

            if (efound == false)
            {
                foreach (ForumUserCommentbyUser uu in uulist)
                {
                    if (uu.forumcommentID == id)
                    {
                        efound  = true;
                        unumber = 2;
                        break;
                    }
                    else
                    {
                        efound = false;
                    }
                }
            }

            if (unumber == 1)
            {
                ForumUserCommentbyEst uecomment = ForumUserCommentbyEstDB.getoneForumCommentbyID(id);
                if (uecomment.status == "allow")
                {
                    uecomment.status = "ban";
                }
                else
                {
                    uecomment.status = "allow";
                }
                ForumUserCommentbyEstDB.updateComment(uecomment);
            }
            else
            {
                ForumUserCommentbyUser uucomment = ForumUserCommentbyUserDB.getoneForumCommentbyID(id);
                if (uucomment.status == "allow")
                {
                    uucomment.status = "ban";
                }
                else
                {
                    uucomment.status = "allow";
                }
                ForumUserCommentbyUserDB.updateComment(uucomment);
            }
        }
        else
        {
            List <ForumEstCommentbyEst>  eelist = ForumEstCommentbyEstDB.getalloneForumAllComment();
            List <ForumEstCommentbyUser> eulist = ForumEstCommentbyUserDB.getalloneForumAllComment();
            foreach (ForumEstCommentbyEst ee in eelist)
            {
                if (ee.forumcommentID == id)
                {
                    efound  = true;
                    enumber = 1;
                    break;
                }
                else
                {
                    efound = false;
                }
            }

            if (efound == false)
            {
                foreach (ForumEstCommentbyUser eu in eulist)
                {
                    if (eu.forumcommentID == id)
                    {
                        efound  = true;
                        enumber = 2;
                        break;
                    }
                    else
                    {
                        efound = false;
                    }
                }
            }

            if (enumber == 1)
            {
                ForumEstCommentbyEst eecomment = ForumEstCommentbyEstDB.getoneForumCommentbyID(id);
                if (eecomment.status == "allow")
                {
                    eecomment.status = "ban";
                }
                else
                {
                    eecomment.status = "allow";
                }
                ForumEstCommentbyEstDB.updateComment(eecomment);
            }
            else
            {
                ForumEstCommentbyUser eucomment = ForumEstCommentbyUserDB.getoneForumCommentbyID(id);
                if (eucomment.status == "allow")
                {
                    eucomment.status = "ban";
                }
                else
                {
                    eucomment.status = "allow";
                }
                ForumEstCommentbyUserDB.updateComment(eucomment);
            }
        }

        //delete the individual comment on each forum
        if (Session["u"] != null)
        {
            List <tempcomment>            tclist = new List <tempcomment>();
            List <ForumUserCommentbyEst>  fuce   = ForumUserCommentbyEstDB.getoneForumAllCommentbyID(Session["forumID"].ToString());
            List <ForumUserCommentbyUser> fucu   = ForumUserCommentbyUserDB.getoneForumAllCommentbyID(Session["forumID"].ToString());

            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();
            }
        }
        else
        {
            List <ForumEstCommentbyUser> fecu = ForumEstCommentbyUserDB.getoneForumAllCommentbyID(Session["forumID"].ToString());
            List <ForumEstCommentbyEst>  fece = ForumEstCommentbyEstDB.getoneForumAllCommentbyID(Session["forumID"].ToString());

            foreach (ForumEstCommentbyUser f in fecu)
            {
                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 (ForumEstCommentbyEst g in fece)
            {
                tempcomment tc = new tempcomment();
                tc.comentID  = g.forumcommentID;
                tc.comment   = g.comments;
                tc.commentby = g.commentby.Name.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();
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if ((Establishment)Session["establishment"] == null)
        {
            Server.Transfer("Login.aspx");
        }
        else
        {
            if (Session["hyper"].ToString() == "1")
            {
                if (Session["hyper1"].ToString() == "1")
                {
                    Server.Transfer("EstForum.aspx");
                }
                else
                {
                    lblNotFound.Visible = false;
                    ForumEstablishment fe = ForumEstablishmentDB.getForumEstbyID(Session["hyper1"].ToString());
                    lblheading.Text = "ForumID: #" + fe.forumID;
                    List <ForumEstablishment> felist = new List <ForumEstablishment>();
                    felist.Add(fe);

                    lbltitle.Text   = fe.Title;
                    lblmessage.Text = fe.message;
                    lblUser.Text    = fe.estID.ID;
                    lblDate.Text    = string.Format("{0:dd/MM/yyyy}", fe.date);

                    List <ForumEstCommentbyUser> fecu = ForumEstCommentbyUserDB.getoneForumAllCommentbyID(fe.forumID);
                    List <ForumEstCommentbyEst>  fece = ForumEstCommentbyEstDB.getoneForumAllCommentbyID(fe.forumID);

                    foreach (ForumEstCommentbyUser f in fecu)
                    {
                        tempcomment tc = new tempcomment();
                        tc.comment   = f.comments;
                        tc.commentby = f.commentby.Name.ToString();
                        tc.time      = f.date;
                        tc.timeshow  = datesub(f.date);
                        if (f.status == "allow")
                        {
                            tclist.Add(tc);
                        }
                    }

                    foreach (ForumEstCommentbyEst g in fece)
                    {
                        tempcomment tc = new tempcomment();
                        tc.comment   = g.comments;
                        tc.commentby = g.commentby.Name.ToString();
                        tc.time      = g.date;
                        tc.timeshow  = datesub(g.date);
                        if (g.status == "allow")
                        {
                            tclist.Add(tc);
                        }
                    }

                    if (tclist.Count == 0)
                    {
                        lblNotFound.Visible = true;
                        lblNotFound.Text    = "There is no comment";
                        PanelCMT.Visible    = false;
                    }
                    else
                    {
                        tclist = tclist.OrderBy(x => x.time).ToList();
                        tclist.Reverse();
                        lblNotFound.Text     = "";
                        PanelCMT.Visible     = true;
                        GridView1.DataSource = tclist;
                        GridView1.DataBind();
                    }
                }
            }
            else
            {
                ForumUser fu = ForumUserDB.getForumUserbyID(Session["hyper"].ToString());
                lblheading.Text = "ForumID: #" + fu.forumID;
                List <ForumUser> flist = new List <ForumUser>();
                flist.Add(fu);

                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.comment   = f.comments;
                    tc.commentby = f.commentby.Name.ToString();
                    tc.time      = f.date;
                    tc.timeshow  = datesub(f.date);
                    if (f.status == "allow")
                    {
                        tclist.Add(tc);
                    }
                }

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

                if (tclist.Count == 0)
                {
                    lblNotFound.Visible = true;
                    lblNotFound.Text    = "There is no comment";
                    PanelCMT.Visible    = false;
                }
                else
                {
                    tclist = tclist.OrderBy(x => x.time).ToList();
                    tclist.Reverse();
                    lblNotFound.Text     = "";
                    PanelCMT.Visible     = true;
                    GridView1.DataSource = tclist;
                    GridView1.DataBind();
                }
            }
        }
    }