visual studio 2008 etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
visual studio 2008 etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

11 Nisan 2012 Çarşamba

C# Access Random Sayıyla Hedefe Ulaşmak(Timer)



Formun Tamamı İçin Tıklayınız.




# BUTON İÇİ #



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 = 33;
        Class1 nalan = new Class1();

        void gonder()
        {
            nalan.okulnno = textBox1.Text;
            nalan.ad = textBox2.Text;
            nalan.saniye = label3.Text;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            sayac = 33;
            timer1.Stop();
            Class1 nalan = new Class1();
            if (nalan.m == 1)
            {
                textBox1.Clear();
                textBox1.Focus();
            }
            if (nalan.m == 0)
            {
                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();
                label4.Text = nalan.sayilar[9].ToString();          
                timer1.Start();
            }
        }

        private void button8_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                nalan.hedef = label4.Text;
                nalan.say = int.Parse(button8.Text);
                nalan.toplama();
                label5.Text = nalan.sonuc.ToString();
                if (nalan.zaman == 1)
                {
                    timer1.Stop();
                    gonder();
                    nalan.yaz();
                    MessageBox.Show("Tebrikler başardınız...");              
                }
            }                
        }

        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...");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                nalan.hedef = label4.Text;
                nalan.say = int.Parse(button2.Text);
                nalan.toplama();
                label5.Text = nalan.sonuc.ToString();
                if (nalan.zaman == 1)
                {
                    timer1.Stop();
                    gonder();
                    nalan.yaz();
                    MessageBox.Show("Tebrikler başardınız...");
                }
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                nalan.hedef = label4.Text;
                nalan.say = int.Parse(button3.Text);
                nalan.toplama();
                label5.Text = nalan.sonuc.ToString();
                if (nalan.zaman == 1)
                {
                    timer1.Stop();
                    gonder();
                    nalan.yaz();
                    MessageBox.Show("Tebrikler başardınız...");
                }
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                nalan.hedef = label4.Text;
                nalan.say = int.Parse(button4.Text);
                nalan.toplama();
                label5.Text = nalan.sonuc.ToString();
                if (nalan.zaman == 1)
                {
                    timer1.Stop();
                    gonder();
                    nalan.yaz();
                    MessageBox.Show("Tebrikler başardınız...");
                }
            }
        }

        private void button7_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                nalan.hedef = label4.Text;
                nalan.say = int.Parse(button7.Text);
                nalan.toplama();
                label5.Text = nalan.sonuc.ToString();
                if (nalan.zaman == 1)
                {
                    timer1.Stop();
                    gonder();
                    nalan.yaz();
                    MessageBox.Show("Tebrikler başardınız...");
                }
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                nalan.hedef = label4.Text;
                nalan.say = int.Parse(button6.Text);
                nalan.toplama();
                label5.Text = nalan.sonuc.ToString();
                if (nalan.zaman == 1)
                {
                    timer1.Stop();
                    gonder();
                    nalan.yaz();
                    MessageBox.Show("Tebrikler başardınız...");
                }
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                nalan.hedef = label4.Text;
                nalan.say = int.Parse(button5.Text);
                nalan.toplama();
                label5.Text = nalan.sonuc.ToString();
                if (nalan.zaman == 1)
                {
                    timer1.Stop();
                    gonder();
                    nalan.yaz();
                    MessageBox.Show("Tebrikler başardınız...");
                }
            }
        }

        private void button10_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                nalan.hedef = label4.Text;
                nalan.say = int.Parse(button10.Text);
                nalan.toplama();
                label5.Text = nalan.sonuc.ToString();
                if (nalan.zaman == 1)
                {
                    timer1.Stop();
                    gonder();
                    nalan.yaz();
                    MessageBox.Show("Tebrikler başardınız...");
                }
            }
        }

        private void button9_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                nalan.hedef = label4.Text;
                nalan.say = int.Parse(button9.Text);
                nalan.toplama();
                label5.Text = nalan.sonuc.ToString();
                if (nalan.zaman == 1)
                {
                    timer1.Stop();
                    gonder();
                    nalan.yaz();
                    MessageBox.Show("Tebrikler başardınız...");
                }
            }
        }

        private void button11_Click(object sender, EventArgs e)
        {
            nalan.listele(this);
        }
    }
}












