private void AddTile_Click(object sender, EventArgs e) { using (JobTitleAddEditForm jobTitleAddEditForm = new JobTitleAddEditForm(null, null, null)) { jobTitleAddEditForm.ShowDialog(); } dataShow(); }
private void EditTile_Click(object sender, EventArgs e) { if (jobTitleDataGridView.Rows.Count != 0 && jobTitleDataGridView.Rows != null) { jobTitleInformation.JobTitleName = jobTitleDataGridView.SelectedRows[0].Cells[0].Value.ToString(); jobTitleInformation.JobTitleDescription = jobTitleDataGridView.SelectedRows[0].Cells[1].Value.ToString(); if (!string.IsNullOrEmpty(jobTitleInformation.JobTitleName)) { try { Connection.Open(); SqlDataAdapter Adapter = new SqlDataAdapter(string.Format("Select JobTitleID From JobTitleInformation Where JobTitle ='{0}'", jobTitleInformation.JobTitleName), Connection); DataTable JobTitleInfoTable = new DataTable(); Adapter.Fill(JobTitleInfoTable); foreach (DataRow row in JobTitleInfoTable.Rows) { jobTitleID = Convert.ToString(row["JobTitleID"]); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Job Title Edit", MessageBoxButtons.OK, MessageBoxIcon.Error); Connection.Close(); } finally { Connection.Close(); } using (JobTitleAddEditForm jobTitleAddEditForm = new JobTitleAddEditForm(jobTitleID, jobTitleInformation.JobTitleName, jobTitleInformation.JobTitleDescription)) { jobTitleAddEditForm.ShowDialog(); } } else { MetroFramework.MetroMessageBox.Show(this, "Data dosen't selected", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } } dataShow(); }