DropDownList3.Items.Add

本文介绍了一个游戏交易平台中用于筛选和展示商品的复杂逻辑实现。通过下拉列表选择游戏和分区,进一步通过按钮触发不同类型的查询,包括出售和求购信息,并能够针对特定服务器进行筛选。此外,还包含了对用户会话状态的管理和页面加载时默认数据的获取。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

private void ImageButton2_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  {
   string subarea=this.DropDownList3.SelectedItem.Text.Trim();
   string game=this.DropDownList4.SelectedItem.Text.Trim();
   string subareaid=this.DropDownList3.SelectedItem.Value;

   string strSql="";
   using(WebShop.Common common=new WebShop.Common())
   {
    if(game!="选择游戏")
    {
     if(subarea!="选择分区")
     {
      strSql="SELECT wupinxinxi.serverid,dbo.game.gamename, wupinxinxi.xinxileixing,dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid ,xinxileixing,wupinxinxi.subareaid HAVING (dbo.wupinxinxi.propid = 1) and xinxileixing='出售' and wupinxinxi.subareaid='"+subareaid+"' ";
      
     }
     else
     {
      this.Response.Write("<script language='javascript'>alert('请选择分区')</script>");
     }
    }
    else
    {
     if(subarea=="选择分区")
     {
       strSql="SELECT wupinxinxi.serverid,dbo.game.gamename, wupinxinxi.xinxileixing,dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid ,xinxileixing HAVING (dbo.wupinxinxi.propid = 1) and xinxileixing='出售' ";

     }
     else
     {
      this.Response.Write("<script language='javascript'>alert('请选择游戏')</script>");

     }
    }

    
    DataSet ds=common.full(strSql,CommandType.Text,"bixiangxi");
    if(ds.Tables[0].Rows.Count>0)
    {
     this.Label5.Visible=false;
     Session["xinxileixing"]="出售";

     this.youxibi.DataSource=ds.Tables[0];
     this.youxibi.DataBind();
    }
    else
    {
     this.Label5.Visible=true;
    }
   }
   
  
  }

 

========================================================================================= 

private void DropDownList4_SelectedIndexChanged(object sender, System.EventArgs e)
  {
   this.DropDownList3.Items.Clear();
   System.Web.UI.WebControls.ListItem h=new ListItem();
   h.Text="请选择分区";
   h.Value="0";


   

   this.DropDownList3.Items.Add(h);
   
   string gameid=this.DropDownList4.SelectedItem.Value;
   string strSql="select * from subarea where gameid='"+gameid+"'";
   WebShop.Common1 comm=new WebShop.Common1();
   SqlDataReader dst;
   dst=comm.full(strSql,CommandType.Text,"game");
   while(dst.Read())
   {
    System.Web.UI.WebControls.ListItem i=new ListItem();
    i.Value=dst[1].ToString();
    i.Text=dst[2].ToString();
    this.DropDownList3.Items.Add(i);
   }
   dst.Close();
  
  }

======================================================================

 

public void game()
  {
   string strSql="select *from game";
   SqlDataReader dst;
   WebShop.Common1 comm=new WebShop.Common1();
   dst=comm.full(strSql,CommandType.Text,"game");
   while(dst.Read())
   {
    System.Web.UI.WebControls.ListItem i=new ListItem();
    i.Value=dst[0].ToString();
    i.Text=dst[1].ToString();
    this.DropDownList4.Items.Add(i);

   }
   dst.Close();
  
  }

 

===================================================

private void DropDownList3_SelectedIndexChanged(object sender, System.EventArgs e)
  {
   this.RadioButtonList1.Visible=false;
   string subareaid=this.DropDownList4.SelectedItem.Text.Trim();
   WebShop.Common common=new WebShop.Common();
   string strSql="SELECT wupinxinxi.serverid,dbo.game.gamename,wupinxinxi.xinxileixing, dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid,wupinxinxi.subareaid,wupinxinxi.xinxileixing HAVING (dbo.wupinxinxi.propid = 1) and wupinxinxi.subareaid='"+this.DropDownList3.SelectedItem.Value+"' ";
   DataSet ds=common.full(strSql,CommandType.Text,"bixiangxi");
   if(ds.Tables[0].Rows.Count>0)
   {
    this.Label5.Visible=false;

    this.youxibi.DataSource=ds.Tables[0];
    this.youxibi.DataBind();
   }
   else
   {
    this.Label5.Visible=true;

    this.youxibi.DataSource=ds.Tables[0];
    this.youxibi.DataBind();
   }
   if(subareaid=="魔兽")
   {
    this.RadioButtonList1.Visible=true;
   }
   else
   {
    this.RadioButtonList1.Visible=false;
   }
  
   
  
  }

