private void buttonEdit_Click(object sender, EventArgs e) { if (listViewBank.SelectedItems.Count == 1) { BankSet bankSet = listViewBank.SelectedItems[0].Tag as BankSet; bankSet.Job = textBoxJob.Text; bankSet.Income = textBoxIncome.Text; bankSet.Need = textBoxNeed.Text; bankSet.Arranged = textBoxArranged.Text; bankSet.idEmployer = Convert.ToInt32(comboBoxEmployer.SelectedItem.ToString().Split('.')[0]); Program.znt.SaveChanges(); ShowBank(); } }
private void buttonAdd_Click(object sender, EventArgs e) { if (comboBoxEmployer.SelectedItem != null && textBoxJob.Text != "" && textBoxIncome.Text != "" && textBoxNeed.Text != "" && textBoxArranged.Text != "") { BankSet bankSet = new BankSet(); bankSet.Job = textBoxJob.Text; bankSet.Income = textBoxIncome.Text; bankSet.Need = textBoxNeed.Text; bankSet.Arranged = textBoxArranged.Text; bankSet.idEmployer = Convert.ToInt32(comboBoxEmployer.SelectedItem.ToString().Split('.')[0]); Program.znt.BankSet.Add(bankSet); Program.znt.SaveChanges(); ShowBank(); } }
private void listViewBank_SelectedIndexChanged(object sender, EventArgs e) { if (listViewBank.SelectedItems.Count == 1) { BankSet bankSet = listViewBank.SelectedItems[0].Tag as BankSet; comboBoxEmployer.SelectedIndex = comboBoxEmployer.FindString(bankSet.idEmployer.ToString()); textBoxJob.Text = bankSet.Job; textBoxIncome.Text = bankSet.Income; textBoxNeed.Text = bankSet.Need; textBoxArranged.Text = bankSet.Arranged; } else { comboBoxEmployer.SelectedItem = null; textBoxJob.Text = ""; textBoxIncome.Text = ""; textBoxNeed.Text = ""; textBoxArranged.Text = ""; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewBank.SelectedItems.Count == 1) { BankSet bankSet = listViewBank.SelectedItems[0].Tag as BankSet; Program.znt.BankSet.Remove(bankSet); Program.znt.SaveChanges(); ShowBank(); } comboBoxEmployer.SelectedItem = null; textBoxJob.Text = ""; textBoxIncome.Text = ""; textBoxNeed.Text = ""; textBoxArranged.Text = ""; } catch { MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }