private void button2_Click(object sender, EventArgs e) { 注册 form2 = new 注册(); form2.Show(); this.Hide(); }
private void button1_Click(object sender, EventArgs e) { String userid, password; userid = textBox1.Text; password = textBox2.Text; String ConnstrWindows = @"Data Source=LAPTOP-6HF7DH62;Initial Catalog=Demo;Integrated Security=True"; SqlConnection SqlCon = new SqlConnection(ConnstrWindows); SqlCon.Open(); //打开数据库 String Sql = "select userid,password from [user] where userid='" + userid + "' and password='******'"; SqlCommand sqlCommand = new SqlCommand(Sql, SqlCon); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); if (sqlDataReader.HasRows) { Form3 form3 = new Form3(); form3.Show(); this.Hide(); } else { DialogResult dr = MessageBox.Show("是否注册新用户?", "登录失败", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { 注册 form2 = new 注册(); form2.Show(); this.Hide(); } else { this.Show(); } } }