private void CurrentSQLConnectionStore_EvntConfigChanged(object sender, BoolEventArgs args) { ISQLConnectionSettings oldSettings = currentSQLConnectionStore?.GetPrevious(); ISQLConnectionSettings newSettings = currentSQLConnectionStore?.GetCurrent(); if (!(string.IsNullOrWhiteSpace(newSettings?.Database)) && File.Exists(newSettings?.Database)) { try { dBOperations.EvntInfoMessage -= AddLineAtTextBoxResultShow; } catch { } dBOperations = SQLSelector.SetConnector(newSettings); dBOperations.EvntInfoMessage += new SqlAbstractConnector.Message <TextEventArgs>(AddLineAtTextBoxResultShow); } if (oldSettings == null) { tableStore.Set(SQLSelector.GetTables(newSettings)); } else { if (oldSettings.Name != newSettings.Name && oldSettings.Database != newSettings.Database) { tableStore.Set(SQLSelector.GetTables(newSettings)); } } if (!string.IsNullOrWhiteSpace(newSettings?.Database) && !string.IsNullOrWhiteSpace(newSettings?.Table)) { SetAdminStatusLabelText($"Текущая база: {newSettings?.Database}, таблица: {newSettings?.Table}"); } }
private void ComboBoxTable_SelectedIndexChanged(object sender, EventArgs e) { ISQLConnectionSettings newSettings = currentSQLConnectionStore?.GetCurrent(); newSettings.Table = comboBoxTable?.SelectedItem?.ToString()?.Split('(')[0]?.Trim(); lstColumn.Clear(); foreach (var col in SQLSelector.GetColumns(newSettings).ToModelList()) { string name = col.Name.Equals(col.Alias) ? col.Name : $"{col.Name} ({col.Alias})"; lstColumn.Add(name); } columnDeleteStore.Reset(); currentSQLConnectionStore.Set(newSettings); }
private async Task GetSample(string columnName) { ISQLConnectionSettings newSettings = currentSQLConnectionStore?.GetCurrent(); ModelCommonStringStore models = null; await Task.Run(() => models = SQLSelector.GetDataSample(newSettings, columnName)); if (models?.ToList()?.Count > 0) { sampleStore.Set(models); } else { sampleStore.Reset(); sampleStore.Add(new ModelCommon() { Name = $"В таблице данные отсутствует в столбце '{columnName}'" }); } }
private void CurrentSQLConnectionStore_EvntConfigChanged(object sender, BoolEventArgs args) { ISQLConnectionSettings oldSettings = currentSQLConnectionStore?.GetPrevious(); ISQLConnectionSettings newSettings = currentSQLConnectionStore?.GetCurrent(); if (oldSettings != null) { if (oldSettings.Name == newSettings.Name) { return; } if (oldSettings.Database == newSettings.Database) { return; } } ModelCommonStringStore tables = SQLSelector.GetTables(currentSQLConnectionStore?.GetCurrent()); tableStore.Set(tables); }
private void ChangeDB() { cmbTables.Enabled = false; cmbTables.DataSource = null; cmbTables.Items.Clear(); ISQLConnectionSettings newSettings = MakeFromControls(currentSQLConnectionStore?.GetCurrent(), ""); tbResultShow.AppendLine("New Connection settings:" + Environment.NewLine + newSettings.AsString()); currentSQLConnectionStore.Set(newSettings); tableStore.Set(SQLSelector.GetTables(newSettings)); tbResultShow.AppendLine("таблиц: " + tableStore.ToList().Count); if (tableStore?.ToList()?.Count > 1) { cmbTables.Enabled = true; } tbName.Text = currentSQLConnectionStore?.GetCurrent()?.Name; }