Advertisement
coasterka

RegisterFormButtonClickEvent

Jan 14th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. // Register form
  2. private void btnRegisterRegister_Click(object sender, EventArgs e)
  3.         {
  4.             if (txtBoxNameRegister.Text != "" && txtBoxTelRegister.Text != "" &&
  5.                 txtBoxPasswordRegister.Text != "" && txtBoxPassCheckRegister.Text != "" &&
  6.                 txtBoxEmailRegister.Text != "" && txtBoxAddressRegister.Text != "")
  7.             {
  8.                 if ((txtBoxPasswordRegister.Text).Equals(txtBoxPassCheckRegister.Text))
  9.                 {
  10.                     SqlConnection sqlConn = new SqlConnection(@"Data Source=HRISI-PC;Initial Catalog=CourseWorkVP;Integrated Security=True");
  11.                     sqlConn.Open();
  12.                     SqlCommand sqlComm = new SqlCommand("INSERT INTO Clients(Name, Telephone, Address, Email, Password) VALUES('" + txtBoxNameRegister.Text + "', '" +
  13.                     txtBoxTelRegister.Text + "', '" + txtBoxAddressRegister.Text + "', '" + txtBoxEmailRegister.Text + "', '" + txtBoxPasswordRegister.Text + "');", sqlConn);
  14.                     object obj = sqlComm.ExecuteNonQuery();
  15.                     MessageBox.Show("The user \"" + txtBoxNameRegister.Text + "\" has been sucessfully registered!");
  16.                     sqlConn.Close();
  17.                 }
  18.                 else
  19.                 {
  20.                     MessageBox.Show("The password didn't match!");
  21.                 }
  22.             }
  23.             else
  24.             {
  25.                 MessageBox.Show("Please fill in all the fields!");
  26.             }
  27.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement