📄 zhedit.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;
public partial class Admin_ZhEdit : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//数据绑定
this.DropDownList1.DataTextField = "楼栋名称";
this.DropDownList1.DataValueField = "楼栋代码";
this.DropDownList1.DataSource = DataControl.GetData("select * from 楼栋 ");
this.DropDownList1.DataBind();
//显示住户信息
DataTable dt = new DataTable();
if (Request.QueryString["ID"] != null)
{
this.TextBox1.ReadOnly = false;
dt = DataControl.GetData("select * from 住户 where 住户代码=" + Request.QueryString["ID"] + "");
if (dt.Rows.Count > 0)
{
this.TextBox1.Text = dt.Rows[0]["户主"].ToString();
this.DropDownList1.SelectedValue = dt.Rows[0]["楼栋代码"].ToString();
this.TextBox3.Text = dt.Rows[0]["房间号"].ToString();
this.Textbox2.Text = dt.Rows[0]["房屋面积"].ToString();
this.Textbox4.Text = dt.Rows[0]["联系方式"].ToString();
this.DropDownList2.SelectedIndex = DataControl.GetIndex(DropDownList2, dt.Rows[0]["房屋用途"].ToString());
}
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
//跳转页面
Response.Redirect("ZhList.aspx");
}
protected void Button2_Click(object sender, EventArgs e)
{
//根据标志 添加或修改住户信息
if (Request.QueryString["ID"] != null)
{
DataControl.Execute("update 住户 set 户主='"+ TextBox1.Text +"',楼栋代码="+ DropDownList1.SelectedValue +"," +
"房间号='"+ TextBox3.Text +"',房屋面积='"+ Textbox2.Text +"',联系方式='"+ Textbox4.Text +"'," +
"房屋用途='" + DropDownList2.SelectedItem.Text + "' where 住户代码='" + Request.QueryString["ID"] + "'");
}
else
{
DataControl.Execute("insert into 住户(户主,楼栋代码,房间号,房屋面积,联系方式,房屋用途) values " +
" ('" + this.TextBox1.Text + "'," + this.DropDownList1.SelectedValue + ",'" + TextBox3.Text + "', " +
" '" + Textbox2.Text + "','" + Textbox4.Text + "','" + DropDownList2.SelectedItem.Text + "')");
}
Response.Redirect("ZhList.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -