public override bool saveChanges() { if (dtpStart.SelectedDateTime == default(DateTime)) { MessageBox.Show("Invalid publish start date.", "Invalid Input", MessageBoxButton.OK, MessageBoxImage.Exclamation); return false; } if (dtpEnd.SelectedDateTime == default(DateTime)) { MessageBox.Show("Invalid publish end date.", "Invalid Input", MessageBoxButton.OK, MessageBoxImage.Exclamation); return false; } RegistrationHelper client = new RegistrationHelper(); try { DateTime startTime = dtpStart.SelectedDateTime; DateTime endTime = dtpEnd.SelectedDateTime; if (endTime > event_.StartDateTime) { MessageBox.Show("Event starts at " + event_.EndDateTime + ", publish date must end before that."); return false; } if (endTime <= startTime) { MessageBox.Show("Publish end date must be after its start date."); return false; } decimal result = 0; if (cboIsPayable.IsChecked == true) { if (!decimal.TryParse(txtamount.Text, out result)) { MessageBox.Show("invalid amount"); return false; } } if (publish == null) {// need to change here client.AddPublish(user, event_.EventID, startTime, endTime, txtRemarks.Text, cboIsPayable.IsChecked.Value, result); } else client.EditPublish(user, event_.EventID, startTime, endTime, txtRemarks.Text, cboIsPayable.IsChecked.Value, result); btnDelete.IsEnabled = true; changed = false; MessageBox.Show("Operation succeeded!"); return true; } catch (Exception ex) { MessageBox.Show(ex.Message); return false; }finally{ client.Close(); } }