78 lines
2.4 KiB
C#
78 lines
2.4 KiB
C#
using AccountingWarehouseProductsContracts.BusinessLogicsContracts;
|
|
using AccountingWarehouseProductsContracts.ViewModels;
|
|
using AccountingWarehouseProductsDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace AccountingWarehouseProductsView
|
|
{
|
|
public partial class FormWarehouseProduct : Form
|
|
{
|
|
private readonly List<ProductViewModel?> _list;
|
|
public int Id { get { return Convert.ToInt32(comboBoxProduct.SelectedValue); } set { comboBoxProduct.SelectedValue = value; } }
|
|
|
|
public IProductModel? ProductModel
|
|
{
|
|
get
|
|
{
|
|
if (_list == null)
|
|
{
|
|
return null;
|
|
}
|
|
foreach (var elem in _list)
|
|
{
|
|
if (elem.Id == Id)
|
|
{
|
|
return elem;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public int Count { get { return Convert.ToInt32(textBoxCount.Text); } set { textBoxCount.Text = value.ToString(); } }
|
|
|
|
public FormWarehouseProduct(IProductLogic logic)
|
|
{
|
|
InitializeComponent();
|
|
_list = logic.ReadList(null);
|
|
if (_list != null)
|
|
{
|
|
comboBoxProduct.DisplayMember = "ProductName";
|
|
comboBoxProduct.ValueMember = "Id";
|
|
comboBoxProduct.DataSource = _list;
|
|
comboBoxProduct.SelectedItem = null;
|
|
}
|
|
}
|
|
|
|
private void buttonSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
|
{
|
|
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
if (comboBoxProduct.SelectedValue == null)
|
|
{
|
|
MessageBox.Show("Выберите продукт", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
DialogResult = DialogResult.OK;
|
|
Close();
|
|
}
|
|
|
|
private void buttonCancel_Click(object sender, EventArgs e)
|
|
{
|
|
DialogResult = DialogResult.Cancel;
|
|
Close();
|
|
}
|
|
}
|
|
}
|