private void button1_Click(object sender, EventArgs e)
        {
            using (HREntity db = new HREntity())
            {
                CurriculumVitae isWorkerHasCv = db.Workers.Find(worker.Id).CurriculumVitae;
                if (isWorkerHasCv != null)
                {
                    bool isWorkerApplied = db.WorkerAdvertisemets.ToList().Exists(x => x.WorkerId == worker.Id && x.AdvertisementId == advertisement.Id);
                    if (isWorkerApplied)
                    {
                        MessageBox.Show($"You already applied to this advertisement", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    db.WorkerAdvertisemets.Add(new WorkerAdvertisement()
                    {
                        AdvertisementId = advertisement.Id, WorkerId = worker.Id
                    });

                    db.SaveChanges();
                    MessageBox.Show($"You succesfully applied", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    MessageBox.Show($"Firstly you must add cv", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Esempio n. 2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;
            int rowIndex   = 0;

            if (e.ColumnIndex >= 0 && senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0)
            {
                rowIndex = e.RowIndex;

                Advertisement clickedAd = advertisements[rowIndex];
                using (HREntity db = new HREntity())
                {
                    bool isWorkerApplied = db.WorkerAdvertisemets.ToList().Exists(x => x.WorkerId == worker.Id && x.AdvertisementId == clickedAd.Id);

                    if (isWorkerApplied)
                    {
                        MessageBox.Show($"You already applied to this advertisement", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    db.WorkerAdvertisemets.Add(new WorkerAdvertisement()
                    {
                        AdvertisementId = clickedAd.Id, WorkerId = worker.Id
                    });

                    ;                  db.SaveChanges();
                    MessageBox.Show($"You succesfully applied", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Esempio n. 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (ValidateInputs())
            {
                using (HREntity db = new HREntity())
                {
                    Advertisement advertisement = new Advertisement()
                    {
                        AdvertisementName = tbxAdName.Text.Trim(),
                        CompanyName       = tbxCompanyName.Text.Trim(),
                        Age         = Convert.ToInt32(tbxAge.Text.Trim()),
                        Catagory    = comboBoxCategory.Text,
                        City        = comboBoxCity.Text,
                        Description = richTextBoxAboutWork.Text.Trim(),
                        Education   = comboBoxEducation.Text,
                        Experience  = comboBoxExperience.Text,
                        PhoneNumber = maskedPhoneNumber.Text,
                        Salary      = Convert.ToDecimal(tbxSalary.Text)
                    };

                    var currentEmployer = db.Employers.FirstOrDefault(x => x.Id == employer.Id);
                    currentEmployer.Advertisements.Add(advertisement);
                    db.SaveChanges();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Cannot be empty");
            }
        }
Esempio n. 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (ValidateInputs())
            {
                using (HREntity db = new HREntity())
                {
                    CurriculumVitae cv = new CurriculumVitae()
                    {
                        Name        = tbxName.Text.Trim(),
                        Surname     = tbxSurname.Text.Trim(),
                        Gender      = comboBoxGender.Text,
                        Age         = Convert.ToInt32(tbxAge.Text.Trim()),
                        Education   = comboBoxEducation.Text,
                        Experience  = comboBoxExperience.Text,
                        Catagory    = comboBoxCategory.Text,
                        City        = comboBoxCity.Text,
                        MinSalary   = Convert.ToDecimal(tbxSalary.Text),
                        PhoneNumber = maskedPhoneNumber.Text,
                    };

                    db.Workers.Find(worker.Id).CurriculumVitae = cv;
                    db.SaveChanges();

                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Cannot be empty");
            }
        }
Esempio n. 5
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (ValidateInputs())
     {
         using (HREntity db = new HREntity())
         {
             var cv = db.CurriculumVitaes.FirstOrDefault(x => x.Id == worker.Id);
             cv.Name        = tbxName.Text;
             cv.Surname     = tbxSurname.Text;
             cv.Age         = Convert.ToInt32(tbxAge.Text);
             cv.MinSalary   = Convert.ToDecimal(tbxSalary.Text);
             cv.Catagory    = comboBoxCategory.Text;
             cv.City        = comboBoxCity.Text;
             cv.Education   = comboBoxEducation.Text;
             cv.Experience  = comboBoxExperience.Text;
             cv.Gender      = comboBoxGender.Text;
             cv.PhoneNumber = maskedPhoneNumber.Text;
             db.SaveChanges();
             this.Close();
         }
     }
     else
     {
         MessageBox.Show("Cannot be empty");
     }
 }
Esempio n. 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            List <string> inputs = new List <string>()
            {
                tbxUsername.Text.Trim(), tbxEmail.Text.Trim(), comboBoxStatus.Text, tbxPassword.Text.Trim(),
                          tbxRePassword.Text.Trim(), tbxRandomText.Text,
            };
            bool isEmpty = inputs.TrueForAll(x => x != "");
            bool isSpace = inputs.TrueForAll(x => x != " ");


            if (isEmpty && isSpace)
            {
                try
                {
                    MailAddress mailAddress = new MailAddress(tbxEmail.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Email is not correct format", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    GenerateRandomText();
                    return;
                }
                if (tbxPassword.Text == tbxRePassword.Text)
                {
                    string password = tbxPassword.Text;

                    if (password.Length <= 15)
                    {
                        var  regex           = new Regex(@"^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!*@#$%^&+=]).*$");
                        bool isCorrectFormat = regex.IsMatch(password);

                        if (!isCorrectFormat)
                        {
                            MessageBox.Show("Password is not in correct format, Must be: en azi bir boyuk herf olmalidir,bir reqem, bir simvol (_+-/. ve s.),maksimum uzunluq 15 simvol", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            GenerateRandomText();
                            return;
                        }
                    }

                    else
                    {
                        MessageBox.Show("Password lentgh must be less than 15", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        GenerateRandomText();
                        return;
                    }
                    if (tbxRandomText.Text == randomText)
                    {
                        using (HREntity db = new HREntity())
                        {
                            //var users = db.Users.ToList();
                            //bool isUsernameExists= users.Exists(x=>x.Username.ToLower()==tbxUsername.Text.ToLower());
                            if (comboBoxStatus.Text == "Worker")
                            {
                                var  workers          = db.Workers.ToList();
                                bool isUsernameExists = workers.Exists(x => x.Username.ToLower() == tbxUsername.Text.ToLower());
                                if (!isUsernameExists)
                                {
                                    //User user = new User()
                                    //{
                                    //    Username = tbxUsername.Text,
                                    //    Email = tbxEmail.Text,
                                    //    Status = comboBoxStatus.Text,
                                    //    Password = tbxPassword.Text

                                    //};
                                    Worker worker = new Worker()
                                    {
                                        Username = tbxUsername.Text,
                                        Email    = tbxEmail.Text,

                                        Password = tbxPassword.Text
                                    };
                                    db.Workers.Add(worker);
                                    db.SaveChanges();
                                }
                                else
                                {
                                    MessageBox.Show("This username already taken, please choose another", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                    GenerateRandomText();
                                    return;
                                }
                            }
                            else if (comboBoxStatus.Text == "Employer")
                            {
                                var  employers        = db.Employers.ToList();
                                bool isUsernameExists = employers.Exists(x => x.Username.ToLower() == tbxUsername.Text.ToLower());
                                if (!isUsernameExists)
                                {
                                    //User user = new User()
                                    //{
                                    //    Username = tbxUsername.Text,
                                    //    Email = tbxEmail.Text,
                                    //    Status = comboBoxStatus.Text,
                                    //    Password = tbxPassword.Text

                                    //};
                                    Employer employer = new Employer()
                                    {
                                        Username = tbxUsername.Text,
                                        Email    = tbxEmail.Text,
                                        Password = tbxPassword.Text
                                    };
                                    db.Employers.Add(employer);
                                    db.SaveChanges();
                                }
                                else
                                {
                                    MessageBox.Show("This username already taken, please choose another", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                    GenerateRandomText();
                                    return;
                                }
                            }
                        }
                        MessageBox.Show("Sign up successful", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Entered 4 digit char code not valid", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    MessageBox.Show("Passwords not same", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    GenerateRandomText();
                }
            }
            else
            {
                MessageBox.Show("Cannot be empty", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                GenerateRandomText();
            }

            randomText         = RandomString(4);
            lblRandomText.Text = randomText;
        }