private void buttonAdd_Click(object sender, EventArgs e) { UchetPostav up = new UchetPostav(); up.IdPostav = Convert.ToInt32(comboBoxPostav.SelectedItem.ToString().Split('.')[0]); up.DatePostav = textBoxDatePostav.Text; up.Price = textBoxPrice.Text; up.Oborud = textBoxOborud.Text; Program.KPDB.UchetPostav.Add(up); Program.KPDB.SaveChanges(); ShowUchet(); }
private void buttonEdit_Click(object sender, EventArgs e) { if (listViewUchet.SelectedItems.Count == 1) { UchetPostav up = listViewUchet.SelectedItems[0].Tag as UchetPostav; up.IdPostav = Convert.ToInt32(comboBoxPostav.SelectedItem.ToString().Split('.')[0]); up.DatePostav = textBoxDatePostav.Text; up.Price = textBoxPrice.Text; up.Oborud = textBoxOborud.Text; Program.KPDB.SaveChanges(); ShowUchet(); } }
private void listViewUchet_SelectedIndexChanged(object sender, EventArgs e) { if (listViewUchet.SelectedItems.Count == 1) { UchetPostav up = listViewUchet.SelectedItems[0].Tag as UchetPostav; comboBoxPostav.SelectedIndex = comboBoxPostav.FindString(up.IdPostav.ToString()); textBoxDatePostav.Text = up.DatePostav; textBoxPrice.Text = up.Price; textBoxOborud.Text = up.Oborud; } else { comboBoxPostav.SelectedItem = null; textBoxDatePostav.Text = ""; textBoxPrice.Text = ""; textBoxOborud.Text = ""; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewUchet.SelectedItems.Count == 1) { UchetPostav up = listViewUchet.SelectedItems[0].Tag as UchetPostav; Program.KPDB.UchetPostav.Remove(up); Program.KPDB.SaveChanges(); ShowUchet(); } comboBoxPostav.SelectedItem = null; textBoxDatePostav.Text = ""; textBoxPrice.Text = ""; textBoxOborud.Text = ""; } catch { MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }