// 点击此按钮进入查询页面 private void search_Click(object sender, EventArgs e) { searchForms c1 = new searchForms(); this.Hide(); c1.ShowDialog(); this.Show(); }
private void login_Click(object sender, EventArgs e) { //用户名不能超过12的字符 if (textBox1.Text.Length >= 12) { MessageBox.Show("用户名不能过长", "错误提示"); return; } if (textBox2.Text.Length < 6 || textBox2.Text.Length > 16) { MessageBox.Show("密码长度必须为6-16位", "错误提示"); return; } if (sqlSearchUser(textBox1.Text) == 0) { MessageBox.Show("未正确连接数据库,请检查网络连接后再次尝试", "错误提示"); return; } else if (sqlSearchUser(textBox1.Text) == 2) { MessageBox.Show("未找到此用户", "错误提示"); return; } //如果是管理员,则设定等级为1 if (MD5Helper.EncryptString(textBox2.Text) == password && Config.level == 1) { Config.id = textBox1.Text; MessageBox.Show("管理员登录", "登录提示"); chooselist c1 = new chooselist(); //Hide函数用于隐藏窗体,但不会真正退出 this.Hide(); c1.ShowDialog(); this.Close(); } else if (MD5Helper.EncryptString(textBox2.Text) == password && Config.level == 0) { Config.id = textBox1.Text; MessageBox.Show("欢迎访问", "登录提示"); searchForms c1 = new searchForms(); //Hide函数用于隐藏窗体,但不会真正退出 this.Hide(); c1.ShowDialog(); this.Close(); } else { MessageBox.Show("用户名或密码错误", "登录提示"); //this.Close(); } }