# 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 int sonuc;
        public int say;
        public string hedef;
        public int zaman=0;
        public string saniye;
        public void yaz()
        {
            con.Open();
            OleDbDataAdapter da = new OleDbDataAdapter("select * from meltem", con);
            OleDbCommand cmd = new OleDbCommand("insert into meltem(okulno,ad,saniye) values('" + okulnno + "','" + ad + "','"+saniye+"')", 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);
            }
            int d = rasgele.Next(50, 90);
            sayilar.Add(d);//hedef sayı arraylistin sonunda...
        }

        public void toplama()
        {
            sonuc = sonuc + say;
            if (hedef == sonuc.ToString())
            {
                zaman = 1;                           
            }         
        }

        public void listele(Form1 okul)
        {
            okul.listBox1.Items.Clear();
            int m=0;
            con.Open();
            OleDbDataAdapter da = new OleDbDataAdapter("select * from meltem order by saniye desc", con);
            DataSet ds = new DataSet();
            da.Fill(ds, "pakize");
            int k = ds.Tables[0].Rows.Count;
            for (int i = 0; i < k; i++)
            {
                okul.listBox1.Items.Add(++m + ")" + ds.Tables[0].Rows[i][0] + " " + ds.Tables[0].Rows[i][1] + " " + ds.Tables[0].Rows[i][2]);

            }
        }
    }
}

20 Mart 2012 Salı

Visual Studio 2010 Projesini VS 2008 ' de Açmak



Visual Studio 2008 kullananlar için Visual Studio 2010 projesini normal yollardan açamayız. Aşağıdaki yöntemleri yaptıktan sonra 2008 projesiymiş gibi kullanabiliriz.






































19 Mart 2012 Pazartesi

Toplayarak ya da Çarparak Sayıya Ulaşmak


Formun Tamamı iç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;

