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

📄 adminreplyedit.aspx.cs

📁 学生寝室管理系统
💻 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 adminreplyedit : System.Web.UI.Page
{
    SqlCommand cmd, cmd2;
    SqlConnection cn;
    SqlDataAdapter da1;
    DataSet ds1 = new DataSet();
    DataTable mytable = new DataTable();
    string strsql, strsql2;
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Labusername.Text = Convert.ToString(Session["adminname"]);
        if (!this.IsPostBack)
        {
            if (Session["adminname"] == null)
            {
                Response.Redirect("index.aspx");
            }
            else
            {
                int i;
                ArrayList n;
                n = new ArrayList();
                for (i = 0; i <= 49; i++)
                {
                    n.Add(i.ToString());
                }
                this.face1.DataSource = n;
                this.face1.DataBind();
                int id = Convert.ToInt32(Request.QueryString["id"]);
                cn = sqldata.createcon();
                cn.Open();
                strsql2 = "select reply,rename from guestbook where id=" + id;
                da1 = new SqlDataAdapter(strsql2, cn);
                da1.Fill(ds1);
                mytable = ds1.Tables[(0)];
                this.txtcontent.Text = Convert.ToString(mytable.Rows[0]["reply"]);
                this.Labusername.Text = Convert.ToString(mytable.Rows[0]["rename"]);

                cn.Close();

            }
        }
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        this.txtcontent.Text = "";
        this.txtcontent.Focus();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

        if (this.IsValid)
        {
            int id = int.Parse(Request.QueryString["id"]);
            cn = sqldata.createcon();
            cn.Open();
            strsql = "update guestbook set reply='" + this.txtcontent.Text.ToString().Trim() + "',replyimg='" + this.face1.SelectedItem.Value.ToString() + "',replytime=getdate()  where id='" + id + "'";
            cmd = new SqlCommand(strsql, cn);
            cmd.ExecuteNonQuery();

            cn.Close();
            this.Labmassage.Text = "编辑成功";
            this.HyperLink1.Visible = true;
        }
    }
}

⌨️ 快捷键说明

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