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

📄 guanlixuanke.aspx.cs

📁 学生网上选课系统,实现了学生的在线选课和教师课程的上传
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Default2 : System.Web.UI.Page
{
    SqlConnection conn;
    protected void Page_Load(object sender, EventArgs e)
    {
        string myconn=System .Configuration .ConfigurationManager .AppSettings ["ConnectionString"];
        conn = new SqlConnection(myconn );
        if (Session["userName"] == null)
        {
            Response.Redirect("Login.aspx");
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        conn.Open();
        string mysql1 = "UPDATE guanlixuanke SET glxkstate='启用' WHERE glxkid=1";
        SqlCommand cm1 = new SqlCommand(mysql1, conn);
        cm1.CommandType = CommandType.Text;
        try
        {
            cm1.ExecuteNonQuery();
            Label1.Text = "提示:启用成功!";
            Label1.Style["color"] = "red";
            Button1.Visible = true;
            Button2.Visible = true;
        }
        catch (SqlException)
        {
            Label1.Text = "提示:启用失败!";
            Label1.Style["color"] = "red";
        }
        conn.Close();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        conn.Open();
        string mysql2 = "UPDATE guanlixuanke SET glxkstate='关闭' WHERE glxkid=1";
        SqlCommand cm2 = new SqlCommand(mysql2, conn);
        cm2.CommandType = CommandType.Text;
        try
        {
            cm2.ExecuteNonQuery();
            Label1.Text = "提示:关闭成功!";
            Label1.Style["color"] = "red";
            Button2.Visible = true;
            Button1.Visible = true;
        }
        catch (SqlException)
        {
            Label1.Text = "提示:关闭失败!";
            Label1.Style["color"] = "red";
        }
        conn.Close();
    }

    protected void Button3_Click(object sender, EventArgs e)
    {
        conn.Open();
        string mysql3 = "update guanlixuanke set glxkms='"+TextBox1.Text+"' ";
        SqlCommand cm3 = new SqlCommand(mysql3, conn);
        cm3.CommandType = CommandType.Text;
        cm3.ExecuteNonQuery();
        conn.Close();
    }
}

⌨️ 快捷键说明

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