private void btnLogin_Click(object sender, EventArgs e) { try { SqlConnection conn = new SqlConnection(returnConnectionString()); string query = "SELECT * FROM tblAdmin WHERE Username = '******'" + " AND PASSWORD = '******'"; conn.Open(); SqlDataAdapter adapter = new SqlDataAdapter(query, conn); DataTable dtbl = new DataTable(); adapter.Fill(dtbl); if (tbUsername.Text.Equals("") || tbPassword.Text.Equals("")) { MessageBox.Show("Please fill out the form!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (dtbl.Rows.Count == 1) { string username = tbUsername.Text; FormControl frmc = new FormControl(); frmc.Username = username; frmc.Show(); this.Hide(); } else { MessageBox.Show("Incorrect Username or Password!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); clear(); } conn.Close(); } catch (SqlException sqlex) { MessageBox.Show("An Error Occured!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); clear(); } }
private void btnInventory_Click(object sender, EventArgs e) { FormControl fc = new FormControl(); fc.btnInventory.PerformClick(); }
private void btnNewUser_Click(object sender, EventArgs e) { FormControl fc = new FormControl(); fc.btnAddUser.PerformClick(); }