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

📄 find_cl3.aspx.cs

📁 本校友录采用Chinaren校友录的内核
💻 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>
	/// find_cl3 的摘要说明。
	/// </summary>
	public class find_cl3 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
		protected System.Web.UI.WebControls.Label lblNoCl;
		protected System.Web.UI.WebControls.TextBox txtClname;
		protected System.Web.UI.WebControls.TextBox txtGrad;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
		protected System.Web.UI.WebControls.RangeValidator RangeValidator1;
		protected System.Web.UI.WebControls.DataGrid dgdCl;
		protected System.Web.UI.WebControls.Button btnNext;

		OleDbConnection cn;
		OleDbCommand cmd;
		OleDbDataReader dr;
		OleDbDataAdapter da;
		DataSet ds;
		string strConn,strSQL,strUrl;
		int i;
	
		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");

            strConn="Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+Server.MapPath("txl.aspx");
			strSQL="select cl_id,cl_name,cl_grad,cl_num,cl_m1,cl_m2,cl_type from classinfo where cl_sid="+Page.Request["schid"].ToString();
			cn=new OleDbConnection(strConn);
			cn.Open();
			da=new OleDbDataAdapter(strSQL,cn);
			ds=new DataSet();
			da.Fill(ds,"cl");
			ds.Tables["cl"].Columns.Add("t_name");
			ds.Tables["cl"].Columns.Add("m1");
			ds.Tables["cl"].Columns.Add("m2");

			/*Page.Response.Write("行数");
			Page.Response.Write(ds.Tables["cl"].Rows.Count);
			Page.Response.Write("<br>");*/

			for(i=0;i<ds.Tables["cl"].Rows.Count;i++)			
				if(ds.Tables["cl"].Rows[i]["cl_type"].ToString()!="")
				{
					strSQL="select t_name from classtype where t_id="+ds.Tables["cl"].Rows[i]["cl_type"].ToString();
					cmd=new OleDbCommand(strSQL,cn);
					dr=cmd.ExecuteReader();
					while(dr.Read())				
					ds.Tables["cl"].Rows[i]["t_name"]=dr[0].ToString();
					dr.Close();
					cmd.Dispose();
					/*Page.Response.Write("添加类型");
					Page.Response.Write(i);
					Page.Response.Write("<br>");*/
				}
				

			
			for(i=0;i<ds.Tables["cl"].Rows.Count;i++)
			{
				if(ds.Tables["cl"].Rows[i]["cl_m1"].ToString()!="")
				{
					strSQL="select u_name from userinfo where u_id="+ds.Tables["cl"].Rows[i]["cl_m1"].ToString();
					cmd=new OleDbCommand(strSQL,cn);
					dr=cmd.ExecuteReader();
					while(dr.Read())
					ds.Tables["cl"].Rows[i]["m1"]=dr[0].ToString();
					dr.Close();
					cmd.Dispose();
					/*Page.Response.Write("添加正");
					Page.Response.Write(i);
					Page.Response.Write("<br>");*/
				}
			}

			for(i=0;i<ds.Tables["cl"].Rows.Count;i++)
			{
				if(ds.Tables["cl"].Rows[i]["cl_m2"].ToString()!="")
				{
					strSQL="select u_name from userinfo where u_id="+ds.Tables["cl"].Rows[i]["cl_m2"].ToString();
					cmd=new OleDbCommand(strSQL,cn);
					dr=cmd.ExecuteReader();
					while(dr.Read())
					ds.Tables["cl"].Rows[i]["m2"]=dr[0].ToString();
					dr.Close();
					cmd.Dispose();
					/*Page.Response.Write("添加副");
					Page.Response.Write(i);
					Page.Response.Write("<br>");*/
				}
			}

			dgdCl.DataSource=ds.Tables["Cl"].DefaultView;
			dgdCl.DataBind();

			da.Dispose();
			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 pid="";string cid="";string tid="";
			strConn="Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+Server.MapPath("txl.aspx");
			strSQL="select s_pid,s_cid,s_type from school where s_id="+Page.Request["schid"].ToString();
			cn=new OleDbConnection(strConn);
			cmd=new OleDbCommand(strSQL,cn);
			cn.Open();
			dr=cmd.ExecuteReader();
			while(dr.Read())
			{
				pid=dr[0].ToString();cid=dr[1].ToString();tid=dr[2].ToString();
			}
			dr.Close();
			cmd.Dispose();
			
			strSQL="Insert into classinfo(cl_name,cl_pid,cl_cid,cl_sid,cl_delflag,cl_m1,cl_type,cl_num,cl_grad) Values('";
			strSQL+=txtClname.Text+"',"+pid+","+cid+","+Page.Request["schid"].ToString()+",0,"+Session["uid"].ToString()+","+tid+",1,"+txtGrad.Text.ToString()+")";
			cmd=new OleDbCommand(strSQL,cn);
			cmd.ExecuteNonQuery();
			cmd.Dispose();


			strSQL="select cl_id from classinfo where cl_m1="+Session["uid"].ToString()+" ORDER BY cl_id DESC";
			cmd=new OleDbCommand(strSQL,cn);
			dr=cmd.ExecuteReader();
			dr.Read();
			strUrl="find_end.aspx?clid="+dr[0].ToString();
			cn.Close();
			Page.Response.Redirect(strUrl);
		}


	}
}

⌨️ 快捷键说明

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