private void txtBoxConnectionString_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtBoxConnectionString.Text)) { btnSaveConnectionStringToFile.Enabled = true; _connectionString = CaesarEncoder.Encrypt(txtBoxConnectionString.Text, true); var connectionSuccessfully = new Repository(_connectionString).CheckConnection(); if (connectionSuccessfully) { lblConnectionStatus.Text = "Подключение к БД успешно установлено"; lblConnectionStatus.ForeColor = Color.ForestGreen; foreach (var tabPage in tabPane.TabPages) { ((TabPage)tabPage).Enabled = true; } } else { lblConnectionStatus.Text = "Подключение к БД отсутствует"; lblConnectionStatus.ForeColor = Color.Red; foreach (var tabPage in tabPane.TabPages) { if (((TabPage)tabPage).Text != "Настройки") { ((TabPage)tabPage).Enabled = false; } } } } }
private void btnGenerateConnectionString_Click(object sender, EventArgs e) { var connectionString = GetConnectionString(string.Empty); if (connectionString != null) { txtBoxConnectionString.Text = CaesarEncoder.Encrypt(connectionString); } }
private void btnLoadSettingsFromFile_Click(object sender, EventArgs e) { var explorer = new OpenFileDialog(); if (explorer.ShowDialog() == DialogResult.OK) { var textFromFile = File.ReadAllText(explorer.FileName); txtBoxConnectionString.Text = textFromFile; _connectionString = CaesarEncoder.Encrypt(textFromFile, true); } }