private void SelectRecord() { AccountProfileInfo profile = this.GetSelectRecord(); if (profile != null) { this.SelectedAccountProfileInfo = profile; this.DialogResult = DialogResult.OK; this.Close(); } }
private AccountProfileInfo GetSelectRecord() { int count = this.dgvDbConnection.SelectedRows.Count; if (count == 0) { MessageBox.Show("Please select row by clicking row header."); return(null); } Guid id = Guid.Parse(this.dgvDbConnection.SelectedRows[0].Cells["Id"].Value.ToString()); IEnumerable <AccountProfileInfo> profiles = this.dgvDbConnection.Tag as IEnumerable <AccountProfileInfo>; AccountProfileInfo profile = profiles.FirstOrDefault(item => item.Id == id); return(profile); }
private void Edit() { AccountProfileInfo profile = this.GetSelectRecord(); if (profile != null) { frmAccountInfo frmAccountInfo = new frmAccountInfo(ManagerUtil.GetDatabaseType(this.cboDbType.Text), true) { AccountProfileInfo = profile }; if (frmAccountInfo.ShowDialog() == DialogResult.OK) { this.LoadAccounts(); } } }
private AccountProfileInfo GetAccountProfileInfo() { ConnectionInfo connectionInfo = this.ucAccountInfo.GetConnectionInfo(); AccountProfileInfo accountProfileInfo = new AccountProfileInfo() { DatabaseType = this.DatabaseType.ToString() }; ObjectHelper.CopyProperties(connectionInfo, accountProfileInfo); if (this.AccountProfileInfo != null) { accountProfileInfo.Id = this.AccountProfileInfo.Id; } return(accountProfileInfo); }
private async void Connect() { AccountProfileInfo profileInfo = this.cboAccount.SelectedItem as AccountProfileInfo; if (!profileInfo.IntegratedSecurity && string.IsNullOrEmpty(profileInfo.Password)) { MessageBox.Show("Please specify password for the database."); if (!this.SetConnectionInfo(profileInfo)) { return; } } this.btnConnect.Enabled = false; try { ConnectionInfo connectionInfo = new ConnectionInfo(); ObjectHelper.CopyProperties(profileInfo, connectionInfo); await this.tvDbObjects.LoadTree(this.DatabaseType, connectionInfo); } catch (Exception ex) { this.tvDbObjects.ClearNodes(); string message = ExceptionHelper.GetExceptionDetails(ex); LogHelper.LogError(message); MessageBox.Show("Error:" + message); if (!this.SetConnectionInfo(profileInfo)) { return; } else { this.Connect(); } } this.btnConnect.Enabled = true; }
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 bool SetConnectionInfo(AccountProfileInfo accountProfileInfo) { DatabaseType dbType = ManagerUtil.GetDatabaseType(this.cboDbType.Text); frmAccountInfo frmAccountInfo = new frmAccountInfo(dbType, true) { AccountProfileInfo = accountProfileInfo }; DialogResult dialogResult = frmAccountInfo.ShowDialog(); if (dialogResult == DialogResult.OK) { AccountProfileInfo profileInfo = frmAccountInfo.AccountProfileInfo; ObjectHelper.CopyProperties(profileInfo, (this.cboAccount.SelectedItem as AccountProfileInfo)); this.cboAccount.Text = profileInfo.Description; return(true); } else { this.btnConnect.Enabled = true; } return(false); }