Пример #1
0
 private void btn_DosyaSec_Click(object sender, EventArgs e)
 {
     ofd.Filter = "Text Files (*.txt)|*.txt";
     if (ofd.ShowDialog() == DialogResult.OK)
     {
         //System.IO.FileInfo File = new System.IO.FileInfo(ofd.FileName);
         UrunTXTReader reader = new UrunTXTReader();
         //reader.fromTxtToTree(ofd.FileName,bst,dt);
         txt_Dosya.Text = ofd.FileName;
     }
 }
Пример #2
0
        //int satilanTop;
        //int satilanMaliyet;

        private void btn_YeniEkle_Click(object sender, EventArgs e)
        {
            if (txt_Dosya.Text != "")
            {
                //Dictionary<string, List<Urun>> dt = new Dictionary<string, List<Urun>>();

                UrunTXTReader reader = new UrunTXTReader();
                try
                {
                    reader.fromTxtToTree(txt_Dosya.Text, bst, dt);
                    MessageBox.Show("Ürünler başarıyla eklendi.");
                }
                catch (FileNotFoundException ex)
                {
                    Console.WriteLine("[Data File Missing] {0}", ex);
                    throw new FileNotFoundException(@"[urunler.txt not in c:\temp directory]", ex);
                }
            }
            else
            {
                Dictionary <string, List <Urun> > dt = new Dictionary <string, List <Urun> >();
                char[] delimiterChars = { '\'', ',' };

                if (!bst.contains(txt_UrunAdi.Text))
                {
                    Urun urun = new Urun();

                    urun.setUrunAdi(txt_UrunAdi.Text);
                    urun.setUrunKategori(txt_UrunKategori.Text);
                    urun.setMarka(txt_UrunMarka.Text);
                    urun.setModel(txt_UrunModel.Text);
                    urun.setMiktar(Convert.ToInt32(txt_UrunMiktar.Text));
                    urun.setMaliyet(Convert.ToInt32(txt_UrunMaliyet.Text));
                    urun.setSatisFiyatı(Convert.ToInt32(txt_UrunSatisFiyati.Text));

                    string[]      words = txt_UrunAciklama.Text.Split(delimiterChars);
                    List <string> lst   = new List <string>();
                    foreach (string str in words)
                    {
                        if (str == null)
                        {
                            break;
                        }

                        lst.Add(str);

                        if (!dt.ContainsKey(str))
                        {
                            List <Urun> hList = new List <Urun>();
                            hList.Add(urun);
                            dt.Add(str, hList);
                        }
                        else
                        {
                            dt[str].Add(urun);
                        }
                    }
                    urun.setAciklama(lst);
                    bst.put(urun);
                    MessageBox.Show(txt_UrunAdi.Text + " ürünü başarıyla eklendi.");
                    temizle();
                }
                else
                {
                    Urun urun = new Urun();
                    urun = bst.get(txt_UrunAdi.Text);

                    List <TheOthers> digerleri = new List <TheOthers>();
                    TheOthers        to        = new TheOthers();
                    to.setMarka(txt_UrunMarka.Text);
                    to.setModel(txt_UrunModel.Text);
                    to.setMiktar(Convert.ToInt32(txt_UrunMiktar.Text));
                    to.setMaliyet(Convert.ToInt32(txt_UrunMaliyet.Text));
                    to.setSatisFiyatı(Convert.ToInt32(txt_UrunSatisFiyati.Text));

                    string[]      words = txt_UrunAciklama.Text.Split(delimiterChars);
                    List <string> lst   = new List <string>();
                    foreach (string str in words)
                    {
                        if (str == null)
                        {
                            break;
                        }

                        lst.Add(str);

                        if (!dt.ContainsKey(str))
                        {
                            List <Urun> hList = new List <Urun>();
                            hList.Add(urun);
                            dt.Add(str, hList);
                        }
                        else
                        {
                            dt[str].Add(urun);
                        }
                    }
                    to.setAciklama(lst);

                    digerleri.Add(to);
                    urun.setDigerleri(digerleri);
                    MessageBox.Show(txt_UrunAdi.Text + " ürünü başarıyla eklendi.");
                    temizle();
                }
            }
        }