//Opens file dialog to choose database private void Choose_Database_Button_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal).ToString(); ofd.Filter = "Database File (*.db)|*.db"; ofd.Title = "Choose Database to connect to"; DialogResult result = ofd.ShowDialog(); if (result == DialogResult.OK) { Global.connectionPath = ofd.FileName; Global.connectionString = Global.connection1 + Global.connectionPath + Global.connection2; Global.writeDatafile("ConnectionString.dat", Global.connectionPath); } else if (result == DialogResult.Cancel) { return; } //Once chosen returns to Initial_Screen this.Hide(); Initial_Screen initial = new Initial_Screen(); initial.ShowDialog(); initial.Focus(); }
//Validates the username and password. Launches initial screen if successful private void Login_Button_Click(object sender, EventArgs e) { //Stops method if testConnection Fails if (testConnection() == false) { return; } //Error if all fields are not filled in if (string.IsNullOrWhiteSpace(Username_Input.Text) || string.IsNullOrWhiteSpace(Password_Input.Text)) { MessageBox.Show("All fields need to be filled in", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Gets username and password Global.userId = UserDatabase.GetUserIdByUsernameAndPassword(Username_Input.Text, Password_Input.Text); //Error if username and password dont match if (Global.userId == 0) { MessageBox.Show("The password or username was incorrect. Check if caps lock is on.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Gets the users name and logs inot intial screen else { Initial_Screen firstScreen = new Initial_Screen(); this.Hide(); firstScreen.ShowDialog(); firstScreen.Focus(); } }
//Returns to intitial screen private void Back_Click(object sender, EventArgs e) { this.Hide(); Initial_Screen initial = new Initial_Screen(); initial.ShowDialog(); initial.Focus(); }
//Return to the previous screen private void Back_Click(object sender, EventArgs e) { Global.addConsultationOpen = false; this.Hide(); Initial_Screen initial = new Initial_Screen(); initial.ShowDialog(); initial.Focus(); }
//********************Other Form and Object Event Methods******************** //Return to the previous screen or to Add Reffering GP private void Back_Click(object sender, EventArgs e) { if (Global.addRefferingGPOpen == true) { this.Close(); } else { this.Hide(); Initial_Screen initial = new Initial_Screen(); initial.ShowDialog(); initial.Focus(); } }
//********************Event Methods******************** //Loads eitther Initial_Screen or closes form private void Back_Click(object sender, EventArgs e) { Global.editingExistingClass = false; //If addnewTime is open then the form will just close as addnew time form will be visible in the background if (Global.addNewTimeOpen == true || Global.addEditTimeOpen == true) { this.Close(); } else { this.Hide(); Initial_Screen initial = new Initial_Screen(); initial.ShowDialog(); initial.Focus(); } }
//Return to the previous screen private void Back_Click(object sender, EventArgs e) { //Handles whether to revert back to initial sceen or back to consultation form Global.addPatientOpen = false; if (Global.addConsultationOpen == true) { this.Close(); } else { this.Hide(); Initial_Screen initial = new Initial_Screen(); initial.ShowDialog(); initial.Focus(); } }