Exemple #1
0
        private void BTNAddBook_Click(object sender, RoutedEventArgs e)
        {
            if (TXTBookId.Text == string.Empty)
            {
                MessageBox.Show("Podaj poprawne ID ksiazki (liczba)!", "Libary System", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }
            if (TXTBookAuthor.Text == string.Empty)
            {
                MessageBox.Show("Podaj autora ksiazki!", "Libary System", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }
            if (TXTBookName.Text == string.Empty)
            {
                MessageBox.Show("Podaj tytul ksiazki!", "Libary System", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            try {
                var book = new Book(TXTBookId.Text, TXTBookName.Text, TXTBookAuthor.Text);
                BookOperations.AddBook(book);
                MessageBox.Show("Ksiazka zostala dodana pomyslnie!", "Libary System", MessageBoxButton.OK,
                                MessageBoxImage.Information);
                TXTBookId.Text     = string.Empty;
                TXTBookAuthor.Text = string.Empty;
                TXTBookName.Text   = string.Empty;
            }
            catch (Exception exception) {
                MessageBox.Show(exception.Message, "Libary System", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
        private async Task RefreshBooksDataGride()
        {
            var bookViewSource =
                (CollectionViewSource)FindResource("bookViewSource");

            bookViewSource.Source = await BookOperations.BooksToListAsync();
        }
Exemple #3
0
 public BookOperation(ApplicationUser user, Book book, BookOperations operationType)
 {
     User = user;
     Book = book;
     Type = operationType;
     Date = DateTime.Now;
 }
Exemple #4
0
        private void FormBook_Load(object sender, EventArgs e)
        {
            bookOpr  = new BookOperations();
            location = "";

            string[] key = { "Book Name", "Author", "Type", "Number" };
            cb_key.Items.AddRange(key);
        }
Exemple #5
0
 private bool DeleteBook(string catalogueNumber)
 {
     try {
         BookOperations.DeleteBook(catalogueNumber);
         return(true);
     }
     catch (Exception) {
         return(false);
     }
 }
        private void FormRent_Load(object sender, EventArgs e)
        {
            rentOpr = new RentOperations();
            bookOpr = new BookOperations();
            stdOpr  = new StudentOperations();

            string[] key = { "Book Name", "Author", "Type", "Number" };
            cb_c_type.Items.AddRange(key);
            cb_r_type.Items.AddRange(key);
        }
Exemple #7
0
        public void AddAndDeleteBookTest()
        {
            using (var context = new DbContext()) {
                var book = new Book("test", "test", "test");
                BookOperations.AddBook(book);

                var bookInDb = context.Books.Find(book.CatalogueNumber);

                if (bookInDb == null)
                {
                    throw new NullReferenceException();
                }

                Assert.AreEqual(book.CatalogueNumber, bookInDb.CatalogueNumber);
                Assert.AreEqual(book.Name, bookInDb.Name);
                Assert.AreEqual(book.Author, bookInDb.Author);
                Assert.IsTrue(DeleteBook(book.CatalogueNumber));
            }
        }
Exemple #8
0
        public void OnBookOperation(BookOperationData data)
        {
            BblBook        b         = data.b;
            BookOperations operation = data.operation;
            BblBook        replace   = data.replace;

            if (operation == BookOperations.Add)
            {
                lock (b.NodeLock) _books.Add(b);
            }
            else if (operation == BookOperations.Replace)
            {
                lock (b.NodeLock) _books[_books.IndexOf(replace)] = b;
            }
            else if (operation == BookOperations.Remove)
            {
                lock (b.NodeLock) _books.Remove(b);
            }
        }
Exemple #9
0
        private void BTNDeleteBook_Click(object sender, RoutedEventArgs e)
        {
            if (TXTBookCatalogueNumber.Text == string.Empty)
            {
                MessageBox.Show("Podaj numer katalogowy ksiazki ktora chcesz usunac!", "Libary System",
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            try {
                BookOperations.DeleteBook(TXTBookCatalogueNumber.Text);
                MessageBox.Show("Ksiazka zostala usunieta pomyslnie!", "Libary System", MessageBoxButton.OK,
                                MessageBoxImage.Information);
                TXTBookCatalogueNumber.Text = string.Empty;
            }
            catch (Exception exception) {
                MessageBox.Show(exception.Message, "Libary System", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
Exemple #10
0
 private async Task InsertBookOperationLog(ApplicationUser currentUser, Book book, BookOperations bookOperationType)
 {
     var bookOperation = new BookOperation(currentUser, book, bookOperationType);
     await _bookOperationRepository.Insert(bookOperation);
 }
        static void Main(string[] args)
        {
            Book b = new Book()
            {
                Author      = "a",
                BindingType = "a",
                BrandName   = "z",
                CategoryID  = "Books",
                //SubCategoryID = "1",
                Edition = "d",
                //Genre = "1",

                Photo           = "1",
                Price           = Convert.ToDouble(23),
                ProductID       = "shs7",
                ProductName     = "sshs",
                PublicationYear = "sjsj",
                Publication     = "hshs"
            };

            BookOperations bOp = new BookOperations();

            bOp.InsertBook(b);
            //ProductComparisonDataContext dataContext = new ProductComparisonDataContext();
            //dataContext.Database.Log = Console.Write;

            ////Insert Categories

            //dataContext.Categories.Add(new Category
            //{
            //    CategoryID = "Books",
            //    CategoryName = "Electronics",
            //    Description = "Electronic Data",

            //});
            //dataContext.SaveChanges();

            //Fetch

            //var cats = dataContext.Categories.ToList();
            //foreach (Category c in cats)
            //{
            //    Console.WriteLine("CategoryID {0} CategoryName {1} Description {2}",c.CategoryID,c.CategoryName,c.Description);
            //}
            //Console.WriteLine("");

            ////Update Categories

            //var query = dataContext.Categories.Where(c => c.CategoryID == "EleID123").First();
            //query.CategoryID = "EleID123";
            //query.CategoryName = "Entc";
            //query.Description = "Electronic data123";
            //dataContext.SaveChanges();

            //Delete code

            //var query = dataContext.Categories.Where(c => c.CategoryID == "EleID123").First();
            //dataContext.Categories.Remove(query);
            //dataContext.SaveChanges();

            //Insert Subcategories

            //dataContext.SubCategories.Add(new SubCategory
            //{
            //    SubCategoryID = "EcsTablets",
            //    SubCategoryName = "Tablets",
            //    CategoryID = "EleID1111"
            //});
            //dataContext.SaveChanges();
            //Console.WriteLine("");

            //Insert Tablet

            //dataContext.Tablets.Add(new Tablet
            //{
            //    ProductID = "Tab123",
            //    ProductName = "Tab",
            //    BrandName = "Apple",
            //    Price = 30000.00 ,
            //    SubCategoryID = "EcsTablets",
            //    Display="LED",
            //    OperatingSystem="Apple-OS",
            //    Photo="lllll",
            // });
            //dataContext.SaveChanges();
            //Console.WriteLine("");

            //Insert Suggestion

            //dataContext.Suggestions.Add(new Suggestion()
            //{
            //    SuggestionID = "SugTabs",
            //    Hits = 7,
            //    RatingFeatureCritic = 2,
            //    RatingPerformanceCritic = 2,
            //    RatingDesignCritic = 4,
            //    RatingDesignUser = 7,
            //    RatingPerformanceUser = 8,
            //    RatingFeatureUser = 8,
            //    ProductID = "Tab123"
            //});
            //dataContext.SaveChanges();

            //update suggestion

            //var query = (from sugg in dataContext.Suggestions
            //             where sugg.SuggestionID == "SugTabs"
            //             select sugg).First();
            //query.RatingDesignCritic = 3;
            //dataContext.SaveChanges();
            //Console.WriteLine("");

            //fetching records of a particular category for a particular product

            //var query1 = from cat in dataContext.Categories
            //            join subCats in dataContext.SubCategories
            //            on cat.CategoryID equals subCats.CategoryID
            //            join tabs in dataContext.Tablets
            //            on subCats.SubCategoryID equals tabs.SubCategoryID
            //             where tabs.ProductName == "Tab"
            //            select new
            //            {
            //                TabName = tabs.ProductName,
            //                CategoryName = cat.CategoryName
            //            };

            //fetching

            //foreach (var item in query1)
            //{
            //    Console.WriteLine("TabName {0} CategoryName {1}", item.TabName, item.CategoryName);
            //}

            //inset userprofile

            //dataContext.UserProfiles.Add(new UserProfile()
            //{
            //    Preference1 = "Tab123",
            //    State="Maharashtra",
            //    UserID="A2",
            //    UserName="******",
            //    City="Pune",
            //    Gender="Female"
            // });
            //dataContext.SaveChanges();

            //var query = from u in dataContext.UserProfiles
            //            join p in dataContext.Products
            //            on u.Preference1 equals p.ProductID
            //            select new {ProductName = p.ProductName, ProductID =u.Preference1, UserID = u.UserID};
            //foreach (var item in query)
            //{
            //    Console.WriteLine("ProductID {0} for ProductName {1} UserID {2} ", item.ProductID,item.ProductName,item.UserID);
            //}

            Console.WriteLine("Done!!");
            Console.ReadKey();
        }
Exemple #12
0
 public BookOperationData(BblBook b, BookOperations operation, BblBook replace)
 {
     this.b         = b;
     this.operation = operation;
     this.replace   = replace;
 }