private void button1_Click(object sender, EventArgs e) { Sqlhelp.Close(); string sql = "select admin from persen where admin='" + textBox1.Text + "'"; SqlDataReader sqlData = Sqlhelp.ExecuteSql(sql); if (!sqlData.HasRows) { if (textBox2.Text == textBox3.Text) { Sqlhelp.Close(); sql = "insert into persen values('" + textBox1.Text + "','" + textBox2.Text + "')"; sqlData = Sqlhelp.ExecuteSql(sql); MessageBox.Show("注册成功!"); Sqlhelp.Close(); Close(); } else { MessageBox.Show("两次密码不一致!"); Sqlhelp.Close(); } } else { MessageBox.Show("用户已存在!"); Sqlhelp.Close(); } }
private void button1_Click(object sender, EventArgs e) { string sql = "select admin,password from persen where admin='" + username_text.Text + "'"; SqlDataReader sqlData = Sqlhelp.ExecuteSql(sql); if (sqlData.HasRows) { Sqlhelp.Close(); sql = "select password from persen where password = '******'"; sqlData = Sqlhelp.ExecuteSql(sql); if (sqlData.HasRows) { MessageBox.Show("登陆成功!"); Form11.Di.user = "******"; Close(); Sqlhelp.Close(); } else { MessageBox.Show("密码错误!"); } } else { MessageBox.Show("账号或密码错误!"); Sqlhelp.Close(); } }