private void btnHome_Click(object sender, EventArgs e) { Home_Admin home = new Home_Admin(); home.Show(); this.Hide(); }
private void btnLogin_Click(object sender, EventArgs e) { string status = "user"; if (chkAdmin.Checked) { status = "admin"; } else { status = "user"; } using (sqlConnection = new MySqlConnection(connectionString)) { try { sqlConnection.Open(); sqlAdapter = new MySqlDataAdapter("LoginAuthentication", sqlConnection); sqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure; sqlAdapter.SelectCommand.Parameters.AddWithValue("_name", txtUserName.Text.Trim()); sqlAdapter.SelectCommand.Parameters.AddWithValue("_password", txtPassword.Text.Trim()); sqlAdapter.SelectCommand.Parameters.AddWithValue("_status", status); DataTable sqlTable = new DataTable(); sqlAdapter.Fill(sqlTable); if (sqlTable.Rows.Count > 0) { this.Hide(); if (status == "admin") { Home_Admin home = new Home_Admin(); _theStatus = "admin"; home.Show(); } else if (status == "user") { Home_Admin home = new Home_Admin(); _theStatus = "user"; home.Show(); } } else { MessageBox.Show("failed authorization"); txtPassword.Text = txtUserName.Text = ""; } sqlConnection.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }