private void Button_Add_Click(object sender, RoutedEventArgs e) { try { PrepareObject(); using (var data = new DataServiceClient()) { data.AddDeal(viewDeal); } MessageBox.Show("Transaction successful !"); } catch (Exception ex) { MessageBox.Show("Error !"); } this.Close(); }