96 lines
2.6 KiB
C#
96 lines
2.6 KiB
C#
|
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;
|
|||
|
using PrecastConcretePlantContracts.BusinessLogicsContracts;
|
|||
|
using PrecastConcretePlantContracts.ViewModels;
|
|||
|
using PrecastConcretePlantDataModels.Models;
|
|||
|
|
|||
|
namespace PrecastConcretePlantView
|
|||
|
{
|
|||
|
public partial class FormReinforcedComponent : Form
|
|||
|
{
|
|||
|
private readonly List<ComponentViewModel>? _list;
|
|||
|
|
|||
|
public int Id
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return Convert.ToInt32(ComponentComboBox.SelectedValue);
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ComponentComboBox.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(CountTextBox.Text); }
|
|||
|
set { CountTextBox.Text = value.ToString(); }
|
|||
|
}
|
|||
|
|
|||
|
public FormReinforcedComponent(IComponentLogic logic)
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
_list = logic.ReadList(null);
|
|||
|
if (_list != null)
|
|||
|
{
|
|||
|
ComponentComboBox.DisplayMember = "ComponentName";
|
|||
|
ComponentComboBox.ValueMember = "Id";
|
|||
|
ComponentComboBox.DataSource = _list;
|
|||
|
ComponentComboBox.SelectedItem = null;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
private void SaveButton_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (string.IsNullOrEmpty(CountTextBox.Text))
|
|||
|
{
|
|||
|
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (ComponentComboBox.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();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|