/// <summary> /// Get all the deatils from the changes implementation. /// </summary> /// <param name="changes">The changes implementation.</param> /// <param name="currentDetails">The current deatils.</param> /// <returns>The current and new details text.</returns> private string GetDetails(Nequeo.IPropertyChanged changes, string currentDetails) { string details = currentDetails; List <string> list = changes.GetDetails(); // If changes exist then add to the details. if (list.Count > 0) { foreach (string detail in list) { details += detail + "\r\n"; } } // Return the details. return(details); }
/// <summary> /// On window application closing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { string details = string.Empty; // Get all data user controls Nequeo.IPropertyChanged invoiceChanged = invoice; Nequeo.IPropertyChanged customerChanged = customer; Nequeo.IPropertyChanged productChanged = product; Nequeo.IPropertyChanged vendorChanged = vendor; Nequeo.IPropertyChanged employeeChanged = employee; Nequeo.IPropertyChanged accountChanged = account; Nequeo.IPropertyChanged companyChanged = company; Nequeo.IPropertyChanged assetChanged = asset; Nequeo.IPropertyChanged managementChanged = management; // Test to see if any data user control has changed. details = GetDetails(invoiceChanged, details); details = GetDetails(customerChanged, details); details = GetDetails(productChanged, details); details = GetDetails(vendorChanged, details); details = GetDetails(employeeChanged, details); details = GetDetails(accountChanged, details); details = GetDetails(companyChanged, details); details = GetDetails(assetChanged, details); details = GetDetails(managementChanged, details); // If the data has been changed and not updated. if (!String.IsNullOrEmpty(details)) { MessageBoxResult result = MessageBox.Show(details + "\r\n\r\n" + "Disregard the changes and close (all changes will be lost)?", "Data Has Changed", MessageBoxButton.YesNo); if (result != MessageBoxResult.Yes) { e.Cancel = true; } } }