private void buttonEdit_Click(object sender, EventArgs e) { if (listViewOrder.SelectedItems.Count == 1) { ProductTraking product = listViewOrder.SelectedItems[0].Tag as ProductTraking; product.IdWorker = Convert.ToInt32(comboBoxWorker.SelectedItem.ToString().Split('.')[0]); product.IdSoups = Convert.ToInt32(comboBoxSoups.SelectedItem.ToString().Split('.')[0]); product.IdSalad = Convert.ToInt32(comboBoxSalad.SelectedItem.ToString().Split('.')[0]); product.IdSecondCourse = Convert.ToInt32(comboBoxSecondCourse.SelectedItem.ToString().Split('.')[0]); product.IdDrink = Convert.ToInt32(comboBoxDrink.SelectedItem.ToString().Split('.')[0]); Program.des.SaveChanges(); ShowProductTraking(); UpdatetextboxPrise(); } }
private void buttonAdd_Click(object sender, EventArgs e) { if (comboBoxWorker.SelectedItem != null && comboBoxSalad.SelectedItem != null && comboBoxSoups.SelectedItem != null && comboBoxSecondCourse.SelectedItem != null && comboBoxDrink.SelectedItem != null) { ProductTraking product = new ProductTraking(); product.IdWorker = Convert.ToInt32(comboBoxWorker.SelectedItem.ToString().Split('.')[0]); product.IdSoups = Convert.ToInt32(comboBoxSoups.SelectedItem.ToString().Split('.')[0]); product.IdSalad = Convert.ToInt32(comboBoxSalad.SelectedItem.ToString().Split('.')[0]); product.IdSecondCourse = Convert.ToInt32(comboBoxSecondCourse.SelectedItem.ToString().Split('.')[0]); product.IdDrink = Convert.ToInt32(comboBoxDrink.SelectedItem.ToString().Split('.')[0]); Program.des.ProductTraking.Add(product); Program.des.SaveChanges(); ShowProductTraking(); UpdatetextboxPrise(); } else { MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void listViewOrder_SelectedIndexChanged(object sender, EventArgs e) { if (listViewOrder.SelectedItems.Count == 1) { ProductTraking product = listViewOrder.SelectedItems[0].Tag as ProductTraking; comboBoxSalad.SelectedIndex = comboBoxSalad.FindString(product.IdSalad.ToString()); comboBoxWorker.SelectedIndex = comboBoxWorker.FindString(product.IdWorker.ToString()); comboBoxSoups.SelectedIndex = comboBoxSoups.FindString(product.IdSoups.ToString()); comboBoxDrink.SelectedIndex = comboBoxDrink.FindString(product.IdDrink.ToString()); comboBoxSecondCourse.SelectedIndex = comboBoxSecondCourse.FindString(product.IdSecondCourse.ToString()); } else { comboBoxSalad.SelectedItem = null; comboBoxSoups.SelectedItem = null; comboBoxWorker.SelectedItem = null; comboBoxDrink.SelectedItem = null; comboBoxSecondCourse.SelectedItem = null; } UpdatetextboxPrise(); }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewOrder.SelectedItems.Count == 1) { ProductTraking product = listViewOrder.SelectedItems[0].Tag as ProductTraking; Program.des.ProductTraking.Remove(product); Program.des.SaveChanges(); ShowProductTraking(); } comboBoxSoups.SelectedItem = null; comboBoxSalad.SelectedItem = null; comboBoxSecondCourse.SelectedItem = null; comboBoxDrink.SelectedItem = null; comboBoxWorker.SelectedItem = null; } catch { MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } UpdatetextboxPrise(); }