private void LogonButton_Click(object sender, EventArgs e) { if (Application.OpenForms.OfType <LogonForm>().Count() == 0) { form2 = new LogonForm(this, imageDictionary); form2.Show(); } else if (Application.OpenForms.OfType <LogonForm>().Count() == 1) { Application.OpenForms.OfType <LogonForm>().First().BringToFront(); } else //if (Application.OpenForms.OfType<LogonForm>().Count() > 1) { FormCollection fc = Application.OpenForms; foreach (Form frm in fc) { if (frm.GetType() == form2.GetType()) { frm.Close(); } } form2 = new LogonForm(this, imageDictionary); form2.Show(); } }
private void SubmitPatternButton_Click(object sender, EventArgs e) { if (patternLa.Text.Length > 7) { string tempColor = patternLa.Text; string colorCode = encr.encryptString(tempColor); string ImageHash = encr.encryptString(ImageforSegmentation); _cmd.Parameters.Clear(); _con.Open(); _cmd.CommandType = CommandType.StoredProcedure; _cmd.CommandText = "dbo.AddAccount"; _cmd.Connection = _con; _cmd.Parameters.AddWithValue("@UserName", Username); _cmd.Parameters.AddWithValue("@Pass1Textphrase", Password); _cmd.Parameters.AddWithValue("@Pass2Colorcode", tempColor); _cmd.Parameters.AddWithValue("@Pass3Image", ImageHash); _cmd.ExecuteNonQuery(); _con.Close(); MessageBox.Show("## Pattern Set! ##\n# User Successfully Created! #", "User Successfully Created!"); if (Application.OpenForms.OfType <LogonForm>().Count() == 0) { logonForm = new LogonForm(ownerForm, imageDictionary); logonForm.Show(); } else if (Application.OpenForms.OfType <LogonForm>().Count() == 1) { Application.OpenForms.OfType <LogonForm>().First().BringToFront(); } else //if (Application.OpenForms.OfType<LogonForm>().Count() > 1) { FormCollection fc = Application.OpenForms; foreach (Form frm in fc) { if (frm.GetType() == logonForm.GetType()) { frm.Close(); } } logonForm = new LogonForm(ownerForm, imageDictionary); logonForm.Show(); } this.Close(); } }