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

📄 mybuy.aspx.cs

📁 .net环境下开发的,很好哦,这是我门最近做的一个电子商务的作业 实现了很多功能,是典型的C2C模式,很有利用价值,大家下载了多给我提意见
💻 CS
📖 第 1 页 / 共 2 页
字号:
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>
	/// mysell 的摘要说明。
	/// </summary>
	public class mysell : System.Web.UI.Page
	{
		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.RadioButtonList RadioButtonList1;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.TextBox TextBox1;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.TextBox TextBox2;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.DropDownList DropDownList1;
		protected System.Web.UI.WebControls.Label Label4;
		protected System.Web.UI.WebControls.Label Label5;
		protected System.Web.UI.WebControls.DropDownList DropDownList2;
		protected System.Web.UI.WebControls.Label Label6;
		protected System.Web.UI.WebControls.TextBox TextBox3;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.Button Button2;
		protected System.Web.UI.WebControls.DataGrid DataGrid3;
		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();
				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();
			}
		}

		#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.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.Button2.Click += new System.EventHandler(this.Button2_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 Button2_Click(object sender, System.EventArgs e)
		{
			RadioButtonList1.ClearSelection();
			TextBox1.Text="";
			TextBox2.Text="";
			TextBox3.Text="";
			string ec=System.Configuration.ConfigurationSettings.AppSettings["ec"];
			SqlConnection conn = new SqlConnection(ec);
			conn.Open();
			SqlCommand cmd=new SqlCommand("select * from category_first",conn);
			DropDownList1.Items.Clear();
			SqlDataReader dr=cmd.ExecuteReader();
			int i;
			while(dr.Read())
			{
				for(i=0;i<dr.FieldCount-1;i++)
				{
					DropDownList1.Items.Add(dr.GetValue(i).ToString());
				}
			}
			dr.Close();
			SqlDataAdapter daa=new SqlDataAdapter("SELECT * FROM category_sec where cat_ID='"+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();
		}

		private void Button1_Click(object sender, System.EventArgs e)
		{
			string ec=System.Configuration.ConfigurationSettings.AppSettings["ec"];
			if(TextBox2.Text!="")
			{
				if(RadioButtonList1.SelectedIndex==-1)
				{
				
					SqlConnection conn = new SqlConnection(ec);
					conn.Open();
					SqlCommand cmd = 
						new SqlCommand( "SELECT * FROM commdotyInfo WHERE comName like '%"+TextBox3.Text+"%' and catid='"+DropDownList1.SelectedValue+"' and cat_secid='"+DropDownList2.SelectedValue+"' and '"+TextBox1.Text+"'<price and price<'"+TextBox2.Text+"' and status='1'", conn );
					SqlDataReader dr=cmd.ExecuteReader();
					if(dr.Read())
					{
						dr.Close();
						SqlDataAdapter da1=new SqlDataAdapter("select commodityID,comName,catID,cat_secID,price,img,'一口价' as deal_auction,userid from commdotyInfo"+
							" where comName like '%"+TextBox3.Text+"%' and status='1' and catid='"+DropDownList1.SelectedValue+"' and cat_secid='"+DropDownList2.SelectedValue+"' and '"+TextBox1.Text+"'<price and price<'"+TextBox2.Text+"' and deal_auction='1'"+
							"union select commodityID,comName,catID,cat_secID,price,img,'拍卖' as deal_auction,userid "+
							"from commdotyInfo where comName like '%"+TextBox3.Text+"%' and status='1' and catid='"+DropDownList1.SelectedValue+"' and cat_secid='"+DropDownList2.SelectedValue+"' and '"+TextBox1.Text+"'<price and price<'"+TextBox2.Text+"' and deal_auction='0'",conn);
						DataSet ds1=new DataSet();
						da1.Fill(ds1);
						DataGrid3.DataSource=ds1;
						DataGrid3.DataBind();
					}
				}
				else
				{
					if(RadioButtonList1.SelectedItem.Value=="1")
					{
					
						SqlConnection conn = new SqlConnection(ec);
						conn.Open();
						SqlCommand cmd = 
							new SqlCommand( "SELECT * FROM commdotyInfo WHERE comName like '%"+TextBox3.Text+"%' and status='1' and catid='"+DropDownList1.SelectedValue+"' and cat_secid='"+DropDownList2.SelectedValue+"' and '"+TextBox1.Text+"'<price and price<'"+TextBox2.Text+"' and deal_auction='1'", conn );
						SqlDataReader dr=cmd.ExecuteReader();
						if(dr.Read())
						{
							dr.Close();
							SqlDataAdapter da1=new SqlDataAdapter("select commodityID,comName,catID,cat_secID,price,img,'一口价' as deal_auction,userid from commdotyInfo"+
								" WHERE comName like '%"+TextBox3.Text+"%' and catid='"+DropDownList1.SelectedValue+"' and status='1' and cat_secid='"+DropDownList2.SelectedValue+"' and '"+TextBox1.Text+"'<price and price<'"+TextBox2.Text+"' and deal_auction='1'",conn);

⌨️ 快捷键说明

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