feat: 添加功能开关控制页面并迁移PHP实现到ASP.NET
添加新的ASP.NET页面用于功能开关控制,包含前端界面和后端逻辑 删除旧的PHP实现文件,完成技术栈迁移
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Web;
|
||||
|
||||
public partial class E3_ycsys : System.Web.UI.Page
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
string connectionString = "Server=localhost;Database=your_database;User Id=your_username;Password=your_password;";
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
// 处理开关操作
|
||||
if (!string.IsNullOrEmpty(Request.QueryString["action"]) && !string.IsNullOrEmpty(Request.QueryString["id"]))
|
||||
{
|
||||
string id = Request.QueryString["id"];
|
||||
int status = Request.QueryString["action"] == "enable" ? 1 : 0;
|
||||
|
||||
string sql = "UPDATE features SET status = @status WHERE id = @id";
|
||||
SqlCommand cmd = new SqlCommand(sql, conn);
|
||||
cmd.Parameters.AddWithValue("@status", status);
|
||||
cmd.Parameters.AddWithValue("@id", id);
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
string logSql = "INSERT INTO operation_logs (feature_id, action, operation_time) VALUES (@id, @action, GETDATE())";
|
||||
SqlCommand logCmd = new SqlCommand(logSql, conn);
|
||||
logCmd.Parameters.AddWithValue("@id", id);
|
||||
logCmd.Parameters.AddWithValue("@action", Request.QueryString["action"]);
|
||||
logCmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
// 查询功能列表
|
||||
string querySql = "SELECT id, name, description, status FROM features";
|
||||
SqlDataAdapter adapter = new SqlDataAdapter(querySql, conn);
|
||||
DataTable dt = new DataTable();
|
||||
adapter.Fill(dt);
|
||||
|
||||
FeaturesRepeater.DataSource = dt;
|
||||
FeaturesRepeater.DataBind();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user