internal Cart(ref User incomingUser) { InitializeComponent(); _currentUser = incomingUser; stockBike = Representative.GetBikesInStock(); }
private void button4_Click(object sender, EventArgs e)//pass order { string client = textBox1.Text; int rowCount = _currentUser.cart.Count(); if (client != "" && rowCount != 0) { string text = ""; if (_estimatedShippingWeek == 0) { _estimatedShippingWeek = app.GetEstimatedTimeBeforeShipping(_currentUser.cart); } //pass order Representative.SetNewOrderBike(_currentUser.GetCartList(), client, _currentUser.GetCartPrice(), _estimatedShippingWeek); MessageBox.Show("The order has been validated!"); //print an invoice foreach (var elem in _currentUser.GetCartList()) { foreach (var value in elem) { text += value + ";"; } text += "\n"; } /*string path = @"../../Data/list_part.csv"; * File.WriteAllText(path, text);*/ printInvoice(client); //Reset the cart _currentUser.EmptyCart(); Cart_Load(); //this.labelPrice.Text = "0 €"; textBox1.Text = ""; label5.Text = "0 Weeks"; } else { MessageBox.Show("Please enter a valid name or add items to the cart!"); } }
public void LoadBikeStock() { dataGridView3.Rows.Clear(); var stockBike = Representative.GetBikesInStock(); App newApp = new App(); newApp.SetBikeModelList(); int i = 0; foreach (var elem in newApp.bikeModels)//for each item in cart { var stock = stockBike.FindAll(x => x.type == elem.type && x.color == elem.color && x.size == elem.size); int quantity = stock.Count(); dataGridView3.Rows.Add(); dataGridView3.Rows[i].Cells[0].Value = elem.type; dataGridView3.Rows[i].Cells[1].Value = elem.color; dataGridView3.Rows[i].Cells[2].Value = elem.size; dataGridView3.Rows[i].Cells[3].Value = quantity; i++; } }