private void buttonEdit_Click(object sender, EventArgs e) { ReceptionSet receptionSet = listViewReception.SelectedItems[0].Tag as ReceptionSet; receptionSet.Type = textBoxType.Text; receptionSet.Date = textBoxDate.Text; receptionSet.IdJobless = Convert.ToInt32(comboBoxJobless.SelectedItem.ToString().Split('.')[0]); receptionSet.IdStaff = Convert.ToInt32(comboBoxStaff.SelectedItem.ToString().Split('.')[0]); Program.WFCZN.SaveChanges(); ShowReception(); }
private void button1Add_Click(object sender, EventArgs e) { if (comboBoxStaff.SelectedItem != null && textBoxType.Text != "" && textBoxDate.Text != "" && comboBoxJobless.SelectedItem != null) { ReceptionSet receptionSet = new ReceptionSet(); receptionSet.Type = textBoxType.Text; receptionSet.Date = textBoxDate.Text; receptionSet.IdJobless = Convert.ToInt32(comboBoxJobless.SelectedItem.ToString().Split('.')[0]); receptionSet.IdStaff = Convert.ToInt32(comboBoxStaff.SelectedItem.ToString().Split('.')[0]); Program.WFCZN.ReceptionSet.Add(receptionSet); Program.WFCZN.SaveChanges(); ShowJobless(); } }
private void listViewReception_SelectedIndexChanged(object sender, EventArgs e) { if (listViewReception.SelectedItems.Count == 1) { ReceptionSet receptionSet = listViewReception.SelectedItems[0].Tag as ReceptionSet; textBoxType.Text = receptionSet.Type; textBoxDate.Text = receptionSet.Date; comboBoxJobless.SelectedIndex = comboBoxJobless.FindString(receptionSet.IdJobless.ToString()); comboBoxStaff.SelectedIndex = comboBoxStaff.FindString(receptionSet.IdStaff.ToString()); } else { textBoxType.Text = ""; textBoxDate.Text = ""; comboBoxJobless.Text = null; comboBoxStaff.Text = null; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewReception.SelectedItems.Count == 1) { ReceptionSet receptionSet = listViewReception.SelectedItems[0].Tag as ReceptionSet; Program.WFCZN.ReceptionSet.Remove(receptionSet); Program.WFCZN.SaveChanges(); ShowReception(); } textBoxDate.Text = ""; textBoxType.Text = ""; comboBoxJobless.SelectedItem = null; comboBoxStaff.SelectedItem = null; } catch { MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }