private void button7_Click(object sender, EventArgs e) { DialogResult soru = MessageBox.Show("Eski tarama verileri silinsin mi?", "Bildirim", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (soru == DialogResult.Yes) { Ayar ayar = new Ayar(Application.StartupPath + @"\ayar.ini"); ayar.yaz("Genel Ayalar", "NumaraYol", "0"); ayar.yaz("Genel Ayalar", "NumaraIndex", "0"); ayar.yaz("Genel Ayalar", "SorgulananlarYol", "0"); lbl_Durum.ForeColor = Color.DarkGreen; lbl_Durum.Text = "Tarama verileri başarıyla silindi."; MessageBox.Show("Tarama verileri başarıyla silindi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void button4_Click(object sender, EventArgs e) { try { Ayar ayar = new Ayar(Application.StartupPath + @"\ayar.ini"); if (ayar.oku("Genel Ayalar", "NumaraYol") != "0") { DialogResult soru = MessageBox.Show("Eski tarama verileri mevcut devam etmek ister misiniz?", "Bilgi", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (soru == DialogResult.No) { if (listBox1.Items.Count > 1) { textBox3.Clear(); textBox7.Clear(); textBox8.Clear(); textBox9.Clear(); listView1.Items.Clear(); lbl_Durum.ForeColor = Color.DarkGreen; lbl_Durum.Text = "Otomatik numara sorgulama başladı..."; button3.Enabled = false; button4.Enabled = false; listBox1.Enabled = false; listBox1.SelectedIndex = -1; button5.Enabled = true; timer2.Enabled = true; gecenSure = 0; } else { MessageBox.Show("Numara listesi boş taramayı başlatabilmek için numara eklemeniz gerek!", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (soru == DialogResult.Yes) { lbl_Durum.ForeColor = Color.DarkGreen; lbl_Durum.Text = "Otomatik numara sorgulama başladı..."; button3.Enabled = false; button4.Enabled = false; listBox1.Enabled = false; textBox13.Text = ayar.oku("Genel Ayalar", "NumaraYol"); StreamReader oku; oku = File.OpenText(ayar.oku("Genel Ayalar", "NumaraYol")); string yaz; while ((yaz = oku.ReadLine()) != null) { yaz = yaz.Replace("+90", ""); yaz = yaz.Replace("90", ""); string varmı = yaz.Substring(0, 1); if (varmı != "0") { yaz = 0 + yaz; } yaz = yaz.Remove(0, 1); listBox1.Items.Add(yaz.ToString()); } oku.Close(); lbl_Durum.ForeColor = Color.DarkGreen; lbl_Durum.Text = listBox1.Items.Count.ToString() + " adet numara yüklendi.."; textBox2.Text = listBox1.Items.Count.ToString(); listBox1.SelectedIndex = int.Parse(ayar.oku("Genel Ayalar", "NumaraIndex")); button5.Enabled = true; timer2.Enabled = true; gecenSure = 0; } } else { if (listBox1.Items.Count > 1) { if (listView1.Items.Count > 1) { DialogResult soru = MessageBox.Show("Sorgulanan numaralar mevcut.\nYeni tarama başlatmak istiyorsanuz 'Evet' butonuna tıklayınız.\nİstemiyorsanuz 'Hayır' butonuna tıklayarak taramayı kaldığı yerdem devam ettirebilirsiniz.", "Bilgi", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (soru == DialogResult.Yes) { textBox3.Clear(); textBox7.Clear(); textBox8.Clear(); textBox9.Clear(); listView1.Items.Clear(); lbl_Durum.ForeColor = Color.DarkGreen; lbl_Durum.Text = "Otomatik numara sorgulama başladı..."; button3.Enabled = false; button4.Enabled = false; listBox1.Enabled = false; listBox1.SelectedIndex = -1; button5.Enabled = true; timer2.Enabled = true; gecenSure = 0; } else if (soru == DialogResult.No) { lbl_Durum.ForeColor = Color.DarkGreen; lbl_Durum.Text = "Otomatik numara sorgulama başladı..."; button3.Enabled = false; button4.Enabled = false; listBox1.Enabled = false; StreamReader oku; oku = File.OpenText(ayar.oku("Genel Ayalar", "NumaraYol")); string yaz; while ((yaz = oku.ReadLine()) != null) { yaz = yaz.Replace("+90", ""); yaz = yaz.Replace("90", ""); string varmı = yaz.Substring(0, 1); if (varmı != "0") { yaz = 0 + yaz; } yaz = yaz.Remove(0, 1); listBox1.Items.Add(yaz.ToString()); } oku.Close(); lbl_Durum.ForeColor = Color.DarkGreen; lbl_Durum.Text = listBox1.Items.Count.ToString() + " adet numara yüklendi.."; textBox2.Text = listBox1.Items.Count.ToString(); listBox1.SelectedIndex = int.Parse(ayar.oku("Genel Ayalar", "NumaraIndex")); button5.Enabled = true; timer2.Enabled = true; gecenSure = 0; } } else { lbl_Durum.ForeColor = Color.DarkGreen; lbl_Durum.Text = "Otomatik numara sorgulama başladı..."; button3.Enabled = false; button4.Enabled = false; listBox1.Enabled = false; listBox1.SelectedIndex = -1; button5.Enabled = true; timer2.Enabled = true; gecenSure = 0; } } else { MessageBox.Show("Numara listesi boş taramayı başlatabilmek için numara eklemeniz gerek!", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch { } }
void kaydet() { try { Ayar ayar = new Ayar(Application.StartupPath + @"\ayar.ini"); if (listBox1.Items.Count - 1 != listBox1.SelectedIndex) { ayar.yaz("Genel Ayalar", "NumaraYol", textBox13.Text); ayar.yaz("Genel Ayalar", "NumaraIndex", textBox14.Text); DateTime dt = DateTime.Now; string kayitYol = Application.StartupPath + @"\Kayıtlar\Sorgulanan-" + String.Format("{0:M/d/yyyy}", dt) + ".txt"; using (StreamWriter sw = new StreamWriter(kayitYol)) { if (listView1.Items.Count > 0) // listview boş değil ise { StringBuilder sb = new StringBuilder(); foreach (ColumnHeader baslik in listView1.Columns) // columns { sb.Append(string.Format("{0}\t", baslik.Text)); } sw.WriteLine(sb.ToString()); foreach (ListViewItem lvi in listView1.Items) { sb = new StringBuilder(); foreach (ListViewItem.ListViewSubItem listViewSubItem in lvi.SubItems) { sb.Append(string.Format("{0}\t", listViewSubItem.Text)); } sw.WriteLine(sb.ToString()); } sw.WriteLine(); } } ayar.yaz("Genel Ayalar", "SorgulananlarYol", kayitYol); } else { if (timer2.Enabled == false) { ayar.yaz("Genel Ayalar", "NumaraYol", textBox13.Text); ayar.yaz("Genel Ayalar", "NumaraIndex", textBox14.Text); DateTime dt = DateTime.Now; string kayitYol = Application.StartupPath + @"\Kayıtlar\Sorgulanan-" + String.Format("{0:M/d/yyyy}", dt) + ".txt"; using (StreamWriter sw = new StreamWriter(kayitYol)) { if (listView1.Items.Count > 0) // listview boş değil ise { StringBuilder sb = new StringBuilder(); foreach (ColumnHeader baslik in listView1.Columns) // columns { sb.Append(string.Format("{0}\t", baslik.Text)); } sw.WriteLine(sb.ToString()); foreach (ListViewItem lvi in listView1.Items) { sb = new StringBuilder(); foreach (ListViewItem.ListViewSubItem listViewSubItem in lvi.SubItems) { sb.Append(string.Format("{0}\t", listViewSubItem.Text)); } sw.WriteLine(sb.ToString()); } sw.WriteLine(); } } ayar.yaz("Genel Ayalar", "SorgulananlarYol", kayitYol); } } } catch { } }