namespace WindowsFormsApplication47
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        int a = 0;
        int c = 1;
        int b = 0;
        int d = 0;
        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();
            if (radioButton1.Checked)
            {
                Random rd = new Random();
                int sayi = rd.Next(1, 10);
                int sayi1 = rd.Next(1, 10);
                int sayi2 = rd.Next(1, 10);
                int sayi3 = rd.Next(1, 10);
                int sayi4 = rd.Next(1, 10);
                int sayi5 = rd.Next(1, 10);
                int sayi6 = rd.Next(1, 10);
                int sayi7 = rd.Next(1, 10);
                int sayi8 = rd.Next(1, 10);
                int sayi9 = rd.Next(1, 10);
                int sayi14 = rd.Next(1, 10);
                int sayi10 = rd.Next(1, 10);
                int sayi11 = rd.Next(1, 10);
                int sayi12 = rd.Next(1, 10);
                int sayi13 = rd.Next(1, 10);
                int sayi15 = rd.Next(1, 10);
                int sayi16 = rd.Next(1, 10);
                int topla = rd.Next(50, 100);
                button2.Text = sayi.ToString();
                button3.Text = sayi1.ToString();
                button4.Text = sayi2.ToString();
                button5.Text = sayi3.ToString();
                button6.Text = sayi4.ToString();
                button7.Text = sayi5.ToString();
                button8.Text = sayi6.ToString();
                button9.Text = sayi7.ToString();
                button10.Text = sayi8.ToString();
                button11.Text = sayi9.ToString();
                button12.Text = sayi10.ToString();
                button13.Text = sayi13.ToString();
                button14.Text = sayi14.ToString();
                button15.Text = sayi15.ToString();
             
                textBox1.Text = topla.ToString();
            }
            if (radioButton2.Checked)
            {
                Random rd = new Random();
                int sayi = rd.Next(1, 10);
                int sayi1 = rd.Next(1, 10);
                int sayi2 = rd.Next(1, 10);
                int sayi3 = rd.Next(1, 10);
                int sayi4 = rd.Next(1, 10);
                int sayi5 = rd.Next(1, 10);
                int sayi6 = rd.Next(1, 10);
                int sayi7 = rd.Next(1, 10);
                int sayi8 = rd.Next(1, 10);
                int sayi9 = rd.Next(1, 10);
                int sayi14 = rd.Next(1, 10);
                int sayi10 = rd.Next(1, 10);
                int sayi11 = rd.Next(1, 10);
                int sayi12 = rd.Next(1, 10);
                int sayi13 = rd.Next(1, 10);
                int sayi15 = rd.Next(1, 10);
                int sayi16 = rd.Next(1, 10);
                int carp = rd.Next(100, 500);
                button2.Text = sayi.ToString();
                button3.Text = sayi1.ToString();
                button4.Text = sayi2.ToString();
                button5.Text = sayi3.ToString();
                button6.Text = sayi4.ToString();
                button7.Text = sayi5.ToString();
                button8.Text = sayi6.ToString();
                button9.Text = sayi7.ToString();
                button10.Text = sayi8.ToString();
                button11.Text = sayi9.ToString();
                button12.Text = sayi10.ToString();
                button13.Text = sayi13.ToString();
                button14.Text = sayi14.ToString();
                button15.Text = sayi15.ToString();
             
                textBox1.Text = carp.ToString();
            }
            button2.Enabled = true;
            button3.Enabled = true;
            button4.Enabled = true;
            button5.Enabled = true;
            button6.Enabled = true;
            button7.Enabled = true;
            button8.Enabled = true;
            button9.Enabled = true;
            button10.Enabled = true;
            button11.Enabled = true;
            button12.Enabled = true;
            button13.Enabled = true;
            button14.Enabled = true;
            button15.Enabled = true;
         
            a = 0;
            textBox2.Text = "0";
            d = 0;
            label3.Visible = true;
        }
        public void metod()
        {

            if (b == a)
            {
                MessageBox.Show("Bravo");
            }
        }
     


        private void button2_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                a = a + Convert.ToInt32(button2.Text);
                textBox2.Text = a.ToString();
                metod();
            }
            if (radioButton2.Checked)
            {
                c = c * Convert.ToInt32(button2.Text);
                textBox2.Text = c.ToString();
                metod();
            }
            button2.Enabled = false;      
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                a = a + Convert.ToInt32(button3.Text);
                textBox2.Text = a.ToString();
                metod();
            }
            if (radioButton2.Checked)
            {
                c = c * Convert.ToInt32(button3.Text);
                textBox2.Text = c.ToString();
                metod();
            }
            button3.Enabled = false;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                a = a + Convert.ToInt32(button4.Text);
                textBox2.Text = a.ToString();
                metod();
            }
            if (radioButton2.Checked)
            {
                c = c * Convert.ToInt32(button4.Text);
                textBox2.Text = c.ToString();
                metod();
            }
            button4.Enabled = false;
        }

        private void button5_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                a = a + Convert.ToInt32(button5.Text);
                textBox2.Text = a.ToString();
                metod();
            }
            if (radioButton2.Checked)
            {
                c = c * Convert.ToInt32(button5.Text);
                textBox2.Text = c.ToString();
                metod();
            }
            button5.Enabled = false;
        }

        private void button6_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                a = a + Convert.ToInt32(button6.Text);
                textBox2.Text = a.ToString();
                metod();
            }
            if (radioButton2.Checked)
            {
                c= c * Convert.ToInt32(button6.Text);
                textBox2.Text = c.ToString();
                metod();
            }
            button6.Enabled = false;
        }

        private void button7_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                a = a + Convert.ToInt32(button7.Text);
                textBox2.Text = a.ToString();
                metod();
            }
            if (radioButton2.Checked)
            {
                c = c * Convert.ToInt32(button7.Text);
                textBox2.Text = c.ToString();
                metod();
            }
            button7.Enabled = false;
        }

        private void button8_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                a = a + Convert.ToInt32(button8.Text);
                textBox2.Text = a.ToString();
                metod();
            }
            if (radioButton2.Checked)
            {
                c = c * Convert.ToInt32(button8.Text);
                textBox2.Text = c.ToString();
                metod();
            }
            button8.Enabled = false;
        }

        private void button9_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                a = a + Convert.ToInt32(button9.Text);
                textBox2.Text = a.ToString();
                metod();
            }
            if (radioButton2.Checked)
            {
                c = c * Convert.ToInt32(button9.Text);
                textBox2.Text = c.ToString();
                metod();
            }
            button9.Enabled = false;
        }

        private void button10_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                a = a + Convert.ToInt32(button10.Text);
                textBox2.Text = a.ToString();
                metod();
            }
            if (radioButton2.Checked)
            {
                c = c * Convert.ToInt32(button10.Text);
                textBox2.Text = c.ToString();
                metod();
            }
            button10.Enabled = false;
        }

        private void button11_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                a = a + Convert.ToInt32(button11.Text);
                textBox2.Text = a.ToString();
                metod();
            }
            if (radioButton2.Checked)
            {
                c = c * Convert.ToInt32(button11.Text);
                textBox2.Text = c.ToString();
                metod();
            }
            button11.Enabled = false;
        }  

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            b = Convert.ToInt32(textBox1.Text);
        }

        private void button12_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                a = a + Convert.ToInt32(button12.Text);
                textBox2.Text = a.ToString();
                metod();
            }
            if (radioButton2.Checked)
            {
                c = c * Convert.ToInt32(button12.Text);
                textBox2.Text = c.ToString();
                metod();
            }
            button12.Enabled = false;
        }

        private void button13_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                a = a + Convert.ToInt32(button13.Text);
                textBox2.Text = a.ToString();
                metod();
            }
            if (radioButton2.Checked)
            {
                c = c * Convert.ToInt32(button13.Text);
                textBox2.Text = c.ToString();
                metod();
            }
            button13.Enabled = false;
        }

        private void button14_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                a = a + Convert.ToInt32(button14.Text);
                textBox2.Text = a.ToString();
                metod();
            }
            if (radioButton2.Checked)
            {
                c = c * Convert.ToInt32(button14.Text);
                textBox2.Text = c.ToString();
                metod();
            }
            button14.Enabled = false;
        }

        private void button15_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                a = a + Convert.ToInt32(button15.Text);
                textBox2.Text = a.ToString();
                metod();
            }
            if (radioButton2.Checked)
            {
                c = c * Convert.ToInt32(button15.Text);
                textBox2.Text = c.ToString();
                metod();
            }
            button15.Enabled = false;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            d = d + 1;
            label3.Text = d.ToString();
            if (d == 15)
            {
                timer1.Stop();
                button2.Enabled = false;
                button3.Enabled = false;
                button4.Enabled = false;
                button5.Enabled = false;
                button6.Enabled = false;
                button7.Enabled = false;
                button8.Enabled = false;
                button9.Enabled = false;
                button10.Enabled = false;
                button11.Enabled = false;
                button12.Enabled = false;
                button13.Enabled = false;
                button14.Enabled = false;
                button15.Enabled = false;

                MessageBox.Show("Süreniz Bitti Yeniden Başlayın");

            }
            if (b == a)
            {
                timer1.Stop();
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            label3.Visible = false;
         
        }

    }
}


