📄 class_neirong.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
{
/// <summary>
/// Summary description for class_neirong.
/// </summary>
public class class_neirong : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlTable wenti;
protected System.Data.SqlClient.SqlConnection myconn;
protected System.Data.SqlClient.SqlCommand mycomm;
private void Page_Load(object sender, System.EventArgs e)
{
string jiaocheng_id=Request.Params["jiaocheng_id"];
string wenti_id=Request.Params["wenti_id"];
myconn=new SqlConnection(Session["str_connection"].ToString());
//书名
string sqlstr="SELECT shuming FROM class_jiaocheng WHERE (id = "+jiaocheng_id+") ";
myconn.Open();
mycomm=new SqlCommand(sqlstr,myconn);
if(mycomm.ExecuteScalar()!=null)
{
Session["shuming"]=mycomm.ExecuteScalar().ToString();
}
//上个问题
sqlstr="SELECT id,neirong FROM class_wenti WHERE (jiaocheng_id= "+jiaocheng_id+" and id = "+wenti_id+"-1) ";
SqlDataAdapter mydada_1;
mydada_1=new SqlDataAdapter(sqlstr,myconn);
DataTable mytable_1;
mytable_1=new DataTable();
mydada_1.Fill(mytable_1);
mytable_1.TableName="zhuanjia";
if(mytable_1.Rows.Count>0)
{
Session["shge"]=mytable_1.Rows[0]["id"].ToString();
Session["proer"]=mytable_1.Rows[0]["neirong"].ToString();
}
else
{
Session["shge"]="";
Session["proer"]="";
}
//下个问题
sqlstr="SELECT id,neirong FROM class_wenti WHERE (jiaocheng_id= "+jiaocheng_id+" and id = "+wenti_id+"+1) ";
// SqlDataAdapter mydada_1;
mydada_1=new SqlDataAdapter(sqlstr,myconn);
// DataTable mytable_1;
mytable_1=new DataTable();
mydada_1.Fill(mytable_1);
mytable_1.TableName="zhuanjia";
if(mytable_1.Rows.Count>0)
{
Session["xiage"]=mytable_1.Rows[0]["id"].ToString();
Session["next"]=mytable_1.Rows[0]["neirong"].ToString();
}
else
{
Session["xiage"]="";
Session["next"]="";
}
//问题
sqlstr="SELECT neirong FROM class_wenti WHERE (jiaocheng_id= "+jiaocheng_id+" and id = "+wenti_id+") ";
mycomm=new SqlCommand(sqlstr,myconn);
if(mycomm.ExecuteScalar()!=null)
{
Session["wenti"]=mycomm.ExecuteScalar().ToString();
}
//内容
sqlstr="SELECT xuhao_id,neirong,tupian FROM class_zhijie WHERE (shuming_id = "+jiaocheng_id+" and wenti_id="+wenti_id+") ORDER BY xuhao_id";
//Try
SqlDataAdapter mydada;
mydada=new SqlDataAdapter(sqlstr,myconn);
DataTable mytable;
mytable=new DataTable();
mydada.Fill(mytable);
mytable.TableName="neirong";
HtmlTableRow myrow;
HtmlTableCell mycell;
if(mytable.Rows.Count>0)
{
for(int i=0;i<=mytable.Rows.Count-1;i++)
{
myrow=new HtmlTableRow();
//
mycell=new HtmlTableCell();
mycell.Width="20px";
mycell.Controls.Add(new LiteralControl(""));
myrow.Cells.Add(mycell);
//
mycell=new HtmlTableCell();
string tupian;
if(mytable.Rows[i]["tupian"].ToString().Trim()!="1")
tupian="<center><IMG alt=''width='400' height='300' src='"+mytable.Rows[i]["tupian"].ToString()+"'></center></div>";
else
{
tupian=null;
tupian="<br>";
}
mycell.Controls.Add(new LiteralControl ("<div><br><FONT face='宋体'>"+mytable.Rows[i]["neirong"].ToString()+"</FONT><br>"+tupian+"</div>"));
myrow.Cells.Add(mycell);
//
mycell=new HtmlTableCell();
//mycell=new HtmlTableCell();
mycell.Width="20px";
mycell.Controls.Add(new LiteralControl(""));
myrow.Cells.Add(mycell);
wenti.Rows.Add(myrow);
}
}
myconn.Close();
}
#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()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -