101
Name.BackColor = System.Drawing.Color.Khaki;
SetLocation(Name, constlistboxX, constlistboxX);
Name.Size = new System.Drawing.Size(570, 20);
form.Controls.Add(Name);
}
//размещения элемента счетчика для количества
public void AddNumericUpDownConter()
{
Counter = new NumericUpDown();
Counter.Value = (decimal)(ElemCart.Amount??0);
SetLocation(Counter, constnumericX, constnumericY);
Counter.Size = new System.Drawing.Size(40, 20);
form.Controls.Add(Counter);
Counter.ValueChanged += new System.EventHandler(
this.numeric_ValueChanged);
}
//размещения текстового элемента для цены
public void AddLabelPrice()
{
Price = new Label();
Price.Text = ElemCart.Product.Price.ToString() + "руб.";
SetLocation(Price, constlabelX, constlabelY);
Price.Size = new System.Drawing.Size(50, 20);
form.Controls.Add(Price);
}
//размещения элемента Кнопки для удаления
public void AddDeleteButton()
{
DeleteButton = new Button();
DeleteButton.Text = "Удалить";
DeleteButton.BackColor = System.Drawing.Color.OliveDrab;
DeleteButton.ForeColor = System.Drawing.Color.White;
SetLocation(DeleteButton, constbuttonX, constbuttonY);
DeleteButton.Size = new System.Drawing.Size(190, 25);
form.Controls.Add(DeleteButton);
DeleteButton.Click += new System.EventHandler(this.button_Click);
}
//метод настройки размещения элемента
public void SetLocation(Control control, int x, int y)
{
control.Location = new System.Drawing.Point(x,
(y + 75 * Index + 25 * Index));
}
//метод для очистки формы от элементов
public void DeleteAllControls()
{
form.Controls.Remove(Name);
form.Controls.Remove(Counter);
form.Controls.Remove(Price);
form.Controls.Remove(DeleteButton);
}
//события при нажатии на кнопку Удалить
private void button_Click(object sender, EventArgs e)
{
using (WholeSale db = new WholeSale())
{
Cart clientcart = db.Clients.Find(User.Id).Carts.ElementAt(Index);
db.Clients.Find(User.Id).Carts.Remove(clientcart);
db.SaveChanges();
}
ActionAfterDeleteButton();
}
//события при нажатии на измения значения счетчика количества
private void numeric_ValueChanged(object sender, EventArgs e)