示例#1
0
        //mark the vacancy as filled
        private void btnMark_Click(object sender, EventArgs e)
        {
            DataRow updateVacancyRow = DM.dtVacancy.Rows[currencyManager.Position];
            string  oldStatus        = updateVacancyRow["Status"].ToString();

            //cannot fill filled vacancy
            if (oldStatus == "filled")
            {
                MessageBox.Show("Vacancy is already filled");
            }
            else
            {
                updateVacancyRow["Status"] = "filled";
                currencyManager.EndCurrentEdit();
                DM.UpdateVacancy();
                MessageBox.Show("Vacancy marked as filled");
                //assign the application table to an array(vacancies)
                vacancies = DM.lookingGlassDS.Tables["APPLICATION"].Select();
                //use for loop to compare input ID with the vacancyID in the application table
                for (int i = 0; i < vacancies.Length; i++)
                {
                    DataRow drVacancy = vacancies[i];
                    int     vacID     = Convert.ToInt32(txtVacancyID.Text);
                    int     vacID2    = Convert.ToInt32(drVacancy["VacancyID"]);
                    //if fine the  same ID,delete the application row
                    if (vacID == vacID2)
                    {
                        drVacancy.Delete();
                        DM.UpdateApplication();
                    }
                }
            }
        }
示例#2
0
        //add an application
        private void btnAddApplication_Click(object sender, EventArgs e)
        {
            DataRow newApplicationRow = DM.dtApplication.NewRow();

            int     vID       = Convert.ToInt32(cboVacancyID.Text);
            DataRow drVacancy = DM.dtVacancy.Rows[DM.vacancyView.Find(vID)];
            string  status    = drVacancy["Status"].ToString();

            //if the vacancy is filled stop the application
            if (status == "filled")
            {
                MessageBox.Show("Candidates can only apply to current vacancies");
                return;
            }
            else
            {
                //select the vacancyskill and candidateskill table
                candidatesSkills = DM.lookingGlassDS.Tables["CANDIDATESKILL"].Select();
                vacancySkills    = DM.lookingGlassDS.Tables["VACANCYSKILL"].Select();
                //set a bool var to check the compare result
                Boolean ok;
                for (int i = 0; i < vacancySkills.Length; i++)
                {
                    //if the input vacancyID can find in the vacancyskill table check other information.
                    //if cannot find then directly add the application
                    if (vacancySkills[i]["VacancyID"].ToString() == cboVacancyID.Text)
                    {
                        //set the ok to false to stop the application
                        ok = false;
                        for (int j = 0; j < candidatesSkills.Length; j++)
                        {
                            //if the input candidateID can find in the candidateskill table check other information.
                            //if cannot find and ok=false so stop the application
                            if (candidatesSkills[j]["CandidateID"].ToString() == cboCandidateID.Text)
                            {
                                //if the candidate has skills for the vacancy then compare the years
                                //if dosen't have and ok=false so stop the application
                                if (vacancySkills[i]["SkillID"].ToString() == candidatesSkills[j]["SkillID"].ToString())
                                {
                                    //if the candidateskill years overweigh the vacancy's ok=true ,and go on the for loop
                                    //if less than the vacancy.ok=false and break the loop .stop the application
                                    if (Convert.ToInt32(vacancySkills[i]["Years"].ToString()) <= Convert.ToInt32(candidatesSkills[j]["Years"].ToString()))
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                        break;
                                    }
                                }
                            }
                        }
                        if (ok == false)
                        {
                            MessageBox.Show("The candidates does not have the experience to apply for the vacancy");
                            return;
                        }
                    }
                }
                //if ok = ture ,add the new application
                //use "try catch" to stop the same assign
                try
                {
                    newApplicationRow["VacancyID"]   = Convert.ToInt32(cboVacancyID.Text);
                    newApplicationRow["CandidateID"] = Convert.ToInt32(cboCandidateID.Text);
                    DM.dtApplication.Rows.Add(newApplicationRow);
                    DM.UpdateApplication();
                    MessageBox.Show("Application added successfully");
                    return;
                }
                catch (ConstraintException)
                {
                    MessageBox.Show("This vacancy has already been allocated to this candidate.", "Error");
                }
            }
        }