137 lines
3.5 KiB
C#
137 lines
3.5 KiB
C#
using SushiBarBusinessLogic;
|
|
using SushiBarContracts.ViewModels;
|
|
|
|
namespace SushiBarView.Forms
|
|
{
|
|
public partial class FormCreateChequeItem : Form
|
|
{
|
|
private readonly List<DishViewModel>? _dishes;
|
|
private readonly List<CookViewModel>? _cooks;
|
|
|
|
public int DishId
|
|
{
|
|
get
|
|
{
|
|
return Convert.ToInt32(DishComboBox.SelectedValue);
|
|
}
|
|
set
|
|
{
|
|
DishComboBox.SelectedValue = value;
|
|
}
|
|
}
|
|
|
|
public int CookId
|
|
{
|
|
get
|
|
{
|
|
return Convert.ToInt32(CookComboBox.SelectedValue);
|
|
}
|
|
set
|
|
{
|
|
CookComboBox.SelectedValue = value;
|
|
}
|
|
}
|
|
|
|
public DishViewModel? DishModel
|
|
{
|
|
get
|
|
{
|
|
if (_dishes == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
foreach (var Elem in _dishes)
|
|
{
|
|
if (Elem.Id == DishId)
|
|
{
|
|
return Elem;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public CookViewModel? CookModel
|
|
{
|
|
get
|
|
{
|
|
if (_cooks == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
foreach (var Elem in _cooks)
|
|
{
|
|
if (Elem.Id == CookId)
|
|
{
|
|
return Elem;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public int Count
|
|
{
|
|
get { return Convert.ToInt32(CountTextBox.Text); }
|
|
set { CountTextBox.Text = value.ToString(); }
|
|
}
|
|
|
|
public FormCreateChequeItem(DishLogic DishLogic, CookLogic CookLogic)
|
|
{
|
|
InitializeComponent();
|
|
|
|
_dishes = DishLogic.ReadList(null);
|
|
if (_dishes != null)
|
|
{
|
|
DishComboBox.DisplayMember = "DishName";
|
|
DishComboBox.ValueMember = "Id";
|
|
DishComboBox.DataSource = _dishes;
|
|
DishComboBox.SelectedItem = null;
|
|
}
|
|
|
|
_cooks = CookLogic.ReadList(null);
|
|
if (_cooks != null)
|
|
{
|
|
CookComboBox.DisplayMember = "Fio";
|
|
CookComboBox.ValueMember = "Id";
|
|
CookComboBox.DataSource = _cooks;
|
|
CookComboBox.SelectedItem = null;
|
|
}
|
|
}
|
|
|
|
private void SaveButton_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(CountTextBox.Text))
|
|
{
|
|
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
|
|
if (DishComboBox.SelectedValue == null)
|
|
{
|
|
MessageBox.Show("Выберите блюдо", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
|
|
if (CookComboBox.SelectedValue == null)
|
|
{
|
|
MessageBox.Show("Выберите повара", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
|
|
DialogResult = DialogResult.OK;
|
|
Close();
|
|
}
|
|
|
|
private void CancelButton_Click(object sender, EventArgs e)
|
|
{
|
|
DialogResult = DialogResult.Cancel;
|
|
Close();
|
|
}
|
|
}
|
|
}
|