Exemple #1
0
        private void btn_rigistration_marathon_Click(object sender, EventArgs e)
        {
            var form = new Register_for_an_event(email);

            Hide();
            form.Show();
        }
        private void btn_registration_Click(object sender, EventArgs e)
        {
            var path_img = "";

            if (tb_path_img.Text == "")
            {
                path_img = Application.StartupPath.Replace("\\bin\\Debug", "") + "\\Resources\\unnamed.jpg";
            }
            else
            {
                path_img = openFileDialog1.FileName;
            }

            if (tb_name.Text != "" && tb_last.Text != "" && Password() && Date() && tb_email.Text != "")
            {
                string SQL1     = $"set language english insert Runner (Email,Gender,DateOfBirth,CountryCode)  values(N'{tb_email.Text}',N'{cb_sex.SelectedItem}',CAST(N'{tb_date.Value.ToString("yyyy-MM-dd HH:mm:ss") + ".000"}' AS DateTime),N'{tb_country.SelectedValue}')";
                string SQL      = $"insert [User] values(N'{tb_email.Text}',N'{tb_password.Text}',N'{tb_name.Text}',N'{tb_last.Text}',N'R',@img)";
                var    img_byte = File.ReadAllBytes(path_img);
                var    conect   = new SqlConnection(Properties.Resources.connection);
                try
                {
                    conect.Open();
                    var command = new SqlCommand(SQL, conect);
                    command.Parameters.Add(new SqlParameter("@img", img_byte));
                    command.ExecuteNonQuery();
                    command = new SqlCommand(SQL1, conect);
                    command.ExecuteNonQuery();
                    Hide();
                    var form = new Register_for_an_event(tb_email.Text);
                    form.Show();
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
                finally
                {
                    conect.Close();
                }
                path_img = "";
            }
        }