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

📄 modify.aspx.cs

📁 大中型酒店管理系统
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;
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;

public partial class modify : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (Session["Admin"] == null)
        //{
        //    Response.Redirect("./Default.Aspx");
        //}

        SqlConnection Conn = db.createconn();

        Conn.Open();

        SqlCommand Cmd = new SqlCommand("select * from news where newsid ="
    + Request.QueryString["id"], Conn);

        if (!IsPostBack)
        {
            SqlDataReader Dr = Cmd.ExecuteReader();

            if (Dr.Read())
            {
                TextBox1.Text=Dr["newstitle"].ToString();
                TextBox2.Text = Dr["newsauthor"].ToString();
                TextBox3.Text = Dr["newscontent"].ToString();
               
            }
        }
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string tit=TextBox1.Text;
        string aut=TextBox2.Text;
        string cont = TextBox3.Text;
        SqlConnection Conn = db.createconn();

        Conn.Open();

        SqlCommand Cmd = new SqlCommand("update news set newstitle='" + tit + "',newsauthor='" + aut + "',newscontent='" + cont + "' where newsid="
            + Request.QueryString["id"], Conn);

        Cmd.ExecuteNonQuery();

        Response.Redirect("./AdminNews.aspx");

        Conn.Close();
    }
}

⌨️ 快捷键说明

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