private void UserNameTB_Enter(object sender, EventArgs e) { if (UserNameTB.Text == "username") { UserNameTB.Clear(); } UserNameTB.SelectAll(); UserNameTB.Focus(); userPic.BackgroundImage = Properties.Resources.userLogin2; UserNameLn.BackColor = Color.White; UserNameTB.ForeColor = Color.White; passPic.BackgroundImage = Properties.Resources.userPassword; PasswordLn.BackColor = Color.Black; PasswordTB.ForeColor = Color.Black; //wrongTB.Visible = false; }
private void LoginBtn_Click(object sender, EventArgs e) { for (int i = 0; i < 5; i++) { if (dllfile.userN[i] == UserNameTB.Text) { if (dllfile.password[i] == dllfile.Decrypt(PasswordTB.Text)) { MessageBox.Show("Login Successfull"); Purchase pur = new Purchase(); pur.Show(); UserNameTB.Clear(); PasswordTB.Clear(); break; } else { MessageBox.Show("Login Failed"); break; } } } }
private void LoginMethod(String Proc) { try { String ConnString = ConfigurationManager.ConnectionStrings["PayrollConn"].ConnectionString; SqlConnection conn = new SqlConnection(ConnString); SqlDataReader reader; using (conn) { SqlCommand cmd1 = new SqlCommand(Proc, conn); cmd1.CommandType = CommandType.StoredProcedure; cmd1.Parameters.AddWithValue("@UserId", UserNameTB.Text); cmd1.Parameters.AddWithValue("@Pass", PassTB.Text); conn.Open(); reader = cmd1.ExecuteReader(); reader.Read(); if (reader.HasRows) { if (comboBox1.SelectedIndex == 0) { if (AccountTypecomboBox.SelectedIndex == 0) { this.Hide(); AdminPortal Ap = new AdminPortal(); Ap.Show(); } else if (AccountTypecomboBox.SelectedIndex == 1) { this.Hide(); AccountantPortal Ap = new AccountantPortal(); Ap.Show(); } else if (AccountTypecomboBox.SelectedIndex == 2) { this.Hide(); ReceptionestPortal Ap = new ReceptionestPortal(); Ap.Show(); } else if (AccountTypecomboBox.SelectedIndex == 3) { this.Hide(); GeneralEmployeePortal Ap = new GeneralEmployeePortal(UserNameTB.Text); Ap.Show(); } } else { System.Diagnostics.Process.Start(Application.StartupPath + @"\inventorysystem\inventorysystem\bin\Debug\inventorysystem.exe"); UserNameTB.Clear(); PassTB.Clear(); UserNameTB.Focus(); comboBox1.SelectedIndex = 0; } } else { MessageBox.Show(" Wrong User Name or Password, Try again", "Invalid User", MessageBoxButtons.OK, MessageBoxIcon.Information); UserNameTB.Focus(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); UserNameTB.Focus(); } }