Esempio n. 1
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. 2
0
 private void SuggestionsForm_Load(object sender, EventArgs e)
 {
     using (HREntity db = new HREntity())
     {
         var advertisements = db.Advertisements.ToList();
         var cv             = db.CurriculumVitaes.FirstOrDefault(x => x.Id == worker.Id);
         var result         = (
             from a in advertisements
             where
             a.Catagory == cv.Catagory ||
             a.City == cv.City ||
             a.Education == cv.Education ||
             a.Experience == cv.Experience
             select a
             ).ToList();
         //, City = cv.City, Education = cv.Education, Experience = cv.Education
         if (result.Count != 0)
         {
             var adColumns = (from a in result
                              select new { a.AdvertisementName, a.CompanyName, a.Catagory, a.Education, a.Experience, a.Salary }).ToList();
             dataGridView1.DataSource = adColumns;
         }
         else
         {
             MessageBox.Show("Advertisement not found");
         }
     }
 }
Esempio n. 3
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");
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            List <string> comboBoxes = new List <string>()
            {
                comboBoxBase.Text, comboBoxItem.Text
            };
            bool isEmpty = comboBoxes.TrueForAll(x => x != "");

            if (isEmpty)
            {
                dataGridView1.DataSource = null;
                dataGridView1.Rows.Clear();
                dataGridView1.Columns.Clear();

                using (HREntity db = new HREntity())
                {
                    advertisements = (from a in db.Advertisements
                                      where a.Catagory == comboBoxItem.Text || a.City == comboBoxItem.Text ||
                                      a.Education == comboBoxItem.Text || a.Experience == comboBoxItem.Text || a.Salary.ToString() == comboBoxItem.Text
                                      select a).ToList();
                    var adColumns = (from a in advertisements
                                     select new { a.AdvertisementName, a.CompanyName, a.Catagory, a.Education, a.Experience, a.Salary }).ToList();
                    dataGridView1.DataSource = adColumns;
                }
                dataGridView1.Columns.Add(dgvBtn);
            }
            else
            {
                MessageBox.Show("Cannot be empty");
            }
        }
Esempio n. 5
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);
                }
            }
        }
        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);
                }
            }
        }
        private void EmployerAppliesForm_Load(object sender, EventArgs e)
        {
            using (db = new HREntity())
            {
                //Get cvs of workers who applied to this employer's ads
                workerCvs = (from wa in db.WorkerAdvertisemets
                             join a in db.Advertisements
                             on
                             wa.AdvertisementId equals a.Id
                             where a.EmployerId == employer.Id
                             join cv in db.CurriculumVitaes
                             on wa.WorkerId equals cv.Id
                             select cv).ToList();

                var data = (from wa in db.WorkerAdvertisemets
                            join a in db.Advertisements
                            on
                            wa.AdvertisementId equals a.Id
                            where a.EmployerId == employer.Id
                            join wcv in db.CurriculumVitaes
                            on wa.WorkerId equals wcv.Id
                            select new { a.AdvertisementName, wcv.Name }).ToList();

                dataGridView1.DataSource = data;
            }
        }
Esempio n. 8
0
        private void AddCVForm_Load(object sender, EventArgs e)
        {
            comboBoxCategory.DropDownStyle   = ComboBoxStyle.DropDownList;
            comboBoxCity.DropDownStyle       = ComboBoxStyle.DropDownList;
            comboBoxEducation.DropDownStyle  = ComboBoxStyle.DropDownList;
            comboBoxExperience.DropDownStyle = ComboBoxStyle.DropDownList;
            comboBoxGender.DropDownStyle     = ComboBoxStyle.DropDownList;

            using (HREntity db = new HREntity())
            {
                var curriculumVitaes = db.CurriculumVitaes.ToList();

                CurriculumVitae cv = curriculumVitaes.FirstOrDefault(x => x.Id == worker.Id);
                if (cv != null)
                {
                    btnAdd.Enabled          = false;
                    btnUpdate.Enabled       = true;
                    tbxName.Text            = cv.Name;
                    tbxSurname.Text         = cv.Surname;
                    tbxAge.Text             = cv.Age.ToString();
                    tbxSalary.Text          = cv.MinSalary.ToString();
                    comboBoxCategory.Text   = cv.Catagory;
                    comboBoxCity.Text       = cv.City;
                    comboBoxEducation.Text  = cv.Education;
                    comboBoxExperience.Text = cv.Experience;
                    comboBoxGender.Text     = cv.Gender;
                    maskedPhoneNumber.Text  = cv.PhoneNumber;
                }
                else
                {
                    btnAdd.Enabled    = true;
                    btnUpdate.Enabled = false;
                }
            }
        }
