9 Mayıs 2015 Cumartesi

C# Kullanıcı Giriş Paneli


3 textboxt üç tane buton ekliyoruz. button2(yeni forma geçiş butonu) Visible özelliğini  false yapın.Eğer şifre dogruysa buton görünür ve diğer panele geçiş yapabilirsiniz. Kullanıcı adına istediğinizi yazabilirsiniz. Şifre:1234


Kodlar;



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
    {
        double b;
        string a;
        Random r = new Random();
      
        public Form1()
        {
            InitializeComponent();
        }
      
        private void button1_Click(object sender, EventArgs e)
        {
           if(textBox1.Text!=""&&textBox2.Text!=""&&textBox3.Text!="")
          
            b = double.Parse(textBox2.Text);
            a = (textBox1.Text);
                 
                if ( b == 1234 &&label4.Text==textBox3.Text)
                {
                    button2.Visible = true;          
                }
                else
                {
                    MessageBox.Show("yanlış giriş");
                    label4.Visible = false;
                    label7.Visible = true;
                  
                }
            }       
        private void button2_Click(object sender, EventArgs e)
        {
            Form2 frm2 = new Form2();
            this.Hide();
            frm2.Show();
            frm2.label1.Text = "Hoşgeldin " +  textBox1.Text;
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            int sayi = r.Next(1000, 9999);
            label4.Text = sayi.ToString();
        }
        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            int sayi = r.Next(1000, 9999);
            label4.Text = sayi.ToString();
            button2.Visible = false;
        }
        private void label8_Click(object sender, EventArgs e)
        {
            int sayi = r.Next(1000, 9999);
            label4.Text = sayi.ToString();
        }
    }
}