private void silToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Id"].Value);

            if (id <= 0)
            {
                MessageBox.Show("Silinecek eleman yoktur");
            }
            else
            {
                Kategoriler k = new Kategoriler();
                k.Id = id;
                bool sonuc = kOrm.Delete(k);
                if (sonuc)
                {
                    MessageBox.Show("Kategori Silindi", "Kategori Silme", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dataGridView1.DataSource = kOrm.Select();
                    dataGridView1.Focus();
                }
                else
                {
                    MessageBox.Show("Kategori Silinmedi\n", "Kategori Silme", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
        }
Esempio n. 2
0
 private void silToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count == 0)
     {
         MessageBox.Show("Kayıt Seçiniz");
     }
     else
     {
         Kategoriler kategori = new Kategoriler();
         kategori.Id = int.Parse(dataGridView1.CurrentRow.Cells["Id"].Value.ToString());
         bool sonuc = kOrm.Delete(kategori);
         if (sonuc)
         {
             MessageBox.Show("Kayıt silindi");
             dataGridView1.DataSource = kOrm.Select();
             txt_KategoriAdi.Text     = "";
         }
         else
         {
             MessageBox.Show("Kayıt silinirken bir hata oluştu ");
         }
     }
 }