2024-02-06 23:13:36 +04:00
|
|
|
|
using FishFactoryContracts.BusinessLogicsContracts;
|
|
|
|
|
using FishFactoryContracts.ViewModels;
|
|
|
|
|
using FishFactoryDataModel.Models;
|
|
|
|
|
using System;
|
2024-02-05 19:09:54 +04:00
|
|
|
|
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 FishFactory.Forms
|
|
|
|
|
{
|
|
|
|
|
public partial class FormCannedComponent : Form
|
|
|
|
|
{
|
2024-02-06 23:13:36 +04:00
|
|
|
|
private readonly List<ComponentViewModel>? _list;
|
|
|
|
|
public int Id
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Convert.ToInt32(comboBoxComponent.SelectedValue);
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
comboBoxComponent.SelectedValue = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public IComponentModel? ComponentModel
|
|
|
|
|
{
|
|
|
|
|
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 FormCannedComponent(IComponentLogic logic)
|
2024-02-05 19:09:54 +04:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2024-02-06 23:13:36 +04:00
|
|
|
|
|
|
|
|
|
_list = logic.ReadList(null);
|
|
|
|
|
if (_list != null)
|
|
|
|
|
{
|
|
|
|
|
comboBoxComponent.DisplayMember = "ComponentName";
|
|
|
|
|
comboBoxComponent.ValueMember = "Id";
|
|
|
|
|
comboBoxComponent.DataSource = _list;
|
|
|
|
|
comboBoxComponent.SelectedItem = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonSave_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (comboBoxComponent.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();
|
2024-02-05 19:09:54 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|