Пример #1
0
        private void Back_Click(object sender, EventArgs e)
        {
            MenuRunner menuRunner = new MenuRunner();

            menuRunner.Show();
            this.Close();
        }
Пример #2
0
        private void button_Cancel_Click(object sender, EventArgs e)
        {
            MenuRunner menuRunner = new MenuRunner();

            menuRunner.Show();
            this.Close();
        }
Пример #3
0
        private void Login_Click(object sender, EventArgs e)
        {
            try
            {
                Connection.connection.Open();

                string     sqlExp = "select [Email], [Password], [RoleId] from [dbo].[User] where [Email]=@login";
                SqlCommand cmd    = new SqlCommand(sqlExp, Connection.connection);
                cmd.Parameters.AddWithValue("@login", textBox_email.Text);
                SqlDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();

                    if ((string)reader[1] == textBox_password.Text)
                    {
                        Connection.userLogin = textBox_email.Text;

                        switch ((string)reader[2])
                        {
                        case "R":
                            MenuRunner mr = new MenuRunner();
                            mr.Show();
                            this.Close();
                            break;

                        case "C":
                            MenuCoordinator mc = new MenuCoordinator();
                            mc.Show();
                            this.Close();
                            break;

                        case "A":
                            MenuAdmin ma = new MenuAdmin();
                            ma.Show();
                            this.Close();
                            break;

                        default:
                            MessageBox.Show("Нет такой роли");
                            break;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Неверный пароль");
                    }
                }
                else
                {
                    MessageBox.Show("Неверный логин");
                }
                reader.Close();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
            Connection.connection.Close();
        }
Пример #4
0
        private void button_Reg_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBox1.Text == "")
                {
                    MessageBox.Show("Вы не выбрали организацию для пожертвования");
                    if (textBox_sumVznosa.Text == "")
                    {
                        MessageBox.Show("Вы не ввели сумму пожертвования");
                    }
                }
                if (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked == false)
                {
                    MessageBox.Show("Выбирите хотя бы 1 вид марафона");
                }
                if (radioButton1.Checked == false && radioButton2.Checked == false && radioButton3.Checked == false)
                {
                    MessageBox.Show("Выбирите комплект");
                }
                else
                {
                    Connection.connection.Open();
                    {
                        string     SqlExpRunnerId = "select [RunnerId] from [Runner] where [Email]=@email";
                        SqlCommand cmdRunnerId    = new SqlCommand(SqlExpRunnerId, Connection.connection);
                        cmdRunnerId.Parameters.AddWithValue("@email", Connection.userLogin);
                        int runnerid = (int)cmdRunnerId.ExecuteScalar();

                        string     SqlExpCharity = "select [CharityId] from [dbo].[Charity] where [CharityName]=@charityname";
                        SqlCommand cmdCharity    = new SqlCommand(SqlExpCharity, Connection.connection);
                        cmdCharity.Parameters.AddWithValue("@charityname", comboBox1.Text);
                        int charityid = (int)cmdCharity.ExecuteScalar();

                        string SqlExp = "insert into [dbo].[Registration] ([RunnerId], [RegistrationDateTime], [RaceKitOptionId], [RegistrationStatusId], [Cost], [CharityId], [SponsorshipTarget]) " +
                                        "VALUES (@runnerid, getdate(), @rkoid, '1', @cost, @charityid, @sponsorship)";
                        SqlCommand cmd = new SqlCommand(SqlExp, Connection.connection);

                        char rkoid = '0';
                        if (radioButton1.Checked)
                        {
                            rkoid = RaceKitOptionId[0].ToCharArray()[0];
                        }
                        if (radioButton2.Checked)
                        {
                            rkoid = RaceKitOptionId[1].ToCharArray()[0];
                        }
                        if (radioButton3.Checked)
                        {
                            rkoid = RaceKitOptionId[2].ToCharArray()[0];
                        }

                        decimal sum = 0;
                        if (checkBox1.Checked)
                        {
                            sum = EventType[0].ToString()[0];
                        }
                        if (checkBox2.Checked)
                        {
                            sum = EventType[1].ToString()[0];
                        }
                        if (checkBox3.Checked)
                        {
                            sum = EventType[2].ToString()[0];
                        }

                        cmd.Parameters.AddWithValue("@runnerid", runnerid);
                        cmd.Parameters.AddWithValue("@rkoid", rkoid);
                        cmd.Parameters.AddWithValue("@cost", sum);
                        cmd.Parameters.AddWithValue("@charityid", charityid);
                        cmd.Parameters.AddWithValue("@sponsorship", textBox_sumVznosa.Text);

                        int i = cmd.ExecuteNonQuery();
                        if (i == 1)
                        {
                            MessageBox.Show("Данные были внесены");
                            Connection.connection.Close();
                            MenuRunner MR = new MenuRunner();
                            MR.Show();
                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Connection.connection.Close();
        }
Пример #5
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            try
            {
                Connection.connection.Open();

                if (textBox_LastName.Text != "" && textBox_Name.Text != "" && comboBox_Gender.Text != "" && comboBox_Country.Text != "")
                {
                    /*Возможно работает некорректно*/
                    if (DateTime.Now.Year - dateTimePicker_DateOfBirthday.Value.Year >= 10)
                    {
                        string     sqlExpUser = "******";
                        SqlCommand cmdUser    = new SqlCommand(sqlExpUser, Connection.connection);

                        cmdUser.Parameters.AddWithValue("@email", Connection.userLogin);
                        cmdUser.Parameters.AddWithValue("@firstname", textBox_Name.Text);
                        cmdUser.Parameters.AddWithValue("@lastname", textBox_LastName.Text);

                        string     SqlExpCountryCode = @"select [CountryCode] from [Country] where [CountryName]=@countryname";
                        SqlCommand cmdCountryCode    = new SqlCommand(SqlExpCountryCode, Connection.connection);
                        cmdCountryCode.Parameters.AddWithValue("@countryname", comboBox_Country.Text);
                        string CountryCode = (string)cmdCountryCode.ExecuteScalar();

                        string     sqlExpRunner = "update [Runner] set [Gender]=@gender, [DateOfBirth]=@DateOfBirth, [CountryCode]=@countrycode where [Email]=@email";
                        SqlCommand cmdRunner    = new SqlCommand(sqlExpRunner, Connection.connection);

                        cmdRunner.Parameters.AddWithValue("@email", Connection.userLogin);
                        cmdRunner.Parameters.AddWithValue("@gender", comboBox_Gender.Text);
                        cmdRunner.Parameters.AddWithValue("@DateOfBirth", dateTimePicker_DateOfBirthday.Value);
                        cmdRunner.Parameters.AddWithValue("@countrycode", CountryCode);

                        if (textBox_Password.Text == "")
                        {
                            int i = cmdUser.ExecuteNonQuery();
                            if (i == 1)
                            {
                                int j = cmdRunner.ExecuteNonQuery();
                                if (j == 1)
                                {
                                    MessageBox.Show("Данные были изменены");
                                    Connection.connection.Close();
                                    MenuRunner MR = new MenuRunner();
                                    MR.Show();
                                    this.Close();
                                }
                            }
                        }
                        else if (textBox_Password.Text.Length >= 6 && textBox_Password.Text.Any(char.IsUpper) && textBox_Password.Text.Any(char.IsDigit) && textBox_Password.Text.IndexOfAny(new char[] { '!', '@', '#', '$', '%', '^' }) > 0)
                        {
                            if (textBox_Password.Text == textBox_RepeatPassword.Text)
                            {
                                string     sqlExpUserPassword = "******";
                                SqlCommand cmdUserPassword    = new SqlCommand(sqlExpUserPassword, Connection.connection);

                                cmdUserPassword.Parameters.AddWithValue("@email", Connection.userLogin);
                                cmdUserPassword.Parameters.AddWithValue("@password", textBox_Password.Text);

                                int i = cmdUser.ExecuteNonQuery();
                                if (i == 1)
                                {
                                    int k = cmdUserPassword.ExecuteNonQuery();
                                    if (k == 1)
                                    {
                                        int j = cmdRunner.ExecuteNonQuery();
                                        if (j == 1)
                                        {
                                            MessageBox.Show("Данные были изменены");
                                            Connection.connection.Close();
                                            MenuRunner MR = new MenuRunner();
                                            MR.Show();
                                            this.Close();
                                        }
                                    }
                                }
                            }
                            else
                            {
                                MessageBox.Show("Пароли не совпадают");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Пароль должен соответвтвовать следующим параметрам: \n" +
                                            "• Минимум 6 символов \n" +
                                            "• Минимум 1 прописная буква \n" +
                                            "• Минимум 1 цифра \n" +
                                            "• По крайней мере один из следующих символов: ! @ # $ % ^ \n");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Для того, чтобы зарегистрироваться, ваш возраст должен быть выше 10 лет");
                    }
                }
                else
                {
                    MessageBox.Show("Не все поля заполнены");
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
            Connection.connection.Close();
        }