private void buttonEdit_Click(object sender, EventArgs e) { if (listViewSuppy.SelectedItems.Count == 1) { try { if (comboBoxClients.Text == "" || comboBoxUslugi1c.Text == "" || comboBoxDelovoePO.Text == "" || comboBoxKA.Text == "") { throw new Exception("Заполните все поля!"); } SupplySet supply = listViewSuppy.SelectedItems[0].Tag as SupplySet; supply.IdClient = Convert.ToInt32(comboBoxClients.SelectedItem.ToString().Split('.')[0]); supply.IdTable_1 = Convert.ToInt32(comboBoxUslugi1c.SelectedItem.ToString().Split('.')[0]); supply.IdDelovoePO = Convert.ToInt32(comboBoxDelovoePO.SelectedItem.ToString().Split('.')[0]); supply.IdKompleksnayaAvtomatizasia = Convert.ToInt32(comboBoxKA.SelectedItem.ToString().Split('.')[0]); Program.rbs.SaveChanges(); ShowSupplySet(); } catch (Exception ex) { MessageBox.Show("" + ex.Message, "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void listViewSuppy_SelectedIndexChanged(object sender, EventArgs e) { if (listViewSuppy.SelectedItems.Count == 1) { SupplySet supply = listViewSuppy.SelectedItems[0].Tag as SupplySet; comboBoxClients.SelectedIndex = comboBoxClients.FindString(supply.IdClient.ToString()); comboBoxUslugi1c.SelectedIndex = comboBoxUslugi1c.FindString(supply.IdTable_1.ToString()); comboBoxDelovoePO.SelectedIndex = comboBoxDelovoePO.FindString(supply.IdDelovoePO.ToString()); comboBoxKA.SelectedIndex = comboBoxKA.FindString(supply.IdKompleksnayaAvtomatizasia.ToString()); } else { comboBoxClients.SelectedItem = null; comboBoxUslugi1c.SelectedItem = null; comboBoxDelovoePO.SelectedItem = null; comboBoxKA.SelectedItem = null; } }
private void buttonAdd_Click(object sender, EventArgs e) { if (comboBoxClients.SelectedItem != null && comboBoxUslugi1c.SelectedItem != null && comboBoxDelovoePO.SelectedItem != null && comboBoxKA.SelectedItem != null) { SupplySet supply = new SupplySet(); supply.IdClient = Convert.ToInt32(comboBoxClients.SelectedItem.ToString().Split('.')[0]); supply.IdTable_1 = Convert.ToInt32(comboBoxUslugi1c.SelectedItem.ToString().Split('.')[0]); supply.IdDelovoePO = Convert.ToInt32(comboBoxDelovoePO.SelectedItem.ToString().Split('.')[0]); supply.IdKompleksnayaAvtomatizasia = Convert.ToInt32(comboBoxKA.SelectedItem.ToString().Split('.')[0]); Program.rbs.SupplySet.Add(supply); Program.rbs.SaveChanges(); ShowSupplySet(); } else { MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewSuppy.SelectedItems.Count == 1) { SupplySet supply = listViewSuppy.SelectedItems[0].Tag as SupplySet; Program.rbs.SupplySet.Remove(supply); Program.rbs.SaveChanges(); ShowSupplySet(); } comboBoxUslugi1c.SelectedItem = null; comboBoxClients.SelectedItem = null; comboBoxDelovoePO.SelectedItem = null; comboBoxKA.SelectedItem = null; } catch { MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }