Formun Tamami İçin Tıklayınız.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsFormsApplication31
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int g = 0;
int i = 0;
int limit;
string[] cevaplar = new string[100];
OleDbConnection baglan = new OleDbConnection("provider=microsoft.ace.oledb.12.0;data source=asd.accdb");
private void button1_Click(object sender, EventArgs e)
{
int m = 0;
baglan.Open();
OleDbDataAdapter adap = new OleDbDataAdapter("select * from bilgi", baglan);
DataSet ds = new DataSet();
adap.Fill(ds, "qwe");
OleDbCommand komut = new OleDbCommand("insert into bilgi(a,b,c,d,soru,dcevap,soruno)values('" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + richTextBox1.Text + "','" + textBox6.Text + "','" + textBox1.Text + "')", baglan);
int a = ds.Tables[0].Rows.Count;
for (int i = 0; i < a; i++)
{
if (textBox1.Text == ds.Tables[0].Rows[i][6].ToString())
{
m = 1;
}
}
if (m == 1)
{
MessageBox.Show("Böyle Bir 'Soru No' Var Başka No Giriniz..");
textBox1.Clear();
textBox1.Focus();
}
if (m == 0)
{
komut.ExecuteNonQuery();
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
textBox6.Clear();
richTextBox1.Clear();
}
baglan.Close();
}
private void button3_Click(object sender, EventArgs e)
{
panel1.Visible = true;
panel2.Visible = false;
}
private void button4_Click(object sender, EventArgs e)
{
panel2.Visible = true;
panel1.Visible = false;
baglan.Open();
OleDbDataAdapter adap = new OleDbDataAdapter("select * from bilgi", baglan);
DataSet ds = new DataSet();
adap.Fill(ds, "qwe");
label8.Text = ds.Tables[0].Rows[i][4].ToString();
radioButton1.Text = ds.Tables[0].Rows[i][0].ToString();
radioButton2.Text = ds.Tables[0].Rows[i][1].ToString();
radioButton3.Text = ds.Tables[0].Rows[i][2].ToString();
radioButton4.Text = ds.Tables[0].Rows[i][3].ToString();
baglan.Close();
}
private void button10_Click(object sender, EventArgs e)
{
baglan.Open();
OleDbDataAdapter adap = new OleDbDataAdapter("select * from bilgi", baglan);
DataSet ds = new DataSet();
adap.Fill(ds, "qwe");
int a = ds.Tables[0].Rows.Count;
for (int i = 0; i < a; i++)
{
if (textBox1.Text == ds.Tables[0].Rows[i][6].ToString())
{
textBox2.Text = ds.Tables[0].Rows[i][0].ToString();
textBox3.Text = ds.Tables[0].Rows[i][1].ToString();
textBox4.Text = ds.Tables[0].Rows[i][2].ToString();
textBox5.Text = ds.Tables[0].Rows[i][3].ToString();
richTextBox1.Text = ds.Tables[0].Rows[i][4].ToString();
textBox6.Text = ds.Tables[0].Rows[i][5].ToString();
}
}
baglan.Close();
}
private void button2_Click(object sender, EventArgs e)
{
baglan.Open();
OleDbDataAdapter adap = new OleDbDataAdapter("select * from bilgi", baglan);
DataSet ds = new DataSet();
adap.Fill(ds, "qwe");
OleDbCommand komut = new OleDbCommand("update bilgi set a='"+textBox2.Text+"',b='"+textBox3.Text+"',c='"+textBox4.Text+"',d='"+textBox5.Text+"',soru='"+richTextBox1.Text+"',dcevap='"+textBox6.Text+"'where soruno='"+textBox1.Text+"'",baglan);
komut.ExecuteNonQuery();
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
textBox6.Clear();
richTextBox1.Clear();
baglan.Close();
}
private void button9_Click(object sender, EventArgs e)
{
baglan.Open();
OleDbCommand komut = new OleDbCommand("delete * from bilgi where soruno='" + textBox1.Text + "'", baglan);
komut.ExecuteNonQuery();
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
textBox6.Clear();
richTextBox1.Clear();
baglan.Close();
}
private void button5_Click(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
cevaplar[g] = "1";
}
if (radioButton2.Checked)
{
cevaplar[g] = "2";
}
if (radioButton3.Checked)
{
cevaplar[g] = "3";
}
if (radioButton4.Checked)
{
cevaplar[g] = "4";
}
}
private void button6_Click(object sender, EventArgs e)
{
i += 1;
baglan.Open();
OleDbDataAdapter adap = new OleDbDataAdapter("select * from bilgi", baglan);
DataSet ds = new DataSet();
adap.Fill(ds, "asd");
limit = ds.Tables[0].Rows.Count;
if (i >= limit)
{
MessageBox.Show("Sorular bitti kontrol et...");
i = limit - 1;
}
else
{
label8.Text = ds.Tables[0].Rows[i][4].ToString();
radioButton1.Text = ds.Tables[0].Rows[i][0].ToString();
radioButton2.Text = ds.Tables[0].Rows[i][1].ToString();
radioButton3.Text = ds.Tables[0].Rows[i][2].ToString();
radioButton4.Text = ds.Tables[0].Rows[i][3].ToString();
g += 1;
}
baglan.Close();
}
private void button7_Click(object sender, EventArgs e)
{
i -= 1;
baglan.Open();
OleDbDataAdapter adap = new OleDbDataAdapter("select * from bilgi", baglan);
DataSet ds = new DataSet();
adap.Fill(ds, "ertq");
if (i <= -1)
{
MessageBox.Show("İlk Sorudasınız ...");
i = 0;
}
else
{
label8.Text = ds.Tables[0].Rows[i][4].ToString();
radioButton1.Text = ds.Tables[0].Rows[i][0].ToString();
radioButton2.Text = ds.Tables[0].Rows[i][1].ToString();
radioButton3.Text = ds.Tables[0].Rows[i][2].ToString();
radioButton4.Text = ds.Tables[0].Rows[i][3].ToString();
g -= 1;
}
baglan.Close();
}
private void button8_Click(object sender, EventArgs e)
{
int ee=0;
baglan.Open();
OleDbDataAdapter adap = new OleDbDataAdapter("select * from bilgi", baglan);
DataSet ds = new DataSet();
adap.Fill(ds, "qwe");
int b = ds.Tables[0].Rows.Count;
for (int k = 0; k < b; k++)
{
if (cevaplar[k] == ds.Tables[0].Rows[k][5].ToString())
{
listBox1.Items.Add(++ee + ")" + "Doğru Bildiniz..");
}
if (cevaplar[k] != ds.Tables[0].Rows[k][5].ToString())
{
listBox1.Items.Add(++ee + ")" + "Yanlış Bildiniz...");
}
}
baglan.Close();
}
}
}
Hiç yorum yok:
Yorum Gönder