private void orderBtn_Click(object sender, EventArgs e) { DateTime dateTime = DateTime.UtcNow.Date; currentOrder = new OrderModel(currCustomer.Customer_Id, dateTime.ToString("dd/MM/yyyy")); SqliteDataAccess.SaveOrders(currentOrder); List <OrderModel> orders = SqliteDataAccess.LoadOrders(); foreach (KeyValuePair <BookModel, int> entry in busketDictionary) { SqliteDataAccess.SaveOrderedBook(orders[orders.Capacity - 1].Order_Id, entry.Key.Book_Id, entry.Value); SqliteDataAccess.UpdateStorageByBookID(entry.Key.Book_Id, entry.Key.On_Storage - entry.Value); } MessageBox.Show("Замовлення прийнято!"); busketDictionary.Clear(); busketList.Clear(); var source = new BindingSource(); source.DataSource = (from d in busketDictionary orderby d.Value select new { d.Key, d.Value }).ToList(); busketDataGrid2.DataSource = source; busketDataGrid2.Columns[0].HeaderText = "Book"; busketDataGrid2.Columns[1].HeaderText = "Amount"; }
public void Reload_Form() { books = SqliteDataAccess.LoadBooks(); bunifuCustomDataGrid1.DataSource = books; bunifuCustomDataGrid1.Columns[0].Visible = false; bunifuCustomDataGrid1.Columns[5].Visible = false; bunifuCustomDataGrid1.Size = new Size(910, 450); if (currCustomer == null) { logoutBtn.Visible = false; panel1.Visible = true; loginBtn.Visible = true; helloLabel.Visible = false; adminAddBookGroupBox.Visible = false; addToBusketGroupBox.Visible = false; hello2Label.Text = "Вітаю! Будь ласка авторизуйтесь"; } else { logoutBtn.Visible = true; panel1.Visible = false; loginBtn.Visible = false; helloLabel.Visible = true; helloLabel.Text = "Привіт, " + currCustomer.Name; hello2Label.Text = "Привіт, " + currCustomer.Name; if (currCustomer.Login.Equals("admin")) { adminAddBookGroupBox.Visible = true; addToBusketGroupBox.Visible = false; tabPage3.Text = "Замовлення"; ordersKek = SqliteDataAccess.LoadOrders(); ordersDataGrid.DataSource = ordersKek; orderBookModels = SqliteDataAccess.LoadInfoAboutOrdered(); orderBookBataGrid.DataSource = orderBookModels; busketGroupBox.Visible = false; ordersGroupBox.Visible = true; bunifuCustomDataGrid1.Columns[0].Visible = true; bunifuCustomDataGrid1.Columns[5].Visible = true; bunifuCustomDataGrid1.Size = new Size(910, 330); } else { busketGroupBox.Visible = true; ordersGroupBox.Visible = false; tabPage3.Text = "Кошик"; adminAddBookGroupBox.Visible = false; addToBusketGroupBox.Visible = true; bunifuCustomDataGrid1.Size = new Size(910, 350); } } }