private void AddTile_Click(object sender, EventArgs e) { using (JobCategoryAddEditForm jobCategoryAddEditForm = new JobCategoryAddEditForm(null, null)) { jobCategoryAddEditForm.ShowDialog(); } dataShow(); }
private void EditTile_Click(object sender, EventArgs e) { if (employmentStatusDataGridView.Rows.Count != 0 && employmentStatusDataGridView.Rows != null) { jobCategoryInformation.JobCategory = employmentStatusDataGridView.SelectedRows[0].Cells[0].Value.ToString(); if (!string.IsNullOrEmpty(jobCategoryInformation.JobCategory)) { try { Connection.Open(); SqlDataAdapter Adapter = new SqlDataAdapter(string.Format("Select JobCategoryID From JobCategoryInformation Where JobCategory='{0}'", jobCategoryInformation.JobCategory), Connection); DataTable JobCategoryInfomationTable = new DataTable(); Adapter.Fill(JobCategoryInfomationTable); foreach (DataRow row in JobCategoryInfomationTable.Rows) { jobCategoryID = Convert.ToString(row["JobCategoryID"]); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Job Category Edit", MessageBoxButtons.OK, MessageBoxIcon.Error); Connection.Close(); } finally { Connection.Close(); } using (JobCategoryAddEditForm jobCategoryAddEditForm = new JobCategoryAddEditForm(jobCategoryID, jobCategoryInformation.JobCategory)) { jobCategoryAddEditForm.ShowDialog(); } } else { MetroFramework.MetroMessageBox.Show(this, "Data dosen't selected", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } } dataShow(); }