예제 #1
0
        public void ReloadSelectBooks(Butiker bookstore)
        {
            using var db = new BokhandelContext();

            if (!db.Database.CanConnect())
            {
                return;
            }

            dataGridViewBooks.Rows.Clear();

            foreach (var book in db.Böcker
                     .Include(b => b.LagerSaldo)
                     .Include(b => b.Förlag)
                     .Include(b => b.BöckerFörfattare)
                     .ThenInclude(b => b.Författare)
                     .Where(s => s.LagerSaldo
                            .All(s => s.ButikerId != bookstore.Id)))
            {
                dataGridViewBooks.Rows.Add(
                    book.Isbn,
                    book.Titel,
                    book.Språk,
                    (int)book.Pris,
                    book.Utgivningsdatum.ToShortDateString(),
                    string.Join(", ", book.BöckerFörfattare.Select(b => b.Författare.ToString())),
                    book.Förlag.Namn
                    );
            }
        }
예제 #2
0
        public void ReloadStockBalance(Butiker bookstore)
        {
            using var db = new BokhandelContext();

            if (!db.Database.CanConnect())
            {
                return;
            }

            selectedBookstore = bookstore;

            dataGridViewStockBalances.Rows.Clear();

            foreach (var book in db.Böcker.Include(book => book.LagerSaldo))
            {
                foreach (var stock in book.LagerSaldo.Where(s => s.ButikerId == bookstore.Id))
                {
                    dataGridViewStockBalances.Rows.Add(
                        stock.ButikerId,
                        book.Isbn,
                        book.Titel,
                        stock.Antal
                        );
                }
            }
        }
예제 #3
0
        private void comboBoxBookstores_SelectedIndexChanged(object sender, EventArgs e)
        {
            ReloadBookstoreInformation();

            SelectedBookstore = comboBoxBookstores.SelectedItem as Butiker;

            OnSelectionChanged(EventArgs.Empty);
        }
        private void userControlBookstores_BookstoreSelectionChanged(object sender, EventArgs e)
        {
            if (userControlBookstores.SelectedBookstore != null)
            {
                SelectedBookstore = userControlBookstores.SelectedBookstore;

                userControlStockBalances.ReloadStockBalance(SelectedBookstore);
            }
        }
예제 #5
0
        public void AddStockBalance(Butiker bookstore)
        {
            Text = "Lägg till bok...";

            var addStockBalance = new UserControlAddStockBalances {
                Dock = DockStyle.Fill
            };

            addStockBalance.StockBalanceCreated += AddStockBalance_StockBalanceCreated;

            Size = addStockBalance.Size;
            Controls.Add(addStockBalance);
            addStockBalance.SelectedBookstore = bookstore;
        }