15 Temmuz 2014 Salı

Doğrulama Kodu Oluşturma

Aşağıdaki tüm kodlar formun içinde yer alır.
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 WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        Form2 form2 = new Form2();

        string sifre;

        string[] k = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "r", "s", "t", "u", "v", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };

        private void button1_Click(object sender, EventArgs e)
        {


            label2.Text = sifre;



            if (textBox1.Text == sifre) { form2.Show(); label2.Text = ""; }

            else
            {
                Random r = new Random();
                sifre = "";
                for (int i = 0; i < 6; i++)
                {
                  
                    sifre += k[r.Next(33)];

                }
               

                label2.Text = sifre;

                label1.Text = "Şifre hatalı";


            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Random r = new Random();

            for (int i = 0; i < 6; i++)

            {

            sifre +=k[r.Next(33)];

            }

            label2.Text = sifre;

           
        }
    }
}
     
   

Kodun Çalıştırılmış Hali



Hiç yorum yok:

Yorum Gönder