void helperButton_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; if (sender is ToolStripItem) { var toolStrip = (ToolStripItem)sender; Keys?key = null; if (toolStrip.Tag != null) { key = (Keys)toolStrip.Tag; } if (SelectedEntity is MetaSource) { if (key == Keys.F7) { MetaSource source = ((MetaSource)SelectedEntity); source.Connection.CheckConnection(); source.Information = source.Connection.Information; source.Error = source.Connection.Error; source.InitEditor(); } } else if (SelectedEntity is MetaConnection) { if (key == Keys.F7) { ((MetaConnection)SelectedEntity).CheckConnection(); } } else if (SelectedEntity is MetaTable) { if (key == Keys.F7) { ((MetaTable)SelectedEntity).CheckTable(null); } if (key == Keys.F8) { if (((MetaTable)SelectedEntity).IsSQL) { EditProperty("SQL Select Statement"); } else { EditProperty("Definition Script"); } } if (key == Keys.F9 && ((MetaTable)SelectedEntity).DynamicColumns) { ((MetaTable)SelectedEntity).Refresh(); if (EntityHandler != null) { EntityHandler.SetModified(); EntityHandler.InitEntity(SelectedEntity); } } if (key == Keys.F12) { EditProperty("Default Load Script"); } } else if (SelectedEntity is MetaColumn) { if (key == Keys.F7) { EditProperty("Check column SQL syntax"); } if (key == Keys.F8) { EditProperty("Show column values"); } } else if (SelectedEntity is MetaEnum) { if (key == Keys.F7) { EditProperty("SQL Select Statement"); } if (key == Keys.F8) { EditProperty("Script"); } if (key == Keys.F9) { if (EntityHandler != null) { EntityHandler.SetModified(); } ((MetaEnum)SelectedEntity).RefreshEnum(); } } else if (SelectedEntity is MetaJoin) { if (key == Keys.F7) { ((MetaJoin)SelectedEntity).CheckJoin(); } if (key == Keys.F8) { EditProperty("Join clause"); } } else if (SelectedEntity is ReportTask) { if (key == Keys.F7) { EditProperty("Script"); } if (key == Keys.F8) { EditProperty("SQL Statement"); } } else if (SelectedEntity is ReportModel) { ReportModel model = SelectedEntity as ReportModel; if (key == null && model.IsLINQ) { model.BuildQuery(false, true); EntityHandler.UpdateModelNode(); MessageBox.Show(string.Format("The LINQ Model has been refreshed...\r\n\r\nIt contains {0} SQL Sub-Model(s) and {1} NoSQL Sub-Table(s).", model.LINQSubModels.Count, model.LINQSubTables.Count), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (key == Keys.F7 || key == Keys.F8) { if (model.IsLINQ) { var frm = new TemplateTextEditorForm(); frm.Text = "LINQ Editor" + (!string.IsNullOrEmpty(model.LoadScript) ? " (WARNING: Script got from the 'Load Script' property of the model)" : ""); frm.ObjectForCheckSyntax = model; ScintillaHelper.Init(frm.textBox, Lexer.Cpp); if (string.IsNullOrEmpty(model.LoadScript)) { model.Report.CheckingExecution = true; try { model.BuildQuery(); frm.textBox.Text = model.LINQLoadScript; model.Report.CheckingExecution = false; model.BuildQuery(); } finally { model.Report.CheckingExecution = false; } if (!string.IsNullOrEmpty(model.ExecutionError)) { throw new Exception(model.ExecutionError); } frm.textBox.Text = model.LINQLoadScript; } else { frm.textBox.Text = model.LoadScript; } if (key == Keys.F8) { frm.CheckSyntax(); } frm.textBox.ReadOnly = true; frm.okToolStripButton.Visible = false; frm.cancelToolStripButton.Text = "Close"; frm.ShowDialog(); } else { var frm = new SQLEditorForm(); frm.Instance = SelectedEntity; frm.PropertyName = ""; frm.InitLexer(Lexer.Sql); if (model.IsSQLModel && key == Keys.F7) { frm.Text = "SQL Editor: Edit the SQL Select Statement"; frm.SetSamples(new List <string>() { "SELECT * FROM Orders", "SELECT *\r\nFROM Employees\r\nWHERE {CommonRestriction_LastName}", "SELECT * FROM Orders", "SELECT *\r\nFROM Employees\r\nWHERE EmployeeID > {CommonValue_ID}" }); frm.WarningOnError = true; frm.sqlTextBox.Text = model.Table.Sql; if (frm.ShowDialog() == DialogResult.OK) { try { Cursor.Current = Cursors.WaitCursor; model.Table.Sql = frm.sqlTextBox.Text; model.RefreshMetaTable(true); } finally { Cursor.Current = Cursors.Default; } if (EntityHandler != null) { EntityHandler.SetModified(); EntityHandler.RefreshModelTreeView(); } if (!string.IsNullOrEmpty(model.Table.Error)) { throw new Exception("Error when building columns from the SQL Select Statement:\r\n" + model.Table.Error); } } } else { model.Report.CheckingExecution = true; try { model.BuildQuery(); frm.SqlToCheck = model.Sql; model.Report.CheckingExecution = false; model.BuildQuery(); } finally { model.Report.CheckingExecution = false; } if (!string.IsNullOrEmpty(model.ExecutionError)) { throw new Exception("Error building the SQL Statement...\r\nPlease fix these errors first.\r\n" + model.ExecutionError); } frm.sqlTextBox.Text = model.Sql; frm.SetReadOnly(); if (key == Keys.F8) { frm.checkSQL(); } frm.ShowDialog(); } } } } else if (SelectedEntity is ReportView) { if (key == Keys.F8) { EditProperty("Custom template"); } } else if (SelectedEntity is Report) { if (key == Keys.F7) { EditProperty("Common Scripts"); } if (key == Keys.F8) { EditProperty("Report Input Values"); } } else if (SelectedEntity is ReportSchedule) { if (key == Keys.F8) { EditProperty("Edit schedule properties"); } if (key == Keys.F9) { EditProperty("Run Task Scheduler MMC"); } } } } finally { Cursor.Current = Cursors.Default; } }
void helperButton_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; if (sender is ToolStripItem) { Keys key = (Keys)((ToolStripItem)sender).Tag; if (SelectedEntity is MetaSource) { if (key == Keys.F7) { MetaSource source = ((MetaSource)SelectedEntity); source.Connection.CheckConnection(); source.Information = source.Connection.Information; source.Error = source.Connection.Error; source.InitEditor(); } if (key == Keys.F8 || key == Keys.F10) { MetaTable table = ((MetaSource)SelectedEntity).MetaData.MasterTable; if (table != null) { TreeViewHelper.SelectNode(MainTreeView, MainTreeView.SelectedNode.Nodes, table); EditProperty(table.IsSQL ? "SQL Statement" : "Default Load Script"); } } } else if (SelectedEntity is MetaConnection) { if (key == Keys.F7) { ((MetaConnection)SelectedEntity).CheckConnection(); } } else if (SelectedEntity is MetaTable) { if (key == Keys.F7) { ((MetaTable)SelectedEntity).CheckTable(null); } if (key == Keys.F8) { if (((MetaTable)SelectedEntity).IsSQL) { EditProperty("SQL Statement"); } else { EditProperty("Definition Script"); } } if (key == Keys.F9 && ((MetaTable)SelectedEntity).DynamicColumns) { ((MetaTable)SelectedEntity).Refresh(); if (EntityHandler != null) { EntityHandler.SetModified(); EntityHandler.InitEntity(SelectedEntity); } } if (key == Keys.F10) { EditProperty("Default Load Script"); } } else if (SelectedEntity is MetaColumn) { if (key == Keys.F7) { EditProperty("Check column SQL syntax"); } if (key == Keys.F8) { EditProperty("Show column values"); } } else if (SelectedEntity is MetaEnum) { if (key == Keys.F8) { EditProperty("Select SQL Statement"); } if (key == Keys.F9) { ((MetaEnum)SelectedEntity).RefreshEnum(); } } else if (SelectedEntity is MetaJoin) { if (key == Keys.F7) { ((MetaJoin)SelectedEntity).CheckJoin(); } if (key == Keys.F8) { EditProperty("SQL Clause"); } } else if (SelectedEntity is ReportTask) { if (key == Keys.F7) { EditProperty("Script"); } if (key == Keys.F8) { EditProperty("SQL Statement"); } } else if (SelectedEntity is ReportModel) { if (key == Keys.F7 || key == Keys.F8) { var frm = new SQLEditorForm(); frm.Instance = SelectedEntity; frm.PropertyName = ""; ReportModel model = SelectedEntity as ReportModel; model.Report.CheckingExecution = true; try { model.BuildSQL(); } finally { model.Report.CheckingExecution = false; } if (!string.IsNullOrEmpty(model.ExecutionError)) { throw new Exception("Error building the SQL Statement...\r\nPlease fix these errors first.\r\n" + model.ExecutionError); } frm.sqlTextBox.Text = model.Sql; frm.SetReadOnly(); if (key == Keys.F8) { frm.checkSQLToolStripButton_Click(null, null); } frm.ShowDialog(); } } else if (SelectedEntity is ReportView) { if (key == Keys.F7) { EditProperty("General Parameters"); } else if (key == Keys.F8) { EditProperty("CSS"); } else if (key == Keys.F9) { EditProperty("Data Table Configuration"); } else if (key == Keys.F10) { EditProperty("NVD3 Chart Configuration"); } } else if (SelectedEntity is ReportSchedule) { if (key == Keys.F8) { EditProperty("Edit schedule properties"); } if (key == Keys.F9) { EditProperty("Run Task Scheduler MMC"); } } } } finally { Cursor.Current = Cursors.Default; } }
void helperButton_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; if (sender is ToolStripItem) { Keys key = (Keys)((ToolStripItem)sender).Tag; if (SelectedEntity is MetaSource) { if (key == Keys.F7) { MetaSource source = ((MetaSource)SelectedEntity); source.Connection.CheckConnection(); source.Information = source.Connection.Information; source.Error = source.Connection.Error; source.InitEditor(); } if (key == Keys.F12) { MetaTable table = ((MetaSource)SelectedEntity).MetaData.MasterTable; if (table != null) { TreeViewHelper.SelectNode(MainTreeView, MainTreeView.SelectedNode.Nodes, table); EditProperty("Default Load Script"); } } } else if (SelectedEntity is MetaConnection) { if (key == Keys.F7) { ((MetaConnection)SelectedEntity).CheckConnection(); } } else if (SelectedEntity is MetaTable) { if (key == Keys.F7) { ((MetaTable)SelectedEntity).CheckTable(null); } if (key == Keys.F8) { if (((MetaTable)SelectedEntity).IsSQL) { EditProperty("SQL Select Statement"); } else { EditProperty("Definition Script"); } } if (key == Keys.F9 && ((MetaTable)SelectedEntity).DynamicColumns) { ((MetaTable)SelectedEntity).Refresh(); if (EntityHandler != null) { EntityHandler.SetModified(); EntityHandler.InitEntity(SelectedEntity); } } if (key == Keys.F12) { EditProperty("Default Load Script"); } } else if (SelectedEntity is MetaColumn) { if (key == Keys.F7) { EditProperty("Check column SQL syntax"); } if (key == Keys.F8) { EditProperty("Show column values"); } } else if (SelectedEntity is MetaEnum) { if (key == Keys.F8) { EditProperty("SQL Select Statement"); } if (key == Keys.F9) { if (EntityHandler != null) { EntityHandler.SetModified(); } ((MetaEnum)SelectedEntity).RefreshEnum(); } } else if (SelectedEntity is MetaJoin) { if (key == Keys.F7) { ((MetaJoin)SelectedEntity).CheckJoin(); } if (key == Keys.F8) { EditProperty("SQL Clause"); } } else if (SelectedEntity is TasksFolder) { if (key == Keys.F7) { EditProperty("Common Scripts"); } } else if (SelectedEntity is ReportTask) { if (key == Keys.F7) { EditProperty("Script"); } if (key == Keys.F8) { EditProperty("SQL Statement"); } } else if (SelectedEntity is ReportModel) { if (key == Keys.F7 || key == Keys.F8) { var frm = new SQLEditorForm(); frm.Instance = SelectedEntity; frm.PropertyName = ""; ReportModel model = SelectedEntity as ReportModel; if (model.IsSQLModel && key == Keys.F7) { frm.Text = "SQL Editor: Edit the SQL Select Statement"; frm.SetSamples(new List <string>() { "SELECT * FROM Orders", "SELECT *\r\nFROM Employees\r\nWHERE {CommonRestriction_LastName}", "SELECT * FROM Orders", "SELECT *\r\nFROM Employees\r\nWHERE EmployeeID > {CommonValue_ID}" }); frm.WarningOnError = true; frm.sqlTextBox.Text = model.Table.Sql; if (frm.ShowDialog() == DialogResult.OK) { try { Cursor.Current = Cursors.WaitCursor; model.Table.Sql = frm.sqlTextBox.Text; model.RefreshMetaTable(true); } finally { Cursor.Current = Cursors.Default; } if (EntityHandler != null) { EntityHandler.SetModified(); EntityHandler.RefreshModelTreeView(); } if (!string.IsNullOrEmpty(model.Table.Error)) { throw new Exception("Error when building columns from the SQL Select Statement:\r\n" + model.Table.Error); } } } else { model.Report.CheckingExecution = true; try { model.BuildSQL(); frm.SqlToCheck = model.Sql; model.Report.CheckingExecution = false; model.BuildSQL(); } finally { model.Report.CheckingExecution = false; } if (!string.IsNullOrEmpty(model.ExecutionError)) { throw new Exception("Error building the SQL Statement...\r\nPlease fix these errors first.\r\n" + model.ExecutionError); } frm.sqlTextBox.Text = model.Sql; frm.SetReadOnly(); if (key == Keys.F8) { frm.checkSQL(); } frm.ShowDialog(); } } } else if (SelectedEntity is ReportView) { if (key == Keys.F8) { EditProperty("Custom template"); } } else if (SelectedEntity is ViewFolder) { if (key == Keys.F8) { EditProperty("Report Input Values"); } } else if (SelectedEntity is ReportSchedule) { if (key == Keys.F8) { EditProperty("Edit schedule properties"); } if (key == Keys.F9) { EditProperty("Run Task Scheduler MMC"); } } } } finally { Cursor.Current = Cursors.Default; } }
void helperButton_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; if (sender is ToolStripItem) { Keys key = (Keys)((ToolStripItem)sender).Tag; if (SelectedEntity is MetaSource) { if (key == Keys.F7) { MetaSource source = ((MetaSource)SelectedEntity); source.Connection.CheckConnection(); source.Information = source.Connection.Information; source.Error = source.Connection.Error; source.InitEditor(); } if (key == Keys.F8 || key == Keys.F12) { MetaTable table = ((MetaSource)SelectedEntity).MetaData.MasterTable; if (table != null) { TreeViewHelper.SelectNode(MainTreeView, MainTreeView.SelectedNode.Nodes, table); EditProperty(table.IsSQL ? "SQL Statement" : "Default Load Script"); } } } else if (SelectedEntity is MetaConnection) { if (key == Keys.F7) ((MetaConnection)SelectedEntity).CheckConnection(); } else if (SelectedEntity is MetaTable) { if (key == Keys.F7) ((MetaTable)SelectedEntity).CheckTable(null); if (key == Keys.F8) { if (((MetaTable)SelectedEntity).IsSQL) EditProperty("SQL Statement"); else EditProperty("Definition Script"); } if (key == Keys.F9 && ((MetaTable)SelectedEntity).DynamicColumns) { ((MetaTable)SelectedEntity).Refresh(); if (EntityHandler != null) { EntityHandler.SetModified(); EntityHandler.InitEntity(SelectedEntity); } } if (key == Keys.F12) { EditProperty("Default Load Script"); } } else if (SelectedEntity is MetaColumn) { if (key == Keys.F7) EditProperty("Check column SQL syntax"); if (key == Keys.F8) EditProperty("Show column values"); } else if (SelectedEntity is MetaEnum) { if (key == Keys.F8) EditProperty("Select SQL Statement"); if (key == Keys.F9) ((MetaEnum)SelectedEntity).RefreshEnum(); } else if (SelectedEntity is MetaJoin) { if (key == Keys.F7) ((MetaJoin)SelectedEntity).CheckJoin(); if (key == Keys.F8) EditProperty("SQL Clause"); } else if (SelectedEntity is TasksFolder) { if (key == Keys.F7) EditProperty("Tasks Script"); } else if (SelectedEntity is ReportTask) { if (key == Keys.F7) EditProperty("Script"); if (key == Keys.F8) EditProperty("SQL Statement"); } else if (SelectedEntity is ReportModel) { if (key == Keys.F7 || key == Keys.F8) { var frm = new SQLEditorForm(); frm.Instance = SelectedEntity; frm.PropertyName = ""; ReportModel model = SelectedEntity as ReportModel; model.Report.CheckingExecution = true; try { model.BuildSQL(); } finally { model.Report.CheckingExecution = false; } if (!string.IsNullOrEmpty(model.ExecutionError)) { throw new Exception("Error building the SQL Statement...\r\nPlease fix these errors first.\r\n" + model.ExecutionError); } frm.sqlTextBox.Text = model.Sql; frm.SetReadOnly(); if (key == Keys.F8) frm.checkSQLToolStripButton_Click(null, null); frm.ShowDialog(); } } else if (SelectedEntity is ReportView) { if (key == Keys.F7) EditProperty("General Parameters"); else if (key == Keys.F8) EditProperty("CSS"); else if (key == Keys.F9) EditProperty("Data Table Configuration"); else if (key == Keys.F12) EditProperty("NVD3 Chart Configuration"); } else if (SelectedEntity is ReportSchedule) { if (key == Keys.F8) EditProperty("Edit schedule properties"); if (key == Keys.F9) EditProperty("Run Task Scheduler MMC"); } } } finally { Cursor.Current = Cursors.Default; } }