Files
g.hnyhua.cn/Mtxfw.shop/bbs/list.aspx.cs
2026-02-07 15:48:27 +08:00

148 lines
7.5 KiB
C#

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Mtxfw.shop.bbs
{
/// <summary>
/// myShoppingCart 的摘要说明。
/// </summary>
public partial class lists : System.Web.UI.Page
{
Mtxfw.DAL.Ads daoAds = new Mtxfw.DAL.Ads();
protected string ShowConent = "";
public Mtxfw.DAL.user_info daoUser = new Mtxfw.DAL.user_info();
public Mtxfw.DAL.forum daoforum = new Mtxfw.DAL.forum();
public Mtxfw.DAL.bbs daobbs = new Mtxfw.DAL.bbs();
Mtxfw.Utility.Config config = new Mtxfw.Utility.Config();
protected int IFStores = 0, ClassID=0;
protected string AdsName01, AdsName02;
protected string indexTP01, indexTP02;
protected string indexTPLink01, indexTPLink02;
protected string strposition = "", iftj = "0", strUrl = "/forum.html?page={0}";
protected void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (Session["MemberId"] != null && Session["MemberIFStores"] != null)
{
IFStores = int.Parse(Session["MemberIFStores"].ToString());
}
System.Data.DataSet Ds_Ads = daoAds.GetCacheList("top 1", "utype=N'论坛广告' Order By AdsSort desc", "bbs_Ads2");
System.Data.DataTable Dt_Ads = Ds_Ads != null && Ds_Ads.Tables[0] != null ? Ds_Ads.Tables[0] : null;
foreach (System.Data.DataRow Dr in Dt_Ads.Rows)
{
indexTP01 = Dr["AdsPic"].ToString();
indexTPLink01 = Dr["AdsUrl"].ToString();
AdsName01 = Dr["AdsName"].ToString();
}
if (!Page.IsPostBack)
{
MyPager.UrlRewritePattern = strUrl;
myDataBind();
}
}
private void myDataBind()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
String ClsID = Mtxfw.Utility.Tools.SafeSQL(Request.QueryString["classid"]);
String stype = Mtxfw.Utility.Tools.SafeSQL(Request.QueryString["stype"]);
String key = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(Request.QueryString["keyword"]));
String iPage = Mtxfw.Utility.Tools.SafeSQL(Request.QueryString["Page"]);
Page.Title = "所有帖子-" + config.webName;
Page.MetaDescription = "所有帖子-" + config.webDescription;
Page.MetaKeywords = "所有帖子-" + config.webKeywords;
strposition = "所有帖子";
if (!String.IsNullOrEmpty(stype) && stype != "-1")
{
strUrl = "/forum-type-" + stype + ".html?page={0}";
MyPager.UrlRewritePattern = strUrl;
if (stype == "tj")
{
iftj = "1";
sb.Append(" and B_IFTJ=1");
Page.Title = "重点推荐帖子-" + config.webName;
Page.MetaDescription = "重点推荐帖子-" + config.webName + "-" + config.webDescription;
Page.MetaKeywords = "重点推荐帖子," + config.webKeywords;
strposition = "重点推荐帖子";
}
if (stype == "hot")
{
sb.Append(" and B_IFHot=1");
Page.Title = "热贴专区-" + config.webName;
Page.MetaDescription = "热贴专区-" + config.webName + "-" + config.webDescription;
Page.MetaKeywords = "热贴专区," + config.webKeywords;
strposition = "热贴专区";
}
if (stype == "0" || stype == "1" || stype == "2" || stype == "3" || stype == "4" || stype == "5" || stype == "6" || stype == "7")
{
sb.Append(" and B_TType=" + stype);
Page.Title = "所有" + Mtxfw.Utility.Common.GetB_TType(stype) + "贴子-" + config.webName;
Page.MetaDescription = "所有" + Mtxfw.Utility.Common.GetB_TType(stype) + "贴子-" + config.webName + "-" + config.webDescription;
Page.MetaKeywords = "所有" + Mtxfw.Utility.Common.GetB_TType(stype) + "贴子," + config.webKeywords;
strposition = "所有" + Mtxfw.Utility.Common.GetB_TType(stype) + "贴子";
}
}
if (!String.IsNullOrEmpty(ClsID) && ClsID != "-1")
{
ClsID = Mtxfw.Utility.Tools.SafeSQL(ClsID);
strUrl = "forum-" + ClsID + ".html?page={0}";
MyPager.UrlRewritePattern = strUrl;
ClassID = Convert.ToInt32(ClsID);
System.Data.DataSet Ds = daoforum.GetList1("B_pid,B_Id,B_ForumName,B_Layer,(select b.B_ForumName From forum b where b.B_Id=a.B_pid) as PForumName", "B_ID=" + ClsID);
if (Ds.Tables[0].Rows.Count > 0)
{
int B_pid = Convert.ToInt32(Ds.Tables[0].Rows[0]["B_pid"].ToString());
int B_Layer = Convert.ToInt32(Ds.Tables[0].Rows[0]["B_Layer"].ToString());
string B_ForumName = Ds.Tables[0].Rows[0]["B_ForumName"].ToString();
string PForumName = Ds.Tables[0].Rows[0]["PForumName"].ToString();
if (B_Layer == 2)
{
sb.Append(" and B_ForumID=" + ClsID);
Page.Title = B_ForumName + "-" + PForumName + "-" + config.webName;
Page.MetaDescription = B_ForumName + "-" + PForumName + "-" + config.webDescription;
Page.MetaKeywords = B_ForumName + "," + PForumName + "-" + config.webKeywords;
strposition = "<a href=\"/bbs/forum-" + B_pid + ".html\">" + PForumName + "</a> &gt; " + B_ForumName;
}
else
{
sb.Append(" and (B_ForumID=" + ClsID + " Or B_ForumIds Like '%," + ClsID + ",%')");
Page.Title = B_ForumName + "-" + config.webName;
Page.MetaDescription = B_ForumName + "-" + config.webDescription;
Page.MetaKeywords = B_ForumName + "-" + config.webKeywords;
strposition = B_ForumName;
}
}
Ds.Clear();
}
if (!String.IsNullOrEmpty(key))
{
key = Mtxfw.Utility.Tools.SafeSQL(key);
strUrl = "/forum.html?keyword=" + key + "&page={0}";
sb.Append(" and (B_Title like '%" + key + "%')");
Page.Title = "搜索相关主题-" + config.webName;
Page.MetaDescription = "搜索相关主题-" + config.webDescription;
Page.MetaKeywords = "搜索相关主题-" + config.webKeywords;
strposition = "搜索相关主题";
}
string strOrder = "B_IFGG Desc,B_SetTop Desc,B_LastSubmitDate Desc,B_UpDate Desc";
MyPager.PageSize = 50;
if (!String.IsNullOrEmpty(iPage) && iPage != "-1")
{
MyPager.CurrentPageIndex = int.Parse(iPage);
}
MyPager.RecordCount = daobbs.GetCount("B_IFDelete=0 And B_seef=1 And B_Layer=0" + sb.ToString());
Mtxfw.Utility.Tools.ToBind(Repeater1, daobbs.GetPager(MyPager, "(Select username From user_info b where b.id=a.B_MemberId) as MemberName,(Select username From user_info b where b.id=a.B_LastMemberId) as LastMemberName,", "B_IFDelete=0 And B_seef=1 And B_Layer=0" + sb.ToString() + " Order by " + strOrder));
}
}
}