|
using System;
using System.Windows.Forms;
namespace AddressBook
{
public partial class frmSettings : Form
{
public frmSettings()
{
InitializeComponent();
}
void LoadSettings(object sender, EventArgs e)
{
if (((ConnectionTypes)DataConnection.ConnectionType) == ConnectionTypes.AccessConnection)
optAccessDatabase.Checked = true;
if (((ConnectionTypes)DataConnection.ConnectionType) == ConnectionTypes.MySQLConnection)
optMySqlConnection.Checked = true;
else optSQLDatabase.Checked = true;
Microsoft.Win32.RegistryKey RegKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (RegKey.GetValue("AddressBook 1.0", null) != null) optRunatCUser.Checked = true;
RegKey.Close();
RegKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (RegKey.GetValue("AddressBook 1.0", null) != null) optRunatAUserStartup.Checked = true;
RegKey.Close();
}
void SaveSettings(object sender, EventArgs e)
{
try
{
Microsoft.Win32.RegistryKey RegKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (optRunatAUserStartup.Checked)
{
RegKey.SetValue("AddressBook 1.0", Environment.GetCommandLineArgs()[0]);
RegKey.Close();
}
else
{
RegKey.DeleteValue("AddressBook 1.0", false);
RegKey.Close();
}
RegKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (optRunatCUser.Checked)
{
RegKey.SetValue("AddressBook 1.0", Environment.GetCommandLineArgs()[0]);
RegKey.Close();
}
else
{
RegKey.DeleteValue("AddressBook 1.0", false);
RegKey.Close();
}
Hide();
Form DatabaseSettings = null;
if (optAccessDatabase.Checked) DatabaseSettings = new frmAccessSettings();
else if (optMySqlConnection.Checked) DatabaseSettings = new frmMySQLSetting();
else DatabaseSettings = new frmSQLSetting();
if (DatabaseSettings.ShowDialog() == DialogResult.Cancel) { this.DialogResult = DialogResult.Cancel; Show(); return; }
Close();
}
catch (Exception Ex) { MessageBox.Show("You do not have sufficient rights to perform this action.\n\nError Message:\n" + Ex.Message, "Access Denied"); this.DialogResult = DialogResult.Cancel; }
}
void CancelSettings(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
void AllUserStartUp_Checked(object sender, EventArgs e)
{
if (optRunatAUserStartup.Checked) optRunatCUser.Checked = optRunatCUser.Enabled = false;
else optRunatCUser.Enabled = true;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Completed B.Com(CS) at DGVC and GNIIT Software Engineering at NIIT. Resident at Chennai and working as a Software Engineer.
Language / Technology :
C#, ADO.NET, ASP.NET, MVC, WCF, ASP, PHP, XML, Java, J2EE, HTML, JavaScript, JQuery, AngularJS, VB Script, C++, MS SQL Server, SSRS, MySql, Oracle, Oracle Forms Development, Windows, Linux.
Click here to view other articles.
Mail Me at: shridhar_tl@ymail.com
Visit my Site: www.iCodeIt.in