100
Приложение 2. Формы приложения
Программный код вспомогательного класса для формы корзины.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DBForms
{
class ClientCartElement
{
//константы для размещения элементов
public const int constlistboxX = 10;
public const int constlistboxY = 25;
public const int constnumericX = 70;
public const int constnumericY = 55;
public const int constlabelX = 10;
public const int constlabelY = 55;
public const int constbuttonX = 10;
public const int constbuttonY = 80;
public Cart ElemCart { get; set; }
public ListBox Name { get; set; }
public NumericUpDown Counter { get; set; }
public Label Price { get; set; }
public Button DeleteButton { get; set; }
//поле для расчета позиции на форме
public int Index { get; set; }
//ссылка на метод для обработки после удаления
Action ActionAfterDeleteButton;
//ссылка на метод для обработки после измения количества
Action ActionAfterNumeric;
private Form form;
public ClientCartElement(Form f, int index, Cart ElemCart,
Action actionAfterDeleteButton, Action actionAfterNumeric)
{
form = f;
Index = index;
this.ElemCart = ElemCart;
AddElement();
this.ActionAfterDeleteButton = actionAfterDeleteButton;
this.ActionAfterNumeric = actionAfterNumeric;
}
// размещения всех элементов на форме
public void AddElement()
{
AddListBoxName();
AddNumericUpDownConter();
AddLabelPrice();
AddDeleteButton();
}
//размещения текстового элемента ListBox для названия
public void AddListBoxName()
{
Name = new ListBox();
Name.Items.Add(ElemCart.Product.Name);