Exemplo n.º 1
0
        private void ProfileSaveButton_Click(object sender, EventArgs e)
        {
            if (this.ProfileComboBox.Text.Length > 0)
            {
            }
            else if ((this.ProfileComboBox.Text.Length == 0) && (this.MSSQLServerNameComboBox.Text.Length > 0))
            {
                DateTime localDate = DateTime.Now;
                this.ProfileComboBox.Text = this.MSSQLServerNameComboBox.Text + "-" + localDate.ToShortDateString();
            }
            else
            {
                DateTime localDate = DateTime.Now;
                this.ProfileComboBox.Text = "Default-" + localDate.ToShortDateString();
            }

            foreach (DatabaseSetting DB in this.AllDatabaseSettings.DBList)
            {
                DB.LastUsed = false;
            }

            DatabaseSetting DBSet = FindDBSetting(this.ProfileComboBox.Text);

            if (DBSet == null)
            {
                DatabaseSetting NewDBSet = new DatabaseSetting();
                NewDBSet.SettingName  = this.ProfileComboBox.Text;
                NewDBSet.MSSQLName    = this.MSSQLServerNameComboBox.Text;
                NewDBSet.MSSQLLogin   = this.MSSQLLogin.Text;
                NewDBSet.MSSQLPass    = this.MSSQLPass.Text;
                NewDBSet.MSSQLWInAuth = this.WinAuthCheckBox.Checked;
                NewDBSet.Query        = this.QueryTextBox.Text;
                NewDBSet.LastUsed     = true;
                NewDBSet.Update       = Convert.ToInt32(this.QueryUpdateTime.Text, 10);
                AllDatabaseSettings.SaveDatabaseSetting(NewDBSet);
                this.ProfileComboBox.Items.Add(NewDBSet.SettingName);
            }
            else
            {
                DBSet.SettingName  = this.ProfileComboBox.Text;
                DBSet.MSSQLName    = this.MSSQLServerNameComboBox.Text;
                DBSet.MSSQLLogin   = this.MSSQLLogin.Text;
                DBSet.MSSQLPass    = this.MSSQLPass.Text;
                DBSet.MSSQLWInAuth = this.WinAuthCheckBox.Checked;
                DBSet.Query        = this.QueryTextBox.Text;
                DBSet.Update       = Convert.ToInt32(this.QueryUpdateTime.Text, 10);
                DBSet.LastUsed     = true;
            }
            this.QueryTimerTextBox.Text = this.QueryUpdateTime.Text;
            SaveIntoReg();
        }