Пример #1
0
 private void metroButton7_Click(object sender, EventArgs e)
 {
     using (var dbb = new OtelDbcontext())
     {
         var       query = from a in dbb.OtelKayits select a;
         OtelKayit o     = new OtelKayit();
         foreach (var item in query)
         {
             o = item;
             heap.Insert(o);
         }
         HeapSort heapSort = new HeapSort(heap.ReturnHeap());
         //heapler icinde en yuksek otel puanına gore asağıdaki sorted ın içine çeker dizi şeklinde
         HeapDugumu[] sorted = heapSort.Sort();
         foreach (var item in sorted)
         {
             if (item == null)
             {
                 break;
             }
             if (item.otelKayit.Sehir == metroComboBox2.SelectedItem.ToString() || item.otelKayit.Ilce == metroComboBox3.SelectedItem.ToString())
             {
                 lw_otelListesi.Items.Add(item.otelKayit.OtelAd.ToString() + " " + item.otelKayit.OtelPuani.ToString());
             }
         }
     }
 }
Пример #2
0
 private void metroButton1_Click(object sender, EventArgs e)
 {
     using (var db = new OtelBilgiEntities())
     {
         if (string.IsNullOrWhiteSpace(oteladTbox.Text) || string.IsNullOrWhiteSpace(ilTbox.Text) || string.IsNullOrWhiteSpace(ilceTbox.Text) ||
             string.IsNullOrWhiteSpace(adresTxt.Text) || string.IsNullOrWhiteSpace(telefonTbox.Text) || string.IsNullOrWhiteSpace(epostaTbox.Text) ||
             string.IsNullOrWhiteSpace(yildizTbox.Text) || string.IsNullOrWhiteSpace(odaTbox.Text))
         {
             MessageBox.Show("You must fill in the all empty fields");
         }
         else
         {
             string o_Ad = oteladTbox.Text, o_Il = ilTbox.Text, o_Ilce = ilceTbox.Text, o_Adres = adresTxt.Text,
                    o_Tel = telefonTbox.Text, o_EPosta = epostaTbox.Text;
             int o_Yildiz = Convert.ToInt32(yildizTbox.Text), o_Oda = Convert.ToInt32(odaTbox.Text);
             var query1 = new OtelKayit
             {
                 otelAdi      = o_Ad,
                 otelIl       = o_Il,
                 otelIlce     = o_Ilce,
                 otelAdres    = o_Adres,
                 otelTel      = o_Tel,
                 otelEPosta   = o_EPosta,
                 yildizSayisi = o_Yildiz,
                 odaSayisi    = o_Oda
             };
             db.OtelKayits.Add(query1);
             db.SaveChanges();
             MessageBox.Show("Insertion successfully!");
         }
     }
 }
Пример #3
0
        public void AddOtel(int key, OtelKayit value)
        {
            int hash = (key % table.Length);

            while (table[hash] != null && table[hash].Anahtar != key)
            {
                hash = (hash + 1) % table.Length;
            }
            table[hash] = new HashEntry(key, value);
        }
Пример #4
0
 public void Sıralama()
 {
     using (var db = new OtelDbcontext())
     {
         var sorgu = from a in db.OtelKayits.OrderByDescending(p => p.Id) select a;
         Ikili = new IkiliAramaAgaci();
         foreach (var item in sorgu)
         {
             o = item;
             Ikili.Ekle(o);
         }
         Ikili.InOrder();
         MessageBox.Show(Ikili.DugumleriYazdir());
     }
 }
        //Ekleme Islemi

        public string Ekle(OtelKayit otel)
        {
            //Yeni eklenecek dugum icin parent olustur
            IkiliAramaAgacDugumu tempParent = new IkiliAramaAgacDugumu();

            //Kokten basla ve ilerle
            IkiliAramaAgacDugumu tempSearch = kok;

            while (tempSearch != null)
            {
                //null olana kadar parent a at
                tempParent = tempSearch;

                //deger varsa ekleme cik
                if ((int)tempSearch.veri.Id > otel.Id)
                {
                    tempSearch = tempSearch.sol;
                }
                else
                {
                    tempSearch = tempSearch.sag;
                }
            }

            //Eklenecek degeri belirt
            IkiliAramaAgacDugumu eklenecek = new IkiliAramaAgacDugumu(otel);

            //agac bos ise koke ata
            if (kok == null)
            {
                kok = eklenecek;
            }
            else if ((int)tempParent.veri.Id > otel.Id)
            {
                tempParent.sol = eklenecek;
            }
            else
            {
                tempParent.sag = eklenecek;
            }
            return(dugumler += eklenecek.veri.Id.ToString() + " ");
        }
 public HashEntry(int anahtar, OtelKayit deger)
 {
     this.anahtar = anahtar;
     this.deger   = deger;
 }
 public HeapDugumu(OtelKayit otelKayit)
 {
     this.otelKayit = otelKayit;
 }
Пример #8
0
 public IkiliAramaAgacDugumu(OtelKayit veri)
 {
     this.veri = veri;
     sol       = null;
     sag       = null;
 }