public DataView GetPerformanceQueryResults(string sqlCode, string connectionString) { DataView result = SqlQueryDataAccess.GetPerformanceQueryResults(sqlCode, connectionString); return(result); // TODO: add assertions to method SqlQueryDataAccessTest.GetPerformanceQueryResults(String, String) }
/// <summary> /// Gets the database view. /// </summary> /// <param name="autoSizeRows">if set to <c>true</c> [auto size rows].</param> private void GetDatabasePerformance(bool autoSizeRows = false) { if (this.formLoaded) { try { this.Cursor = Cursors.WaitCursor; this.DataGridViewPerformance.Cursor = Cursors.WaitCursor; this.panelNoData.SendToBack(); this.toolStripStatusExecuting.Visible = true; this.ToolStripButtonAutoSizeRows.Visible = false; this.DataGridViewPerformance.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None; this.DataGridViewPerformance.DataSource = null; Application.DoEvents(); this.ConnectionString = this.GetConnectionString(); SqlQueryDataAccess.ExecuteUseDatabase(this.DatabaseName, this.ConnectionString); string sqlStatement = string.Empty; foreach (SqlQuery sql in this.SqlPerformanceQueries.QueryItems) { if (sql.SqlName == this.CurrentQuery) { this.DataGridViewPerformance.DataSource = SqlQueryDataAccess.GetPerformanceQueryResults(sql.SqlCode, this.ConnectionString); break; } } if (this.DataGridViewPerformance.Rows.Count > 0) { int maxColumnWidth = Properties.Settings.Default.MaxColumnWidth; foreach (DataGridViewColumn column in this.DataGridViewPerformance.Columns) { if (column.Width > maxColumnWidth) { column.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; column.Width = maxColumnWidth; if (autoSizeRows) { column.DefaultCellStyle.WrapMode = DataGridViewTriState.True; this.DataGridViewPerformance.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells; } this.ToolStripButtonAutoSizeRows.Visible = true; } if (column.IsNumericColumn()) { column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopRight; if (column.IsDecimalColumn()) { column.DefaultCellStyle.Format = "N2"; } else { column.DefaultCellStyle.Format = "N0"; } } } } else { this.ShowNoDataPanel(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.toolStripStatusRowCount.Text = string.Format("{0} rows ", this.DataGridViewPerformance.Rows.Count); this.toolStripStatusExecuting.Visible = false; this.DataGridViewPerformance.Cursor = Cursors.Default; this.Cursor = Cursors.Default; this.DataGridViewPerformance.Focus(); } }