private void SetTabPageContent(DatabaseObjectDisplayInfo info, TabPage tabPage) { if (info.DisplayType == DatabaseObjectDisplayType.Script) { UC_SqlQuery sqlQuery = this.GetUcControl <UC_SqlQuery>(tabPage); if (sqlQuery == null) { sqlQuery = this.AddControlToTabPage <UC_SqlQuery>(tabPage); } sqlQuery.Show(info); if (!string.IsNullOrEmpty(sqlQuery.Editor.Text)) { RichTextBoxHelper.Highlighting(sqlQuery.Editor, info.DatabaseType, false); if (info.Error != null) { RichTextBoxHelper.HighlightingError(sqlQuery.Editor, info.Error); } } else { sqlQuery.Editor.Focus(); } } else if (info.DisplayType == DatabaseObjectDisplayType.Data) { UC_DataViewer dataViewer = this.GetUcControl <UC_DataViewer>(tabPage); if (dataViewer == null) { dataViewer = this.AddControlToTabPage <UC_DataViewer>(tabPage); dataViewer.OnDataFilter += this.DataFilter; } dataViewer.Show(info); } else if (info.DisplayType == DatabaseObjectDisplayType.TableDesigner) { UC_TableDesigner tableDesigner = this.GetUcControl <UC_TableDesigner>(tabPage); if (tableDesigner == null) { tableDesigner = this.AddControlToTabPage <UC_TableDesigner>(tabPage); tableDesigner.OnFeedback += this.Feedback; } tableDesigner.Show(info); } }
private void Save() { if (this.tabControl1.TabCount < 1) { return; } TabPage tabPage = this.tabControl1.SelectedTab; if (tabPage == null) { return; } DatabaseObjectDisplayInfo displayInfo = tabPage.Tag as DatabaseObjectDisplayInfo; if (displayInfo == null) { return; } DatabaseObjectDisplayType displayType = displayInfo.DisplayType; if (displayType == DatabaseObjectDisplayType.Script || displayType == DatabaseObjectDisplayType.Data) { if (File.Exists(displayInfo.FilePath)) { this.SaveToFile(tabPage, displayInfo.FilePath); return; } if (this.dlgSave == null) { this.dlgSave = new SaveFileDialog(); } this.dlgSave.FileName = tabPage.Text.Trim(); if (displayType == DatabaseObjectDisplayType.Script) { this.dlgSave.Filter = "sql file|*.sql|txt file|*.txt"; } else if (displayType == DatabaseObjectDisplayType.Data) { this.dlgSave.Filter = "csv file|*.csv|txt file|*.txt"; } DialogResult result = this.dlgSave.ShowDialog(); if (result == DialogResult.OK) { string filePath = this.dlgSave.FileName; this.SaveToFile(tabPage, filePath); displayInfo.FilePath = filePath; string name = Path.GetFileNameWithoutExtension(filePath); displayInfo.IsNew = false; displayInfo.Name = name; tabPage.Text = this.GetFormatTabHeaderText(name); this.SetTabPageTooltip(tabPage); } } else if (displayType == DatabaseObjectDisplayType.TableDesigner) { UC_TableDesigner tableDesigner = this.GetUcControl <UC_TableDesigner>(tabPage); ContentSaveResult result = tableDesigner.Save(new ContentSaveInfo() { }); if (result.IsOK) { Table table = result.ResultData as Table; displayInfo.IsNew = false; displayInfo.Name = table.Name; tabPage.Text = this.GetFormatTabHeaderText(displayInfo.Name); this.SetTabPageTooltip(tabPage); } } }