private void btnUpdate_Click(object sender, EventArgs e) { if (listViewCourse.SelectedItems.Count > 0) { try { if (IsValid()) { int courseID = int.Parse(listViewCourse.SelectedItems[0].SubItems[0].Text); BusinessLogic.CourseManager courseManager = new BusinessLogic.CourseManager(); BusinessEntity.CourseEntity oldCourse = courseManager.GetSingle(courseID); BusinessEntity.CourseEntity newCourse = new BusinessEntity.CourseEntity(); newCourse.ID = courseID; newCourse.Title = txtTitle.Text; newCourse.Description = txtDescription.Text; courseManager.Update(newCourse); MessageBox.Show("Course Information Updated Successfully."); LoadCourses(); } } catch (Exception ex) { //save to log table MessageBox.Show("Update Failed, Please try again."); } } else { MessageBox.Show("Please select course from the list first."); } }
private void btnDelete_Click(object sender, EventArgs e) { if (listViewCourse.SelectedItems.Count > 0) { try { DialogResult result = MessageBox.Show("Are you sure you want to delete the selected record?", "Training Information Management System", MessageBoxButtons.YesNo); if (result == DialogResult.OK) { int courseID = int.Parse(listViewCourse.SelectedItems[0].SubItems[0].Text); BusinessLogic.CourseManager courseManager = new BusinessLogic.CourseManager(); BusinessEntity.CourseEntity oldCourse = courseManager.GetSingle(courseID); courseManager.Delete(oldCourse); MessageBox.Show("Course Information Deleted Successfully."); LoadCourses(); } } catch (Exception ex) { //save to log table MessageBox.Show("Delete Failed, Please try again."); } } else { MessageBox.Show("Please select trainee from the list first."); } }
private void listViewCourse_SelectedIndexChanged(object sender, EventArgs e) { if (listViewCourse.SelectedItems.Count > 0) { int courseID = int.Parse(listViewCourse.SelectedItems[0].SubItems[0].Text); BusinessLogic.CourseManager courseManager = new BusinessLogic.CourseManager(); BusinessEntity.CourseEntity course = courseManager.GetSingle(courseID); txtTitle.Text = course.Title; txtDescription.Text = course.Description; } }