==============================================

public void game()
  {
   string strSql="select *from game";
   SqlDataReader dst;
   WebShop.Common1 comm=new WebShop.Common1();
   dst=comm.full(strSql,CommandType.Text,"game");
   while(dst.Read())
   {
    System.Web.UI.WebControls.ListItem i=new ListItem();
    i.Value=dst[0].ToString();
    i.Text=dst[1].ToString();
    this.DropDownList4.Items.Add(i);

   }
   dst.Close();
  
  }

===============================================================

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 bargaining
{
 /// <summary>
 /// youxibiserver 的摘要说明。
 /// </summary>
 public class youxibiserver : System.Web.UI.Page
 {
  protected System.Web.UI.HtmlControls.HtmlGenericControl Span1;
  protected System.Web.UI.WebControls.DropDownList DropDownList3;
  protected System.Web.UI.WebControls.DropDownList DropDownList4;
  protected System.Web.UI.WebControls.Label Label5;
  protected System.Web.UI.WebControls.ImageButton ImageButton1;
  protected System.Web.UI.WebControls.ImageButton ImageButton2;
  protected System.Web.UI.WebControls.RadioButtonList RadioButtonList1;
  protected System.Web.UI.WebControls.Button Button1;
  protected System.Web.UI.WebControls.DataList youxibi;
 
  private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此处放置用户代码以初始化页面
   if(!this.IsPostBack)
   {
    game();
    if(this.Request.QueryString.Count==0)
    {
     using(WebShop.Common common=new WebShop.Common())
     {

      string strSql="SELECT wupinxinxi.serverid,dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shengyushuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid HAVING (dbo.wupinxinxi.propid = 1) and gamesubarea='欧服' ";
      DataSet ds=common.full(strSql,CommandType.Text,"bixiangxi");
      if(ds.Tables[0].Rows.Count>0)
      {

       this.youxibi.DataSource=ds.Tables[0];
       this.youxibi.DataBind();
      }
     }
    }
    else
    {
     string str=this.Request.QueryString["str"];
     using(WebShop.Common common=new WebShop.Common())
     {
      string strSql="SELECT wupinxinxi.serverid,wupinxinxi.subareaid,dbo.game.gamename,wupinxinxi.xinxileixing, dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid,wupinxinxi.xinxileixing,wupinxinxi.subareaid HAVING (dbo.wupinxinxi.propid = 1) and gamename like '魔兽' and gamesubarea='"+str+"'";
      DataSet ds=common.full(strSql,CommandType.Text,"bixiangxi");
      if(ds.Tables[0].Rows.Count>0)
      {

       this.youxibi.DataSource=ds.Tables[0];
       this.youxibi.DataBind();
      }
     }
    }
   }
  }
  public void game()
  {
   string strSql="select *from game";
   SqlDataReader dst;
   WebShop.Common1 comm=new WebShop.Common1();
   dst=comm.full(strSql,CommandType.Text,"game");
   while(dst.Read())
   {
    System.Web.UI.WebControls.ListItem i=new ListItem();
    i.Value=dst[0].ToString();
    i.Text=dst[1].ToString();
    this.DropDownList4.Items.Add(i);

   }
   dst.Close();
  
  }


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

  }
  #endregion

  private void DropDownList4_SelectedIndexChanged(object sender, System.EventArgs e)
  {
   this.DropDownList3.Items.Clear();
   System.Web.UI.WebControls.ListItem h=new ListItem();
   h.Text="请选择分区";
   h.Value="0";


   

   this.DropDownList3.Items.Add(h);
   
   string gameid=this.DropDownList4.SelectedItem.Value;
   string strSql="select * from subarea where gameid='"+gameid+"'";
   WebShop.Common1 comm=new WebShop.Common1();
   SqlDataReader dst;
   dst=comm.full(strSql,CommandType.Text,"game");
   while(dst.Read())
   {
    System.Web.UI.WebControls.ListItem i=new ListItem();
    i.Value=dst[1].ToString();
    i.Text=dst[2].ToString();
    this.DropDownList3.Items.Add(i);
   }
   dst.Close();
  
  }

  private void DropDownList3_SelectedIndexChanged(object sender, System.EventArgs e)
  {
   this.RadioButtonList1.Visible=false;
   string subareaid=this.DropDownList4.SelectedItem.Text.Trim();
   WebShop.Common common=new WebShop.Common();
   string strSql="SELECT wupinxinxi.serverid,dbo.game.gamename,wupinxinxi.xinxileixing, dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid,wupinxinxi.subareaid,wupinxinxi.xinxileixing HAVING (dbo.wupinxinxi.propid = 1) and wupinxinxi.subareaid='"+this.DropDownList3.SelectedItem.Value+"' ";
   DataSet ds=common.full(strSql,CommandType.Text,"bixiangxi");
   if(ds.Tables[0].Rows.Count>0)
   {
    this.Label5.Visible=false;

    this.youxibi.DataSource=ds.Tables[0];
    this.youxibi.DataBind();
   }
   else
   {
    this.Label5.Visible=true;

    this.youxibi.DataSource=ds.Tables[0];
    this.youxibi.DataBind();
   }
   if(subareaid=="魔兽")
   {
    this.RadioButtonList1.Visible=true;
   }
   else
   {
    this.RadioButtonList1.Visible=false;
   }
  
   
  
  }

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

  private void ImageButton2_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  {
   string subarea=this.DropDownList3.SelectedItem.Text.Trim();
   string game=this.DropDownList4.SelectedItem.Text.Trim();
   string subareaid=this.DropDownList3.SelectedItem.Value;

   string strSql="";
   using(WebShop.Common common=new WebShop.Common())
   {
    if(game!="选择游戏")
    {
     if(subarea!="选择分区")
     {
      strSql="SELECT wupinxinxi.serverid,dbo.game.gamename, wupinxinxi.xinxileixing,dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid ,xinxileixing,wupinxinxi.subareaid HAVING (dbo.wupinxinxi.propid = 1) and xinxileixing='出售' and wupinxinxi.subareaid='"+subareaid+"' ";
      
     }
     else
     {
      this.Response.Write("<script language='javascript'>alert('请选择分区')</script>");
     }
    }
    else
    {
     if(subarea=="选择分区")
     {
       strSql="SELECT wupinxinxi.serverid,dbo.game.gamename, wupinxinxi.xinxileixing,dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid ,xinxileixing HAVING (dbo.wupinxinxi.propid = 1) and xinxileixing='出售' ";

     }
     else
     {
      this.Response.Write("<script language='javascript'>alert('请选择游戏')</script>");

     }
    }

    
    DataSet ds=common.full(strSql,CommandType.Text,"bixiangxi");
    if(ds.Tables[0].Rows.Count>0)
    {
     this.Label5.Visible=false;
     Session["xinxileixing"]="出售";

     this.youxibi.DataSource=ds.Tables[0];
     this.youxibi.DataBind();
    }
    else
    {
     this.Label5.Visible=true;
    }
   }
   
  
  }

  private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  {
   string subarea=this.DropDownList3.SelectedItem.Text.Trim();
   string game=this.DropDownList4.SelectedItem.Text.Trim();
   string subareaid=this.DropDownList3.SelectedItem.Value;

   string strSql="";
   using(WebShop.Common common=new WebShop.Common())
   {
    if(game!="选择游戏")
    {
     if(subarea!="选择分区")
     {
      strSql="SELECT wupinxinxi.serverid,dbo.game.gamename, wupinxinxi.xinxileixing,dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid ,xinxileixing,wupinxinxi.subareaid HAVING (dbo.wupinxinxi.propid = 1) and xinxileixing='求购' and wupinxinxi.subareaid='"+subareaid+"' ";
      
     }
     else
     {
      this.Response.Write("<script language='javascript'>alert('请选择分区')</script>");
     }
    }
    else
    {
     if(subarea=="选择分区")
     {
       strSql="SELECT wupinxinxi.serverid,dbo.game.gamename, wupinxinxi.xinxileixing,dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid ,xinxileixing HAVING (dbo.wupinxinxi.propid = 1) and xinxileixing='求购' ";

     }
     else
     {
      this.Response.Write("<script language='javascript'>alert('请选择游戏')</script>");

     }
    }

    
    DataSet ds=common.full(strSql,CommandType.Text,"bixiangxi");
    if(ds.Tables[0].Rows.Count>0)
    {
     this.Label5.Visible=false;
     Session["xinxileixing"]="求购";

     this.youxibi.DataSource=ds.Tables[0];
     this.youxibi.DataBind();
    }
    else
    {
     this.Label5.Visible=true;
    }
   }
  
  }

  private void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e)
  {
   using(WebShop.Common common=new WebShop.Common())
   {
    string gameserver=this.RadioButtonList1.SelectedItem.Text.Trim();
    string subareaid=this.DropDownList3.SelectedItem.Value;

    string strSql="SELECT wupinxinxi.serverid,dbo.game.gamename,wupinxinxi.xinxileixing, dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shengyushuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid,wupinxinxi.subareaid,wupinxinxi.xinxileixing HAVING (dbo.wupinxinxi.propid = 1) and wupinxinxi.subareaid='"+subareaid+"' and server.gameserver like '"+gameserver+"%' ";
    DataSet ds=common.full(strSql,CommandType.Text,"bixiangxi");
    if(ds.Tables[0].Rows.Count>0)
    {
     this.Label5.Visible=false;

     this.youxibi.DataSource=ds.Tables[0];
     this.youxibi.DataBind();
    }
    else
    {
     this.Label5.Visible=true;
     Session["subareaid"]=this.DropDownList3.SelectedItem.Value;

     this.youxibi.DataSource=ds.Tables[0];
     this.youxibi.DataBind();
    }
   }
  
  }

  public void Button1_Click(object sender, System.EventArgs e)
  {
   LinkButton d=(LinkButton)sender;
   string xinxileixing="";
   string serverid=d.CommandArgument.ToString();
   if(Session["xinxileixing"]!=null)
   {
    xinxileixing=Session["xinxileixing"].ToString();
    Response.Redirect("youxibiList.aspx?serverid="+serverid+"&xinxileixing='"+xinxileixing+"'");
   }
   else
   {
    Response.Redirect("youxibiList.aspx?serverid="+serverid+"");

   }
   
  }
    
 }
}

