private void buttonEdit_Click(object sender, EventArgs e) { if (listViewComeback.SelectedItems.Count == 1) { ComebackSet comeback = listViewComeback.SelectedItems[0].Tag as ComebackSet; comeback.idNameMaterial = Convert.ToInt32(comboBoxMaterials.SelectedItem.ToString().Split('.')[0]); comeback.idClient = Convert.ToInt32(comboBoxClients.SelectedItem.ToString().Split('.')[0]); comeback.idStaff = Convert.ToInt32(comboBoxStaff.SelectedItem.ToString().Split('.')[0]); Program.wftDb.SaveChanges(); ShowComeback(); } }
private void listViewComeback_SelectedIndexChanged(object sender, EventArgs e) { if (listViewComeback.SelectedItems.Count == 1) { ComebackSet comeback = listViewComeback.SelectedItems[0].Tag as ComebackSet; comboBoxMaterials.SelectedIndex = comboBoxMaterials.FindString(comeback.idNameMaterial.ToString()); comboBoxClients.SelectedIndex = comboBoxClients.FindString(comeback.idClient.ToString()); comboBoxStaff.SelectedIndex = comboBoxStaff.FindString(comeback.idStaff.ToString()); } else { comboBoxMaterials.SelectedItem = null; comboBoxClients.SelectedItem = null; comboBoxStaff.SelectedItem = null; } }
private void buttonAdd_Click(object sender, EventArgs e) { if (comboBoxMaterials.SelectedItem != null && comboBoxStaff.SelectedItem != null && comboBoxClients.SelectedItem != null) { ComebackSet comeback = new ComebackSet(); comeback.idNameMaterial = Convert.ToInt32(comboBoxMaterials.SelectedItem.ToString().Split('.')[0]); comeback.idClient = Convert.ToInt32(comboBoxClients.SelectedItem.ToString().Split('.')[0]); comeback.idStaff = Convert.ToInt32(comboBoxStaff.SelectedItem.ToString().Split('.')[0]); Program.wftDb.ComebackSet.Add(comeback); Program.wftDb.SaveChanges(); ShowComeback(); } else { MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewComeback.SelectedItems.Count == 1) { ComebackSet comeback = listViewComeback.SelectedItems[0].Tag as ComebackSet; Program.wftDb.ComebackSet.Remove(comeback); Program.wftDb.SaveChanges(); ShowComeback(); } comboBoxMaterials.SelectedItem = null; comboBoxClients.SelectedItem = null; comboBoxStaff.SelectedItem = null; } catch { MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }