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

📄 displaycom.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>
	/// mybuy 的摘要说明。
	/// </summary>
	public class mybuy : System.Web.UI.Page
	{
		public static int Button;
		protected System.Web.UI.WebControls.ImageButton ImageButton1;
		protected System.Web.UI.WebControls.ImageButton ImageButton2;
		protected System.Web.UI.WebControls.ImageButton ImageButton3;
		protected System.Web.UI.WebControls.ImageButton ImageButton4;
		protected System.Web.UI.WebControls.DropDownList DropDownList1;
		protected System.Web.UI.WebControls.DropDownList DropDownList2;
		protected System.Web.UI.WebControls.DataGrid DataGrid3;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.ImageButton ImageButton5;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if(!IsPostBack)
			{
				string ec=System.Configuration.ConfigurationSettings.AppSettings["ec"];
				SqlConnection conn = new SqlConnection(ec);
				conn.Open();
				SqlDataAdapter da=new SqlDataAdapter("SELECT * from category_first", conn );
				DataSet ds=new DataSet();
				da.Fill(ds);
				DropDownList1.DataSource=ds.Tables[0].DefaultView;
				DropDownList1.DataTextField= "catName";
				DropDownList1.DataValueField="catID";
				DropDownList1.DataBind();
				DropDownList1.Items[0].Selected=true;
				SqlDataAdapter daa=new SqlDataAdapter("SELECT * FROM category_sec "+
					"where cat_ID=(select catid from category_first "+
					"where catname='"+DropDownList1.SelectedItem.ToString()+"')", conn );

				DataSet dss=new DataSet();
				daa.Fill(dss);
				DropDownList2.DataSource=dss.Tables[0].DefaultView;
				DropDownList2.DataTextField= "cat_secName";
				DropDownList2.DataValueField="cat_secID";
				DropDownList2.DataBind();
				DropDownList2.Items[0].Selected=true;
				SqlDataAdapter da1=new SqlDataAdapter("select commodityID,comName,catID,cat_secID,price,img,'一口价' as deal_auction,userid from commdotyInfo"+
					" where deal_auction='1' and status='1' and catid="+DropDownList1.SelectedValue+" and cat_secid="+DropDownList2.SelectedValue+""+
					"union select commodityID,comName,catID,cat_secID,price,img,'拍卖' as deal_auction,userid "+
					"from commdotyInfo where deal_auction='0' and status='1' and catid="+DropDownList1.SelectedValue+" and cat_secid="+DropDownList2.SelectedValue+"",conn);
				DataSet ds1=new DataSet();
				da1.Fill(ds1);
				DataGrid3.DataSource=ds1;
				DataGrid3.DataBind();
				Button=1;

			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.ImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);
			this.ImageButton2.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton2_Click);
			this.ImageButton3.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton3_Click);
			this.ImageButton4.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton4_Click);
			this.ImageButton5.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton5_Click);
			this.DropDownList1.SelectedIndexChanged += new System.EventHandler(this.DropDownList1_SelectedIndexChanged);
			this.DropDownList2.SelectedIndexChanged += new System.EventHandler(this.DropDownList2_SelectedIndexChanged);
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.DataGrid3.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid3_PageIndexChanged);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			Server.Transfer("default.aspx");
		}

		private void ImageButton2_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			Server.Transfer("mybuy.aspx");
		}

		private void ImageButton3_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			if( Session["ID"]==null||Session["pwd"]==null)
		 
				Response.Write ("<script>alert(\"请先登陆!\");</script>");
			else
				Server.Transfer("myyigo.aspx");
		
		}

		private void ImageButton4_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			if( Session["ID"]==null||Session["pwd"]==null)
		 
				Response.Write ("<script>alert(\"请先登陆!\");</script>");
			else
				Server.Transfer("myyigo.aspx");
			
		}

		private void ImageButton5_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			if( Session["ID"]==null||Session["pwd"]==null)
		 
				Response.Write ("<script>alert(\"请先登陆!\");</script>");
			else
				Server.Transfer("myyigo.aspx");
		 
		}

		private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			string ec=System.Configuration.ConfigurationSettings.AppSettings["ec"];
			Session["catnm"]=DropDownList1.SelectedItem.ToString();
			SqlConnection conn = new SqlConnection(ec);
			conn.Open();
			SqlDataAdapter daa=new SqlDataAdapter("SELECT * FROM category_sec "+
				"where cat_ID=(select catid from category_first "+
				"where catname='"+Session["catnm"]+"')", conn );DataSet dss=new DataSet();
			daa.Fill(dss);
			DropDownList2.DataSource=dss.Tables[0].DefaultView;
			DropDownList2.DataTextField= "cat_secName";
			DropDownList2.DataValueField="cat_secID";
			DropDownList2.DataBind();	
		}

		private void DropDownList2_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			Button=1;
			DataGrid3.CurrentPageIndex=0;
			string ec=System.Configuration.ConfigurationSettings.AppSettings["ec"];
			SqlConnection conn = new SqlConnection(ec);
			conn.Open();
			SqlDataAdapter da1=new SqlDataAdapter("select commodityID,comName,catID,cat_secID,price,img,'一口价' as deal_auction,userid from commdotyInfo"+
				" where deal_auction='1' and status='1' and catid="+DropDownList1.SelectedValue+" and cat_secid="+DropDownList2.SelectedValue+""+
				"union select commodityID,comName,catID,cat_secID,price,img,'拍卖' as deal_auction,userid "+
				"from commdotyInfo where deal_auction='0' and status='1' and catid="+DropDownList1.SelectedValue+" and cat_secid="+DropDownList2.SelectedValue+"",conn);
			DataSet ds1=new DataSet();
			da1.Fill(ds1);
			DataGrid3.DataSource=ds1;
			DataGrid3.DataBind();
		
		}

		private void Button1_Click(object sender, System.EventArgs e)
		{
			Button=0;
			DataGrid3.CurrentPageIndex=0;
			string ec=System.Configuration.ConfigurationSettings.AppSettings["ec"];
			SqlConnection conn = new SqlConnection(ec);
			conn.Open();
			SqlDataAdapter da1=new SqlDataAdapter("select commodityID,comName,catID,cat_secID,price,img,'一口价' as deal_auction,userid from commdotyInfo"+
				" where deal_auction='1' and status='1'"+
				"union select commodityID,comName,catID,cat_secID,price,img,'拍卖' as deal_auction,userid "+
				"from commdotyInfo where deal_auction='0' and status='1'",conn);
			DataSet ds1=new DataSet();
			da1.Fill(ds1,"record");
			
			DataGrid3.DataSource=ds1;
			DataGrid3.DataBind();
		}

		private void DataGrid3_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
		{
			DataGrid3.CurrentPageIndex=e.NewPageIndex;
			string ec=System.Configuration.ConfigurationSettings.AppSettings["ec"];
			SqlConnection conn = new SqlConnection(ec);
			conn.Open();
			if(Button==1)
			{
				SqlDataAdapter da1=new SqlDataAdapter("select commodityID,comName,catID,cat_secID,price,img,'一口价' as deal_auction,userid from commdotyInfo"+
					" where deal_auction='1' and status='1' and catid="+DropDownList1.SelectedValue+" and cat_secid="+DropDownList2.SelectedValue+""+
					"union select commodityID,comName,catID,cat_secID,price,img,'拍卖' as deal_auction,userid "+
					"from commdotyInfo where deal_auction='0' and status='1' and catid="+DropDownList1.SelectedValue+" and cat_secid="+DropDownList2.SelectedValue+"",conn);
				DataSet ds1=new DataSet();
				da1.Fill(ds1);
				DataGrid3.DataSource=ds1;}
			else
			{


				SqlDataAdapter da1=new SqlDataAdapter("select commodityID,comName,catID,cat_secID,price,img,'一口价' as deal_auction,userid from commdotyInfo"+
					" where deal_auction='1' and status='1'"+
					"union select commodityID,comName,catID,cat_secID,price,img,'拍卖' as deal_auction,userid "+
					"from commdotyInfo where deal_auction='0' and status='1'",conn);
				DataSet ds1=new DataSet();
				da1.Fill(ds1,"record");
				
				DataGrid3.DataSource=ds1;
			}
			DataGrid3.DataBind();
		}
	}
}

⌨️ 快捷键说明

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