private void Btn_edit_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(tb_BookID.Text))                   //ถ้าในกล่องข้อความว่างเปล่า
            {
                MessageBox.Show("Please input 'book ID' ");
            }
            else if (String.IsNullOrEmpty(tb_BookTitle.Text))
            {
                MessageBox.Show("Please input 'Title' ");
            }
            else if (String.IsNullOrEmpty(tb_BookDescription.Text))
            {
                MessageBox.Show("Please input 'Description' ");
            }
            else if (String.IsNullOrEmpty(tb_BookPrice.Text))
            {
                MessageBox.Show("Please input 'Price' ");
            }
            else
            {
                if (MessageBox.Show("Do you want to save changing ?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    DataAccessBook.UpdateData(tb_BookID.Text, tb_BookTitle.Text, tb_BookDescription.Text, tb_BookPrice.Text);
                    MessageBox.Show("Update completed !!");

                    tb_BookDescription.Clear();
                    tb_BookID.Clear();
                    tb_BookTitle.Clear();
                    tb_BookPrice.Clear();
                }
            }
        }
Esempio n. 2
0
        private void Btn_search_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(tb_BookID.Text))
            {
                MessageBox.Show("Please input 'BookID' ");
            }
            else
            {
                ArrayList arrayList = DataAccessBook.GetDataBook(tb_BookID.Text);
                string    data      = "";
                int       counter   = 0;
                foreach (string list in arrayList)
                {
                    counter = counter + 1;
                    data    = data + list + "\n";
                }

                if (counter == 0)
                {
                    MessageBox.Show("No member data found", "Member detail");
                }
                else
                {
                    MessageBox.Show(data, "Member detail");
                }


                tb_BookID.Clear();
            }
        }
        private void Btn_find_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(tb_find.Text))
            {
                MessageBox.Show("Please input 'Book ID' ");
            }
            else
            {
                ArrayList bookID          = DataAccessBook.GetBookID(tb_find.Text);
                ArrayList bookTitle       = DataAccessBook.GetBookTitle(tb_find.Text);
                ArrayList bookDescription = DataAccessBook.GetBookDescription(tb_find.Text);
                ArrayList bookPrice       = DataAccessBook.GetBookPrice(tb_find.Text);


                string dataID  = "";
                int    counter = 0;
                foreach (string listID in bookID)
                {
                    counter = counter + 1;
                    dataID  = listID;
                }

                string dataTitle = "";
                foreach (string listTitle in bookTitle)
                {
                    dataTitle = listTitle;
                }

                string dataDescription = "";
                foreach (string listDescription in bookDescription)
                {
                    dataDescription = listDescription;
                }

                string dataPrice = "";
                foreach (string listPrice in bookPrice)
                {
                    dataPrice = listPrice;
                }


                if (counter == 0)
                {
                    MessageBox.Show("No member data found", "Member detail");
                }
                else
                {
                    tb_BookID.Text          = dataID;
                    tb_BookTitle.Text       = dataTitle;
                    tb_BookDescription.Text = dataDescription;
                    tb_BookPrice.Text       = dataPrice;
                }
            }
        }
 private void Btn_delete_Click(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrEmpty(tb_BookID.Text))
     {
         MessageBox.Show("Please input CustomerID");
     }
     else
     {
         if (MessageBox.Show("Do you want to delete BookID : " + tb_BookID.Text + " ?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             DataAccessBook.DeleteBookData(tb_BookID.Text);
             MessageBox.Show("Delete BookID : " + tb_BookID.Text + " complete", "Delete complete");
             tb_BookID.Clear();
         }
     }
 }
        private void Btn_add_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(tb_BookID.Text))                   //ถ้าในกล่องข้อความว่างเปล่า
            {
                MessageBox.Show("Please input 'ISBN' ");
            }
            else if (String.IsNullOrEmpty(tb_BookTitle.Text))
            {
                MessageBox.Show("Please input 'Title' ");
            }
            else if (String.IsNullOrEmpty(tb_BookDescription.Text))
            {
                MessageBox.Show("Please input 'Description' ");
            }
            else if (String.IsNullOrEmpty(tb_BookPrice.Text))
            {
                MessageBox.Show("Please input 'Price' ");
            }
            else
            {
                int keyCheck = 1;
                foreach (string list in DataAccessBook.CheckBookID())
                {
                    if (list == tb_BookID.Text)
                    {
                        keyCheck = 2;
                        MessageBox.Show("ID : " + list + " already exist");
                        break;
                    }
                }

                if (keyCheck == 1)
                {
                    DataAccessBook.AddData(tb_BookID.Text, tb_BookTitle.Text, tb_BookDescription.Text, tb_BookPrice.Text);
                    MessageBox.Show("added ID " + tb_BookID.Text + " done");
                    tb_BookID.Clear();
                    tb_BookTitle.Clear();
                    tb_BookDescription.Clear();
                    tb_BookPrice.Clear();
                }
            }
        }
        private void Btn_show_Click(object sender, RoutedEventArgs e)
        {
            string data    = "";
            int    counter = 0;

            foreach (string list in DataAccessBook.GetData())
            {
                counter = counter + 1;
                data    = data + list + "\n";
            }

            if (counter == 0)
            {
                MessageBox.Show("No member data found", "Member detail");
            }
            else
            {
                MessageBox.Show(data, "Member detail");
            }
        }
Esempio n. 7
0
        private void Tb_BookID_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (String.IsNullOrEmpty(tb_BookPrice.Text))
            {
                tb_TotalPrice.Clear();
            }

            ArrayList bookTitle       = DataAccessBook.GetBookTitle(tb_BookID.Text);
            ArrayList bookDescription = DataAccessBook.GetBookDescription(tb_BookID.Text);
            ArrayList bookPrice       = DataAccessBook.GetBookPrice(tb_BookID.Text);



            string dataTitle = "";

            foreach (string listTitle in bookTitle)
            {
                dataTitle = listTitle;
            }

            string dataDescription = "";

            foreach (string listDescription in bookDescription)
            {
                dataDescription = listDescription;
            }

            string dataPrice = "";

            foreach (string listPrice in bookPrice)
            {
                dataPrice = listPrice;
            }


            tb_BookTitle.Text       = dataTitle;
            tb_BookDescription.Text = dataDescription;
            tb_BookPrice.Text       = dataPrice;
        }
Esempio n. 8
0
        public WindowBookMenu()
        {
            InitializeComponent();

            DataAccessBook.InitializeBookDatabase();
        }