Пример #1
0
        private void BtnAddToCard_Click_1(object sender, EventArgs e)
        {
            if (_selectedCustomer == null ||
                _selectedBook == null)
            {
                MessageBox.Show("Please select customer and book", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (_selectedBook.Count < NupBookCount.Value)
            {
                MessageBox.Show("No available books", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            PnlOrderInfo.Visible = true;
            DgvBasket.Rows.Clear();


            decimal price = _selectedBook.Price * NupBookCount.Value;

            RtbTotalPrice.Text = price.ToString();
            FillBasket();
            TxbCustomerSearch.Clear();
            TxbBookSearch.Clear();
        }
Пример #2
0
        private void BtnBookSearch_Click_1(object sender, EventArgs e)
        {
            DgvBookSearch.Rows.Clear();
            string searchText = TxbBookSearch.Text.Trim();

            if (string.IsNullOrEmpty(searchText))
            {
                FillBooksSearch();
                return;
            }

            var books = _context.Books
                        .Where(b => searchText != string.Empty ? b.Name.StartsWith(searchText) : false)
                        .OrderBy(b => b.Name)
                        .ToList();



            foreach (var item in books)
            {
                DgvBookSearch.Rows.Add(item.Id,
                                       item.Name,
                                       item.Genre.Name,
                                       item.Author.Fullname,
                                       item.Price,
                                       item.Count
                                       );
            }

            TxbBookSearch.Clear();
        }