private void button1_Click(object sender, EventArgs e)
        {
            baglan.Open();
            SqlCommand    bul          = new SqlCommand("select *from Ogrenci", baglan);
            SqlCommand    kitapsayisil = new SqlCommand("delete from OkumaSayisi where OkulNo=@OkulNo", baglan);
            SqlDataReader oku          = bul.ExecuteReader();
            SqlCommand    sil          = new SqlCommand("delete from Ogrenci where Id=@Id", baglan);
            SqlCommand    kontrol      = new SqlCommand("select *from Durum", baglan);
            SqlDataReader kontroloku   = kontrol.ExecuteReader();

            while (oku.Read())
            {
                if (id == Convert.ToInt32(oku["OkulNo"].ToString()))
                {
                    okulno = Convert.ToInt32(oku["OkulNo"].ToString());
                    while (kontroloku.Read())
                    {
                        if (Convert.ToInt32(kontroloku["OkulNo"].ToString()) == Convert.ToInt32(oku["OkulNo"].ToString()))
                        {
                            sayac++;
                            break;
                        }
                    }

                    if (sayac == 1)
                    {
                        MessageBox.Show("        Şuanda Emanet Kitap Bulunuyor!\n   \t     Silinme Başarısız!");
                    }
                    else
                    {
                        int id = Convert.ToInt32(oku["Id"].ToString());
                        sayac++;
                        if (MessageBox.Show("Öğrenci Bilgileri:\n     Adı: " + oku["Ad"] + "\n     Soyisim: " + oku["Soyad"] + "\n\n          Silinsinmi?", "Öğrenci Sil", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            kitapsayisil.Parameters.Add("@OkulNo", okulno);
                            sil.Parameters.Add("@Id", id);
                            kitapsayisil.ExecuteNonQuery();
                            MessageBox.Show("Öğrenci Silinmiştir.");
                            sil.ExecuteNonQuery();
                            this.Hide();
                            ol.Show();
                            break;
                        }
                    }
                }
            }
            oku.Close();



            baglan.Close();
        }
Exemple #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            OgrListe list = new OgrListe();

            list.Show();
        }