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

📄 welcome.aspx.cs

📁 ASP.NET实战编程(六) 电子商务系统
💻 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.OleDb;

namespace txl
{
	/// <summary>
	/// welcome 的摘要说明。
	/// </summary>
	public class welcome : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Button btnNext;
		protected System.Web.UI.WebControls.DropDownList ddlProve;
		protected System.Web.UI.WebControls.Label lblNo;
		protected System.Web.UI.WebControls.DataGrid DataGrid1;

		string strConn,strSQL;
		int uid;
		char[] de={'&'};
		string[] strCl={};// 记录所有的注册班级(1&12&5)
		string scl;
		int i;
		OleDbConnection cn;
		OleDbDataAdapter da;
		DataSet ds;
		OleDbDataReader dr;
		OleDbCommand cmd;



	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if(Session.Count==0) Page.Response.Redirect("default.aspx");
			else 
				if(Session["uid"].ToString()=="") Page.Response.Redirect("default.aspx");


			uid=Convert.ToInt32(Session["uid"].ToString());
			strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("txl.mdb");
			strSQL="Select u_class from userinfo where u_id="+uid.ToString();
			cn=new OleDbConnection(strConn);
			cmd=new OleDbCommand(strSQL,cn);
			cn.Open();
			dr=cmd.ExecuteReader();
			
			while(dr.Read())
			{
				scl=dr["u_class"].ToString();
				strCl=scl.Split(de);
				/*Page.Response.Write(strCl.Length);
				Page.Response.Write("<br>");
				Page.Response.Write(strCl[0]);*/

			}
			dr.Close();

			if(!Page.IsPostBack)
			{

				strSQL="select p_name from prove";			
				da=new OleDbDataAdapter(strSQL,cn);
				ds=new DataSet();
				da.Fill(ds,"prove");
				for(i=0;i<ds.Tables["prove"].Rows.Count;i++)
					ddlProve.Items.Add(ds.Tables["prove"].Rows[i]["p_name"].ToString());
				da.Dispose();
			}
			
			
			
			
 
			if(strCl[0].ToString()!="")
			{

				strSQL="select cl_name,cl_m1,cl_m2,cl_id,cl_sid from classinfo where cl_id=";
				for(i=0;i<strCl.Length;i++)
				{

					if(i==strCl.Length-1)
						strSQL+=strCl[i].ToString();
					else
						strSQL+=strCl[i].ToString()+" or cl_id=";
				}

				ds=new DataSet();
				da=new OleDbDataAdapter(strSQL,cn);
				da.Fill(ds,"clinfo");
				ds.Tables["clinfo"].Columns.Add("A1");
				ds.Tables["clinfo"].Columns.Add("A2");
				for(i=0;i<strCl.Length;i++)
					ds.Tables["clinfo"].Rows[i]["A1"]=i+1;
				for(i=0;i<strCl.Length;i++)
				{
					strSQL="select u_name from userinfo where u_id="+ds.Tables[0].Rows[i]["cl_m1"].ToString();
					cmd=new OleDbCommand(strSQL,cn);
					dr=cmd.ExecuteReader();
					while(dr.Read())
						if(dr[0].ToString().Length==2)
							ds.Tables["clinfo"].Rows[i]["A2"]="正:"+dr[0].ToString()+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;副:";
						else
							ds.Tables["clinfo"].Rows[i]["A2"]="正:"+dr[0].ToString()+"&nbsp;&nbsp;&nbsp;&nbsp;副:";

					dr.Close();


					strSQL="select u_name from userinfo where u_id="+ds.Tables[0].Rows[i]["cl_m2"].ToString();
					cmd=new OleDbCommand(strSQL,cn);
					dr=cmd.ExecuteReader();
					while(dr.Read())
						ds.Tables["clinfo"].Rows[i]["A2"]+=dr[0].ToString();
					dr.Close();
					ds.Tables["clinfo"].Rows[i]["A2"]="<table border=0 width=62% cellSpacing=0 cellPadding=0 style='BORDER-COLLAPSE:collapse' bordercolor='#C8E4FF'><tr><td align=left bgcolor='#C8E4FF'>"+ds.Tables["clinfo"].Rows[i]["A2"]+"</td></tr></table>";

				}
				ds.Tables["clinfo"].Columns.Add("A3");
				for(i=0;i<strCl.Length;i++)
				{
					strSQL="select s_name from school where s_id="+ds.Tables["clinfo"].Rows[i]["cl_sid"].ToString();
					cmd=new OleDbCommand(strSQL,cn);
					dr=cmd.ExecuteReader();
					while(dr.Read())
						ds.Tables["clinfo"].Rows[i]["A3"]="<table border=0 width=100% cellSpacing=0 cellPadding=0 style='BORDER-COLLAPSE:collapse' bordercolor='#C8E4FF'><tr><td align=left bgcolor='#C8E4FF'>"+dr[0].ToString()+"&nbsp;&nbsp;---&nbsp;&nbsp;"+ds.Tables["clinfo"].Rows[i]["cl_name"].ToString()+"</td></tr></table>";
					dr.Close();
				}

				DataGrid1.DataSource=ds.Tables["clinfo"].DefaultView;
				DataGrid1.DataBind();
				cn.Close();
			}
			else
			{
				lblNo.Visible=true;
				cn.Close();
			}
		}

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

		}
		#endregion

		private void btnNext_Click(object sender, System.EventArgs e)
		{
			string strPam="";
			strPam=Convert.ToString(ddlProve.SelectedIndex+1);
			Page.Response.Redirect("find_cl.aspx?pid="+strPam);
			
		}
	}
}

⌨️ 快捷键说明

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