=====================================================

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;
using System.Configuration;

namespace bargaining.houtai
{
 /// <summary>
 /// danbaoselect 的摘要说明。
 /// </summary>
 public class danbaoselect : System.Web.UI.Page
 {
  protected System.Web.UI.WebControls.HyperLink HyperLink2;
  protected System.Web.UI.WebControls.HyperLink HyperLink1;
  protected System.Web.UI.WebControls.Label Label1;
  protected System.Web.UI.WebControls.DataList Repeater1;
  protected System.Web.UI.WebControls.Button insert;
  protected System.Web.UI.WebControls.Label Label2;
  string strConn=ConfigurationSettings.AppSettings["sqlconn"];
 
  private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此处放置用户代码以初始化页面
   string h="";
   if(!Page.IsPostBack)
   {
    try
    {
     h=Session["admin"].ToString();
    }
    catch
    {
     h="";
    }
    if(h=="")
    {
     Response.Write( "<script language='javascript'>") ;
     Response.Write("alert('请先登陆');");
     Response.Write("document.location.href='denglu.aspx'");
     Response.Write("</script>");
    }
    else
    {
   
     bind();
    }
   }
  }
  public void bind()
  {
   SqlConnection sqlconn=new SqlConnection(strConn);
   string strSql="select dandingdanid,wupinname,shuliang,money,wantime,lirun from danbaodingdan ";
   SqlDataAdapter strgh=new SqlDataAdapter(strSql,sqlconn);
   sqlconn.Open();
   DataSet ds=new DataSet();
   strgh.Fill(ds);
   if(ds.Tables[0].Rows.Count==0)
   {
    
    Label2.Visible=true;
    this.Repeater1.Visible=false;
    this.Label1.Visible=false;
    this.HyperLink1.Visible=false;
    this.HyperLink2.Visible=false;

   }
   PagedDataSource sqlpage=new PagedDataSource();
   sqlpage.DataSource=ds.Tables[0].DefaultView;
   sqlpage.AllowPaging=true;
   sqlpage.PageSize=15;
   int curpage;
   if(Request.QueryString.Count>0)
   {
    curpage=Convert.ToInt32(Request.QueryString["Page"]);
   }
   else
   
    curpage=1;
   sqlpage.CurrentPageIndex=curpage-1;
   this.Label1.Text="当前页:"+curpage.ToString();
   
   if(!sqlpage.IsFirstPage)
   {
    this.HyperLink1.NavigateUrl=Request.CurrentExecutionFilePath+"?Page="+Convert.ToString(curpage-1);
     
   }
   if(!sqlpage.IsLastPage)
   {
    this.HyperLink2.NavigateUrl=Request.CurrentExecutionFilePath+ "?Page=" + Convert.ToString(curpage+1);
   }
   
   this.Repeater1.DataSource=sqlpage;
   this.Repeater1.DataKeyField="dandingdanid";
   this.Repeater1.DataBind();
  }

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

  }
  #endregion

  public void insert_Click(object sender, System.EventArgs e)
  {
   string tmp="";
   foreach(DataListItem item in this.Repeater1.Items)
   {
    TextBox txt = (TextBox)item.FindControl("text1");
    tmp = txt.Text;
    LinkButton d=(LinkButton)sender;
    string id=d.CommandArgument.ToString();
    string strSql1="update danbaodingdan set lirun="+tmp+" where dandingdanid='"+id+"'";
    WebShop.Common1 comm=new WebShop.Common1();
    comm.exec(strSql1,CommandType.Text,"bidingdan");
    if(int.Parse(tmp.ToString())>0)
    {
     break;
    }
    
   }
   
   bind();
  
  }
 }
}

