private void button2_Click(object sender, EventArgs e) { this.Hide(); var LoginAndRegister = new LoginAndRegister(); LoginAndRegister.Closed += (s, args) => this.Close(); LoginAndRegister.Show(); }
private void btnLoginSubmit_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(connectionstring); try { con.Open(); DataTable dt = new DataTable(); SqlCommand cmd = new SqlCommand("SP_REG", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@actiontype", "REGISTER"); cmd.Parameters.AddWithValue("@username", textBoxUsername.Text.Trim().ToString()); cmd.Parameters.AddWithValue("@password", textBoxPassword.Text.Trim().ToString()); cmd.Parameters.AddWithValue("@email", textBoxEmail.Text.Trim().ToString()); if (textBoxPassword.Text == "" || textBoxConfPassword.Text == "") { MessageBox.Show("Enter correct Password !!!", "Password Error"); textBoxPassword.Focus(); return; } else if (textBoxPassword.Text != textBoxConfPassword.Text) { MessageBox.Show("Enter correct Password !!!", "Password Error"); textBoxConfPassword.Focus(); return; } int numrec = cmd.ExecuteNonQuery(); if (numrec > 0) { MessageBox.Show("Success !!!"); } else { MessageBox.Show("Failure !!!"); } con.Close(); clear(); LoginAndRegister log = new LoginAndRegister(); log.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }