2024-02-24 21:32:11 +04:00
|
|
|
|
using DinerContracts.BusinessLogicsContacts;
|
|
|
|
|
using DinerContracts.ViewModels;
|
|
|
|
|
using DinerDataModels.Models;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
namespace DinerView
|
|
|
|
|
{
|
|
|
|
|
public partial class FormSnackFood : Form
|
|
|
|
|
{
|
|
|
|
|
private readonly List<FoodViewModel>? _list;
|
|
|
|
|
public int ID
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Convert.ToInt32(comboBoxComponent.SelectedValue);
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
comboBoxComponent.SelectedValue = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public IFoodModel? foodModel
|
|
|
|
|
{
|
|
|
|
|
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 FormSnackFood(IFoodLogic logic)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
_list = logic.ReadList(null);
|
|
|
|
|
if (_list != null)
|
|
|
|
|
{
|
2024-05-01 21:21:08 +04:00
|
|
|
|
comboBoxComponent.DisplayMember = "ComponentName";
|
2024-02-24 21:32:11 +04:00
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|