0c72514b07
- 添加UTF-8 BOM头到所有文件 - 修改页面标题和按钮文字为中文 - 更新Web.config支持中文编码和区域设置 - 改进界面描述文字使其更清晰
53 lines
2.2 KiB
C#
53 lines
2.2 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Web;
|
|
using System.Configuration;
|
|
|
|
public partial class E3_ycsys : System.Web.UI.Page
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
var connString = ConfigurationManager.ConnectionStrings["E3_ycsysConnection"];
|
|
string connectionString = connString != null ? connString.ConnectionString : null;
|
|
|
|
if(string.IsNullOrEmpty(connectionString))
|
|
{
|
|
throw new Exception("请在Web.config中配置名为'E3_ycsysConnection'的连接字符串");
|
|
}
|
|
|
|
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" ? 2 : 0;
|
|
|
|
// 修改更新状态的SQL语句,确保表名一致
|
|
string sql = "UPDATE ycsys SET vip_saomiao = @status WHERE dm = @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 khdm,khmc,cast(ycsys.vip_saomiao as int) as status FROM kehu1 inner join ycsys on kehu1.khdm=ycsys.dm";
|
|
SqlDataAdapter adapter = new SqlDataAdapter(querySql, conn);
|
|
DataTable dt = new DataTable();
|
|
adapter.Fill(dt);
|
|
|
|
FeaturesRepeater.DataSource = dt;
|
|
FeaturesRepeater.DataBind();
|
|
}
|
|
}
|
|
} |