private void logout_button_Click(object sender, RoutedEventArgs e)//logout
        {
            BookData bd = new BookData();

            //clear the cart
            bd.ClearCart();
            //return user to login page
            LoginPage lp = new LoginPage();

            lp.Show();
            this.Close();
        }
Exemple #2
0
        private void button_yes_Click(object sender, RoutedEventArgs e)//yes cancel
        {
            //remove all items from cart
            BookData bd = new BookData();

            bd.ClearCart();
            listBox.Items.Clear();
            //send user back to clerk homepage
            ClerkHome ch = new ClerkHome();

            ch.Show();
            this.Close();
        }
 private void button_add_Click(object sender, RoutedEventArgs e)//add book to cart
 {
     //removes from listbox and adds to cart
     if (listBox.SelectedItems.Count > 0)
     {
         string book = listBox.SelectedItems[0].ToString();
         listBox.Items.Remove(listBox.SelectedItems[0]);
         BookData bd = new BookData();
         bd.updateCart(book, 1); //updates InCart status to true/1
     }
     else
     {
         MessageBox.Show("You must first select a book to add.");
     }
 }
Exemple #4
0
 private void button_Click(object sender, RoutedEventArgs e)//remove selected item
 {
     if (listBox.SelectedItems.Count > 0)
     {
         //get selected item
         string book = listBox.SelectedItems[0].ToString();
         listBox.Items.Remove(listBox.SelectedItems[0]); //removes item from listbox display
         BookData bd = new BookData();
         bd.updateCart(book, 0);                         //changes specific book's "InCart" status to false/0
         //recalculate checkout totals
         checkoutTotals();
     }
     else
     {
         MessageBox.Show("You must first choose a book to remove.");
     }
 }
        private void button1_Click_1(object sender, RoutedEventArgs e)//display books button
        {
            //get books from database
            BookData bd = new BookData();

            string[] books = bd.list_books(1).ToArray();
            //display books in listbox
            listBox.Items.Clear();
            foreach (var book in books)
            {
                ListBoxItem tb = new ListBoxItem();
                tb.Width   = 310;
                tb.Content = new TextBlock {
                    Text = book, TextWrapping = TextWrapping.Wrap
                };
                listBox.Items.Add(tb);
            }
        }
Exemple #6
0
        private void fillListBox()//fills the listbox with books that are "InCart"
        {
            //get books that are in cart
            BookData      bd    = new BookData();
            List <string> books = new List <string>();

            books = bd.list_books_incart();
            //put books into listbox
            foreach (var book in books)
            {
                ListBoxItem tb = new ListBoxItem();
                tb.Width   = 440;
                tb.Content = new TextBlock {
                    Text = book, TextWrapping = TextWrapping.Wrap
                };                                                                           //+ "\n"
                listBox.Items.Add(tb);
            }
        }
        private void button_report_Click(object sender, RoutedEventArgs e)//create report button
        {
            //show listbox
            listBox_report.Visibility = Visibility.Visible;
            button_hide.Visibility    = Visibility.Visible;
            button_copy.Visibility    = Visibility.Visible;
            BookData bd = new BookData();

            //clear cart so all books in system are shown
            bd.ClearCart();
            List <string> report = new List <string>();

            report = bd.CreateReport();  //create the report
            foreach (var item in report) //put report into the listbox
            {
                listBox_report.Items.Add(item);
            }
        }
        private void button_isbn_search_Click(object sender, RoutedEventArgs e)//search for book
        {
            BookData bd = new BookData();

            if (label_isbn.Content.ToString().Contains("ISBN"))//search by isbn
            {
                string[] books = new string[1];
                books[0] = bd.Search_Book2(textBox_search.Text);
                if (books[0] != "")
                {
                    FillListbox(books);
                }
            }
            else if (label_isbn.Content.ToString().Contains("title"))//search by title
            {
                string[] books = bd.Search_Title(textBox_search.Text).ToArray();
                FillListbox(books);
            }
            else if (label_isbn.Content.ToString().Contains("Author")) //search by author
            {
                string[] books = bd.Search_Author(textBox_search.Text).ToArray();
                FillListbox(books);
            }
        }
Exemple #9
0
        private void rect_confirm_btn_Click(object sender, RoutedEventArgs e)//processes the  order
        {
            string   value = rect_email_textBox.Text;
            Regex    rg    = new Regex("[a-zA-Z0-9]{1,25}@[a-zA-Z0-9]{1,25}.[a-zA-Z]{2,3}");//valid email layout
            DateTime today = DateTime.Today;

            if (rg.IsMatch(value) && (value.Contains(".com") || value.Contains(".net") || value.Contains(".edu") || value.Contains(".gov") || value.Contains(".org")) && value != "")
            {
                BookData      bd         = new BookData();
                List <string> isbns      = listISBNs();
                string        isbnholder = "";
                double        price      = Convert.ToDouble(label_totalCost.Content.ToString().Replace("$", ""));
                foreach (var item in isbns)
                {
                    bd.RentBook(item);
                    isbnholder += item + ",";
                }
                Boolean processed = bd.addRent(rect_fname_textBox.Text, rect_lname_textBox.Text, isbnholder, price, rect_email_textBox.Text, today);
                if (processed)
                {
                    MessageBox.Show("Order has been processed. " + label_numberOfBooks.Content + " books rented for a total price: " + label_totalCost.Content + ".\nReturn date: " + today.AddMonths(6).ToString("D"));
                    bd.ClearCart();
                    ClerkHome ch = new ClerkHome();
                    ch.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Error processing order.");
                }
            }
            else
            {
                MessageBox.Show("Please verify you entered the email correctly.");
            }
        }