private void buttonEdit_Click(object sender, EventArgs e) { { if (listViewNal.SelectedItems.Count == 1) { Nalichie nalichie = listViewNal.SelectedItems[0].Tag as Nalichie; nalichie.IdApteka = comboBoxApteka.SelectedItem.ToString()[0]; nalichie.IdLekarstvo = comboBoxLekarstvo.SelectedItem.ToString()[0]; nalichie.Count = textBoxCount.Text; nalichie.Price = textBoxPrice.Text; Program.apteka.SaveChanges(); Nal nal = new Nal(); nal.Show(); this.Hide(); } } }
private void buttonAdd_Click(object sender, EventArgs e) { if (comboBoxApteka.Text == "" || comboBoxLekarstvo.Text == "" || textBoxCount.Text == "" || textBoxPrice.Text == "") { MessageBox.Show("Введите данные", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Nalichie nalichie = new Nalichie(); nalichie.Count = textBoxCount.Text; nalichie.Price = textBoxPrice.Text; nalichie.IdApteka = Convert.ToInt32(comboBoxApteka.SelectedItem.ToString().Split('.')[0]); nalichie.IdLekarstvo = Convert.ToInt32(comboBoxLekarstvo.SelectedItem.ToString().Split('.')[0]); Program.apteka.Nalichie.Add(nalichie); Program.apteka.SaveChanges(); Nal nal = new Nal(); nal.Show(); this.Hide(); } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewNal.SelectedItems.Count == 1) { Nalichie nalichie = listViewNal.SelectedItems[0].Tag as Nalichie; Program.apteka.Nalichie.Remove(nalichie); Program.apteka.SaveChanges(); Nal nal = new Nal(); nal.Show(); this.Hide(); } comboBoxApteka.SelectedItem = null; comboBoxLekarstvo.SelectedItem = null; textBoxCount.Text = ""; textBoxPrice.Text = ""; } catch { MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button3_Click(object sender, EventArgs e) { Form nal = new Nal(); nal.Show(); }