2024-02-26 10:12:21 +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
|
|
|
|
|
{
|
|
|
|
|
private readonly List<WorkPieceViewModel>? _list;
|
|
|
|
|
|
2024-05-11 23:46:17 +04:00
|
|
|
|
public int Id { get { return Convert.ToInt32(comboBoxWorkPiece.SelectedValue); }
|
|
|
|
|
set { comboBoxWorkPiece.SelectedValue = value; } }
|
2024-02-26 10:12:21 +04:00
|
|
|
|
|
|
|
|
|
public IWorkPieceModel? WorkPieceModel
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2024-05-11 23:46:17 +04:00
|
|
|
|
if(_list == null)
|
2024-02-26 10:12:21 +04:00
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-11 23:46:17 +04:00
|
|
|
|
foreach(var elem in _list)
|
2024-02-26 10:12:21 +04:00
|
|
|
|
{
|
2024-05-11 23:46:17 +04:00
|
|
|
|
if(elem.Id == Id)
|
2024-02-26 10:12:21 +04:00
|
|
|
|
{
|
|
|
|
|
return elem;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-11 23:46:17 +04:00
|
|
|
|
public int Count { get { return Convert.ToInt32(textBoxCount.Text); } set {
|
|
|
|
|
textBoxCount.Text = value.ToString(); } }
|
2024-02-26 10:12:21 +04:00
|
|
|
|
|
|
|
|
|
public FormFurnitureWorkPiece(IWorkPieceLogic logic)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
_list = logic.ReadList(null);
|
|
|
|
|
|
2024-05-11 23:46:17 +04:00
|
|
|
|
if(_list != null)
|
2024-02-26 10:12:21 +04:00
|
|
|
|
{
|
|
|
|
|
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);
|
2024-05-11 23:46:17 +04:00
|
|
|
|
|
2024-02-26 10:12:21 +04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (comboBoxWorkPiece.SelectedValue == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Выберите заготовку", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2024-05-11 23:46:17 +04:00
|
|
|
|
|
2024-02-26 10:12:21 +04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DialogResult = DialogResult.OK;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DialogResult = DialogResult.Cancel;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|