15 Temmuz 2014 Salı

Oturum Açma

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 kullanıcışifre
{
    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)
        {
            label6.Text = sifre;

            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" )
            {
                MessageBox.Show("Lütfen boş geçmeyiniz");

            }
            else if (textBox1.Text == "hafize" && textBox2.Text == "12345" && textBox3.Text == sifre)
            {
                
                form2.Show();
                this.Hide();
            }
            else
            {

                   Random r = new Random();
                    sifre = "";// her buton tıklandığında değişmesi için label içini boşaltıp tekrar yazdırıyorum
                    for (int i = 0; i < 6; i++)
                    {

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

                    }


                    label6.Text = sifre; //doğrulama kodunu gösteren label

                    textBox1.Text = "";
                    textBox2.Text = "";
                    textBox3.Text = "";

                    MessageBox.Show("şifreyi yanlış girdiniz");

                }
              
            }
       

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

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

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

            }

            label6.Text = sifre;//doğrulama kodunu gösteren label
        }

      
    }

}

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

















Kullanıcı Adı =hafize
Şifre =12345
Doğrulama kodu da doğru girildiği an 2.form ekranımıza gelir . 

Hiç yorum yok:

Yorum Gönder