public LoginForm() { AppDomain.CurrentDomain.SetData("DataDirectory", @Application.StartupPath.Substring(0, (Application.StartupPath.Length - 10))); InitializeComponent(); checkLogin = new RegisterDatasetTableAdapters.LoginCheckTableAdapter(); tblLogin = new RegisterDataset.LoginCheckDataTable(); ddlRole.Items.Insert(0, "Select a role"); ddlRole.SelectedIndex = 0; }
/** * Name:Harsh patel * Description: this below even authiticate users * */ private void btnLogin_Click(object sender, EventArgs e) { if (validateMe()) { string email = txtEmail.Text.Trim(); string password = txtPassword.Text.Trim(); int role = ddlRole.SelectedIndex; tblLogin = checkLogin.GetDataByLogin(email, password, role); if (tblLogin.Count == 1) { Program.UserID = email; MessageBox.Show("Welcome " + email); LoginForm f1 = new LoginForm(); this.Hide(); if (ddlRole.SelectedIndex == 1) { AdminProfile ap = new AdminProfile(); ap.Show(); } else if (ddlRole.SelectedIndex == 2) { WindowsFormsApp1.LibrarianPage librarianPage = new WindowsFormsApp1.LibrarianPage(); librarianPage.Show(); } else if (ddlRole.SelectedIndex == 3) { // Open Librarian Members/Students Page MemberPage mp = new MemberPage(); mp.Show(); } } else { lblErrorMsg.Text = "UserName or Password not correct.. Please Try Again !!"; lblErrorMsg.ForeColor = System.Drawing.Color.Red; txtEmail.Clear(); txtPassword.Clear(); ddlRole.SelectedIndex = 0; txtEmail.Focus(); } } }