/// <summary> /// Remove project /// </summary> private void btnRemove_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Do you want remove " + txtName.Text + " from project " + gvProject.CurrentRow.Cells[1].Value.ToString() + " ?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int projectID = int.Parse(gvProject.CurrentRow.Cells[0].Value.ToString()); foreach (tbl_ProjectDTO item in listProject) { if (item.Id == projectID) { listProject.Remove(item); tbl_JoiningDAO joinDAO = new tbl_JoiningDAO(); joinDAO.DeleteByProID_EmID(projectID, int.Parse(txtId.Text)); gvProject.DataSource = null; gvProject.DataSource = listProject; return; } } } } catch (Exception) { } }
// //Remove Employee from project // private void btnDeleteEmp_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Do you want remove " + gvListEmployee.CurrentRow.Cells[1].Value.ToString() + " from project?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int empID = int.Parse(gvListEmployee.CurrentRow.Cells[0].Value.ToString()); foreach (tbl_EmployeeDTO item in listEmployee) { if (item.Id == empID) { listEmployee.Remove(item); tbl_JoiningDAO joinDAO = new tbl_JoiningDAO(); joinDAO.DeleteByProID_EmID(int.Parse(txtID.Text), empID); gvListEmployee.DataSource = null; gvListEmployee.DataSource = listEmployee; return; } } } } catch (Exception) { MessageBox.Show("Remove employee not successfull!"); } }