📄 adminhomebadedit.aspx.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 adminhomebadedit : System.Web.UI.Page
{
SqlCommand cmd, cmd1;
SqlConnection cn;
SqlDataReader dr, dr1;
SqlDataAdapter da, da1;
DataSet ds = new DataSet();
DataSet ds1 = new DataSet();
DataTable mytable = new DataTable();
string strcon, strsql, strsql1, strsql2;
protected void Page_Load(object sender, EventArgs e)
{
this.Label1.Text = Convert.ToString (Request.QueryString["id"]);
int id = Convert.ToInt32(this.Label1.Text);
this.Labshenhe.Text = this.DropDownList1.SelectedItem.Value.ToString();
if (!this.IsPostBack)
{
if (Session["adminname"] == null)
{
Response.Redirect("index.aspx");
}
else
{
cn = sqldata.createcon();
cn.Open();
strsql = "select *from homebad where id=" + id;
da = new SqlDataAdapter(strsql, cn);
da.Fill(ds);
mytable = ds.Tables[(0)];
this.Labuserid.Text = Convert.ToString(mytable.Rows[0]["userid"]);
this.Labusername.Text = Convert.ToString(mytable.Rows[0]["username"]);
this.Labhomeflood.Text = Convert.ToString(mytable.Rows[0]["homeflood"]);
this.Labhomesex.Text = Convert.ToString(mytable.Rows[0]["homesex"]);
this.Labhomehao.Text = Convert.ToString(mytable.Rows[0]["homehao"]);
this.Labhomephone.Text = Convert.ToString(mytable.Rows[0]["homephone"]);
this.TextBox1.Text = Convert.ToString(mytable.Rows[0]["content"]);
this.Labshenhe.Text = Convert.ToString(mytable.Rows[0]["shenhe"]);
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
int id =int.Parse (Request .QueryString ["id"]);
cn = sqldata.createcon();
cn.Open();
strsql1 = "update homebad set shenhe='" + this.Labshenhe.Text.ToString() + "' where userid='" + this.Labuserid.Text.ToString() + "' and username='" + this.Labusername.Text + "' and homeflood='" + this.Labhomeflood.Text + "' and homesex='" + this.Labhomesex.Text + "' and homehao='" + this.Labhomehao.Text + "' and homephone='" + this.Labhomephone.Text + "' and content='" + this.TextBox1.Text + "' and id="+id;
cmd1 = new SqlCommand (strsql1, cn);
cmd1.ExecuteNonQuery();
this.Label2.Text = "更新成功!";
this.HyperLink1.Visible = true;
cn.Close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -