public void InitControls() { if (this.DatabaseType == DatabaseType.MySql) { this.lblPort.Visible = this.txtPort.Visible = true; this.txtPort.Text = MySqlInterpreter.DEFAULT_PORT.ToString(); this.chkUseSsl.Visible = true; } else if (this.DatabaseType == DatabaseType.Oracle) { this.lblPort.Visible = this.txtPort.Visible = true; this.txtPort.Text = OracleInterpreter.DEFAULT_PORT.ToString(); } var authTypes = Enum.GetNames(typeof(AuthenticationType)); this.cboAuthentication.Items.AddRange(authTypes); if (this.DatabaseType != DatabaseType.SqlServer) { this.cboAuthentication.Text = AuthenticationType.Password.ToString(); //this.cboAuthentication.Enabled = false; } else { this.cboAuthentication.Text = AuthenticationType.IntegratedSecurity.ToString(); } this.chkAsDba.Visible = this.DatabaseType == DatabaseType.Oracle; var profiles = AccountProfileManager.GetProfiles(this.DatabaseType.ToString()); var serverNames = profiles.Select(item => item.Server).Distinct().OrderBy(item => item).ToArray(); this.cboServer.Items.AddRange(serverNames); }
private void LoadAccounts(Guid?defaultValue = default(Guid?)) { string type = this.cboDbType.Text; var profiles = AccountProfileManager.GetProfiles(type).OrderBy(item => item.Description); this.cboAccount.DataSource = profiles.ToList(); this.cboAccount.DisplayMember = nameof(AccountProfileInfo.Description); this.cboAccount.ValueMember = nameof(AccountProfileInfo.Id); List <Guid> ids = profiles.Select(item => item.Id).ToList(); if (!defaultValue.HasValue) { if (profiles.Count() > 0) { this.cboAccount.SelectedIndex = 0; } } else { if (ids.Contains(defaultValue.Value)) { this.cboAccount.Text = profiles.FirstOrDefault(item => item.Id == defaultValue)?.Description; } } btnConnect.Enabled = this.cboAccount.Items.Count > 0; }
private void LoadAccounts() { this.dgvDbConnection.Rows.Clear(); string type = this.cboDbType.Text; var profiles = AccountProfileManager.GetProfiles(type); foreach (AccountProfileInfo profile in profiles) { this.dgvDbConnection.Rows.Add(profile.Id, profile.Server, profile.IntegratedSecurity, profile.UserId); } this.dgvDbConnection.Tag = profiles; }
private void btnConfirm_Click(object sender, EventArgs e) { if (!this.ucAccountInfo.ValidateInfo()) { return; } AccountProfileInfo accountProfileInfo = this.GetAccountProfileInfo(); var profiles = AccountProfileManager.GetProfiles(this.DatabaseType.ToString()); bool isAdd = this.AccountProfileInfo == null; if (isAdd) { if (profiles.Any(item => item.Server == accountProfileInfo.Server && item.IntegratedSecurity == accountProfileInfo.IntegratedSecurity && item.UserId == accountProfileInfo.UserId)) { MessageBox.Show($"The record has already existed:{accountProfileInfo.Description}"); return; } } else { if (profiles.Where(item => item.Id != this.AccountProfileInfo.Id).Any(item => item.Server == accountProfileInfo.Server && item.IntegratedSecurity == accountProfileInfo.IntegratedSecurity && item.UserId == accountProfileInfo.UserId)) { MessageBox.Show($"The record has already existed:{accountProfileInfo.Description}"); return; } } this.AccountProfileId = AccountProfileManager.Save(accountProfileInfo, this.ucAccountInfo.RememberPassword); this.AccountProfileInfo = accountProfileInfo; this.DialogResult = DialogResult.OK; this.Close(); }
private void DeleteConnections(List <Guid> ids) { AccountProfileManager.Delete(ids); }