📄 product.aspx.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int id = Convert.ToInt32(Request.QueryString["id"]);
string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\searcher\\GotoBuy.mdb";
string Sql = "SELECT [ztm], [ISBN],[ZZ],[CBS],[jg],[M_ID],[Detail],[zyj],[ddj],[ztj] FROM [goods_mouse] WHERE M_ID=" + id+";";
OleDbConnection thisConnection = new OleDbConnection(ConnectionString);
OleDbCommand thisCommand = new OleDbCommand(Sql, thisConnection);
thisCommand.CommandType = CommandType.Text;
try
{
// 打开数据库连接
thisCommand.Connection.Open();
OleDbDataReader dr = thisCommand.ExecuteReader();
// 循环读取结果集
while (dr.Read())
{
string zy, dd, zt, str = "";
int zyj, ddj, ztj;
zyj = Convert.ToInt16(dr["zyj"]);
ddj = Convert.ToInt16(dr["ddj"]);
ztj = Convert.ToInt16(dr["ztj"]);
zy = "<a href='http://www.amazon.cn/mn/advancedSearchApp?type=book&isbn=" + dr["ISBN"] + "'><image src=jlogo.gif border=0><font size=2 color=#2554C7><strong>¥" + dr["zyj"] + " (" + (Convert.ToDouble(dr["zyj"]) / Convert.ToDouble(dr["jg"]) * 10 + 0.0001).ToString().Substring(0, 3) + "折)</strong></font><br>";
dd = "<a href='http://search.book.dangdang.com/search.aspx?key=" + dr["ISBN"] + "&page=1'><image src=dlogo.gif border=0><font size=2 color=#2554C7><strong>¥" + dr["ddj"] + " (" + (Convert.ToDouble(dr["ddj"]) / Convert.ToDouble(dr["jg"]) * 10 + 0.0001).ToString().Substring(0, 3) + "折)</strong></font><br>";
zt = "<a href=' http://www.bookschina.com/book_find/bookFindResult.aspx?bookname=" + dr["ztm"] + "'><image src=bclogo.gif border=0><font size=2 color=#2554C7><strong>¥" + dr["ztj"] + " (" + (Convert.ToDouble(dr["ztj"]) / Convert.ToDouble(dr["jg"]) * 10 + 0.0001).ToString().Substring(0, 3) + "折)</strong></font><br>";
if (zyj == 0) { zy = ""; }
if (ddj == 0) { dd = ""; }
if (ztj == 0) { zt = ""; }
if (zyj <= ddj && ddj <= ztj) { str = zy + dd + zt; }
if (zyj <= ztj && ztj <= ddj) { str = zy + zt + dd; }
if (ddj <= zyj && zyj <= ztj) { str = dd + zy + zt; }
if (ddj <= ztj && ztj <= zyj) { str = dd + zt + zy; }
if (ztj <= ddj && ddj <= zyj) { str = zt + dd + zy; }
if (ztj <= zyj && zyj <= ddj) { str = zt + zy + dd; }
// 读取两个列值并输出到Label中
Label1.Text += "<font color=#2554C7><strong>" + dr["ztm"] + "</strong></font><br><font size=2>作者:<font color=#2554C7>" + dr["ZZ"] + "</font><br> 出版社:<font color=#2554C7>" + dr["CBS"] + " </font><br>ISBN:<font color=#2554C7>" + dr["ISBN"] + " </font><br>定价:<font color=#2554C7>" + dr["jg"] + "</font></font><br><br><br><br>";
/* if (Convert.ToInt16(dr["zyj"]) != 0) { Label1.Text += "<font color=#7D9EC0 size=2><strong>卓越网价格:<strong></font>" + dr["zyj"] + "<br> "; }
if (Convert.ToInt16(dr["ddj"]) != 0) { Label1.Text += "<font color=#7D9EC0 size=2><strong>当当网价格:<strong></font>" + dr["ddj"] + "<br> "; }
if (Convert.ToInt16(dr["ztj"]) != 0) { Label1.Text += "<font color=#7D9EC0 size=2><strong>中国图书网价格:<strong></font>" + dr["ztj"] + "<br> "; }*/
Label1.Text += str;
Label2.Text += "<font color=#2554C7><strong>内容简介</strong></font><br><br>" + dr["Detail"] + "</font><br><br>";
Label3.Text = "<br><br><br><br><br><br><font size=5 font='微软雅黑'>抱歉,没有找到本书的封面....<font>";
}
// 关闭DataReader
dr.Close();
}
catch (SqlException ex)
{
// 异常处理
Response.Write(ex.ToString());
}
finally
{
// 关闭数据库连接
thisCommand.Connection.Close();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text != "")
{
Response.Redirect("result.aspx?page=1&bookname=" + TextBox1.Text);
}
else
{
Response.Redirect("index.aspx");
}
}
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -