Ejemplo n.º 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();
            }
        }
Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 3
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));
            }
        }
Ejemplo n.º 4
0
            public void TestMethodAddBook()
            {
                BookOrder bookOrder = new BookOrder();
                OrderItem orderItem;

                string bookISBN     = "8398230985";
                string bookTitle    = "Agile Software Development";
                double bookPrice    = 50.40;
                int    bookQuantity = 1;
                string description  = "sample description";

                // Creating a sample book entry
                orderItem = new OrderItem(bookISBN, bookTitle, bookPrice, bookQuantity, description);
                bookOrder.AddItem(orderItem);

                bool expectedReturnWithBook = true;

                //Checking if newly created item exists in orderItem
                bool actualReturnWithBook = bookOrder.HasItem(orderItem);

                Assert.AreEqual(expectedReturnWithBook, actualReturnWithBook);
            }
Ejemplo n.º 5
0
            public void TestMethodAddBook2()
            {
                BookOrder bookOrder = new BookOrder();
                OrderItem orderItem;

                string bookISBN     = " ";
                string bookTitle    = "Comp Sci";
                double bookPrice    = 99.99;
                int    bookQuantity = 1;
                string description  = "sample description";

                // Creating a sample book entry
                orderItem = new OrderItem(bookISBN, bookTitle, bookPrice, bookQuantity, description);
                bookOrder.AddItem(orderItem);

                bool expectedReturnWithBook = false;

                //Checking if newly created item exists in orderItem
                bool actualReturnWithBook = bookOrder.HasItem(orderItem);

                Assert.AreEqual(expectedReturnWithBook, actualReturnWithBook);
            }
        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");
            }
        }
Ejemplo n.º 7
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();
            }
        }