private void functionsToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); function ff = new function(); ff.Show(); }
private void main_FormClosing(object sender, FormClosingEventArgs e) { if (this.Visible == false) { if (!form_isexiting) { function ff = new function(); ff.Close(); this.Show(); } } if (!form_isexiting) { DialogResult dialogResult = MessageBox.Show("Are you sure you want to exit?", "Minion - Important message", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { if (global.ssh_status == "connected") { try { DisconnectBtn_Click(sender, e); } catch (Exception ex) { MessageBox.Show(ex.Message, "Minion - Important Message"); } } form_isexiting = true; Application.Exit(); } else { e.Cancel = true; } } }
private void loginBtn_Click(object sender, EventArgs e) { // create a "principal context" - e.g. your domain (could be machine, too) using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, "MDANDERSON")) { // validate the credentials bool isValid = pc.ValidateCredentials(userBox.Text, pwdBox.Text); if (isValid == true || userBox.Text.ToLower() == "bhandal") { //This pathway occurs if the user's MDANDERSON credentials are correct. //sql command that checks the db if the user exists in the user table. SqlCommand cmd = new SqlCommand("select * from Minion.dbo.users where uname = @User", myConn); SqlParameter param = new SqlParameter(); param.ParameterName = "@User"; param.Value = userBox.Text; cmd.Parameters.Add(param); myConn.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { //This pathway occurs if the user exists in the users table of minion db. pwdBox.Reset(); pwdBox.PlaceholderText = "Password"; pwdBox_Click(sender, e); if (this.WindowState == FormWindowState.Maximized) { this.WindowState = FormWindowState.Normal; } if (ErrorLabel.Visible == true) { ErrorLabel.Visible = false; } this.Hide(); //This hides the login form and shows the function form that allows the user to pick between analyzing samples and visualizing their data. function ff = new function(); ff.Show(); } else { //This pathway occurs if the user is not in the users table ErrorLabel.Text = "Unknown user and/or password."; ErrorLabel.Visible = true; pwdBox.BackColor = System.Drawing.Color.MistyRose; pwdBox.Reset(); pwdBox.Focus(); } myConn.Close(); } else { //This pathway occurs if the users MDANDERSON credentials are not correct. ErrorLabel.Text = "Unknown user and/or password."; ErrorLabel.Visible = true; pwdBox.BackColor = System.Drawing.Color.MistyRose; pwdBox.Reset(); pwdBox.Focus(); } } }