maintable.aspx.cs
上传用户:scene123
上传日期:2010-02-19
资源大小:3311k
文件大小:8k
源码类别:

.net编程

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.OleDb;
  12. using System.Configuration;
  13. using System.Text;
  14. namespace kuangren
  15. {
  16. /// <summary>
  17. /// maintable 的摘要说明。
  18. /// </summary>
  19. public class maintable : System.Web.UI.Page
  20. {  
  21. protected DateTime dtStartTime = DateTime.Now;
  22. protected System.Web.UI.WebControls.Repeater parent;
  23. protected System.Web.UI.WebControls.Repeater Repeater1;
  24. protected Wuqi.Webdiyer.AspNetPager AspNetPager1;
  25. protected System.Data.OleDb.OleDbCommand cmd;
  26. protected System.Data.OleDb.OleDbConnection conn;
  27. public    DataSet dsPending;
  28. public string usercook;
  29. public string shownone;
  30. public string sql;
  31. public string title;
  32. public int pass;
  33. public string master;
  34. public string OleDbSqlforum;
  35. public int showpower;
  36. public int  showpower2;
  37. public int showpower6;
  38. public int showpower7;
  39. public int showpower8;
  40. public int showpower9;
  41. public int  todaynum;
  42. public int yestoday;
  43. protected string FilterBadWords(string msg)
  44. {
  45. string badwords="妈妈的|我靠|fuck|bitch|他妈的|性爱|法轮功|falundafa|falun|江泽民|共产党|操你妈|三级片|sex|腚|妓|娼|阴蒂|奸|尻|贱|婊|靠|叉|龟头|屄|赑|妣|肏|尻|屌";
  46. string[] tempstr=badwords.Split('|');
  47. string finalstr=msg;
  48. for(int i=0;i<tempstr.Length;i++)
  49. {
  50. finalstr=finalstr.Replace(tempstr[i],new String('*',tempstr[i].Length));
  51. }
  52. return finalstr;
  53. return msg;
  54. }
  55. protected string getModerator(string strModerators)
  56. {
  57. StringBuilder strResult = new StringBuilder();
  58. if (strModerators != "")
  59. {
  60. string[] strModerator = strModerators.Split('|');
  61. foreach (string strInfos in strModerator)
  62. {
  63. strResult.Append("<a href="user_infor.aspx?u_user=");
  64. strResult.Append(strInfos);
  65. strResult.Append("" target="_blank">");
  66. strResult.Append(strInfos);
  67. strResult.Append("</a> ");
  68. }
  69. }
  70. else
  71. {
  72. strResult.Append("暂无版主");
  73. }
  74. return strResult.ToString();
  75. }
  76. public string GetReply(object o)
  77. {
  78. if (Convert.IsDBNull(o) || (string)o == "")
  79. return "尚未回复";
  80. else
  81. return "<a href='user_infor.aspx?u_user="+o+"' target='_blank'>"+o+"</a>";
  82. }
  83. public string JudgeImage(string s_1,string s_2,string s_3,int s_4)
  84. {
  85. if (s_1=="4")
  86. return "ztop.gif";
  87. if (s_1 == "3")
  88. return "istop.gif";
  89. if (s_1!= "3"&&s_1!="4"&&s_2=="1")
  90. return "isbest.gif";
  91.             if (s_3 == "1")
  92. return "lockfolder.gif";
  93. if (s_4 >= 10)
  94. return "hotfolder.gif";
  95. else
  96. return "folder.gif";
  97. }
  98. private void Page_Load(object sender, System.EventArgs e)
  99. {
  100. if (Request.Cookies["jhidden"]!=null)
  101. {
  102. usercook=Request.Cookies["jhidden"].Value;
  103. }
  104. //从数据表中搜索在线会员和客人数量
  105. conn = new OleDbConnection(ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
  106. conn = new OleDbConnection(ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
  107. OleDbCommand cmd4 = new OleDbCommand("select count(id) from online where username='客人' and boardid="+Request.QueryString["f2_id"]+"",conn);
  108. OleDbCommand cmd5 = new OleDbCommand("select count(id) from online where username<>'客人' and boardid="+Request.QueryString["f2_id"]+"",conn);
  109. conn.Open();
  110. showpower=(int)cmd4.ExecuteScalar();
  111. showpower2=(int)cmd5.ExecuteScalar();
  112. conn.Close();
  113. //结束
  114. //搜索该论坛详细信息
  115. sql="SELECT f2_id, f2_caption, f2_pass, f2_master, f2_todaynum,f2_yestoday  FROM forum_2 where f2_id="+Request.QueryString["f2_id"]+"";
  116. dsPending=new DataSet();
  117. OleDbDataAdapter adWord=new OleDbDataAdapter(sql,conn);
  118. adWord.Fill(dsPending,"forum_2");
  119. Page.DataBind();
  120. title=Convert.ToString(dsPending.Tables[0].Rows[0]["f2_caption"]);
  121. todaynum=Convert.ToInt32(dsPending.Tables[0].Rows[0]["f2_todaynum"]);
  122. master=Convert.ToString(dsPending.Tables[0].Rows[0]["f2_master"]);
  123. pass=Convert.ToInt32(dsPending.Tables[0].Rows[0]["f2_pass"]);
  124. yestoday=Convert.ToInt32(dsPending.Tables[0].Rows[0]["f2_yestoday"]);
  125. //结束
  126. //获得今日发帖数和昨日发帖数
  127. OleDbCommand cmd6= new OleDbCommand("SELECT count(f3_id) FROM forum_3  WHERE f3_date=Date()-0 and f3_sy="+Request.QueryString["f2_id"]+"",conn);
  128. OleDbCommand cmd7 = new OleDbCommand("SELECT count(f4_id) FROM forum_4  WHERE f4_date=Date()-0 and f4_sy1="+Request.QueryString["f2_id"]+"",conn);
  129. OleDbCommand cmd8= new OleDbCommand("SELECT count(f3_id) FROM forum_3  WHERE f3_date=Date()-1 and f3_sy="+Request.QueryString["f2_id"]+"",conn);
  130. OleDbCommand cmd9 = new OleDbCommand("SELECT count(f4_id) FROM forum_4  WHERE f4_date=Date()-1 and f4_sy1="+Request.QueryString["f2_id"]+"",conn);
  131. conn.Open();
  132. showpower6=(int)cmd6.ExecuteScalar();
  133. showpower7=(int)cmd7.ExecuteScalar();
  134. showpower8=(int)cmd8.ExecuteScalar();
  135. showpower9=(int)cmd9.ExecuteScalar();
  136. conn.Close();
  137. OleDbSqlforum="update forum_2 set f2_todaynum="+showpower6+"+"+showpower7+",f2_yestoday="+showpower8+"+"+showpower9+" where f2_id="+Request.QueryString["f2_id"]+"";
  138. OleDbCommand cmd10=new OleDbCommand(OleDbSqlforum,conn);
  139. conn.Open();
  140. bool doredirect=true;
  141. try
  142. {
  143. cmd10.ExecuteNonQuery();
  144. }
  145. catch
  146. {
  147. doredirect=false;
  148. }
  149. finally
  150. {
  151. conn.Close();
  152. }
  153. if(doredirect)
  154. {
  155. }
  156. else
  157. {
  158. }
  159. //结束
  160. if(!Page.IsPostBack)
  161. {
  162. cmd=new OleDbCommand("select count(f3_id) from forum_3 where f3_sy="+Request.QueryString["f2_id"]+"",conn);
  163. conn.Open();
  164. AspNetPager1.RecordCount=(int)cmd.ExecuteScalar();
  165. if (AspNetPager1.RecordCount==0)
  166. {shownone="<tr align=center bgColor=#ffffff height=28><td colSpan=5>本版未添加任何记录</td></tr>";}
  167. conn.Close();
  168. DataBind();
  169. }
  170. }
  171. void DataBind()
  172. {  
  173. cmd=new OleDbCommand("SELECT f3_id, f3_motif, f3_count, f3_face, f3_sy, f3_state, f3_top,f3_distillate, f3_name, f3_now, f3_replynum, f3_replyname from forum_3 where f3_sy="+Request.QueryString["f2_id"]+" and f3_state<>2 ORDER BY f3_top DESC ,f3_now DESC",conn);
  174. OleDbDataAdapter adapter=new OleDbDataAdapter(cmd);
  175. DataSet ds=new DataSet();
  176. adapter.Fill(ds,AspNetPager1.PageSize*(AspNetPager1.CurrentPageIndex-1),AspNetPager1.PageSize,"forum_3");
  177. Repeater1.DataSource=ds.Tables["forum_3"];
  178. Repeater1.DataBind();
  179. //动态设置用户自定义文本内容
  180. AspNetPager1.CustomInfoText="记录总数:<b>"+AspNetPager1.RecordCount.ToString()+"</b>";
  181. AspNetPager1.CustomInfoText+=" 总页数:<b>"+AspNetPager1.PageCount.ToString()+"</b>";
  182. AspNetPager1.CustomInfoText+=" 当前页:<font color="red"><b>"+AspNetPager1.CurrentPageIndex.ToString()+"</b></font>";
  183. }
  184. #region Web 窗体设计器生成的代码
  185. override protected void OnInit(EventArgs e)
  186. {
  187. //
  188. // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
  189. //
  190. InitializeComponent();
  191. base.OnInit(e);
  192. }
  193. /// <summary>
  194. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  195. /// 此方法的内容。
  196. /// </summary>
  197. private void InitializeComponent()
  198. {    
  199. this.AspNetPager1.PageChanged += new Wuqi.Webdiyer.PageChangedEventHandler(this.AspNetPager1_PageChanged);
  200. this.Load += new System.EventHandler(this.Page_Load);
  201. }
  202. #endregion
  203. private void AspNetPager1_PageChanged(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
  204. {
  205. AspNetPager1.CurrentPageIndex=e.NewPageIndex;
  206. DataBind();
  207. }
  208. }
  209. }