using CarServiceContracts.BusinessLogicsContracts; namespace CarServiceView { public partial class FormAddItemForRepairTest : Form { IItemLogic _itemLogic; IRepairRequestLogic _repairRequestLogic; IItemForRepairLogic _itemForRepairLogic; public FormAddItemForRepairTest(IItemLogic itemLogic, IRepairRequestLogic repairRequestLogic, IItemForRepairLogic itemForRepairLogic) { _itemLogic = itemLogic; _repairRequestLogic = repairRequestLogic; _itemForRepairLogic = itemForRepairLogic; InitializeComponent(); } private void FormAddItemForRepairTest_Load(object sender, EventArgs e) { LoadData(); } private void LoadData() { //загружаем заказы var listRR = _repairRequestLogic.ReadList(null); if (listRR != null) { comboBoxRepairRequest.DisplayMember = "Id"; comboBoxRepairRequest.ValueMember = "Id"; comboBoxRepairRequest.DataSource = listRR; comboBoxRepairRequest.SelectedItem = null; } //загружаем статьи затрат var listI = _itemLogic.ReadList(null); if (listI != null) { comboBoxItem.DisplayMember = "Name"; comboBoxItem.ValueMember = "Id"; comboBoxItem.DataSource = listI; comboBoxItem.SelectedItem = null; } } private void buttonAdd_Click(object sender, EventArgs e) { _itemForRepairLogic.Create(new() { Count = Convert.ToInt32(textBoxCount.Text), ItemId = Convert.ToInt32(comboBoxItem.SelectedValue), RepairRequestId = Convert.ToInt32(comboBoxRepairRequest.SelectedValue) }); } } }