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(); }
private void BtnCustomerSearch_Click_1(object sender, EventArgs e) { DgvCustomersSearch.Rows.Clear(); //UpdateContext(); string searchText = TxbCustomerSearch.Text.Trim(); if (string.IsNullOrEmpty(searchText)) { FillCustomersSearch(); return; } var customers = _context.Customers .Where(c => searchText != string.Empty ? c.Name.StartsWith(searchText) : false) .OrderBy(c => c.Name) .ToList(); foreach (var item in customers) { DgvCustomersSearch.Rows.Add(item.Id, item.Name, item.Surname, item.Phone, item.Address ); } TxbCustomerSearch.Clear(); }