private void SaveBusinessPartner(object obj) { try { var newObject = SelectedBusinessPartner.Id; var stat = _businessPartnerService.InsertOrUpdate(SelectedBusinessPartner); if (stat != string.Empty) { MessageBox.Show("Can't save" + Environment.NewLine + stat, "Can't save", MessageBoxButton.OK, MessageBoxImage.Error); } else if (newObject == 0) { BusinessPartners.Insert(0, SelectedBusinessPartner); SelectedBusinessPartner.Number = _businessPartnerService.GetBusinessPartnerNumber(SelectedBusinessPartner.Id); stat = _businessPartnerService.InsertOrUpdate(SelectedBusinessPartner); if (stat != string.Empty) { MessageBox.Show("Can't save Number" + Environment.NewLine + stat, "Can't save", MessageBoxButton.OK, MessageBoxImage.Error); } else { CloseWindow(obj); } } } catch (Exception exception) { MessageBox.Show("Can't save" + Environment.NewLine + exception.Message, "Can't save", MessageBoxButton.OK, MessageBoxImage.Error); } }