📄 ryedit.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_RyEdit : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
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.Textbox4.Text = dt.Rows[0]["名称"].ToString();
this.TextBox3.Text = dt.Rows[0]["职位"].ToString();
this.Textbox2.Text = dt.Rows[0]["介绍"].ToString();
}
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
//跳转页面
Response.Redirect("RyList.aspx");
}
protected void Button2_Click(object sender, EventArgs e)
{
//添加或修改人员信息
if (Request.QueryString["ID"] != null)
{
DataControl.Execute("update 人员 set 名称='"+ Textbox4.Text +"',职位='"+ TextBox3.Text +"',介绍='"+ Textbox2.Text +"' where 帐号='"+ Request.QueryString["ID"] +"'");
}
else
{
if (DataControl.GetData("select * from 人员 where 帐号='" + this.TextBox1.Text + "'").Rows.Count > 0)
{
Response.Write("<script>alert('帐号重复');</script>");
return;
}
DataControl.Execute("insert into 人员(帐号,密码,名称,职位,介绍) values " +
" ('" + this.TextBox1.Text + "','000000','"+ Textbox4.Text +"','"+ TextBox3.Text +"','"+ Textbox2.Text +"')");
}
Response.Redirect("RyList.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -