//Add Books button Click private void addButton_Click(object sender, RoutedEventArgs e) { int bookQuantity; String addToWLResult = ""; OrderItemDialog orderItemDialog = new OrderItemDialog(); //Initiate Window DataRowView selectedRow; selectedRow = (DataRowView)this.ProductsDataGrid.SelectedItems[0]; //this.totalTextBox.Text = bookOrder.GetOrderTotal().ToString(); bookQuantity = int.Parse(selectedRow.Row.ItemArray[8].ToString()); if (bookQuantity < 1) { WishlistDialog result = new WishlistDialog(); result.Owner = this; result.ShowDialog(); if (result.DialogResult == true) { //Need to add username here !!!! addToWLResult = bookWishList.AddBookToWishList(selectedRow.Row.ItemArray[0].ToString(), userData.UserID); MessageBox.Show(addToWLResult, "Adding to wish list", MessageBoxButton.YesNo, MessageBoxImage.Question); } } else { orderItemDialog.isbnTextBox.Text = selectedRow.Row.ItemArray[0].ToString(); orderItemDialog.titleTextBox.Text = selectedRow.Row.ItemArray[2].ToString(); orderItemDialog.priceTextBox.Text = selectedRow.Row.ItemArray[4].ToString(); orderItemDialog.Owner = this; orderItemDialog.ShowDialog(); if (orderItemDialog.DialogResult == true) { string isbn = orderItemDialog.isbnTextBox.Text; string title = orderItemDialog.titleTextBox.Text; double unitPrice = double.Parse(orderItemDialog.priceTextBox.Text); int quantity = int.Parse(orderItemDialog.quantityTextBox.Text); double price = unitPrice * quantity; bookOrder.AddItem(new OrderItem(isbn, title, unitPrice, quantity)); globalTotal += price; this.totalTextBox.Text = globalTotal.ToString(); } } }