?? addclas.aspx.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(\"選課人數(shù)已慢!\");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="跨學(xué)科";
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(\"你已經(jīng)選了這門課!\")</script>");
Response.Write ("<script>window.close('addclas.aspx')</script>");
}
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:該調(diào)用是 ASP.NET Web 窗體設(shè)計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設(shè)計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -