private async void mtrBtnEkle_Click(object sender, EventArgs e) { using (FormOdalarEkleDuzenle frm = new FormOdalarEkleDuzenle(new Odalar())) { if (frm.ShowDialog() == DialogResult.OK) { try { bindingSourceOdalar.Add(frm.OdalarBilgi); db.Odalar.Add(frm.OdalarBilgi); await db.SaveChangesAsync(); this.Renklendir(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Mesaj", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private async void mtrBtnDuzenle_Click(object sender, EventArgs e) { Odalar obj = bindingSourceOdalar.Current as Odalar; if (obj != null) { using (FormOdalarEkleDuzenle frm = new FormOdalarEkleDuzenle(obj)) { if (frm.ShowDialog() == DialogResult.OK) { try { bindingSourceOdalar.EndEdit(); await db.SaveChangesAsync(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Mesaj", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }