private void buttonEdit_Click(object sender, EventArgs e) { if (ListViewSUDENT.SelectedItems.Count == 1) { SUDENT sUDENT = ListViewSUDENT.SelectedItems[0].Tag as SUDENT; sUDENT.LASTNAME = textBoxLASTNAME.Text; sUDENT.NAME = textBoxNAME.Text; sUDENT.IDGRUP = Convert.ToInt32(textBoxGRUP.Text); Program.BD.SaveChanges(); showvis(); } }
private void buttonAdd_Click(object sender, EventArgs e) { SUDENT sUDENT = new SUDENT(); sUDENT.LASTNAME = textBoxLASTNAME.Text; sUDENT.NAME = textBoxNAME.Text; sUDENT.IDGRUP = Convert.ToInt32(comboBoxGRUP.SelectedIndex.ToString().Split()[0]); sUDENT.IDGRUP = Convert.ToInt32(textBoxGRUP.Text); Program.BD.SUDENT.Add(sUDENT); Program.BD.SaveChanges(); showvis(); }
private void ListViewSUDENT_SelectedIndexChanged(object sender, EventArgs e) { if (ListViewSUDENT.SelectedItems.Count == 1) { SUDENT sUDENT = ListViewSUDENT.SelectedItems[0].Tag as SUDENT; textBoxLASTNAME.Text = sUDENT.LASTNAME; textBoxNAME.Text = sUDENT.NAME; textBoxGRUP.Text = Convert.ToString(sUDENT.IDGRUP); } else { textBoxLASTNAME.Text = ""; textBoxNAME.Text = ""; textBoxGRUP.Text = ""; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (ListViewSUDENT.SelectedItems.Count == 1) { SUDENT sUDENT = ListViewSUDENT.SelectedItems[0].Tag as SUDENT; Program.BD.SUDENT.Remove(sUDENT); Program.BD.SaveChanges(); showvis(); } textBoxLASTNAME.Text = ""; textBoxNAME.Text = ""; textBoxGRUP.Text = ""; } catch { MessageBox.Show("не возможно удалить эту запись, эта запись используется!", "ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }