|
1金钱
public partial class gly : System.Web.UI.Page
{
Datashuoshuo dss = new Datashuoshuo();
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
disp();
}
}
protected void btnadd_Click(object sender, EventArgs e)
{
if (txbuser.Text == "")
{
Response.Write("<script>alert('管理员用户名不能为空!')</script>");
return;
}
if (txbpwd.Text == "")
{
Response.Write("<script>alert('密码不能为空!')</script>");
return;
}
dss.operate("insert into users values('" + txbuser.Text.Trim() + "','" + txbpwd.Text.Trim() + "')");
Response.Write("<script>alert('添加成功!')</script>");
disp();
}
void disp()
{
DataTable dta_mana = dss.disptable("select * from users", "uu");
grvmana.DataSource = dta_mana;
grvmana.DataBind();
}
protected void btnupdate_Click(object sender, EventArgs e)
{
dss.operate("update users set u_pwd='" + txbpwd.Text + "'where u_name='" + txbuser.Text + "' ");
Response.Write("<script>alert('修改成功!')</script>");
disp();
}
protected void btndel_Click(object sender, EventArgs e)
{
dss.operate("delete from users where u_name='" + txbuser.Text + "'");
Response.Write("<script>alert('删除成功!')</script>");
}
protected void grvmana_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void txbuser_TextChanged(object sender, EventArgs e)
{
DataTable dta = dss.disptable("select * from users where u_name='" + txbuser.Text + "'","users");
if (txbuser.Text == dta.Rows[0].ItemArray[1].ToString())
{
Response.Write("<script>alert('该用户已经存在,请重新输入!')</script>");
}
}
}
|
|