================================================================================

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 bargaining
{
 /// <summary>
 /// youxibiserver 的摘要说明。
 /// </summary>
 public class youxibiserver : System.Web.UI.Page
 {
  protected System.Web.UI.HtmlControls.HtmlGenericControl Span1;
  protected System.Web.UI.WebControls.DropDownList DropDownList3;
  protected System.Web.UI.WebControls.DropDownList DropDownList4;
  protected System.Web.UI.WebControls.Label Label5;
  protected System.Web.UI.WebControls.ImageButton ImageButton1;
  protected System.Web.UI.WebControls.ImageButton ImageButton2;
  protected System.Web.UI.WebControls.RadioButtonList RadioButtonList1;
  protected System.Web.UI.WebControls.Button Button1;
  protected System.Web.UI.WebControls.DataList youxibi;
 
  private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此处放置用户代码以初始化页面
   if(!this.IsPostBack)
   {
    game();
    if(this.Request.QueryString.Count==0)
    {
     using(WebShop.Common common=new WebShop.Common())
     {

      string strSql="SELECT wupinxinxi.serverid,dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shengyushuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid HAVING (dbo.wupinxinxi.propid = 1) and gamesubarea='欧服' ";
      DataSet ds=common.full(strSql,CommandType.Text,"bixiangxi");
      if(ds.Tables[0].Rows.Count>0)
      {

       this.youxibi.DataSource=ds.Tables[0];
       this.youxibi.DataBind();
      }
     }
    }
    else
    {
     string str=this.Request.QueryString["str"];
     using(WebShop.Common common=new WebShop.Common())
     {
      string strSql="SELECT wupinxinxi.serverid,wupinxinxi.subareaid,dbo.game.gamename,wupinxinxi.xinxileixing, dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid,wupinxinxi.xinxileixing,wupinxinxi.subareaid HAVING (dbo.wupinxinxi.propid = 1) and gamename like '魔兽' and gamesubarea='"+str+"'";
      DataSet ds=common.full(strSql,CommandType.Text,"bixiangxi");
      if(ds.Tables[0].Rows.Count>0)
      {

       this.youxibi.DataSource=ds.Tables[0];
       this.youxibi.DataBind();
      }
     }
    }
   }
  }
  public void game()
  {
   string strSql="select *from game";
   SqlDataReader dst;
   WebShop.Common1 comm=new WebShop.Common1();
   dst=comm.full(strSql,CommandType.Text,"game");
   while(dst.Read())
   {
    System.Web.UI.WebControls.ListItem i=new ListItem();
    i.Value=dst[0].ToString();
    i.Text=dst[1].ToString();
    this.DropDownList4.Items.Add(i);

   }
   dst.Close();
  
  }


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

  }
  #endregion

  private void DropDownList4_SelectedIndexChanged(object sender, System.EventArgs e)
  {
   this.DropDownList3.Items.Clear();
   System.Web.UI.WebControls.ListItem h=new ListItem();
   h.Text="请选择分区";
   h.Value="0";


   

   this.DropDownList3.Items.Add(h);
   
   string gameid=this.DropDownList4.SelectedItem.Value;
   string strSql="select * from subarea where gameid='"+gameid+"'";
   WebShop.Common1 comm=new WebShop.Common1();
   SqlDataReader dst;
   dst=comm.full(strSql,CommandType.Text,"game");
   while(dst.Read())
   {
    System.Web.UI.WebControls.ListItem i=new ListItem();
    i.Value=dst[1].ToString();
    i.Text=dst[2].ToString();
    this.DropDownList3.Items.Add(i);
   }
   dst.Close();
  
  }

  private void DropDownList3_SelectedIndexChanged(object sender, System.EventArgs e)
  {
   this.RadioButtonList1.Visible=false;
   string subareaid=this.DropDownList4.SelectedItem.Text.Trim();
   WebShop.Common common=new WebShop.Common();
   string strSql="SELECT wupinxinxi.serverid,dbo.game.gamename,wupinxinxi.xinxileixing, dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid,wupinxinxi.subareaid,wupinxinxi.xinxileixing HAVING (dbo.wupinxinxi.propid = 1) and wupinxinxi.subareaid='"+this.DropDownList3.SelectedItem.Value+"' ";
   DataSet ds=common.full(strSql,CommandType.Text,"bixiangxi");
   if(ds.Tables[0].Rows.Count>0)
   {
    this.Label5.Visible=false;

    this.youxibi.DataSource=ds.Tables[0];
    this.youxibi.DataBind();
   }
   else
   {
    this.Label5.Visible=true;

    this.youxibi.DataSource=ds.Tables[0];
    this.youxibi.DataBind();
   }
   if(subareaid=="魔兽")
   {
    this.RadioButtonList1.Visible=true;
   }
   else
   {
    this.RadioButtonList1.Visible=false;
   }
  
   
  
  }

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

  private void ImageButton2_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  {
   string subarea=this.DropDownList3.SelectedItem.Text.Trim();
   string game=this.DropDownList4.SelectedItem.Text.Trim();
   string subareaid=this.DropDownList3.SelectedItem.Value;

   string strSql="";
   using(WebShop.Common common=new WebShop.Common())
   {
    if(game!="选择游戏")
    {
     if(subarea!="选择分区")
     {
      strSql="SELECT wupinxinxi.serverid,dbo.game.gamename, wupinxinxi.xinxileixing,dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid ,xinxileixing,wupinxinxi.subareaid HAVING (dbo.wupinxinxi.propid = 1) and xinxileixing='出售' and wupinxinxi.subareaid='"+subareaid+"' ";
      
     }
     else
     {
      this.Response.Write("<script language='javascript'>alert('请选择分区')</script>");
     }
    }
    else
    {
     if(subarea=="选择分区")
     {
       strSql="SELECT wupinxinxi.serverid,dbo.game.gamename, wupinxinxi.xinxileixing,dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid ,xinxileixing HAVING (dbo.wupinxinxi.propid = 1) and xinxileixing='出售' ";

     }
     else
     {
      this.Response.Write("<script language='javascript'>alert('请选择游戏')</script>");

     }
    }

    
    DataSet ds=common.full(strSql,CommandType.Text,"bixiangxi");
    if(ds.Tables[0].Rows.Count>0)
    {
     this.Label5.Visible=false;
     Session["xinxileixing"]="出售";

     this.youxibi.DataSource=ds.Tables[0];
     this.youxibi.DataBind();
    }
    else
    {
     this.Label5.Visible=true;
    }
   }
   
  
  }

  private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  {
   string subarea=this.DropDownList3.SelectedItem.Text.Trim();
   string game=this.DropDownList4.SelectedItem.Text.Trim();
   string subareaid=this.DropDownList3.SelectedItem.Value;

   string strSql="";
   using(WebShop.Common common=new WebShop.Common())
   {
    if(game!="选择游戏")
    {
     if(subarea!="选择分区")
     {
      strSql="SELECT wupinxinxi.serverid,dbo.game.gamename, wupinxinxi.xinxileixing,dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid ,xinxileixing,wupinxinxi.subareaid HAVING (dbo.wupinxinxi.propid = 1) and xinxileixing='求购' and wupinxinxi.subareaid='"+subareaid+"' ";
      
     }
     else
     {
      this.Response.Write("<script language='javascript'>alert('请选择分区')</script>");
     }
    }
    else
    {
     if(subarea=="选择分区")
     {
       strSql="SELECT wupinxinxi.serverid,dbo.game.gamename, wupinxinxi.xinxileixing,dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid ,xinxileixing HAVING (dbo.wupinxinxi.propid = 1) and xinxileixing='求购' ";

     }
     else
     {
      this.Response.Write("<script language='javascript'>alert('请选择游戏')</script>");

     }
    }

    
    DataSet ds=common.full(strSql,CommandType.Text,"bixiangxi");
    if(ds.Tables[0].Rows.Count>0)
    {
     this.Label5.Visible=false;
     Session["xinxileixing"]="求购";

     this.youxibi.DataSource=ds.Tables[0];
     this.youxibi.DataBind();
    }
    else
    {
     this.Label5.Visible=true;
    }
   }
  
  }

  private void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e)
  {
   using(WebShop.Common common=new WebShop.Common())
   {
    string gameserver=this.RadioButtonList1.SelectedItem.Text.Trim();
    string subareaid=this.DropDownList3.SelectedItem.Value;

    string strSql="SELECT wupinxinxi.serverid,dbo.game.gamename,wupinxinxi.xinxileixing, dbo.subarea.gamesubarea, dbo.server.gameserver,prop.propname,prop.propid, SUM(dbo.wupinxinxi.shengyushuliang) AS shu FROM dbo.wupinxinxi INNER JOIN dbo.game ON dbo.wupinxinxi.gameid = dbo.game.gameid INNER JOIN dbo.server ON dbo.wupinxinxi.serverid = dbo.server.serverid INNER JOIN dbo.subarea ON dbo.wupinxinxi.subareaid = dbo.subarea.subareaid inner join prop on wupinxinxi.propid=prop.propid GROUP BY dbo.game.gamename, dbo.subarea.gamesubarea, dbo.server.gameserver,dbo.prop.propname,prop.propid,wupinxinxi.propid,wupinxinxi.serverid,wupinxinxi.subareaid,wupinxinxi.xinxileixing HAVING (dbo.wupinxinxi.propid = 1) and wupinxinxi.subareaid='"+subareaid+"' and server.gameserver like '"+gameserver+"%' ";
    DataSet ds=common.full(strSql,CommandType.Text,"bixiangxi");
    if(ds.Tables[0].Rows.Count>0)
    {
     this.Label5.Visible=false;

     this.youxibi.DataSource=ds.Tables[0];
     this.youxibi.DataBind();
    }
    else
    {
     this.Label5.Visible=true;
     Session["subareaid"]=this.DropDownList3.SelectedItem.Value;

     this.youxibi.DataSource=ds.Tables[0];
     this.youxibi.DataBind();
    }
   }
  
  }

  public void Button1_Click(object sender, System.EventArgs e)
  {
   LinkButton d=(LinkButton)sender;
   string xinxileixing="";
   string serverid=d.CommandArgument.ToString();
   if(Session["xinxileixing"]!=null)
   {
    xinxileixing=Session["xinxileixing"].ToString();
    Response.Redirect("youxibiList.aspx?serverid="+serverid+"&xinxileixing='"+xinxileixing+"'");
   }
   else
   {
    Response.Redirect("youxibiList.aspx?serverid="+serverid+"");

   }
   
  }
    
 }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值