⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 detail.aspx.cs

📁 .net环境下开发的,很好哦,这是我门最近做的一个电子商务的作业 实现了很多功能,是典型的C2C模式,很有利用价值,大家下载了多给我提意见
💻 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 secondhand
{
	/// <summary>
	/// detail 的摘要说明。
	/// </summary>
	public class detail : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Image Image1;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.Label Label5;
		protected System.Web.UI.WebControls.Label Label6;
		protected System.Web.UI.WebControls.Label Label7;
		protected System.Web.UI.WebControls.Label Label8;
		protected System.Web.UI.WebControls.Label Label9;
		protected System.Web.UI.WebControls.Label Label10;
		protected System.Web.UI.WebControls.Label Label12;
		protected System.Web.UI.WebControls.Label Label13;
		protected System.Web.UI.WebControls.Label Label14;
		protected System.Web.UI.WebControls.Label Label15;
		protected System.Web.UI.WebControls.Label Label16;
		protected System.Web.UI.WebControls.Label Label17;
		protected System.Web.UI.WebControls.Label Label1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if( Session["ID"]==null||Session["pwd"]==null)
				Server.Transfer("default.aspx");
			else
			{
				if(!IsPostBack)  
				{  
					DataGrid1DataGrid(); 
				}
			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
		private void  DataGrid1DataGrid()
		{
			string commodityID=Request.QueryString["ID"];
			string ec_Data = 
				"Server=(local);"+
				"uid=sa;pwd=sa;"+
				"database=ec";
			SqlConnection conn= 
				new SqlConnection(ec_Data);
			string sql="select Img ,'已卖出' as Status,introduction ,commodityID ,comName ,userID,price,date,catName,cat_secName,expire_date from category_first,category_sec,commdotyInfo where category_first.catID=commdotyInfo.catID and category_sec.cat_secID=commdotyInfo.cat_secID and Status=0 and commodityID='"+commodityID+"' " ; 
			conn.Open();
			SqlCommand cmd = 
				new SqlCommand( sql, conn );
			SqlDataReader dr=cmd.ExecuteReader();
			if(dr.Read())
			{
				Image1.ImageUrl=dr["img"].ToString();
				Label9.Text=dr["commane"].ToString();
				Label12.Text=dr["price"].ToString();
				Label13.Text=dr["userid"].ToString();
				Label14.Text=dr["date"].ToString();
				Label15.Text=dr["expire_date"].ToString();
				Label17.Text=dr["Status"].ToString();
				Label10.Text=dr["introduction"].ToString();
		/*		conn.Close();
				conn.Open();
				SqlDataAdapter myDataAdapter=new SqlDataAdapter(sql,conn);
				DataSet myDs=new DataSet();
		//		myDataAdapter.Fill(myDs,"commdotyInfo");
		//		this.DataList1.DataSource=myDs.Tables["commdotyInfo"];
				myDataAdapter.Fill(myDs);
	    		this.DataList1.DataSource=myDs;//.Tables[0];
				this.DataList1.DataBind();
				conn.Close();
		*/	}
			else 
			{
				conn.Close();
				string sql1="select Img, '出售中' as Status,introduction ,commodityID ,comName ,userID,price,date,catName,cat_secName,expire_date from category_first,category_sec,commdotyInfo where category_first.catID=commdotyInfo.catID and category_sec.cat_secID=commdotyInfo.cat_secID  and Status=1 and commodityID='"+commodityID+"'";
				conn.Open();
				dr.Close();
				SqlCommand cmmd=new SqlCommand(sql1,conn);
				SqlDataReader ddr=cmmd.ExecuteReader();
				Image1.ImageUrl=ddr["img"].ToString();
				Label9.Text=ddr["commane"].ToString();
				Label12.Text=ddr["price"].ToString();
				Label13.Text=ddr["userid"].ToString();
				Label14.Text=ddr["date"].ToString();
				Label15.Text=ddr["expire_date"].ToString();
				Label17.Text=ddr["Status"].ToString();
				Label10.Text=ddr["introduction"].ToString();

		/*		SqlDataAdapter myDataAdapter=new SqlDataAdapter(sql1,conn);
				DataSet myDs=new DataSet();
		//		myDataAdapter.Fill(myDs,"commdotyInfo");
		//		this.DataList1.DataSource=myDs.Tables["commdotyInfo"];
				myDataAdapter.Fill(myDs);
				this.DataList1.DataSource=myDs;//.Tables[0];
				this.DataList1.DataBind();
		*/		conn.Close();
			}
		}
		private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}

		private void DataList1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}

		

		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -