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

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

                fu.forumcommentID = reader["forumcommentID"].ToString();
                ForumEstablishment onef = ForumEstablishmentDB.getForumEstbyID(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.º 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
     {
         Establishment      es = (Establishment)Session["establishment"];
         ForumEstablishment fu = new ForumEstablishment(tbxFtitle.Text, tbxFmessage.Text, DateTime.Now, "allow", es);
         int num = ForumEstablishmentDB.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;
             elist            = ForumEstablishmentDB.getAllForumEstbyStatus();
             gvEst.DataSource = elist;
             gvEst.DataBind();
         }
     }
 }
Exemplo n.º 3
0
 protected void gvEst_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     allelist         = ForumEstablishmentDB.getAllForumEstablishment();
     gvEst.PageIndex  = e.NewPageIndex;
     gvEst.DataSource = allelist;
     gvEst.DataBind();
 }
Exemplo n.º 4
0
    protected void gvEst_SelectedIndexChanged1(object sender, EventArgs e)
    {
        List <ForumEstablishment> elist = ForumEstablishmentDB.getAllForumEstbyStatus();
        ForumEstablishment        afa   = elist[gvEst.PageSize * gvEst.PageIndex + gvEst.SelectedIndex];

        Session["hyper1"] = afa.forumID;
        Session["hyper"]  = "1";
        Server.Transfer("ForumCommentE.aspx");
    }
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 = 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";
            }
        }
    }
Exemplo n.º 6
0
    protected void gvEst_SelectedIndexChanged1(object sender, EventArgs e)
    {
        List <tempcomment> tclist = new List <tempcomment>();

        Panel1.Visible = true;
        allelist       = ForumEstablishmentDB.getAllForumEstablishment();
        ForumEstablishment fe = allelist[gvEst.PageSize * gvEst.PageIndex + gvEst.SelectedIndex];

        gvEst.SelectedIndex = -1;
        Session["forumID"]  = fe.forumID;
        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.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();
        }
    }
Exemplo n.º 7
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);
                }
            }
        }
    }
Exemplo n.º 8
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();
                }
            }
        }
    }
Exemplo n.º 9
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();
            }
        }
    }