private void button1_Click(object sender, EventArgs e) { String lastNameQuery = searchBox.Text.ToUpper(); PimsMain.Program.currentPatient = null; //Open MainGrid if (PimsMain.Program.currentUser is PIMSController.Volunteer) { PIMS.volunteerGrid volGrid = new PIMS.volunteerGrid(lastNameQuery); volGrid.Visible = true; this.Hide(); } else if (PimsMain.Program.currentUser is PIMSController.Doctor || PimsMain.Program.currentUser is PIMSController.MedStaff || PimsMain.Program.currentUser is PIMSController.OfficeStaff) { PIMS.mainGrid MainGrid = new PIMS.mainGrid(lastNameQuery); MainGrid.Visible = true; //Hide mainForm this.Hide(); } else { // This case should not happen, but here just in case MessageBox.Show("Invalid User! Closing Program", "Invalid User", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } }