private void button1_Click(object sender, EventArgs e) { if (GuncellemeMi == true) { if (result != null) { try { result.UrunAdi = textBox1.Text; result.Fiyat = numericUpDown1.Value; ctx.Entry(result).State = EntityState.Modified; ctx.SaveChanges(); MessageBox.Show("Ürün Güncellendi"); SiparisEkrani s = (SiparisEkrani)Application.OpenForms["SiparisEkrani"]; s.Yenile(); } catch (Exception) { MessageBox.Show("Hata"); } } } else { Urun u = new Urun(); u.Fiyat = numericUpDown1.Value; u.UrunAdi = textBox1.Text; ctx.Urunler.Add(u); ctx.SaveChanges(); MessageBox.Show("Ürün Eklendi"); SiparisEkrani s = (SiparisEkrani)Application.OpenForms["SiparisEkrani"]; s.Yenile(); } }
private void toolStripMenuItem2_Click(object sender, EventArgs e) {//sil Urun u = (Urun)listBox2.SelectedItem; ctx.Urunler.Remove(u); ctx.SaveChanges(); Yenile(); }