📄 product_display.aspx.cs
字号:
using System;
using System.Data;
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;
//该源码下载自www.51aspx.com(51aspx.com)
using System.Configuration;
using System.Data.SqlClient;
public partial class product_display : System.Web.UI.Page
{
public string ProductID;
public string ProductName;//产品名称
public string ProductPicture;//图片
public string ProductPrice;//当前价格
public string ProductQuantity;//产品数量
public string ProudctBegin;//上架时间
public string ProductEnd;//结束时间
TimeSpan ProductSpare;//所剩时间
public string ProductAddress;//所在地
public string ProductPost;//运费支付
public string ProductFax;
//public string productfax;
public string ProductDetail;//商品详情
public string apper;//显示日期
DateTime dt1;
DateTime dt2;
DateTime dt;
public string strUserName="";
public string shopID="";
public String strDaohang =""; //导航条
public string strTypeID=""; //类别ID
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ProductID = Request.QueryString["id"].ToString();
dt = DateTime.Now.Date;
SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["ConnStr"]);
string sql = "select * from Products where ProductState=0 and ProductId=" + ProductID; //数据库连接字符串
SqlCommand command = new SqlCommand(sql, connection);//构件执行数据命令
connection.Open();
SqlDataReader dr = command.ExecuteReader();//保存从数据库里面返回的一条记录
if (dr.Read())
{
IMG1.Src = "showProductPicture.aspx?id=" + dr["ProductId"].ToString();
strTypeID = dr["ProductType"].ToString();
ProductName = dr["ProductName"].ToString();
ProductPicture = dr["ProductPicture"].ToString();
ProductPrice = dr["ProductPrice"].ToString();
ProductQuantity = dr["ProductQuantity"].ToString();
ProudctBegin = dr["ProductStart"].ToString();
ProductEnd = dr["ProductLeft"].ToString();
//dt1=ProudctBegin;
dt1 = Convert.ToDateTime(ProudctBegin);
ProudctBegin = dt1.ToLongTimeString();
dt2 = dt1.AddDays(14);
System.DateTime s = DateTime.Now;
ProductSpare = dt2 - s;
apper = ProductSpare.Days.ToString() + "天" + ProductSpare.Hours.ToString() + "小时" + ProductSpare.Minutes.ToString() + "分" + ProductSpare.Seconds.ToString() + "秒";
ProductAddress = dr["ProductAddress"].ToString();
ProductPost = dr["ProductPost"].ToString();
ProductFax = dr["ProductFax"].ToString();
ProductDetail = dr["ProductDetail"].ToString();
strUserName = dr["UserName"].ToString();
Label1.Text = ProductPrice;
Label2.Text = ProductQuantity;
Label3.Text = apper;
Label4.Text = ProductAddress;
Label5.Text = "平邮:" + ProductPost + "元 " + "快递:" + ProductFax + "元";
Label6.Text = ProductName;
Label8.Text = strUserName;
}
//
SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnStr"]);
string sql2 = "select * from DianPuDetail where DianPuUser='" + strUserName + "'";
SqlCommand command2 = new SqlCommand(sql2, conn);
conn.Open();
SqlDataReader dr2 = command2.ExecuteReader();
if (dr2.Read())
{
shopID = dr2["DianPuId"].ToString();
}
dr2.Close();
conn.Close();
//导航条
InitDaohang(strDaohang, strTypeID);
daohang.Text = strDaohang;
}
}
private void InitDaohang(string strTmp, string parentId)//初始化导航条
{
SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnStr"]);
String sql = "SELECT * FROM PType where category_ID=" + parentId;
SqlCommand command = new SqlCommand(sql, conn);
conn.Open();
SqlDataReader dr = command.ExecuteReader();
if (dr.Read())
{
InitDaohang(strTmp, dr["parentId"].ToString());
strTmp += " >> ";
strTmp += "<a href ='productList.aspx?categoryid=";
strTmp += dr["category_ID"].ToString();
strTmp += "'>";
strTmp += dr["category_name"].ToString();
strTmp += "</a>";
strDaohang += strTmp;
}
dr.Close();
conn.Close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -