private void btnSaveApplication_Click(object sender, EventArgs e) { if (!checkIfVacancyIsCurrent()) { MessageBox.Show("Candidates can only apply to current vacancies.", "Error"); return; } try { bool match = checkCandidate(); if (match)//skills reach the level { DataRow newApplication = DM.dtApplication.NewRow(); newApplication["VacancyID"] = cboAddVacancyID.Text; newApplication["CandidateID"] = cboAddCandidateID.Text; DM.dsLooking1.Tables["Application"].Rows.Add(newApplication); DM.UpdateApplication(); //Give the user a success message MessageBox.Show("Application added succesfully", "Success"); } else { MessageBox.Show("The candidate does not have the experience to apply for the vacancy.", "Error"); } } catch (ConstraintException) { MessageBox.Show("Candidate can only apply to current vacancies.", "Error"); } }
private void btnMark_Click(object sender, EventArgs e) { DataRow updateVacancyRow = DM.dtVancancy.Rows[currencyManager.Position]; if (txtStatus.Text == "Filled") { MessageBox.Show("The vacancy is already filled", "Error"); } else { updateVacancyRow["Status"] = "Filled"; //Update the database currencyManager.EndCurrentEdit(); DM.UpdateVacancy(); //delete associated records in application table string VacancyID = DM.dtVancancy.Rows[currencyManager.Position]["VacancyID"].ToString(); string strFilter = "VacancyID = " + VacancyID; string strSort = "VacancyID"; DataRow[] matchRecords = DM.dsLooking1.Tables["APPLICATION"].Select(strFilter, strSort, DataViewRowState.CurrentRows); int count = matchRecords.Length; if (count > 0) { foreach (DataRow matchRecord in matchRecords) { matchRecord.Delete(); } DM.UpdateApplication(); } //Give the user a success message MessageBox.Show("Vacancy marked as filled", "Success"); } }