/
DaNN26
/
sql-utility-manager
Обзор
Документация
Войти
/
DaNN26
/
sql-utility-manager
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Demo/ProductUserControl.cs
121 строка
3 KB
DaNN
Добавьте файлы проекта.
25 май 2026, 17:03
25 май 2026, 17:03
9efb65a
Код
Авторство
О чём код?
using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; namespace Demo { public partial class ProductUserControl: UserControl { string art; MainForm mainForm; public ProductUserControl(string id, MainForm form) { InitializeComponent(); art = id; mainForm = form; } public void SetProduct( string name, string category, string description, string manufacturer, string supplier, string unit, decimal price, int discount, int count, string photoPath ) { lblName.Text = $"{category} | {name}"; lblDesc.Text = $"Описание: {description}"; lblManufacturer.Text = "Производитель: " + manufacturer; lblSupplier.Text = "Поставщик: " + supplier; lblUnit.Text = "Единица измерения: " + unit; lblCount.Text = "Количество на складе: " + count; decimal finalPrice = price - (price * discount / 100); lblDiscount.Text = $"Скидка: {discount}%"; if (discount > 0) { lblOldPrice.Text = $"{price} ₽"; lblOldPrice.Font = new Font(lblOldPrice.Font, FontStyle.Strikeout); lblOldPrice.ForeColor = Color.Red; lblNewPrice.Text = $"{finalPrice} ₽"; lblNewPrice.ForeColor = Color.Black; } else { lblOldPrice.Text = ""; lblNewPrice.Text = $"{price} ₽"; } if (discount > 15) { this.BackColor = ColorTranslator.FromHtml("#E8B757"); } if (count == 0) { lblCount.ForeColor = Color.LightBlue; } try { if (!string.IsNullOrEmpty(photoPath)) { picture.Image = Image.FromFile(@"Images\" + photoPath); } else { picture.Image = Properties.Resources.picture; } } catch { picture.Image = Properties.Resources.picture; } } private void lblNewPrice_Click(object sender, EventArgs e) { } private void ProductUserControl_Load(object sender, EventArgs e) { } private void ProductUserControl_DoubleClick(object sender, EventArgs e) { if (mainForm.role == "Администратор") { EditForm editForm = new EditForm(art, mainForm); if (!editForm.Visible) { editForm.Show(); } else { return; } } else { return; } } } }