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; using System.Data.OleDb; namespace Accreditation { public partial class LoginForm : Form { public LoginForm() { InitializeComponent(); } private void LoginForm_Load(object sender, EventArgs e) { this.AcceptButton = btnLogin; this.CancelButton = btnCancel; } int ctr; private void btnLogin_Click(object sender, EventArgs e) { OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Accreditation.mdb; User ID=admin; Password=delhigames;"); ctr = ctr + 1; OleDbDataAdapter adp1 = new OleDbDataAdapter("select * from ComLogin", con); DataSet ds1 = new DataSet(); adp1.Fill(ds1, "ComLogin"); if (ds1.Tables.Count > 0) { bool validUser1 = false; validUser1 = false; foreach (DataRow dr in ds1.Tables[0].Rows) { if (dr[0].ToString() == txtUsername.Text && dr[1].ToString() == txtPassword.Text) { validUser1 = true; Visitors frm = new Visitors(); this.Hide(); frm.Show(); } } if (validUser1 == false) { MessageBox.Show("Enter valid User ID/Password!"); } } else { if (ctr < 3) { MessageBox.Show("Incorrect User Name & Password. Please Try again."); txtUsername.Focus(); } else { MessageBox.Show("Unauthorized Access. Aborting.."); this.Close(); } } } private void btnCancel_Click(object sender, EventArgs e) { this.Close(); Application.Exit(); } } }
WHERE
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)