예제 #1
0
        private void button_Login_Click(object sender, EventArgs e)
        {
            string user_login    = LoginField.Text;
            string user_password = PasswordField.Text;

            DB dB = new DB();

            DataTable datatable = new DataTable();

            MySqlDataAdapter adapter = new MySqlDataAdapter();

            MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE `Login` = @u_l AND `password` = @u_p", dB.getConnection());

            command.Parameters.Add("@u_l", MySqlDbType.VarChar).Value = user_login;
            command.Parameters.Add("@u_p", MySqlDbType.VarChar).Value = user_password;

            adapter.SelectCommand = command;
            adapter.Fill(datatable);

            if (datatable.Rows.Count > 0)
            {
                HeadForm headForm = new HeadForm(user_login);
                headForm.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("Неправильный логин или пароль!");
            }
        }
예제 #2
0
        private void mainMenu_Click(object sender, EventArgs e)
        {
            HeadForm headForm = new HeadForm(user_login);

            headForm.Show();
            Close();
        }
예제 #3
0
        private void button_Login_Click(object sender, EventArgs e)
        {
            if (firstnameTB.Text == "" || firstnameTB.Text == "Имя")
            {
                return;
            }
            if (lastnameTB.Text == "" || lastnameTB.Text == "Фамилия")
            {
                return;
            }
            if (emailTB.Text == "" || emailTB.Text == "email")
            {
                return;
            }
            if (phoneTB.Text == "" || phoneTB.Text == "Телефон")
            {
                return;
            }
            if (LoginTB.Text == "" || LoginTB.Text == "Логин")
            {
                return;
            }
            if (PasswordTB.Text == "" || PasswordTB.Text == "Пароль")
            {
                return;
            }
            if (checkUser())
            {
                return;
            }

            DB db = new DB();

            MySqlCommand command = new MySqlCommand("INSERT INTO `users` (`Login`, `First_name`, `Last_name`, `User_group`, `password`, `email`, `phone`, `Voices_player_id`, `Voices_coach_id`) VALUES (@login, @first_name, @last_name, 'user', @password, @email, @phone, NULL, NULL);", db.getConnection());

            command.Parameters.Add("@login", MySqlDbType.VarChar).Value      = LoginTB.Text;
            command.Parameters.Add("@first_name", MySqlDbType.VarChar).Value = firstnameTB.Text;
            command.Parameters.Add("@last_name", MySqlDbType.VarChar).Value  = lastnameTB.Text;
            command.Parameters.Add("@password", MySqlDbType.VarChar).Value   = PasswordTB.Text;
            command.Parameters.Add("@email", MySqlDbType.VarChar).Value      = emailTB.Text;
            command.Parameters.Add("@phone", MySqlDbType.VarChar).Value      = phoneTB.Text;
            db.openConnection();
            if (command.ExecuteNonQuery() == 1)
            {
                this.Hide();
                HeadForm headForm = new HeadForm(LoginTB.Text);
                headForm.Show();
            }
            else
            {
                MessageBox.Show("Error");
            }

            db.closeConnection();
        }