Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Hasta hastamiz = new Hasta();

            hastamiz.TCKimlikNo = textBox1.Text;
            hastamiz.Adi        = textBox2.Text;
            hastamiz.Soyadi     = textBox3.Text;
            Randevu r = new Randevu();

            r.Kisi  = hastamiz;
            r.bolum = comboBox1.SelectedItem.ToString();
            r.tarih = dateTimePicker1.Value.ToShortDateString();
            r.saat  = comboBox2.SelectedItem.ToString();

            RandevuSistemi rs    = new RandevuSistemi();
            bool           varMi = rs.BTSArama(r);

            if (varMi == true)
            {
                MessageBox.Show("Secilen Bolume, secilen tarih ve saatte randevu var");
            }
            else
            {
                rs.RandevuEkle(r);
                MessageBox.Show("Randevu alınmıştır");
            }
        }
        public void RandevuEkle(Randevu r)
        {
            Hasta        h            = r.Kisi;
            StreamWriter yazmaNesnesi = new StreamWriter(dosyaYolu, true);
            string       satir        = h.TCKimlikNo + "~" + h.Adi + "~" + h.Soyadi + "~" + r.bolum + "~" + r.tarih + "~" + r.saat;

            yazmaNesnesi.WriteLine(satir);
            yazmaNesnesi.Close();
        }
        public bool BTSArama(Randevu r)
        {
            bool sonuc = false;

            try
            {
                StreamReader okumaNesnesi = new StreamReader(dosyaYolu);
                while (okumaNesnesi.EndOfStream == false)
                {
                    string   satir    = okumaNesnesi.ReadLine();
                    string[] parcalar = satir.Split('~');
                    if ((parcalar[3] == r.bolum) && (parcalar[4] == r.tarih) && (parcalar[5] == r.saat))
                    {
                        sonuc = true;
                    }
                }
                okumaNesnesi.Close();
            }
            catch
            {
                //Error Exception
            }
            return(sonuc);
        }