//Button to delete all child test results private void btnDeleteAll_Click(object sender, RoutedEventArgs e) { if(!getChildID.Equals("")) { int convChildId = myChildId(getChildID); int convParentId = myParentId(getParentID); objChildrenViewModel = new ChildrenViewModel(); objRegChild = new RegisterChild(); objTestViewModel = new TestViewModel(); objRegChild = objChildrenViewModel.getChildDetails(convChildId, convParentId); objTestViewModel.deleteChildTestRecords(convChildId); this.Frame.Navigate(typeof(SelectChildToViewPage), convParentId); string msg = "All child test records for " + objRegChild.Name + " " + objRegChild.Surname + " were successfully deleted"; messageBox(msg); } else { messageBox("Child id can't be empty!"); } }
//Button for deleting a child from an account private void btnDeleteChild_Click(object sender, RoutedEventArgs e) { childrenViewModel = new ChildrenViewModel(); objTestViewModel = new TestViewModel(); string strMsg = ""; int convNum = 0; try { int verifyNum; bool isNumerical = int.TryParse(idNum, out verifyNum); if (idNum.Equals("") || isNumerical == false) { strMsg = "Please select a child first before proceeding with the deleting process!"; messageBox(strMsg); } else { convNum = myParentId(idNum); if (convNum <= 0) { strMsg = "Please select a child first before proceeding with the delete process!"; messageBox(strMsg); } else { childrenViewModel.deleteChildRecords(convNum); objTestViewModel.deleteChildTestRecords(convNum); strMsg = "You have successfully deleted: " + name + " from the database!"; messageBox(strMsg); this.Frame.Navigate(typeof(MenuPage), parentId); } } } catch (Exception) { } }