Exemplo n.º 1
0
    public void MyBind()
    {
        int        pageCount = 0;
        DataTable  dt        = new DataTable();
        M_UserInfo mu        = tpuser_Bll.GetLogin(); //barBll.GetUser();

        if (!string.IsNullOrEmpty(Request.QueryString["searchstr"]) || !string.IsNullOrEmpty(Request.QueryString["uid"]) || !string.IsNullOrEmpty(Request.QueryString["islike"]))
        {
            string skey    = Request.QueryString["searchstr"];
            int    uid     = DataConvert.CLng(Request.QueryString["uid"]);
            bool   sellike = DataConvert.CLng(Request.QueryString["islike"]) > 0 ? true : false;
            string skeyTlp = "\"<span style='color:#ff6a00;'>{0}</span>\"";

            if (!string.IsNullOrEmpty(skey))
            {
                BarName_L.Text = "相关" + string.Format(skeyTlp, skey) + "的贴子";
                Title_L.Text   = skey + "\"的贴子";
                dt             = barBll.SelByCateID(skey, 3);
            }
            else if (sellike)
            {
                BarName_L.Text = string.Format(skeyTlp, "我的收藏");
                Title_L.Text   = "我的收藏";
                dt             = barBll.SelByCateID(mu.UserID.ToString(), 4);
            }
            else
            {
                M_UserInfo smu = new M_UserInfo();
                if (uid < 1)//匿名用户不允许搜索
                {
                    smu.UserName = "******";
                }
                else
                {
                    smu = buser.GetUserByUserID(uid);
                    dt  = barBll.SelByCateID(uid.ToString(), 2);
                }
                BarName_L.Text = string.Format(skeyTlp, smu.HoneyName) + "的贴子";
                Title_L.Text   = smu.HoneyName + "的贴子";
            }
            Cid = cateMod.CateID;
            totalspan.InnerText = "共搜索到" + dt.Rows.Count + "个贴子";
            function.Script(this, "SetImg('/App_Themes/User/timg.jpg');");
            IsSearch             = true;
            MsgTitle_T.Enabled   = false;
            MsgContent_T.Enabled = false;
            SendDiv.Visible      = false;
        }
        else
        {
            Cid     = cateMod.CateID;
            dt      = barBll.SelByCateID(CateID.ToString(), 1, true);
            cateMod = guestBll.GetCate(CateID);

            #region 权限校验
            if (cateMod.IsBarOwner(mu.UserID))
            {
                barowner_div.Visible = true;
                IsBarOwner           = true;
                DPBind();
            }
            else//非吧主权限验证
            {
                switch (cateMod.PermiBit)
                {
                case "1":    //版面类别
                    emptydiv.Style.Add("display", "none");
                    send_div.Visible = false;
                    RPT.Visible      = false;
                    break;

                default:
                    if (!authBll.AuthCheck(cateMod, mu, "needlog"))    //访问权限
                    {
                        function.WriteErrMsg("你没有访问权限");
                    }
                    if (!authBll.AuthCheck(cateMod, mu, "send"))    //发贴权限
                    {
                        send_div.Visible   = false;
                        noauth_div.Visible = true;
                    }
                    break;
                }
            }
            #endregion
            BarInfo_L.Text = cateMod.Desc;
            function.Script(this, "SetImg('" + cateMod.BarImage + "');");
            if (cateMod.IsNull)
            {
                function.WriteErrMsg("该贴吧不存在!!");
            }
            Title_L.Text   = cateMod.CateName;
            BarName_L.Text = cateMod.CateName;
            DataTable chdt = B_GuestBook.GetCateList(CateID);
            if (chdt.Rows.Count > 0)
            {
                ChildRPT.DataSource = chdt;
                ChildRPT.DataBind();
            }
            else
            {
                childBar.Visible = false;
            }
        }
        RPT.DataSource = PageCommon.GetPageDT(pageSize, CPage, dt, out pageCount);
        RPT.DataBind();
        int tiecount = 0;
        int recout   = 0;
        barBll.GetCount(CateID, out tiecount, out recout);
        replycount.InnerText    = recout.ToString();
        dnum_span.InnerText     = dt.Rows.Count.ToString();
        dnum_span2.InnerText    = tiecount.ToString();
        pagenum_span1.InnerText = pageCount.ToString();
        MsgPage_L.Text          = PageCommon.CreatePageHtml(pageCount, CPage);
        if (dt.Rows.Count > 0)
        {
            contentdiv.Visible = true;
        }
        else
        {
            emptydiv.Visible = true;
        }
        Anony_Span.Visible = mu.UserID <= 0;
    }