📄 adminhomeinfoedit.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 adminhomeinfoedit : 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)
{
int homeid = int.Parse(Request .QueryString ["homeid"]);
this.Labhomeyn.Text = this.ddlhomegood.SelectedItem.Value.ToString();
if (!this.IsPostBack)
{
if (Session["adminname"] == null)
{
Response.Redirect("index.aspx");
}
else
{
cn = sqldata.createcon();
cn.Open();
strsql1 = "select * from home where homeid='" + homeid + "'";
da = new SqlDataAdapter(strsql1, cn);
da.Fill(ds);
mytable = ds.Tables[(0)];
this.Labhomeid.Text = Convert.ToString(mytable.Rows[0]["homeid"]);
this.Labuid.Text = Convert.ToString(mytable.Rows[0]["uid"]);
this.Labhomeflood.Text = Convert.ToString(mytable.Rows[0]["homeflood"]);
this.Labhomecount.Text = Convert.ToString(mytable.Rows[0]["homecount"]);
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.txtcontent.Text = Convert.ToString(mytable.Rows[0]["homefen"]);
this.Labhomeyn.Text = Convert.ToString(mytable.Rows[0]["homeyn"]);
}
}
}
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)
{
cn = sqldata.createcon();
cn.Open();
strsql = "update home set homefen='" + this.txtcontent.Text.ToString() + "',homeyn='" + this.Labhomeyn.Text + "' where homesex='" + this.Labhomesex.Text + "'and homeflood='" + this.Labhomeflood .Text.ToString() + "' and homehao='" + this.Labhomehao.Text + "' and homecount='" + this.Labhomecount.Text.ToString() + "' and homephone='" + this.Labhomephone .Text + "'";
cmd = new SqlCommand(strsql, cn);
cmd.ExecuteNonQuery();
this.Label2.Text = "更新成功";
this.HyperLink1.Visible = true;
cn.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -