Beispiel #1
0
        private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            string email = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();

            if (email != "")
            {
                int id_Applicant = workWithDataOfApplicants.findId(email);
                this.id_Applicant = id_Applicant;
            }
            else
            {
                MessageBox.Show("Соискатель не выбран!");
            }
        }
        private void LoginButton_Click(object sender, EventArgs e)
        {
            string loginUser = loginField.Text;
            string passUser  = passField.Text;

            if ((loginUser == "Введите email") || (passUser == "Введите пароль"))
            {
                MessageBox.Show("Вы ввели не все данные!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                WorkWithDataOfApplicants workWithDataOfApplicants = new WorkWithDataOfApplicants();
                WorkWithJobData          workWithJobData          = new WorkWithJobData();
                bool result;
                if (role.Equals("admin"))
                {
                    result = workWithJobData.employerLogin(loginUser, passUser);
                    int id_key = workWithJobData.findIdKey(textAccessKey.Text);
                    if ((result == true) && (textAccessKey.Text == "JY4TJ-68L9H-8ZQE1"))
                    {
                        this.Hide();
                        FormAdminActions formAdminActions = new FormAdminActions();
                        formAdminActions.Show();
                    }
                    else
                    {
                        MessageBox.Show("Вход не выполнен!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else if (role.Equals("aspirant"))
                {
                    result = workWithDataOfApplicants.userLogin(loginUser, passUser);
                    if (result == true)
                    {
                        int id_appl = workWithDataOfApplicants.findId(loginUser);
                        this.Hide();
                        ApplicantAccountForm applicantAccountForm = new ApplicantAccountForm(id_appl);
                        applicantAccountForm.Show();
                    }
                    else
                    {
                        MessageBox.Show("Неизвестный пользователь!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else if (role.Equals("employer"))
                {
                    result = workWithJobData.employerLogin(loginUser, passUser);
                    if (result == true)
                    {
                        int Id_Employer = workWithJobData.findIdEmployer(loginUser);
                        this.Hide();
                        FormPublishingVacancies formPublishingVacancies = new FormPublishingVacancies(Id_Employer);
                        formPublishingVacancies.Show();
                    }
                    else
                    {
                        MessageBox.Show("Неизвестный пользователь!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
        private void RegisterButton_Click(object sender, EventArgs e)
        {
            string surname = textBox1.Text;            // фамилия
            string name = textBox2.Text;               // имя
            string middlename = textBox3.Text;         // отчество
            string dateOfBirth = dateTimePicker1.Text; // дата рождения
            string phone = textBox4.Text;              // номер телефона
            string address = textBox5.Text;            // адрес
            int    gender = 0, nation = 0;             // пол и гражданство

            if (radioButton1.Checked)
            {
                gender = 1;
            }
            else if (radioButton2.Checked)
            {
                gender = 2;
            }

            if (comboBox1.Text.Equals("Русское"))
            {
                nation = 1;
            }
            else if (comboBox1.Text.Equals("Иностранное"))
            {
                nation = 2;
            }
            string email      = textBox6.Text; // электронная почта
            string pass       = textBox7.Text; // пароль
            string doublepass = textBox8.Text; // повтор пароля

            if ((surname == "") || (name == "") || (middlename == "") || (dateOfBirth == "") || (phone == "") || (address == "") || (gender == 0) || (nation == 0) || (email == "") || (pass == "") || (doublepass == ""))
            {
                MessageBox.Show("Вы ввели не все данные!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (pass != doublepass)
            {
                MessageBox.Show("Вы не правильно повторили пароль!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (workWithDataOfApplicants.isUserExists(email))
            {
                MessageBox.Show("Такой email уже есть, введите другой", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                workWithDataOfApplicants.addApplicants(surname, name, middlename, dateOfBirth, phone, email, address, gender, nation);
                int  id_appl = workWithDataOfApplicants.findId(email);
                bool result  = workWithDataOfApplicants.userRegistration(email, pass, id_appl);
                if (result == true)
                {
                    MessageBox.Show("Аккаунт для пользователя " + name + " " + surname + " создан!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Hide();
                    LoginForm loginForm = new LoginForm("aspirant");
                    loginForm.Show();
                }
                else
                {
                    MessageBox.Show("Аккаунт не создан!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }