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 WindowsFormsApplication3
{
public partial class Form1 : Form
{
int c = 0; // it is counter variable
string uid = "hithin";
string pwd = "hithin";
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//string uid = "hithin";
// string pwd = "hithin";
if((textBox1.Text!="")&&(textBox2.Text!=""))
{
c = c + 1;
if ((textBox2.Text ==uid)&&(textBox1.Text == pwd))
{
c = 0;
MessageBox.Show("valid user attempts"+c);
}
else
if (c <= 3)
{
MessageBox.Show("invalid user attempts:" + c);
textBox1.Clear();// used to clear text box1
textBox2.Clear();//used to clear text box2
}
else
{
MessageBox.Show("application is terminating:");
this.Close();//used to close the running application
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
label3.Text = "";
textBox1.PasswordChar = '*';
}
}
}
No comments:
Post a Comment