private void LBL_BACK_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { this.Hide(); AdminForm af = new AdminForm(); af.Show(); }
private void btnadmin_Click(object sender, EventArgs e) { timer1.Start(); checkBtnToday(); panIcon.Top = btnadmin.Top; panIcon.Visible = true; AdminForm adm = new AdminForm(); adm.Show(); }
private void button1_Click(object sender, EventArgs e) { bool valid = false; int userNdx = -1; int length = UserList.Count; for (int i = 0; i < length; ++i) { if (UsernameText.Text == UserList[i].UserName) { valid = true; userNdx = i; i = length; } } if (valid && (UserList[userNdx].isPassword(passwordText.Text))) { if (UserList[userNdx].Status == "faculty") { FacultyMain fctmain = new FacultyMain(ref Courses, ref UserList, ref UserList[userNdx]); fctmain.Show(); this.Close(); } else if (UserList[userNdx].Status == "admin") { AdminForm adm = new AdminForm(ref Courses, ref UserList, ref UserList[userNdx]); adm.Show(); this.Close(); } else { Form3 frm3 = new Form3(ref Courses, ref UserList, ref UserList[userNdx]); frm3.Show(); this.Close(); } } else { UsernameText.Text = ""; UsernameText.Focus(); passwordText.Text = ""; IncorrectLabel.Visible = true; } }
private void btn_login_Click(object sender, EventArgs e) { FieldValidation FV = new FieldValidation(); if ((FV.isNumber(txt_loginid.Text))) { MessageBox.Show("ENTER ONLY NUMERICS"); } else { try { if (cmbloginas.SelectedItem.ToString().Equals("Administrator")) { using (con = new SqlConnection()) { con.ConnectionString = Properties.Settings.Default.ConnectionString; con.Open(); cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "select count(*) from Administrator where LoginID=@LoginID and password=@password"; cmd.CommandType = CommandType.Text; SqlParameter param1 = new SqlParameter("@LoginID", SqlDbType.VarChar, 20); SqlParameter param2 = new SqlParameter("@password", SqlDbType.VarChar, 20); cmd.Parameters.Add(param1).Value = txt_loginid.Text; cmd.Parameters.Add(param2).Value = txt_pwd.Text; int status = Convert.ToInt32(cmd.ExecuteScalar()); if (status > 0) { AdminForm af = new AdminForm(); af.Show(); } else { MessageBox.Show("Invalid Username or Password"); } con.Close(); } } else if (cmbloginas.SelectedItem.ToString().Equals("Staff")) { using (con = new SqlConnection()) { con.ConnectionString = Properties.Settings.Default.ConnectionString; con.Open(); cmd = new SqlCommand(); cmd.Connection = con; string query = "select count(*) from LoginDetails where LoginID=@LoginID and password=@password"; cmd.CommandText = query; cmd.CommandType = CommandType.Text; SqlParameter param1 = new SqlParameter("@LoginID", SqlDbType.VarChar, 20); SqlParameter param2 = new SqlParameter("@password", SqlDbType.VarChar, 20); cmd.Parameters.Add(param1).Value = txt_loginid.Text; cmd.Parameters.Add(param2).Value = txt_pwd.Text; int status = Convert.ToInt32(cmd.ExecuteScalar()); if (status > 0) { Staff_Home ph = new Staff_Home(); GetLoginID.UserName_Role = txt_loginid.Text; ph.Show(); } else { MessageBox.Show("Invalid Username or Password"); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void button1_Click(object sender, EventArgs e) { bool valid = false; int userNdx = -1; int length = UserList.Count; for(int i = 0; i < length; ++i) { if (UsernameText.Text == UserList[i].UserName) { valid = true; userNdx = i; i = length; } } if (valid && (UserList[userNdx].isPassword(passwordText.Text))) { if (UserList[userNdx].Status == "faculty") { FacultyMain fctmain = new FacultyMain(ref Courses, ref UserList, ref UserList[userNdx] ); fctmain.Show(); this.Close(); } else if (UserList[userNdx].Status == "admin") { AdminForm adm = new AdminForm(ref Courses, ref UserList, ref UserList[userNdx]); adm.Show(); this.Close(); } else { Form3 frm3 = new Form3( ref Courses, ref UserList, ref UserList[userNdx]); frm3.Show(); this.Close(); } } else { UsernameText.Text = ""; UsernameText.Focus(); passwordText.Text = ""; IncorrectLabel.Visible = true; } }
MySqlCommand command; // Used to launch a command to database // Event handler for button click private void button1_Click(object sender, EventArgs e) { // Check if the text boxes have any text if (string.IsNullOrEmpty(textBox1.Text)) { MessageBox.Show("You have to complete the username field!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop); textBox1.Focus(); } else if (string.IsNullOrEmpty(textBox2.Text)) { MessageBox.Show("You have to complete the password field!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop); textBox2.Focus(); } string connectionString = "Server = 127.0.0.1; Port = 3306; Database = db_admin; Uid = root; Pwd=; "; // Details for connection //string connectionString = "Server = 192.168.1.113; Port = 3306; Database = db_A030; Uid = user_A030; Pwd = pass_A030"; string querry = "SELECT userType FROM users WHERE userName = '******' AND userPass = '******'"; // The querry for the database connection = new MySqlConnection(connectionString); // Create a connection with the database command = new MySqlCommand(querry, connection); // Create a command for the database connection.Open(); // Connect to the database string userType = command.ExecuteScalar() as string; // Execute the command and return the result as a string connection.Close(); // Close the connection to the database // Check if any results have been returned. If there is no result, return an error to the user if (string.IsNullOrEmpty(userType)) { MessageBox.Show("Wrong username or password!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Text = ""; textBox2.Text = ""; } // If there is a result, check if the user is an administrator or an user based on what the database returned and // open the form for the administrator or the user else if (userType.Equals("A")) { AdminForm f = new AdminForm(); f.Show(); this.Close(); } else if (userType.Equals("U")) { UserForm f = new UserForm(); f.Show(); this.Close(); } /*if (textBox1.Text == "") * { * MessageBox.Show("You have to complete the username field!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop); * textBox1.Focus(); * } * else if (textBox2.Text == "") * { * MessageBox.Show("You have to complete the password field!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop); * textBox2.Focus(); * } * else if (textBox1.Text == "admin") * { * AdminForm f = new AdminForm(); * f.Show(); * this.Close(); * } * else * { * UserForm f = new UserForm(); * f.Show(); * this.Close(); * }*/ }
// Event handler for button click private void button1_Click(object sender, EventArgs e) { // Check if the text boxes have any text if(string.IsNullOrEmpty(textBox1.Text)) { MessageBox.Show("You have to complete the username field!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop); textBox1.Focus(); } else if(string.IsNullOrEmpty(textBox2.Text)) { MessageBox.Show("You have to complete the password field!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop); textBox2.Focus(); } string connectionString = "Server = 127.0.0.1; Port = 3306; Database = db_admin; Uid = root; Pwd=; "; // Details for connection //string connectionString = "Server = 192.168.1.113; Port = 3306; Database = db_A030; Uid = user_A030; Pwd = pass_A030"; string querry = "SELECT userType FROM users WHERE userName = '******' AND userPass = '******'"; // The querry for the database connection = new MySqlConnection(connectionString); // Create a connection with the database command = new MySqlCommand(querry, connection); // Create a command for the database connection.Open(); // Connect to the database string userType = command.ExecuteScalar() as string; // Execute the command and return the result as a string connection.Close(); // Close the connection to the database // Check if any results have been returned. If there is no result, return an error to the user if (string.IsNullOrEmpty(userType)) { MessageBox.Show("Wrong username or password!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Text = ""; textBox2.Text = ""; } // If there is a result, check if the user is an administrator or an user based on what the database returned and // open the form for the administrator or the user else if (userType.Equals("A")) { AdminForm f = new AdminForm(); f.Show(); this.Close(); } else if (userType.Equals("U")) { UserForm f = new UserForm(); f.Show(); this.Close(); } /*if (textBox1.Text == "") { MessageBox.Show("You have to complete the username field!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop); textBox1.Focus(); } else if (textBox2.Text == "") { MessageBox.Show("You have to complete the password field!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop); textBox2.Focus(); } else if (textBox1.Text == "admin") { AdminForm f = new AdminForm(); f.Show(); this.Close(); } else { UserForm f = new UserForm(); f.Show(); this.Close(); }*/ }