private void registerButton_Click(object sender, EventArgs e)
        {
            string result = checkToAdd();

            if (result == "ОК")
            {
                try
                {
                    DateTime dateOfBirth = Convert.ToDateTime(birthDateTimePicker.Value);
                    connectionSql.Open();

                    command = new SqlCommand($"insert into [dbo].[User] (Email, Password, FirstName, LastName, RoleId, Picture) values('{emailTextBox.Text}', '{passwordTextBox.Text}','{nameTextBox.Text.ToUpper()}','{lastNameTextBox.Text.ToUpper()}','R', '{photoTextBox.Text.ToUpper()}')", connectionSql);
                    command.ExecuteNonQuery();
                    connectionSql.Close();



                    connectionSql.Open();
                    command = new SqlCommand($"insert into [dbo].[Runner] (Email, Gender, DateOfBirth, CountryCode) values('{emailTextBox.Text}','{genderComboBox.Text}', '{birthDateTimePicker.Value}',(select [CountryCode] from [Country] where CountryName = '{countryComboBox.Text}'))", connectionSql);

                    command.ExecuteNonQuery();

                    Login.email = emailTextBox.Text;
                    RunnerRegistratsia.ActiveForm.Hide();
                    RunnerMaraphonRegister form = new RunnerMaraphonRegister();
                    form.Show();
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
                finally
                {
                    connectionSql.Close();
                }
            }
            else
            {
                MessageBox.Show(result);
            }
        }
Exemple #2
0
 private void button3_Click(object sender, EventArgs e)
 {
     RunnerMenu.ActiveForm.Hide();
     Runer.RunnerMaraphonRegister rmr = new RunnerMaraphonRegister();
     rmr.Show();
 }