private void BuyButton_Click(object sender, EventArgs e) { BasketProductControl product = (sender as Control).Parent as BasketProductControl; //MessageBox.Show("Нажата кнопка в продукте " + product.Name + "."); //MessageBox.Show("Количество: " + product.Count); if (cashPayRB.Checked) { Functions functions = new Functions(); functions.AddOrder(product.ID, (uint)product.Count, "Наличный"); (Application.OpenForms["MainForm"] as MainForm).basketControl1.ReloadBasket(); } else if (nonCashPayRB.Checked) { Functions functions = new Functions(); functions.AddOrder(product.ID, (uint)product.Count, "Безналичный"); (Application.OpenForms["MainForm"] as MainForm).basketControl1.ReloadBasket(); } else { MessageBox.Show("Выберите тип оплаты!"); } }
private void DeleteProduct_Click(object sender, EventArgs e) { BasketProductControl product = (sender as Control).Parent as BasketProductControl; Functions functions = new Functions(); functions.DeleteBasketProduct(product.ID); (Application.OpenForms["MainForm"] as MainForm).basketControl1.ReloadBasket(); }
private void UpdateTotalPrice(object sender, EventArgs e) { BasketProductControl product = (sender as Control).Parent as BasketProductControl; Functions functions = new Functions(); functions.UpdateBasketProduct(product.ID, (uint)product.Count); productPrice.Text = (Count * price).ToString() + " ₽"; }
public void Display(Functions functions, int i, int id, int kol) { //MessageBox.Show(functions.Adress); int stepY = 60; products[i] = new BasketProductControl { ID = id, Title = functions.ProductName, Count = kol, Price = decimal.Parse(functions.Price), Location = new Point(24, 28 + stepY * i), Name = "ProductPanel " + id.ToString() }; products[i].productBuy.Click += new EventHandler(this.BuyButton_Click); Controls.Add(products[i]); }