private void buttonAdd_Click(object sender, EventArgs e) { GetOborudovanie go = new GetOborudovanie(); go.IdPostav = Convert.ToInt32(comboBoxPostav.SelectedItem.ToString().Split('.')[0]); go.IdSotr = Convert.ToInt32(comboBoxSotr.SelectedItem.ToString().Split('.')[0]); go.IdObor = Convert.ToInt32(comboBoxOborud.SelectedItem.ToString().Split('.')[0]); go.Price = textBoxPriceOborud.Text; go.DateVid = textBoxDateVid.Text; Program.KPDB.GetOborudovanie.Add(go); Program.KPDB.SaveChanges(); ShowGet(); }
private void buttonEdit_Click(object sender, EventArgs e) { if (listViewGet.SelectedItems.Count == 1) { GetOborudovanie go = listViewGet.SelectedItems[0].Tag as GetOborudovanie; go.IdPostav = Convert.ToInt32(comboBoxPostav.SelectedItem.ToString().Split('.')[0]); go.IdSotr = Convert.ToInt32(comboBoxSotr.SelectedItem.ToString().Split('.')[0]); go.IdObor = Convert.ToInt32(comboBoxOborud.SelectedItem.ToString().Split('.')[0]); go.Price = textBoxPriceOborud.Text; go.DateVid = textBoxDateVid.Text; Program.KPDB.SaveChanges(); ShowGet(); } }
private void listViewGet_SelectedIndexChanged(object sender, EventArgs e) { if (listViewGet.SelectedItems.Count == 1) { GetOborudovanie go = listViewGet.SelectedItems[0].Tag as GetOborudovanie; comboBoxPostav.SelectedIndex = comboBoxPostav.FindString(go.IdPostav.ToString()); comboBoxSotr.SelectedIndex = comboBoxSotr.FindString(go.IdSotr.ToString()); comboBoxOborud.SelectedIndex = comboBoxOborud.FindString(go.IdObor.ToString()); textBoxPriceOborud.Text = go.Price; textBoxDateVid.Text = go.DateVid; } else { comboBoxPostav.SelectedItem = null; comboBoxSotr.SelectedItem = null; comboBoxOborud.SelectedItem = null; textBoxPriceOborud.Text = ""; textBoxDateVid.Text = ""; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewGet.SelectedItems.Count == 1) { GetOborudovanie go = listViewGet.SelectedItems[0].Tag as GetOborudovanie; Program.KPDB.GetOborudovanie.Remove(go); Program.KPDB.SaveChanges(); ShowGet(); } comboBoxPostav.SelectedItem = null; comboBoxSotr.SelectedItem = null; comboBoxOborud.SelectedItem = null; textBoxPriceOborud.Text = ""; textBoxDateVid.Text = ""; } catch { MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }