protected void Unnamed2_Click(object sender, EventArgs e) { string userNameStr=Tools.safeUserInput(TextBox1.Text.ToString().Trim()); string passWordStr = Tools.safeUserInput(TextBox2.Text.ToString().Trim()); if(userNameStr.Length<1){ MessageBox.Show(this,"用户名不能为空!"); return; } if(passWordStr.Length<1){ MessageBox.Show(this,"密码不能为空!"); return; } administratorBLL AdminBLL = new administratorBLL(); if (AdminBLL.Exists(userNameStr)) { MessageBox.Show(this, "用户名已存在!"); return; } administrator Admin = new administrator(); Admin.userName = userNameStr; Admin.passWord = Tools.encrypt(passWordStr); Admin.type = DropDownList1.SelectedItem.Value; try { AdminBLL.Add(Admin); } catch { MessageBox.Show(this, "添加失败!"); } MessageBox.Show(this, "添加成功!"); dataBind(); }