📄 jinrizhuti.aspx.cs
字号:
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;
using System.Data.SqlClient;
namespace free.bbs.state
{
/// <summary>
/// Summary description for jinrizhuti.
/// </summary>
public partial class jinrizhuti : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Image Image2;
DateTime time=DateTime.Today;
DateTime time1=DateTime.Now.Date;
SqlDataReader myread;
SqlDataAdapter myada;
SqlCommand command;
HtmlTableRow myrow;
HtmlTableCell mycell;
DataSet ds;
SqlConnection monn;
protected void Page_Load(object sender, System.EventArgs e)
{
DateTime time2=time1.AddDays(1);
try
{
shui.Text=Request.Cookies["huiyuan"].Value.ToString();
}
catch
{
shui.Text="游客";
}
try
{
monn=new SqlConnection(Session["str_connection"].ToString());
}
catch
{
Response.Write("数据库连接出现错误!!");
}
string jinri_zong="select count(huifu.huifu_id) from posts,huifu where posts.postid=huifu.post_id and (huifu.shijian between '"+time+"' and '"+time2+"')";
string tiezi_zong="select count(*) from huifu";
string zhuti_zong="select count(zhuti) from posts";
monn.Open();
SqlCommand command22=new SqlCommand(zhuti_zong,monn);
SqlDataReader reader22=command22.ExecuteReader();
if(reader22.Read())
{
int shu=reader22.GetInt32(0);
zhuti.Text=shu.ToString();
reader22.Close();
}
SqlCommand command20=new SqlCommand(jinri_zong,monn);
SqlDataReader reader20=command20.ExecuteReader();
if(reader20.Read())
{
int shu=reader20.GetInt32(0);
tieshu.Text=shu.ToString();
reader20.Close();
}
SqlCommand mycommand21=new SqlCommand(tiezi_zong,monn);
SqlDataReader reader21=mycommand21.ExecuteReader();
if(reader21.Read())
{
int shu=reader21.GetInt32(0);
zongshu.Text=shu.ToString();
reader21.Close();
}
monn.Close();
binding();
}
private void binding()
{
try
{
monn=new SqlConnection(Session["str_connection"].ToString());
}
catch
{
Response.Write("<script>alert('数据库连接出错!!')</script>");
}
string sql="select ancestor_id,neirong from ancestor";
try
{
ds=new DataSet();
monn.Open();
myada=new SqlDataAdapter(sql,monn);
myada.Fill(ds,"luntan");
if(ds.Tables["luntan"].Rows.Count>0)
try
{
DateTime time2=time1.AddDays(1);
for(int i=0;i<=ds.Tables["luntan"].Rows.Count-1;i++)
{
int j=i+1;
string mysql="select count(zhuti) from posts where ancestor_id="+Convert.ToInt32(ds.Tables["luntan"].Rows[i]["ancestor_id"].ToString())+" and shijian between '"+time+"' and '"+time2+"'";
command=new SqlCommand(mysql,monn);
myread=command.ExecuteReader();
myread.Read();
int count=myread.GetInt32(0);
int chang=count+4;
if(chang>=520)
chang=520;
myread.Close();
myrow=new HtmlTableRow();
mycell=new HtmlTableCell();
string nr=ds.Tables["luntan"].Rows[i]["neirong"].ToString();
if(j>10&&j<=20)
{
j=i-9;
mycell.Controls.Add(new LiteralControl("<td class='tableBody2' align='center'>※<a href='zhuti.aspx?ancestor_id="+Convert.ToInt32(ds.Tables["luntan"].Rows[i]["ancestor_id"].ToString())+"&Page=1'>"+nr+"</a>※</td><td class='tableBody2'><img src='./tuli_pic/"+j+".gif' width="+chang+" height=10></td><td class='tableBody2' align='center'><font color='red'>"+count+"</font></td>"));
}
else if(j>20&&j<=30)
{
j=i-19;
mycell.Controls.Add(new LiteralControl("<td class='tableBody2' align='center'>※<a href='zhuti.aspx?ancestor_id="+Convert.ToInt32(ds.Tables["luntan"].Rows[i]["ancestor_id"].ToString())+"&Page=1'>"+nr+"</a>※</td><td class='tableBody2'><img src='./tuli_pic/"+j+".gif' width="+chang+" height=10></td><td class='tableBody2' align='center'><font color='red'>"+count+"</font></td>"));
}
else if(j>30)
{
j=i-29;
mycell.Controls.Add(new LiteralControl("<td class='tableBody2' align='center'>※<a href='zhuti.aspx?ancestor_id="+Convert.ToInt32(ds.Tables["luntan"].Rows[i]["ancestor_id"].ToString())+"&Page=1'>"+nr+"</a>※</td><td class='tableBody2'><img src='./tuli_pic/"+j+".gif' width="+chang+" height=10></td><td class='tableBody2' align='center'><font color='red'>"+count+"</font></td>"));
}
else
{
mycell.Controls.Add(new LiteralControl("<td class='tableBody2' align='center' >※<a href='zhuti.aspx?ancestor_id="+Convert.ToInt32(ds.Tables["luntan"].Rows[i]["ancestor_id"].ToString())+"&Page=1'>"+nr+"</a>※</td><td class='tableBody2'><img src='./tuli_pic/"+j+".gif' width="+chang+" height=10></td><td class='tableBody2' align='center'><font color='red'>"+count+"</font></td>"));
}
myrow.Cells.Add(mycell);
peter.Rows.Add(myrow);
}
monn.Close();
}
catch
{}
}
catch
{}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -