private void buttonEditInfo_Click(object sender, EventArgs e) { if (listViewConsAction.SelectedItems.Count == 1) { ConsultAction ca = listViewConsAction.SelectedItems[0].Tag as ConsultAction; ca.IdSotr = Convert.ToInt32(comboBoxSotr.SelectedItem.ToString().Split('.')[0]); ca.IdAction = Convert.ToInt32(comboBoxAction.SelectedItem.ToString().Split('.')[0]); ca.Qwen = Convert.ToString(textBoxQwen.Text); ca.Actual = Convert.ToInt32(comboBoxActual.Text); Program.ADb.SaveChanges(); ShowConsAct(); } }
private void buttonAddInfo_Click(object sender, EventArgs e) { if (comboBoxAction.SelectedItem != null && comboBoxSotr.SelectedItem != null) { ConsultAction ca = new ConsultAction(); ca.IdSotr = Convert.ToInt32(comboBoxSotr.SelectedItem.ToString().Split('.')[0]); ca.IdAction = Convert.ToInt32(comboBoxAction.SelectedItem.ToString().Split('.')[0]); ca.Qwen = Convert.ToString(textBoxQwen.Text); ca.Actual = Convert.ToInt32(comboBoxActual.Text); Program.ADb.ConsultAction.Add(ca); Program.ADb.SaveChanges(); ShowConsAct(); } else { MessageBox.Show("Данные не выбраны", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void listViewConsAction_SelectedIndexChanged(object sender, EventArgs e) { if (listViewConsAction.SelectedItems.Count == 1) { ConsultAction ca = listViewConsAction.SelectedItems[0].Tag as ConsultAction; comboBoxSotr.SelectedIndex = comboBoxSotr.FindString(ca.IdSotr.ToString()); comboBoxAction.SelectedIndex = comboBoxAction.FindString(ca.IdAction.ToString()); textBoxQwen.Text = ca.Qwen.ToString(); comboBoxActual.Text = ca.Actual.ToString(); } else { comboBoxAction.SelectedItem = null; comboBoxSotr.SelectedItem = null; textBoxQwen.Text = ""; comboBoxActual.Text = ""; } }
private void buttonDelInfo_Click(object sender, EventArgs e) { try { if (listViewConsAction.SelectedItems.Count == 1) { ConsultAction ca = listViewConsAction.SelectedItems[0].Tag as ConsultAction; Program.ADb.ConsultAction.Remove(ca); Program.ADb.SaveChanges(); ShowConsAct(); } comboBoxAction.SelectedItem = null; comboBoxSotr.SelectedItem = null; textBoxQwen.Text = ""; comboBoxActual.Text = ""; } catch { MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }