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

📄 find_cl2.aspx.cs

📁 网上考试系统
💻 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;
using System.Configuration;

namespace ClassOnline
{
	/// <summary>
	/// Find_cl2 的摘要说明。
	/// </summary>
	public class Find_cl2 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label lblNoSchool;
		protected System.Web.UI.WebControls.DataGrid dgdSch;
		protected System.Web.UI.WebControls.TextBox txtSchname;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
		protected System.Web.UI.WebControls.TextBox txtScherea;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
		protected System.Web.UI.WebControls.TextBox txtSchzip;
		protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator2;
		protected System.Web.UI.WebControls.TextBox txtSchhttp;
		protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator3;
		protected System.Web.UI.WebControls.Button btnNext;
		string strSQL,strUrl;
		SqlConnection objconn;
		SqlDataAdapter da;
		DataSet ds;
		SqlDataReader dr;
		SqlCommand objcmd;

	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if(Session.Count==0) Page.Response.Redirect("default.aspx");
			else 
				if(Session["UserID"].ToString()=="") Page.Response.Redirect("default.aspx");
			objconn=new SqlConnection(ConfigurationSettings.AppSettings["connstr"]);
			objconn.Open();
			strSQL="select School.SID,school.SName,Province.PName,City.CityName,School.SErea,SNum,ClassType.CTypeName from School,Province,ClassType,City";
			strSQL+=" where CityID="+Page.Request["CityID"].ToString();
			strSQL+=" and CTypeID="+Page.Request["CTypeID"].ToString();
			strSQL+=" and PID="+Page.Request["PID"].ToString();
			strSQL+=" and SCID="+Page.Request["CityID"].ToString();
			strSQL+=" and SType="+Page.Request["CTypeID"].ToString();
			strSQL+=" and SProID="+Page.Request["PID"].ToString();
			
			da=new SqlDataAdapter(strSQL,objconn);
			ds=new DataSet();
			da.Fill(ds,"school");
			/*ds.Tables["school"].Columns.Add("s_url");

			for(i=0;i<ds.Tables["school"].Rows.Count;i++)
				ds.Tables["school"].Rows[i]["s_url"]="schid="+ds.Tables["school"].Rows[i][0].ToString()+"&uid="+Session["uid"].ToString();*/
			dgdSch.DataSource=ds.Tables["school"].DefaultView;
			dgdSch.DataBind();

			da.Dispose();
			objconn.Close();
		}

		#region Web 窗体设计器生成的代码
		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)
		{
			objconn=new SqlConnection(ConfigurationSettings.AppSettings["connstr"]);
			objconn.Open();
			strSQL="INSERT INTO School(SName,SProID,SCID,SErea,SType,SNum,SZip,SHttp,SDelFlag,SWho) VALUES('";
			strSQL+=txtSchname.Text+"',";
			strSQL+=Page.Request["PID"].ToString()+","+Page.Request["CityID"].ToString()+",'"+txtScherea.Text+"',"+Page.Request["CTypeID"].ToString()+",0,'";
			strSQL+=txtSchzip.Text+"','"+txtSchhttp.Text+"','0',"+Session["UserID"].ToString()+")";
			
			objcmd=new SqlCommand(strSQL,objconn);
		
			objcmd.ExecuteNonQuery();
			objcmd.Dispose();


			strSQL="select SID from School where SWho="+Session["UserID"].ToString()+" ORDER BY SID DESC";
			objcmd=new SqlCommand(strSQL,objconn);
			dr=objcmd.ExecuteReader();
			dr.Read();
			strUrl="find_cl3.aspx?SID="+dr[0].ToString();
			objconn.Close();
			Page.Response.Redirect(strUrl);
		}
	}
}

⌨️ 快捷键说明

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