2024-05-24 12:23:50 +04:00
|
|
|
|
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
|
|
|
|
using FurnitureAssemblyContracts.ViewModels;
|
|
|
|
|
using FurnitureAssemblyDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection.Metadata.Ecma335;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace FurnitureAssemblyView
|
|
|
|
|
{
|
|
|
|
|
public partial class FormFurnitureWorkPiece : Form
|
|
|
|
|
{
|
2024-05-24 13:05:47 +04:00
|
|
|
|
private readonly List<KommentViewModel>? _list;
|
2024-05-24 12:23:50 +04:00
|
|
|
|
|
|
|
|
|
public int Id
|
|
|
|
|
{
|
|
|
|
|
get { return Convert.ToInt32(comboBoxWorkPiece.SelectedValue); }
|
|
|
|
|
set { comboBoxWorkPiece.SelectedValue = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-24 13:05:47 +04:00
|
|
|
|
public IKommentModel? WorkPieceModel
|
2024-05-24 12:23:50 +04:00
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-24 13:05:47 +04:00
|
|
|
|
public FormFurnitureWorkPiece(IKommentLogic logic)
|
2024-05-24 12:23:50 +04:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
_list = logic.ReadList(null);
|
|
|
|
|
|
|
|
|
|
if (_list != null)
|
|
|
|
|
{
|
|
|
|
|
comboBoxWorkPiece.DisplayMember = "WorkPieceName";
|
|
|
|
|
comboBoxWorkPiece.ValueMember = "Id";
|
|
|
|
|
comboBoxWorkPiece.DataSource = _list;
|
|
|
|
|
comboBoxWorkPiece.SelectedItem = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ButtonSave_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (comboBoxWorkPiece.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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|