private void BtnRegitrationRunner_Click(object sender, EventArgs e) { ActiveForm.Hide(); FormRegistrationMaraphone formRegistration = new FormRegistrationMaraphone(); formRegistration.ShowDialog(); Close(); }
private async void SignupButton_Click(object sender, EventArgs e) { MemoryStream ms = new MemoryStream(); pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat); byte[] a = ms.GetBuffer(); ms.Close(); try { Regex emailRegex = new Regex(@"\w{2,10}@\w{2,10}.\w{2,10}"); Match emailMatch = emailRegex.Match(txt_Email.Text); if (emailMatch.Value == "") { MessageBox.Show("Некорректный формат email", "Оповещение системы!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { bool digit = false; bool spec = false; bool lowChar = false; for (int i = 0; i < txt_Password.TextLength; i++) { if (char.IsDigit(txt_Password.Text[i])) { digit = true; break; } } for (int i = 0; i < txt_Password.TextLength; i++) { if (char.IsLower(txt_Password.Text[i])) { lowChar = true; break; } } for (int i = 0; i < txt_Password.TextLength; i++) { if (txt_Password.Text[i] == '#' || txt_Password.Text[i] == '!' || txt_Password.Text[i] == '@' || txt_Password.Text[i] == '$' || txt_Password.Text[i] == '%' || txt_Password.Text[i] == '^') { spec = true; break; } } if (txt_Password.TextLength < 6 || !spec || !digit || !lowChar) { MessageBox.Show("Некорректный формат пароля! Длина пароля должно быть не менее шести символов, из которых должна быть, как минимум, одна буква нижнего регистра, одна цифра и одна из следующих символов: !,#,%,^,@", "Оповещение системы!", MessageBoxButtons.OK, MessageBoxIcon.Information); } DateTime dateOfBirth = Convert.ToDateTime(txt_DateOfBirth.Value); if (DateTime.Now.Year - dateOfBirth.Year < 10) { MessageBox.Show("Возраст бегуна на момент регистрации должен быть не менее 10-ти лет!", "Оповещение системы!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { using (SqlConnection connection = new SqlConnection(Connection.GetSetring())) { await connection.OpenAsync(); string query = $"INSERT INTO [UserPersonalInformation] VALUES (@e,@p,@n,@s,@g,@pn,@picture,@d,@cn)"; SqlCommand command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@e", txt_Email.Text); command.Parameters.AddWithValue("@p", txt_Password.Text); command.Parameters.AddWithValue("@n", txt_Name.Text); command.Parameters.AddWithValue("@s", txt_Surname.Text); command.Parameters.AddWithValue("@g", cmb_Gender.Text); command.Parameters.AddWithValue("@pn", txt_NamePicture.Text); command.Parameters.AddWithValue("@picture", a); command.Parameters.AddWithValue("@d", txt_DateOfBirth.Value); command.Parameters.AddWithValue("@cn", cmb_Country.Text); await command.ExecuteNonQueryAsync(); ActiveForm.Hide(); FormRegistrationMaraphone formRegistrationMaraphone = new FormRegistrationMaraphone(); formRegistrationMaraphone.ShowDialog(); Close(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }