private void listView_SelectedIndexChanged(object sender, EventArgs e) { if (listView.SelectedItems.Count == 1) { DealSet deal = listView.SelectedItems[0].Tag as DealSet; comboBoxSupply.SelectedIndex = comboBoxSupply.FindString(deal.idSupply.ToString()); comboBoxDemand.SelectedIndex = comboBoxDemand.FindString(deal.idDemand.ToString()); } }
private void buttonEdit_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count == 1) { DealSet deal = listView.SelectedItems[0].Tag as DealSet; deal.idSupply = Convert.ToInt32(comboBoxSupply.SelectedItem.ToString().Split('.')[0]); deal.idDemand = Convert.ToInt32(comboBoxDemand.SelectedItem.ToString().Split('.')[0]); Program.RPE.SaveChanges(); ShowDealSet(); } }
private void buttonAdd_Click(object sender, EventArgs e) { if (comboBoxDemand.SelectedItem != null && comboBoxSupply.SelectedItem != null) { DealSet deal = new DealSet(); deal.idSupply = Convert.ToInt32(comboBoxSupply.SelectedItem.ToString().Split('.')[0]); deal.idDemand = Convert.ToInt32(comboBoxDemand.SelectedItem.ToString().Split('.')[0]); Program.RPE.DealSet.Add(deal); Program.RPE.SaveChanges(); ShowDealSet(); } else { MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listView.SelectedItems.Count == 1) { DealSet deal = listView.SelectedItems[0].Tag as DealSet; Program.RPE.DealSet.Remove(deal); Program.RPE.SaveChanges(); ShowDealSet(); } } catch { MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }