private void btnRegister_Click(object sender, EventArgs e)
{
if (txtUserName.Text != "" && txtPassword.Text != "" && txtConfirmPassword.Text != "")
{
if (txtPassword.Text.ToString().Trim().ToLower() == txtConfirmPassword.Text.ToString().Trim().ToLower())
{
String connstring = ConfigurationManager.ConnectionStrings["Data"].ConnectionString;
string cmdstring = "Insert Into userID (UserName, Password) Values (@User, @Password)";
using (OleDbConnection con = new OleDbConnection(connstring))
{
using (OleDbCommand cmd = new OleDbCommand(cmdstring, con))
{
string UserName = txtUserName.Text;
string Password = Cryptography.Encrypt(txtPassword.Text.ToString());
con.Open();
cmd.Parameters.AddWithValue("@User", txtUserName.Text);
cmd.Parameters.AddWithValue("@Password", Cryptography.Encrypt(txtPassword.Text.ToString()));
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Record inserted successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
else
{
MessageBox.Show("Password and Confirm Password doesn't match", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
MessageBox.Show("Please fill all the fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}