Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

Samles Forms Login form

Login Form usingSystem; usingSystem.Drawing; usingSystem.Collections; usingSystem.ComponentModel; usingSystem.Windows.Forms; usingSystem.Data; usingSystem.Data.SqlClient; usingMicrosoft.VisualBasic; Public classForm1 : System.Windows.Forms.Form {

DataSet ds; intcount=0; Form2 f2; privateSystem.Windows.Forms.TextBox textBox1; privateSystem.Windows.Forms.TextBox textBox2; privateSystem.Windows.Forms.Label label1; privateSystem.Windows.Forms.Button button1; privateSystem.Windows.Forms.Button button2; privateSystem.Windows.Forms.ProgressBar progressBar1; privateSystem.Windows.Forms.Timer timer1; privateSystem.Windows.Forms.Label label3; privateSystem.Windows.Forms.Label label2; privateSystem.ComponentModel.IContainer components;static voidMain() { Application. Run (newForm1()); } private voidForm1_Load(objectsender, System.EventArgs e) { SqlConnection con=newSqlConnection("server=.;uid=sa;database=gasagency"); SqlDataAdapter sd=newSqlDataAdapter("select * from login",con); Ds=newDataset(); sd.Fill(ds,"login"); progressBar1.Visible=false; textBox2.PasswordChar='*'; this.Text="LOGIN TO NK GAS AGENCY"; progressBar1.Minimum=0; progressBar1.Maximum=120; } private voidForm1_Closing(objectsender, System.ComponentModel.CancelEventArgs e) { Application.Exit(); } private voidbutton1_Click(objectsender, System.EventArgs e) { Data Table dt=ds.Tables[0]; for each(DataRow drindt.Rows) { if(dr[0].ToString()==textBox1.Text.Trim()) String () ==textBox2.Text.Trim ()) { i=1;progressBar1.Visible=true; label3.Text="Now Loading..... timer1.Start (); } Else

{ i=1; MessageBox.Show("invalid password"); textBox2.Focus(); textBox2.Clear(); count++; } } } if(i!=1) { if(textBox1.Text.Length==0) { MessageBox.Show("enter a user name"); textBox1.Focus(); } Else { MessageBox.Show("Invalid User, User Does not exist"); count++; textBox1.Focus(); textBox1.Clear(); textBox2.Clear(); } } if(count==3) { button1.Enabled=false; } private voidbutton2_Click(objectsender, System.EventArgs e) { Application.Exit(); } private voidtextBox2_KeyDown(objectsender,System.Windows.Forms.KeyEventAr gs e) { if(e.KeyCode==Keys.Enter) { button1_Click(sender,e); } } private voidtimer1_Tick(objectsender, System.EventArgs e) { b u t t o n 2 . E n a b l e d = false; progressBar1.Value+=10; if(progressBar1.Value==120) {

timer1.Stop(); this.Visible=false; f2.Show(); } }

MAIN FORM

You might also like