private void btnSave_Click(object sender, EventArgs e) { try { string[] nl = { "SqlConnectionString", "CreatedBy", "CreatedDate" }; string[] vl = { Kryptos.Encrypt(SqlConnectionString, Kryptos.GetHardwareID()), Environment.UserName, DateTime.Now.ToString("F") }; XmlConfigurator.Write("Connections\\" + txtConnectionName.Text + ".config", nl, vl); if (File.Exists("Connections\\" + txtConnectionName.Text + ".config")) { MessageBox.Show("Connection Saved", "New Connection", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// Decrypts a string using laim.utility public static string Decrypt(string value) { return(Kryptos.Decrypt(value, Kryptos.GetHardwareID())); }
private void btnStartProgram_Click(object sender, EventArgs e) { try { if (File.Exists(Local.AppConfig)) { FrmMain frm = new FrmMain { SqlConnection = Kryptos.Decrypt(XmlConfigurator.Read("Connections\\" + cbConnectionList.Text + ".config", "SqlConnectionString"), Kryptos.GetHardwareID()) }; frm.Show(); Hide(); } else { FrmSettings frm = new FrmSettings(); using (frm) { frm.FirstStart = true; frm.ShowDialog(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Uncaught Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }