コード例 #1
0
        private void btnSaveVacancy_Click(object sender, EventArgs e)
        {
            //Create a new row that variables will be added into
            DataRow newVacancyRow = DM.dtVacancy.NewRow();

            //If the salary isn't fulfill the condition then do not write data and return;
            if ((txtAddVacancyDescription.Text == "") || (txtAddVacancySalary.Text == ""))
            {
                MessageBox.Show("You must type a value for each of the text fields", "Error");
                return;
            }
            //transfer the object then it can compare with number .
            int x = Convert.ToInt32(this.txtAddVacancySalary.Text);

            if (x < 30000 || x > 200000)
            {
                MessageBox.Show("The salary must meet the condition of between 30000 and 200000", "Error");
                return;
            }
            else
            {
                newVacancyRow["Description"] = txtAddVacancyDescription.Text;
                newVacancyRow["Salary"]      = txtAddVacancySalary.Text;
                newVacancyRow["Status"]      = "current";
                newVacancyRow["EmployerID"]  = cboEmID.Text;
                DM.dtVacancy.Rows.Add(newVacancyRow);
                DM.UpdateVacancy();
                MessageBox.Show("Vacancy added successfully", "Success");
            }
            return;
        }
コード例 #2
0
ファイル: VacancyForm.cs プロジェクト: kekakuka/LookingGlass
        //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;
            }
        }