Formun Tamamı İçin Tıklayınız.
Button
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;
namespace WindowsFormsApplication57
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int sayac = 12;
private void button1_Click(object sender, EventArgs e)
{
sayac = 12;
timer1.Stop();
Class1 nalan = new Class1();
nalan.okulnno = textBox1.Text;
nalan.ad = textBox2.Text;
nalan.yaz();//access e yazdırıyoruz...
if (nalan.m == 1)
{
textBox1.Clear();
textBox1.Focus();
}
if (nalan.m == 0)
{
textBox1.Clear();
textBox2.Clear();
nalan.elif();//sayılar geliyor...
button2.Text = nalan.sayilar[0].ToString();
button3.Text = nalan.sayilar[1].ToString();
button4.Text = nalan.sayilar[2].ToString();
button5.Text = nalan.sayilar[3].ToString();
button6.Text = nalan.sayilar[4].ToString();
button7.Text = nalan.sayilar[5].ToString();
button8.Text = nalan.sayilar[6].ToString();
button9.Text = nalan.sayilar[7].ToString();
button10.Text = nalan.sayilar[8].ToString();
timer1.Start();
}
}
private void button8_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
sayac -= 1;
label3.Text = sayac.ToString();
if (sayac == 0)
{
timer1.Stop();
button2.Enabled = false;
MessageBox.Show("Süreniz doldu...");
}
}
}
}
Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;
using System.Collections;
using System.Windows.Forms;
namespace WindowsFormsApplication57
{
class Class1
{
OleDbConnection con = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=okul.mdb");
public string okulnno,ad;
public int m=0;
public ArrayList sayilar=new ArrayList();
public void yaz()
{
con.Open();
OleDbDataAdapter da = new OleDbDataAdapter("select * from meltem", con);
OleDbCommand cmd = new OleDbCommand("insert into meltem(okulno,ad) values('" + okulnno + "','" + ad + "')", con);
DataSet ds = new DataSet();
da.Fill(ds, "pakize");
int k = ds.Tables[0].Rows.Count;
for (int i = 0; i < k; i++)
{
if (okulnno == ds.Tables[0].Rows[i][0].ToString())
{
m = 1;
}
}
if (m == 1)
{
MessageBox.Show("Başka okul no giriniz");
}
else
{
cmd.ExecuteNonQuery();
}
con.Close();
}
public void elif()
{
Random rasgele = new Random();
for (int j = 1; j <= 9; j++)
{
int c = rasgele.Next(0, 9);
sayilar.Add(c);
}
}
}
}
Hiç yorum yok:
Yorum Gönder