public static List <ForumUserCommentbyEst> getoneForumAllCommentbyID(string forumID)
    {
        List <ForumUserCommentbyEst> fulists = new List <ForumUserCommentbyEst>();

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

                fu.forumcommentID = reader["forumcommentID"].ToString();
                ForumUser onef = ForumUserDB.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);
    }
Пример #2
0
 protected void btnFpost_Click(object sender, EventArgs e)
 {
     if (tbxFtitle.Text == "")
     {
         lblOutputPost.Text = "Title cannot to blank";
         return;
     }
     else if (tbxFmessage.Text == "")
     {
         lblOutputPost.Text = "Message cannot to blank";
         return;
     }
     else
     {
         ForumUser fu  = new ForumUser(tbxFtitle.Text, tbxFmessage.Text, DateTime.Now, "allow", currentu);
         int       num = ForumUserDB.insertForum(fu);
         if (num != 1)
         {
             lblOutputPost.Text = "Cannot Post Forum Right Now!";
             return;
         }
         else
         {
             lblOutputPost.Text = "Successfully Posted!";
             lblGVOutput.Text   = "";
             tbxFmessage.Text   = "";
             tbxFtitle.Text     = "";
             Panel1.Visible     = true;
             flist             = ForumUserDB.getAllForumUserbyStatus();
             gvUser.DataSource = flist;
             gvUser.DataBind();
         }
     }
 }
Пример #3
0
 protected void gvUser_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     allflist          = ForumUserDB.getAllForumUser();
     gvUser.PageIndex  = e.NewPageIndex;
     gvUser.DataSource = allflist;
     gvUser.DataBind();
 }
    public static List <ForumUserCommentbyUser> getalloneForumAllComment()
    {
        List <ForumUserCommentbyUser> fulists = new List <ForumUserCommentbyUser>();

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

                fu.forumcommentID = reader["forumcommentID"].ToString();
                ForumUser onef = ForumUserDB.getForumUserbyID(reader["forumID"].ToString());
                fu.forumID  = onef;
                fu.comments = reader["comments"].ToString();
                Users u = UsersDB.getUserbyID(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);
    }
Пример #5
0
    protected void gvUser_SelectedIndexChanged1(object sender, EventArgs e)
    {
        List <ForumUser> flist = ForumUserDB.getAllForumUserbyStatus();
        ForumUser        afa   = flist[gvUser.PageSize * gvUser.PageIndex + gvUser.SelectedIndex];

        Session["hyper"]  = afa.forumID;
        Session["hyper1"] = "1";
        Server.Transfer("ForumCommentE.aspx");
    }
Пример #6
0
    protected void gvUser_SelectedIndexChanged1(object sender, EventArgs e)
    {
        List <tempcomment> tclist = new List <tempcomment>();

        Panel1.Visible = true;
        allflist       = ForumUserDB.getAllForumUser();
        ForumUser 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();
        }
    }
Пример #7
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 = ForumUserDB.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 = ForumEstablishmentDB.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";
            }
        }
    }
Пример #8
0
    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);
                }
            }
        }
    }
Пример #9
0
    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();
                }
            }
        }
    }
Пример #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["establishment"] == null)
        {
            Server.Transfer("Login.aspx");
        }
        else
        {
            tbxChat.Text = "";
            List <Chat> clist = ChatDB.getallChat();
            foreach (Chat ch in clist)
            {
                Users s = UsersDB.getUserbyID(ch.by);
                if (s.email == null)
                {
                    Establishment es = EstablishmentDB.getEstablishmentByID(ch.by);
                    if (ch.status == "allow")
                    {
                        tbxChat.Text += es.Name + " @ " + ch.time + " : " + ch.message + "\r\n";
                    }
                }
                else
                {
                    if (ch.status == "allow")
                    {
                        tbxChat.Text += s.username + " @ " + ch.time + " : " + ch.message + "\r\n";
                    }
                }
            }
            cnum = clist.Count;


            currente           = (Establishment)(Session["establishment"]);
            lblOutputPost.Text = "";
            List <ForumUser> flist = ForumUserDB.getAllForumUserbyStatus();

            if (flist.Count == 0)
            {
                Panel1.Visible   = false;
                lblGVOutput.Text = "There is no forum posted by user right now!";
            }
            else
            {
                Panel1.Visible    = true;
                gvUser.DataSource = flist;
                gvUser.DataBind();
                lblGVOutput.Text = "";
            }

            List <ForumEstablishment> elist = ForumEstablishmentDB.getAllForumEstbyStatus();

            if (elist.Count == 0)
            {
                Panel2.Visible      = false;
                lblGVEstOutput.Text = "There is no forum posted by establishment right now!";
            }
            else
            {
                lblGVEstOutput.Text = "";
                Panel2.Visible      = true;
                gvEst.DataSource    = elist;
                gvEst.DataBind();
            }
        }
    }