How to use timer and create login page in c#.net






using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Use_Of_Timer
{
    public partial class Form1 : Form
    {
        public int count = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void btnlogin_Click(object sender, EventArgs e)
        {
            timer.Start();
        }

        private void timer_Tick(object sender, EventArgs e)
        {
            count=count+1;
            if(count<10)
                lbltime.Text = (10 - count).ToString();
            if (count > 10 && count <12)
            {
               
                MessageBox.Show("Time is out ! wait 5 seconds");
                txtpassword.Enabled = false;
                txtusername.Enabled = false;
              

            }
            else if (count == 15)
            {
                count = 0;
                txtusername.Text = "";
                txtpassword.Text = "";
                txtpassword.Enabled = true;
                txtusername.Enabled = true;
                lbltime.Text = "0";
            }
            else
            {
                if (txtusername.Text == "sushil" && txtpassword.Text == "12345")
                {
                    timer.Stop();
                    Form2 o = new Form2();
                    o.Show();
                    this.Hide();
                }
               
            }

        }
    }
}


Comments