8 Mart 2012 Perşembe

C# Access Bağlantısı ve Soru Cevaplandırma-Değiştirme ve Timer


Formun Tamamı İç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;
using System.Collections;

namespace WindowsFormsApplication59
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        ArrayList say = new ArrayList();
        OleDbConnection con = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=okul.mdb");
        int i = 0;
        int limit;
        int sure = 60;
        string[] cevaplar = new string[101];
        int g = 0;
        private void button1_Click(object sender, EventArgs e)
        {
            con.Open();
            OleDbDataAdapter da = new OleDbDataAdapter("select * from sinif", con);
            DataSet ds = new DataSet();
            da.Fill(ds, "pelin");      
            listBox1.Visible = true;
            listBox1.Items.Clear();
            int m=0;
            for (int j = 0; j < limit; j++)
            {
                if (ds.Tables[0].Rows[j][6].ToString() == cevaplar[j].ToString())
                {
                    listBox1.Items.Add(++m + ".soru DOĞRU");
                }
                else
                {
                    listBox1.Items.Add(++m + ".soru YANLIŞ");
                }
            }            
            con.Close();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            con.Open();
            OleDbDataAdapter da = new OleDbDataAdapter("select * from sinif", con);
            DataSet ds = new DataSet();
            da.Fill(ds, "pelin");
            label1.Text = ds.Tables[0].Rows[i][1].ToString();
            radioButton1.Text = ds.Tables[0].Rows[i][2].ToString();
            radioButton2.Text = ds.Tables[0].Rows[i][3].ToString();
            radioButton3.Text = ds.Tables[0].Rows[i][4].ToString();
            radioButton4.Text = ds.Tables[0].Rows[i][5].ToString();
            timer1.Start();                
            con.Close();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            sure -= 1;
            label2.Text = sure.ToString();
            if (sure == 0)
            {
                timer1.Stop();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            i += 1;
            con.Open();
            OleDbDataAdapter da = new OleDbDataAdapter("select * from sinif", con);
            DataSet ds = new DataSet();
            da.Fill(ds, "pelin");
            limit = ds.Tables[0].Rows.Count;
            if (i >= limit)
            {
                MessageBox.Show("Sorular bitti kontrol et...");
                i = limit-1;
            }
            else
            {
                label1.Text = ds.Tables[0].Rows[i][1].ToString();
                radioButton1.Text = ds.Tables[0].Rows[i][2].ToString();
                radioButton2.Text = ds.Tables[0].Rows[i][3].ToString();
                radioButton3.Text = ds.Tables[0].Rows[i][4].ToString();
                radioButton4.Text = ds.Tables[0].Rows[i][5].ToString();
                g += 1;
            }        
            con.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            i -= 1;
            con.Open();
            OleDbDataAdapter da = new OleDbDataAdapter("select * from sinif", con);
            DataSet ds = new DataSet();
            da.Fill(ds, "pelin");
            if (i <= -1)
            {
                MessageBox.Show("Zaten ilk sorudasın...   ??????");
                i = 0;
            }
            else
            {
                label1.Text = ds.Tables[0].Rows[i][1].ToString();
                radioButton1.Text = ds.Tables[0].Rows[i][2].ToString();
                radioButton2.Text = ds.Tables[0].Rows[i][3].ToString();
                radioButton3.Text = ds.Tables[0].Rows[i][4].ToString();
                radioButton4.Text = ds.Tables[0].Rows[i][5].ToString();
                g -= 1;
            }
            con.Close();
        }

        private void button4_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";
            }
        }
    }
}