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

📄 addclas.aspx.cs

📁 这是暑假做的一个选课系统,可以供学习ASP的朋友借鉴
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient ;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace class_kinghome
{
	/// <summary>
	/// addclas 的摘要说明。
	/// </summary>
	public class addclas : System.Web.UI.Page
	{
		private void Page_Load(object sender, System.EventArgs e)
		{
				string getkind=Request["kind"];
			string getno=Request["no"];
			SqlConnection Con = new SqlConnection("Data Source=HSJ;Initial Catalog=class;User ID=sa;Pwd=hsj;"); 
			string sql="select * from csee where cno='"+getno+"'";
			SqlCommand addCommand =new SqlCommand(sql,Con);
			addCommand.Connection.Open();
			SqlDataReader selreader ;
			selreader=addCommand.ExecuteReader();
			if (selreader.Read() == true) 
			{
				if (selreader.GetValue(5).ToString()==selreader.GetValue(12).ToString())
				{addCommand.Connection.Close();
					Response.Write ("<script>alert(\"选课人数已慢!\");window.close('addclas.aspx')</script>");}
				else
				{addCommand.Connection.Close();
					sql="select * from sco where sno='" + Session["s_no"] +"' and cno='"+getno+"'"  ; 
					addCommand =new SqlCommand(sql,Con);
					addCommand.Connection.Open();
			
					selreader=addCommand.ExecuteReader();
					if (selreader.Read() == false) 
					{
						addCommand.Connection.Close();
						if (getkind=="1")
							getkind="必修";
						else if (getkind=="2")
							getkind="系选修";
						else if (getkind=="3")
							getkind="跨学科";
						sql = "insert into sco (sno,cno,ckind) values ('" + Session["s_no"] + "','"+getno+ "','"+getkind+"')";
						addCommand =new SqlCommand(sql,Con);
						addCommand.Connection.Open();
						addCommand.ExecuteNonQuery();
						addCommand.Connection.Close();
					sql="update csee set cpeo=cpeo+1 where cno='"+getno+"'";
						addCommand =new SqlCommand(sql,Con);
						addCommand.Connection.Open();
						addCommand.ExecuteNonQuery();
						addCommand.Connection.Close();
					}
					else 
						Response.Write ("<script>alert(\"你已经选了这门课!\")</script>");
					Response.Write ("<script>window.close('addclas.aspx')</script>");
			  
				}
			}
		}

		#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.Load += new System.EventHandler(this.Page_Load);
		}
		#endregion
	}
}

⌨️ 快捷键说明

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