protected void btnEnter_Click(object sender, EventArgs e)
 {
     if (txtUserID.Text.ToString().ToLower().IndexOf("delete") != -1 || txtUserID.Text.ToString().ToLower().IndexOf(";") != -1 || txtUserID.Text.ToString().ToLower().IndexOf("select") != -1 || txtUserID.Text.ToString().ToLower().IndexOf("insert") != -1 || txtUserID.Text.ToString().ToLower().IndexOf("update") != -1 || txtUserPWD.Text.ToString().ToLower().IndexOf("select") != -1 || txtUserPWD.Text.ToString().ToLower().IndexOf(";") != -1 || txtUserPWD.Text.ToString().ToLower().IndexOf("delete") != -1 || txtUserPWD.Text.ToString().ToLower().IndexOf("insert") != -1 || txtUserPWD.Text.ToString().ToLower().IndexOf("update") != -1 || txtUserName.Text.ToString().ToLower().IndexOf("update") != -1 || txtUserName.Text.ToString().ToLower().IndexOf("insert") != -1 || txtUserName.Text.ToString().ToLower().IndexOf("select") != -1 || txtUserName.Text.ToString().ToLower().IndexOf("delete") != -1 || txtUserName.Text.ToString().ToLower().IndexOf(";") != -1)
     {
         lblMessage.Visible = true;
         lblMessage.Text    = "(含有关键词!请重新输入!)";
     }
     else
     {
         try//和数据库UserID不能为空且唯一对应,try catch  异常处理
         {
             if (txtUserID.Text != "" && txtUserPWD.Text != "" && txtUserName.Text != "")
             {
                 AddSQLStringToDAL.Insert("TabTeachers", ddlTeachersType.SelectedItem.ToString(), ddlDepartment.SelectedItem.ToString(), txtUserID.Text, txtUserName.Text, FormsAuthentication.HashPasswordForStoringInConfigFile(txtUserPWD.Text, "MD5").ToString(), ddlRole.SelectedItem.ToString());
                 Clear();
                 lblMessage.Visible = true;
                 lblMessage.Text    = "添加成功";
             }
             else
             {
                 lblMessage.Visible = true;
                 lblMessage.Text    = "教师工号、姓名或密码不能为空";
             }
         }
         catch
         {
             Clear();
             lblMessage.Visible = true;
             lblMessage.Text    = "输入有误!请核对教师工号等信息!教师工号不能重复!";
         }
     }
 }
示例#2
0
 protected void btnEnter_Click(object sender, EventArgs e)
 {
     try//和数据库UserID不能为空且唯一对应,try catch  异常处理
     {
         if (txtUserID.Text != "" && txtUserPWD.Text != "" && txtUserName.Text != "")
         {
             AddSQLStringToDAL.Insert("TabTeachers", ddlTeachersType.SelectedItem.ToString(), ddlDepartment.SelectedItem.ToString(), txtUserID.Text, txtUserName.Text, txtUserPWD.Text, ddlRole.SelectedItem.ToString());
             Clear();
             lblMessage.Visible = true;
             lblMessage.Text    = "添加成功";
         }
         else
         {
             lblMessage.Visible = true;
             lblMessage.Text    = "教师工号、姓名或密码不能为空";
         }
     }
     catch
     {
         Clear();
         lblMessage.Visible = true;
         lblMessage.Text    = "输入有误!请核对教师工号等信息!教师工号不能重复!";
     }
 }