?? guanlixuanke.aspx.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 + -