private void buttonAdd_Click(object sender, EventArgs e) { WarehouseSet warehouseSet = new WarehouseSet(); warehouseSet.idProduct = Convert.ToInt32(comboBoxProduct.SelectedItem.ToString().Split('.')[0]); warehouseSet.idProvider = Convert.ToInt32(comboBoxProvider.SelectedItem.ToString().Split('.')[0]); Program.master.WarehouseSet.Add(warehouseSet); Program.master.SaveChanges(); ShowPWarehouseSet(); }
private void buttonEdit_Click(object sender, EventArgs e) { if (listViewWarehouse.SelectedItems.Count == 1) { WarehouseSet warehouseSet = listViewWarehouse.SelectedItems[0].Tag as WarehouseSet; warehouseSet.idProduct = Convert.ToInt32(comboBoxProduct.SelectedItem.ToString().Split('.')[0]); warehouseSet.idProvider = Convert.ToInt32(comboBoxProvider.SelectedItem.ToString().Split('.')[0]); Program.master.SaveChanges(); ShowPWarehouseSet(); } }
private void listViewWarehouse_SelectedIndexChanged(object sender, EventArgs e) { if (listViewWarehouse.SelectedItems.Count == 1) { WarehouseSet warehouseSet = listViewWarehouse.SelectedItems[0].Tag as WarehouseSet; comboBoxProduct.SelectedIndex = comboBoxProduct.FindString(warehouseSet.idProduct.ToString()); comboBoxProvider.SelectedIndex = comboBoxProvider.FindString(warehouseSet.idProvider.ToString()); } else { comboBoxProduct.SelectedItem = null; comboBoxProvider.SelectedItem = null; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewWarehouse.SelectedItems.Count == 1) { WarehouseSet warehouseSet = listViewWarehouse.SelectedItems[0].Tag as WarehouseSet; Program.master.WarehouseSet.Remove(warehouseSet); Program.master.SaveChanges(); ShowPWarehouseSet(); } comboBoxProduct.SelectedItem = null; comboBoxProvider.SelectedItem = null; } catch { MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }