Пример #1
0
        private void addToOrder_Click(object sender, RoutedEventArgs e)
        {
            DataRowView selectedRow;
            DataSet     newBookList;

            //this.DialogResult = false;
            OrderItemDialog orderItemDialog = new OrderItemDialog();


            selectedRow = (DataRowView)AvailableBookView.SelectedItems[0];
            orderItemDialog.isbnTextBox.Text  = selectedRow.Row.ItemArray[0].ToString();
            orderItemDialog.titleTextBox.Text = selectedRow.Row.ItemArray[1].ToString();
            orderItemDialog.priceTextBox.Text = selectedRow.Row.ItemArray[3].ToString();
            orderItemDialog.Owner             = this;
            orderItemDialog.ShowDialog();

            if (orderItemDialog.DialogResult == true)
            {
                string order_isbn      = orderItemDialog.isbnTextBox.Text;
                string order_title     = orderItemDialog.titleTextBox.Text;
                double order_unitPrice = double.Parse(orderItemDialog.priceTextBox.Text);
                int    quantity        = int.Parse(orderItemDialog.quantityTextBox.Text);
                bookOrder.AddItem(new OrderItem(order_isbn, order_title, order_unitPrice, quantity));

                if (selectedBooks != "")
                {
                    selectedBooks += ",'" + order_isbn + "'";
                }
                else
                {
                    selectedBooks += "'" + order_isbn + "'";
                }

                newBookList = bookWishList.HideBooks(selectedBooks, UserId);
                AvailableBookView.ItemsSource = newBookList.Tables["HideBookTable"].DefaultView;
                AvailableBookView.Items.Refresh();

                /*AvailableBookView.ItemsSource = null;
                 * AvailableBookView.Items.Remove(selectedRow);
                 *
                 * removeResult = bookWishList.RemoveItem(selectedRow.Row.ItemArray[0].ToString(), UserId);
                 * if (removeResult)
                 * {
                 *  MessageBox.Show("Successfully Added to order and remove from wishlist", "Adding book to order",
                 *          MessageBoxButton.YesNo, MessageBoxImage.Question);
                 *  DataSet books = bookWishList.getAvailableBooks(UserId);
                 *  AvailableBookView.ItemsSource = books.Tables["BookTable"].DefaultView;
                 *  AvailableBookView.Items.Refresh();
                 * }
                 * else
                 * {
                 *  MessageBox.Show("Something went wrong while trying to delete the data", "Removing from wish list",
                 *          MessageBoxButton.YesNo, MessageBoxImage.Question);
                 * }  */
                //               DataSet books = bookWishList.HideBooks(isbn, UserId);
                //               AvailableBookView.ItemsSource = books.Tables["HideBookTable"].DefaultView;
                //               AvailableBookView.Items.Refresh();
            }
        }
Пример #2
0
        //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();
                }
            }
        }
Пример #3
0
        private void AddBookButton_Click(object sender, RoutedEventArgs e)
        {
            // Check if row selected
            if (this.dataGridBooks.SelectedItems.Count < 1)
            {
                MessageBox.Show("You must select a book before adding.");
                return;
            }

            // An empty row that is selected will return something other than a DataRowView (why god why?)
            if (!(this.dataGridBooks.SelectedItems[0] is System.Data.DataRowView))
            {
                MessageBox.Show("Row is empty. Must select a valid book..");
                return;
            }

            // Selected row is valid.
            DataRowView selectedRow = (DataRowView)this.dataGridBooks.SelectedItems[0];

            // Check if selected row has empty fields
            for (int i = 0; i < selectedRow.Row.ItemArray.Count(); i++)
            {
                if (selectedRow.Row.IsNull(i))
                {
                    MessageBox.Show("Cannot add a book with empty fields.");
                    return;
                }
            }

            // Create book order from the chosen book and user input
            OrderItemDialog orderItemDialog = new OrderItemDialog();

            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);
                bookOrder.AddItem(new OrderItem(isbn, title, unitPrice, quantity));
                updateTotal();
            }
        }
Пример #4
0
        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            OrderItemDialog orderItemDialog = new OrderItemDialog();
            DataRowView     selectedRow;

            selectedRow = (DataRowView)this.ProductsDataGrid.SelectedItems[0];
            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);
                bookOrder.AddItem(new OrderItem(isbn, title, unitPrice, quantity));
            }
        }
        private void addToCart_Click(object sender, EventArgs e)
        {
            OrderItemDialog orderItemDialog = new OrderItemDialog();

            Int32 selectedRowCount =
                dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected);

            if (selectedRowCount > 0)
            {
                dbQ = new DBQueries();
                ds  = new DataSet();
                ds  = dbQ.SELECT_FROM_TABLE("SELECT * FROM BookData WHERE Title = '" +
                                            dataGridView1.SelectedCells[0].Value.ToString() + "'");

                orderItemDialog.isbnTextBox.Text        = ds.Tables[0].Rows[0]["ISBN"].ToString();
                orderItemDialog.titleTextBox.Text       = ds.Tables[0].Rows[0]["Title"].ToString();
                orderItemDialog.priceTextBox.Text       = ds.Tables[0].Rows[0]["Price"].ToString();
                orderItemDialog.descriptionTextBox.Text = ds.Tables[0].Rows[0]["Description"].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);
                    string description = orderItemDialog.descriptionTextBox.Text;

                    bookOrder.AddItem(new OrderItem(isbn, title, unitPrice, quantity, description));
                }
            }
            else
            {
                MessageBox.Show("Please make sure a book is selected");
            }
        }
Пример #6
0
        /*
         *      private void ok_Click(object sender, RoutedEventArgs e)
         *      {
         *          this.DialogResult = true;
         *      }
         */

        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            DataRowView selectedRow;
            DataSet     newBookList;

            //this.DialogResult = false;
            OrderItemDialog orderItemDialog = new OrderItemDialog();

            selectedRow = (DataRowView)wishListView.SelectedItems[0];
            orderItemDialog.isbnTextBox.Text  = selectedRow.Row.ItemArray[0].ToString();
            orderItemDialog.titleTextBox.Text = selectedRow.Row.ItemArray[1].ToString();
            orderItemDialog.priceTextBox.Text = selectedRow.Row.ItemArray[3].ToString();
            orderItemDialog.Owner             = this;
            orderItemDialog.ShowDialog();

            if (orderItemDialog.DialogResult == true)
            {
                string order_isbn      = orderItemDialog.isbnTextBox.Text;
                string order_title     = orderItemDialog.titleTextBox.Text;
                double order_unitPrice = double.Parse(orderItemDialog.priceTextBox.Text);
                int    quantity        = int.Parse(orderItemDialog.quantityTextBox.Text);
                bookOrder.AddItem(new OrderItem(order_isbn, order_title, order_unitPrice, quantity));

                if (selectedBooks != "")
                {
                    selectedBooks += ",'" + order_isbn + "'";
                }
                else
                {
                    selectedBooks += "'" + order_isbn + "'";
                }

                newBookList = bookWishList.HideBooks(selectedBooks, UserId);
                wishListView.ItemsSource = newBookList.Tables["HideBookTable"].DefaultView;
                wishListView.Items.Refresh();
            }
        }