public string SMTPConfig = "smtp.config"; // mail server, the configuration file for storing the SMTP information for emailing public string SaveConfig(string config, string[] nl, string[] vl) { try { if (config == "servers") { XmlConfigurator.Write(dc.Config + ServerConfig, nl, vl); return("configsaved"); } else if (config == "smtp") { XmlConfigurator.Write(dc.Config + SMTPConfig, nl, vl); return("configsaved"); } else if (config == "spm") { XmlConfigurator.Write(dc.Config + AppConfig, nl, vl); return("configsaved"); } else { return(""); } } catch (Exception ex) { return(ex.Message); } }
private void btnSaveSettings_Click(object sender, EventArgs e) { try { if (cblReportingTableDesign.SelectedIndex < 0 || txtReportingWorkbookCompany.Text.Length < 0 || txtReportingWorkbookTitle.Text.Length < 0 || txtReportingWorksheetName.Text.Length < 0) { MessageBox.Show("One or more required entries are empty.", "Save Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); tcAppSettings.SelectedIndex = 1; } else { // memory saving check boxes string[] NodeList = { "HiddenColumnsAppList", "HiddenColumnsAppListRules", "HiddenColumnsAppUnassignedList", "ReportingTableDesign", "ReportingWorkbookTitle", "ReportingWorkbookCompany", "ReportingWorksheetName", "DatabaseCommandTimeout", "MemorySavingDoubleBuffer" }; string[] ValueList = { txtAppListColumns.Text, txtAppListRulesColumns.Text, txtUnassignedAppListColumns.Text, cblReportingTableDesign.Text, txtReportingWorkbookTitle.Text, txtReportingWorkbookCompany.Text, txtReportingWorksheetName.Text, Convert.ToString(numDatabaseCommandTimeout.Value), Convert.ToString(MemorySavingDoubleBufferCheck()) }; XmlConfigurator.Write(Local.AppConfig, NodeList, ValueList); if (FirstStart == false) { MessageBox.Show("Application Restart required for changes to take affect.", "Save Settings", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Configuration Complete", "First Run", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Uncaught Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
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); } }