예제 #1
0
파일: Display.aspx.cs 프로젝트: youye00/UDS
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                username = Request.Cookies["Username"].Value;
                itemid   = (Request.QueryString["ItemID"] == null)?0:Int32.Parse(Request.QueryString["ItemID"].ToString());
                boardid  = (Request.QueryString["BoardID"] == null)?0:Int32.Parse(Request.QueryString["BoardID"].ToString());

                ViewState["username"]      = username;
                ViewState["itemid"]        = itemid;
                ViewState["boardid"]       = boardid;
                ViewState["isboardmaster"] = isboardmaster;

                BBSClass     bbsclass     = new BBSClass();
                BBSForumItem bbsforumitem = new BBSForumItem();
                bbsforumitem.ItemID = itemid;
                SqlDataReader dr = null;
                dr = bbsclass.ReadBBSForumItem(bbsforumitem);

                //判断是否是斑竹
                isboardmaster = bbsclass.IsBoardMaster(boardid, username);
                if (isboardmaster)
                {
                    cbx_boardBulletin.Visible = true;
                }
                else
                {
                    cbx_boardBulletin.Visible = false;
                }

                if (Request.Cookies["UDSBBSAdmin"] != null)
                {
                    if (Request.Cookies["UDSBBSAdmin"].Value == "1")
                    {
                        cbx_sysBulletin.Visible = true;
                    }
                    else
                    {
                        cbx_sysBulletin.Visible = false;
                    }
                }
                else
                {
                    cbx_sysBulletin.Visible = false;
                    cbx_sysBulletin.Visible = false;
                }


                while (dr.Read())
                {
                    this.title       = lblTitle.Text = dr["title"].ToString();
                    sendtime.Text    = dr["send_time"].ToString();
                    browsetime.Text  = dr["hit_times"].ToString();
                    replaytimes.Text = dr["replay_times"].ToString();
                    sendman.Text     = dr["sender"].ToString();
                    //判断是否是系统公告,如果是只有管理员能够操作
                    if (Boolean.Parse(dr["sysbulletin"].ToString()))
                    {
                        if (Request.Cookies["UDSBBSAdmin"] != null)
                        {
                            if (Request.Cookies["UDSBBSAdmin"].Value == "1")
                            {
                                itemcontent.InnerHtml  += "<b>操作:</b><a href=javascript:window.open('DeleteItem.aspx?ItemID=" + itemid + "&BoardID=" + boardid + "','_self','');>删除此贴</a>|<a href='MoveItem.aspx?ItemID=" + itemid + "'>移动帖子</a><br><hr color='#C0C0C0' size='1'>";
                                cbx_DeskTop.Visible     = true;
                                cbx_sysBulletin.Checked = true;
                                if (Boolean.Parse(dr["DeskTop"].ToString()))
                                {
                                    cbx_DeskTop.Checked = true;
                                }
                                else
                                {
                                    cbx_DeskTop.Checked = false;
                                }
                            }
                            else
                            {
                                cbx_sysBulletin.Checked = false;
                            }
                        }
                    }
                    else
                    {
                        if ((Request.Cookies["UDSBBSAdmin"].Value == "1") || (isboardmaster))
                        {
                            itemcontent.InnerHtml += "<b>操作:</b><a href=javascript:window.open('DeleteItem.aspx?ItemID=" + itemid + "&BoardID=" + boardid + "','_self','');>删除此贴</a>|<a href='MoveItem.aspx?ItemID=" + itemid + "'>移动帖子</a><br><hr color='#C0C0C0' size='1'>";
                            cbx_DeskTop.Visible    = false;

                            if (Boolean.Parse(dr["bulletin"].ToString()))
                            {
                                cbx_boardBulletin.Checked = true;
                            }
                            else
                            {
                                cbx_boardBulletin.Checked = false;
                            }
                        }
                    }

                    itemcontent.InnerHtml += FormatTxt(UBB.txtMessage(dr["content"].ToString()));
                }
                dr.Close();
                BindData();
            }
            else
            {
                username      = ViewState["username"].ToString();
                itemid        = Int32.Parse(ViewState["itemid"].ToString());
                boardid       = Int32.Parse(ViewState["boardid"].ToString());
                isboardmaster = Boolean.Parse(ViewState["isboardmaster"].ToString());
            }
        }