Esempio n. 9
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");
            }
        }
 private void ShowCvInfoForm_Load(object sender, EventArgs e)
 {
     using (HREntity db = new HREntity())
     {
         var cv = db.CurriculumVitaes.FirstOrDefault(x => x.Id == worker.Id);
         if (cv != null)
         {
             tbxName.Text               = cv.Name;
             tbxName.Enabled            = false;
             tbxSurname.Text            = cv.Surname;
             tbxSurname.Enabled         = false;
             comboBoxGender.Text        = cv.Gender;
             comboBoxGender.Enabled     = false;
             tbxAge.Text                = cv.Age.ToString();
             tbxAge.Enabled             = false;
             comboBoxEducation.Text     = cv.Education;
             comboBoxEducation.Enabled  = false;
             comboBoxExperience.Text    = cv.Experience;
             comboBoxExperience.Enabled = false;
             comboBoxCategory.Text      = cv.Catagory;
             comboBoxCategory.Enabled   = false;
             comboBoxCity.Text          = cv.City;
             comboBoxCity.Enabled       = false;
             tbxSalary.Text             = cv.MinSalary.ToString();
             tbxSalary.Enabled          = false;
             maskedPhoneNumber.Text     = cv.PhoneNumber;
             maskedPhoneNumber.Enabled  = false;
         }
         else
         {
             MessageBox.Show("Not found, please add cv before");
         }
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            List <string> inputs = new List <string>()
            {
                tbxUsername.Text.Trim(), tbxPassword.Text.Trim(), comboBoxLoginAs.Text
            };
            bool isEmpty = inputs.TrueForAll(x => x != "");
            bool isSpace = inputs.TrueForAll(x => x != " ");

            if (isEmpty && isSpace)
            {
                using (HREntity db = new HREntity())
                {
                    if (comboBoxLoginAs.Text == "Worker")
                    {
                        Worker worker = db.Workers.FirstOrDefault(x => x.Username == tbxUsername.Text && x.Password == tbxPassword.Text);
                        if (worker != null)
                        {
                            WorkerMain workerMain = new WorkerMain();
                            workerMain.GetUser(worker);
                            workerMain.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("User not Found", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                    }
                    else if (comboBoxLoginAs.Text == "Employer")
                    {
                        Employer employer = db.Employers.FirstOrDefault(x => x.Username == tbxUsername.Text && x.Password == tbxPassword.Text);
                        if (employer != null)
                        {
                            EmployerMain employerMain = new EmployerMain();
                            employerMain.GetEmployer(employer);
                            employerMain.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("User not Found", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Cannot be empty", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Esempio n. 12
0
 private void teklisflerToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (HREntity db = new HREntity())
     {
         var isWorkerAddedCv = db.CurriculumVitaes.ToList().Exists(x => x.Id == worker.Id);
         if (isWorkerAddedCv)
         {
             SuggestionsForm suggestionsForm = new SuggestionsForm();
             suggestionsForm.GetWorker(worker);
             suggestionsForm.ShowDialog();
         }
         else
         {
             MessageBox.Show("Firstly you must add cv");
         }
     }
 }
 private void butunElanlariGosterToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (HREntity db = new HREntity())
     {
         var isWorkerAddedCv = db.CurriculumVitaes.ToList().Exists(x => x.Id == worker.Id);
         if (isWorkerAddedCv)
         {
             ShowAllAdvertisementsForm showAllAdvertisementsForm = new ShowAllAdvertisementsForm();
             showAllAdvertisementsForm.GetWorker(worker);
             showAllAdvertisementsForm.ShowDialog();
         }
         else
         {
             MessageBox.Show("Firstly you must add cv");
         }
     }
 }
Esempio n. 14
0
        private void AppliedAdvertisements_Load(object sender, EventArgs e)
        {
            using (HREntity db = new HREntity())
            {
                appliedAdvertisements = (from wa in db.WorkerAdvertisemets
                                         where wa.WorkerId == worker.Id
                                         join a in db.Advertisements

                                         on wa.AdvertisementId equals a.Id

                                         select a
                                         ).ToList();
            }
            var adColumns = (from a in appliedAdvertisements
                             select new { a.AdvertisementName, a.CompanyName, a.Catagory, a.Education, a.Experience, a.Salary }).ToList();

            dataGridView1.DataSource = adColumns;
        }
        private void ShowAllAdvertisementsForm_Load(object sender, EventArgs e)
        {
            using (HREntity db = new HREntity())
            {
                advertisements = db.Advertisements.ToList();
            }
            var adColums = (from a in advertisements
                            select a.Catagory).ToList();

            //DataGridViewButtonColumn dgvBtn = new DataGridViewButtonColumn();
            //dgvBtn.HeaderText = "Ad number";

            //dgvBtn.UseColumnTextForButtonValue = true;

            dataGridView1.Columns.Add("Number", "Number");

            dataGridView1.DataSource       = adColums.Select(x => new { Name = x }).ToList();;
            dataGridView1.Columns[0].Width = 50;
        }
Esempio n. 16
0
        private void isAxtarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //List<Advertisement> advertisements = new List<Advertisement>();
            using (HREntity db = new HREntity())
            {
                var isWorkerAddedCv = db.CurriculumVitaes.ToList().Exists(x => x.Id == worker.Id);
                if (isWorkerAddedCv)
                {
                    var result = (from cv in db.CurriculumVitaes
                                  where cv.Id == worker.Id
                                  join a in db.Advertisements
                                  on new { Catagory = cv.Catagory, City = cv.City, Education = cv.Education, Experience = cv.Education }
                                  equals
                                  new { Catagory = a.Catagory, City = a.City, Education = a.Education, Experience = a.Education }
                                  select a).ToList();
                    if (result.Count != 0)
                    {
                        SearchJobForm searchJobForm = new SearchJobForm();
                        searchJobForm.GetAdList(result);
                        searchJobForm.GetWorker(worker);
                        searchJobForm.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Advertisement not found");
                    }
                }
                else
                {
                    MessageBox.Show("Firstly you must add cv");
                }
                //bool isAdExists = false;
                //var workerCv = db.CurriculumVitaes.FirstOrDefault(x=>x.WorkerId==worker.Id);

                //var advertisemetColumns = from data in db.Advertisements.ToList()
                //                          select data;


                //foreach (var ad in advertisemetColumns)
                //{
                //    if (workerCv.Catagory==ad.Catagory&&workerCv.City==ad.City&&workerCv.Education==ad.Education&&workerCv.Experience==ad.Experience)
                //    {
                //        advertisements.Add(ad);
                //        isAdExists = true;
                //    }

                //}
                //if (isAdExists)
                //{

                //    SearchJobForm searchJobForm = new SearchJobForm();
                //    searchJobForm.GetAdList(advertisements);
                //    searchJobForm.ShowDialog();

                //}
                //else
                //{
                //    MessageBox.Show("Advertisement not found");
                //}
            }
        }
Esempio n. 17
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;
        }