Esempio n. 1
0
 //assign skill to vacancy
 private void btnAssignSkill_Click(object sender, EventArgs e)
 {
     //use "try catch" to stop the same assign
     try
     {
         //stop the empty text or more than 10 in the year text area
         if ((txtYears.Text == "") || (Convert.ToInt32(txtYears.Text) > 10))
         {
             MessageBox.Show("Please set the right value of years(1-10)");
         }
         //assign skill to vacancy
         else
         {
             DataRow newVacancySkill = DM.dtVacancySkill.NewRow();
             newVacancySkill["Years"]     = txtYears.Text;
             newVacancySkill["VacancyID"] = dgvVacancy["VacancyID", cmVacancy.Position].Value;
             newVacancySkill["SkillID"]   = dgvSkill["SkillID", cmSkill.Position].Value;
             DM.lookingGlassDS.Tables["VacancySkill"].Rows.Add(newVacancySkill);
             DM.UpdateVacancySkill();
             MessageBox.Show("Skill assigned successfully");
         }
     }
     catch (ConstraintException)
     {
         MessageBox.Show("This skill has already been assigned to this vacancy.");
     }
 }
Esempio n. 2
0
        private void btnAssignSkill_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtYears.Text == "")
                {
                    MessageBox.Show("You must type a valid number", "Error");
                }
                else if (DM.dtSkill.Rows[cmSkill.Position]["SkillID"] != DM.dtVacancySkill.Rows[cmVacancySkill.Position]["SkillID"])
                {
                    DataRow newVacancySkill = DM.dtVacancySkill.NewRow();
                    newVacancySkill["VacancyID"] = dgvVacancy["VacancyID", cmVacancy.Position].Value;
                    newVacancySkill["Years"]     = Convert.ToInt32(this.txtYears.Text);
                    newVacancySkill["SkillID"]   = dgvSkill["SkillID", cmSkill.Position].Value;

                    DM.dsLookingGlass.Tables["VacancySkill"].Rows.Add(newVacancySkill);
                    DM.UpdateVacancySkill();
                    MessageBox.Show("Skill assigned successfully", "Success");
                }
            }
            catch
            {
                MessageBox.Show("This skill has already been assigned to this vacancy");
            }
        }
Esempio n. 3
0
        //delete the current row
        private void btnDeleteVacancy_Click(object sender, EventArgs e)
        {
            DataRow deleteVacancyRow = DM.dtVacancy.Rows[currencyManager.Position];

            if (MessageBox.Show("Are you sure you want to delete this record?", "Warning", MessageBoxButtons.OKCancel) ==
                DialogResult.OK)
            {
                //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 find the same id ,return
                    if (vacID == vacID2)
                    {
                        MessageBox.Show("You may only delete a vacancy that has no applications");
                        return;
                    }
                }
                //assign the vacancyskills table to an array(vacancyskill)
                vacancyskills = DM.lookingGlassDS.Tables["VACANCYSKILL"].Select();
                //use for loop to compare input ID with the vacancyID in the vacancyskill table
                for (int i = 0; i < vacancyskills.Length; i++)
                {
                    DataRow drVacancySkill = vacancyskills[i];
                    int     vacID          = Convert.ToInt32(txtVacancyID.Text);
                    int     vacID2         = Convert.ToInt32(drVacancySkill["VacancyID"]);
                    //if find the same id delete the vacancy information from the vacancyskill table
                    if (vacID == vacID2)
                    {
                        drVacancySkill.Delete();
                        DM.UpdateVacancySkill();
                    }
                }
                deleteVacancyRow.Delete();
                MessageBox.Show("Vacancy deleted successfully");
                DM.UpdateVacancy();
                return;
            }
            else
            {
                return;
            }
        }
Esempio n. 4
0
        private void btnDeleteVacancy_Click(object sender, EventArgs e)
        {
            CurrencyManager cmVacancySkill;

            cmVacancySkill = (CurrencyManager)this.BindingContext[DM.dsLookingGlass, "VacancySkill"];
            //Select the related data.
            int aVacancyID = Convert.ToInt32(txtVacancyID.Text);

            cmVacancySkill.Position = DM.vacancySkillView.Find(aVacancyID);
            DataRow[] VacanciSkillRow = DM.dtVacancySkill.Select("VacancyID =" + aVacancyID);
            //Create new row for delete
            DataRow deleteVacancyRow = DM.dtVacancy.Rows[currencyManager.Position];

            DataRow[] drApplication = deleteVacancyRow.GetChildRows(DM.dtVacancy.ChildRelations["VACANCY_APPLICATION"]); //Get the position of the determined table
            if (drApplication.Length == 0)                                                                               //determine if existed or not
            {
                if (MessageBox.Show("Are you sure you want to delete this vacancy record?", "Warning",
                                    MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    foreach (DataRow dvs in VacanciSkillRow)//delete all the records in VacancySKill
                    {
                        dvs.Delete();
                    }
                    deleteVacancyRow.Delete();
                    //update row
                    DM.UpdateVacancySkill();
                    DM.UpdateVacancy();
                    MessageBox.Show("Vacancy deleted successfully", "Success");
                    MessageBox.Show("Vacancy Skills deleted successfully", "Success");
                }
                else
                {
                    return;
                }
            }
            else
            {
                MessageBox.Show("You may only delete Vacancies who have no applications", "Error");
            }
            return;
        }