modify.aspx.cs

来自「大中型酒店管理系统」· CS 代码 · 共 62 行

CS
62
字号
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 + =
减小字号Ctrl + -
显示快捷键?