private void buttonAdd_Click(object sender, EventArgs e) { StockroomSet stockroomSet = new StockroomSet(); stockroomSet.IdProduct = Convert.ToInt32(comboBoxNameProduct.SelectedItem.ToString().Split('.')[0]); stockroomSet.IdProvider = Convert.ToInt32(comboBoxNameProvider.SelectedItem.ToString().Split('.')[0]); Program.wFShop.StockroomSet.Add(stockroomSet); Program.wFShop.SaveChanges(); ShowStockRoom(); }
private void buttonEdit_Click(object sender, EventArgs e) { if (listViewStockRoom.SelectedItems.Count == 1) { StockroomSet stockroomSet = listViewStockRoom.SelectedItems[0].Tag as StockroomSet; stockroomSet.IdProduct = Convert.ToInt32(comboBoxNameProduct.SelectedItem.ToString().Split('.')[0]); stockroomSet.IdProvider = Convert.ToInt32(comboBoxNameProvider.SelectedItem.ToString().Split('.')[0]); } Program.wFShop.SaveChanges(); ShowStockRoom(); }
private void listViewStockRoom_SelectedIndexChanged(object sender, EventArgs e) { if (listViewStockRoom.SelectedItems.Count == 1) { StockroomSet stockroomSet = listViewStockRoom.SelectedItems[0].Tag as StockroomSet; comboBoxNameProduct.SelectedIndex = comboBoxNameProduct.FindString(stockroomSet.IdProduct.ToString()); comboBoxNameProvider.SelectedIndex = comboBoxNameProvider.FindString(stockroomSet.IdProvider.ToString()); } else { comboBoxNameProduct = null; comboBoxNameProvider = null; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewStockRoom.SelectedItems.Count == 1) { StockroomSet stockroomSet = listViewStockRoom.SelectedItems[0].Tag as StockroomSet; Program.wFShop.StockroomSet.Remove(stockroomSet); Program.wFShop.SaveChanges(); ShowStockRoom(); } comboBoxNameProduct.SelectedItem = null; comboBoxNameProvider.SelectedItem = null; } catch { MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }