public void LoadSettings()
        {
            Reset();

            if (Globals.GetSetting != null)
            {
                DBServer      = Globals.GetSetting("DBServer");
                DBCatalog     = Globals.GetSetting("DBCatalog");
                DBWinSecurity = Globals.GetSetting("DBIntegratedSecurity").SafeInt(1).SafeBool();
                DBUser        = Globals.GetSetting("DBUser");
                if (this.PasswordEncryptionService != null)
                {
                    DBPassword = this.PasswordEncryptionService.DecryptString(Globals.GetSetting("DBPassword").SafeString());
                }

                DBSavePasswords   = Globals.GetSetting("DBSavePasswords").SafeBool();
                ConnectionTimeout = Globals.GetSetting("DBConnectionTimeout").SafeInt(15);
                CommandTimeout    = Globals.GetSetting("DBCommandTimeout").SafeInt(40);
            }
            else if (!String.IsNullOrEmpty(Globals.RegistrySectionKey))
            {
                KSRegistry cReg = new KSRegistry();
                cReg.sectionKey = Globals.RegistrySectionKey;

                cReg.valueKey     = "DBServer";
                cReg.defaultValue = String.Empty;
                DBServer          = cReg.value.SafeString();

                cReg.valueKey     = "DBCatalog";
                cReg.defaultValue = String.Empty;
                DBCatalog         = cReg.value.SafeString();

                cReg.valueKey     = "DBIntegratedSecurity";
                cReg.defaultValue = true;
                DBWinSecurity     = cReg.value.SafeBool();

                cReg.valueKey     = "DBSavePasswords";
                cReg.defaultValue = true;
                DBSavePasswords   = cReg.value.SafeBool();

                cReg.valueKey     = "DBUser";
                cReg.defaultValue = String.Empty;
                DBUser            = cReg.value.SafeString();

                if (this.PasswordEncryptionService != null)
                {
                    cReg.valueKey     = "DBPassword";
                    cReg.defaultValue = String.Empty;
                    DBPassword        = this.PasswordEncryptionService.DecryptString(cReg.value.SafeString());
                }

                cReg.valueKey     = "DBConnectionTimeout";
                cReg.defaultValue = 15;
                ConnectionTimeout = cReg.value.SafeInt(15);

                cReg.valueKey     = "DBCommandTimeout";
                cReg.defaultValue = 40;
                CommandTimeout    = cReg.value.SafeInt(40);
            }
        }
        public void SaveSettings()
        {
            if (Globals.SaveSetting != null)
            {
                Globals.SaveSetting("DBServer", DBServer);
                Globals.SaveSetting("DBPort", DBPort);
                Globals.SaveSetting("DBCatalog", DBCatalog);

                Globals.SaveSetting("DBIntegratedSecurity", DBWinSecurity.ToInt().ToString());

                if (!DBWinSecurity)
                {
                    Globals.SaveSetting("DBSavePasswords", DBSavePasswords.ToInt().ToString());
                    Globals.SaveSetting("DBUser", DBUser);
                    if (CanSavePasswords)
                    {
                        Globals.SaveSetting("DBPassword", this.PasswordEncryptionService.EncryptString(DBPassword));
                    }
                }
                else
                {
                    Globals.SaveSetting("DBSavePasswords", String.Empty);
                    Globals.SaveSetting("DBUser", String.Empty);
                    Globals.SaveSetting("DBPassword", String.Empty);
                }

                Globals.SaveSetting("DBConnectionTimeout", ConnectionTimeout.ToString());
                Globals.SaveSetting("DBCommandTimeout", CommandTimeout.ToString());
            }
            else if (!String.IsNullOrEmpty(Globals.RegistrySectionKey))
            {
                KSRegistry cReg = new KSRegistry();
                cReg.sectionKey = Globals.RegistrySectionKey;

                cReg.valueKey     = "DBServer";
                cReg.defaultValue = String.Empty;
                cReg.value        = DBServer;

                cReg.valueKey     = "DBPort";
                cReg.defaultValue = String.Empty;
                cReg.value        = DBPort;

                cReg.valueKey     = "DBCatalog";
                cReg.defaultValue = String.Empty;
                cReg.value        = DBCatalog;

                cReg.valueKey     = "DBIntegratedSecurity";
                cReg.defaultValue = false;
                cReg.value        = DBWinSecurity;

                if (!DBWinSecurity)
                {
                    cReg.valueKey     = "DBSavePasswords";
                    cReg.defaultValue = false;
                    cReg.value        = DBSavePasswords.ToInt();

                    cReg.valueKey     = "DBUser";
                    cReg.defaultValue = String.Empty;
                    cReg.value        = DBUser;

                    if (CanSavePasswords)
                    {
                        cReg.valueKey     = "DBPassword";
                        cReg.defaultValue = String.Empty;
                        cReg.value        = this.PasswordEncryptionService.EncryptString(DBPassword);
                    }
                }
                else
                {
                    cReg.valueKey     = "DBSavePasswords";
                    cReg.defaultValue = String.Empty;
                    cReg.value        = String.Empty;

                    cReg.valueKey     = "DBUser";
                    cReg.defaultValue = String.Empty;
                    cReg.value        = String.Empty;

                    cReg.valueKey     = "DBPassword";
                    cReg.defaultValue = String.Empty;
                    cReg.value        = String.Empty;
                }

                cReg.valueKey     = "DBConnectionTimeout";
                cReg.defaultValue = 20;
                cReg.value        = ConnectionTimeout;

                cReg.valueKey     = "DBCommandTimeout";
                cReg.defaultValue = 40;
                cReg.value        = CommandTimeout;
            }
        }