コード例 #1
0
 protected void gvEst_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     allelist         = ForumEstablishmentsDB.getAllForumEstablishment();
     gvEst.PageIndex  = e.NewPageIndex;
     gvEst.DataSource = allelist;
     gvEst.DataBind();
 }
コード例 #2
0
    public static ForumEstCommentbyUser getoneForumCommentbyID(string forumcommentID)
    {
        ForumEstCommentbyUser fu = new ForumEstCommentbyUser();

        try
        {
            SqlCommand command = new SqlCommand("Select * from ForumEstCommentbyUser 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();
                ForumEstablishments onef = ForumEstablishmentsDB.getForumEstbyID(reader["forumID"].ToString());
                fu.forumID  = onef;
                fu.comments = reader["comments"].ToString();
                AUser u = AUserDB.getUserbyID(reader["commentby"].ToString());
                fu.commentby = u;
                fu.date      = Convert.ToDateTime(reader["date"]);
                fu.status    = reader["status"].ToString();
            }
            reader.Close();
        }
        finally
        {
            connection.Close();
        }
        return(fu);
    }
コード例 #3
0
    public static List <ForumEstCommentbyUser> getalloneForumAllComment()
    {
        List <ForumEstCommentbyUser> fulists = new List <ForumEstCommentbyUser>();

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

                fu.forumcommentID = reader["forumcommentID"].ToString();
                ForumEstablishments onef = ForumEstablishmentsDB.getForumEstbyID(reader["forumID"].ToString());
                fu.forumID  = onef;
                fu.comments = reader["comments"].ToString();
                AUser u = AUserDB.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);
    }
コード例 #4
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";
            }
        }
    }
コード例 #5
0
    protected void gvEst_SelectedIndexChanged1(object sender, EventArgs e)
    {
        List <tempcomment> tclist = new List <tempcomment>();

        Panel1.Visible = true;
        allelist       = ForumEstablishmentsDB.getAllForumEstablishment();
        ForumEstablishments 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();
        }
    }
コード例 #6
0
    protected void gvEst_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        allelist = ForumEstablishmentsDB.getAllForumEstablishment();
        ForumEstablishments fe = allelist[gvEst.PageSize * gvEst.PageIndex + e.RowIndex];

        if (fe.status == "allow")
        {
            fe.status = "ban";
        }
        else
        {
            fe.status = "allow";
        }
        ForumEstablishmentsDB.updateEstForum(fe);
        allelist         = ForumEstablishmentsDB.getAllForumEstablishment();
        gvEst.DataSource = allelist;
        gvEst.DataBind();
    }