📄 editareafac.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 admin_editareafac : System.Web.UI.Page
{
BaseClass bc = new BaseClass();
protected void Page_Load(object sender, EventArgs e)
{
if (Convert.ToString(Session["UID"]) == "")
{
Response.Redirect("login.aspx");
}
if (!IsPostBack)
{
string str2 = "select * from type where type = 'Area'";
bc.ExecDropDownList(ddl, str2, "Name", "code");//绑定设备类型到下拉列表框
this.bind();
}
}
protected void bind()
{ string ID=Request.QueryString["ID"].ToString();
string str="select * from areaFacility where ID='"+ID+"'";
SqlDataReader sda=bc.ExecRead(str);
if(sda.Read())
{ //绑定数据
TextBox1.Text=sda["unitName"].ToString();
TextBox2.Text=sda["mainHead"].ToString();
TextBox4.Text = sda["contactPerson"].ToString();
TextBox5.Text=sda["tel"].ToString();
FreeTextBox1.Text =sda["memo"].ToString();
string typeID = sda["typeID"].ToString();
sda.Close();
ddl.Text = typeID;//默认选择
}
}
protected void Button1_Click(object sender, EventArgs e)
{
BaseClass bcc = new BaseClass();
string ID=Request.QueryString["ID"].ToString();
try
{
string sqlstr = "update areaFacility set unitName='" + TextBox1.Text + "',mainHead='" + TextBox2.Text + "',contactPerson='" + TextBox4.Text + "',typeID='" + ddl.SelectedValue.ToString() + "',tel='" + TextBox5.Text + "',memo='" + FreeTextBox1.Text + "' where ID='" + ID + "'";
//Response.Write(sqlstr);
//Response.End();
if(bcc.ExecSql(sqlstr))
{
Response.Write("<script language=javascript>alert('修改公共设施成功!');location='areafacility.aspx'</script>");
}
else
{
Response.Write("<script>alert(修改失败,请重试!');</script>");
}
}
catch(Exception ex)
{
Response.Write("<script language=javascript>alert('系统出错,出错原因"+ex.Message+"');location='areafacility.aspx'</script>");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -