Merhaba arkadaşlar2 tane form var form1 ve form2 olarakform1 de listview ve bir buton var. Butona basınca form2 açılıyor ve form 2 de bir tane buton ve 3 tane textbox var ad, soyad, yaş olarakform2'den kayitları girince veritabanına kaydediyor. Form2'den kayıt yaparken listview de var olan kayıt mesajla bildirilsin diyorum ama olmuyor. For döngüsünün olduğu yerde ve altındaki if bloğunda sorun çıkıyor.
[CODE lang="csharp" title="Kodlar"]public void VeriEkle()
{
if (textBox1.Text == "")
{
MessageBox.Show("Adı boş bırakılamaz");
return;
}
if (textBox2.Text == "")
{
MessageBox.Show("Soyadı boş bırakılamaz");
return;
}
if (textBox3.Text == "")
{
MessageBox.Show("Yaşı boş bırakılamaz");
return;
}
else.
{
for (int i = 0; i < f1.listView1.Items.Count; i++)
{
if (textBox1.Text == f1.listView1.Items.SubItems[0].Text)
{
MessageBox.Show("Kayıt Mevcuttur");
}
else.
{
connection.Open();
komut = new OleDbCommand("Insert Into Kisiler (Adi,Soyadi,Yas) Values (q0,@q1,@q2)", connection);
komut.Parameters.AddWithValue("@q0", textBox1.Text);
komut.Parameters.AddWithValue("@q1", textBox2.Text);
komut.Parameters.AddWithValue("@q2", textBox3.Text);
komut.ExecuteNonQuery();
connection.Close();
komut.Dispose();
this.Close();
}
}
}
}[/CODE]
[CODE lang="csharp" title="Kodlar"]public void VeriEkle()
{
if (textBox1.Text == "")
{
MessageBox.Show("Adı boş bırakılamaz");
return;
}
if (textBox2.Text == "")
{
MessageBox.Show("Soyadı boş bırakılamaz");
return;
}
if (textBox3.Text == "")
{
MessageBox.Show("Yaşı boş bırakılamaz");
return;
}
else.
{
for (int i = 0; i < f1.listView1.Items.Count; i++)
{
if (textBox1.Text == f1.listView1.Items.SubItems[0].Text)
{
MessageBox.Show("Kayıt Mevcuttur");
}
else.
{
connection.Open();
komut = new OleDbCommand("Insert Into Kisiler (Adi,Soyadi,Yas) Values (q0,@q1,@q2)", connection);
komut.Parameters.AddWithValue("@q0", textBox1.Text);
komut.Parameters.AddWithValue("@q1", textBox2.Text);
komut.Parameters.AddWithValue("@q2", textBox3.Text);
komut.ExecuteNonQuery();
connection.Close();
komut.Dispose();
this.Close();
}
}
}
}[/CODE]