Beispiel #1
0
        // return the items
        private void Return_ItemBtr(object sender, RoutedEventArgs e)
        {
            double a    = double.Parse(EditionTxt.Text);
            string name = NameTxt.Text;

            BookLib.ItemCollection collection = libraryManager.GetItemCollection();
            // we compre the the name and the edition of the item to check if he valid
            AbstractItem item  = collection[a];
            AbstractItem item2 = collection[name];

            // if this 2 itmes founded are the same obj so the input is valid

            if (item == item2 && item != null && item2 != null)
            {
                if (libraryManager.ReturnItemFromRent(user, item))
                {
                    //the return succes
                    System.Windows.Forms.MessageBox.Show("Book returned!", "Sucess");
                }
                else
                {
                    //the return faild
                    System.Windows.Forms.MessageBox.Show("Book was not found!", "Error");
                }
            }
            else
            {
                // input wrong!
                System.Windows.Forms.MessageBox.Show("Incorrect information!", "Error");
            }
        }
        private void Search_Item(object sender, RoutedEventArgs e)
        {
            //we check 2 thing's the name and the edition they qunic, and if they valid we can to the add and remove
            BookLib.ItemCollection collection = libraryManager.GetItemCollection();
            item  = collection[double.Parse(EditionTxt.Text)];
            item2 = collection[NameTxtt.Text];
            if (item == item2 && item != null)
            {
                ItemNameblock.Text = "Item was Found";
                addbt.IsEnabled    = true;
                removebt.IsEnabled = true;
            }

            else
            {
                ItemNameblock.Text = "Item was Not Found";
                item            = null;
                item2           = null;
                EditionTxt.Text = "";
                NameTxtt.Text   = "";
            }
        }