コード例 #1
0
        private void ParseDataSetResultsToResultsBox(DataSet dataset)
        {
            ClearResults();

            foreach (DataTable table in dataset.Tables)
            {
                txtTime.Text = txtTime.Text + " / " + table.Rows.Count + " rows ";
                var textBox = new TextBox();
                textBox.FontFamily = _fontFamiliy;
                textBox.FontSize   = _fontSize;
                textBox.Foreground = Brushes.Black;
                DockPanel.SetDock(textBox, Dock.Top);
                if (table.Rows.Count == 0)
                {
                    textBox.Text = string.Format("{0} rows affected", table.MinimumCapacity);
                    Resultspanel.Children.Add(textBox);
                    resultsTabControl.SelectedIndex = 1;
                }
                else
                {
                    if (_showResultInGrid)
                    {
                        if (_useClassicGrid)
                        {
                            var grid = BuildPlainGrid(table);
                            DockPanel.SetDock(grid, Dock.Top);
                            GridPanel.Children.Add(grid);
                        }
                        else
                        {
                            var grid = new ExtEditControl();
                            grid.SourceTable = table;
                            DockPanel.SetDock(grid, Dock.Top);
                            GridPanel.Children.Add(grid);
                        }
                        resultsTabControl.SelectedIndex = 0;
                    }
                    else
                    {
                        tab1.Visibility = Visibility.Collapsed;
                        tab2.Header     = "Results";
                        resultsTabControl.SelectedIndex = 1;
                        var results = new StringBuilder();
                        foreach (var column in table.Columns)
                        {
                            results.Append(column + "\t");
                        }
                        results.Remove(results.Length - 1, 1);
                        results.Append(Environment.NewLine);

                        foreach (DataRow row in table.Rows)
                        {
                            foreach (var item in row.ItemArray)
                            {
                                if (item == DBNull.Value)
                                {
                                    if (_showNullValuesAsNull)
                                    {
                                        results.Append("NULL\t");
                                    }
                                    else
                                    {
                                        results.Append("\t");
                                    }
                                }
                                //This formatting is optional (causes perf degradation)
                                else if (item.GetType() == typeof(byte[]) && _showBinaryValuesInResult)
                                {
                                    var buffer = (byte[])item;
                                    results.Append("0x");
                                    for (var i = 0; i < buffer.Length; i++)
                                    {
                                        results.Append(buffer[i].ToString("X2", System.Globalization.CultureInfo.InvariantCulture));
                                    }
                                    results.Append("\t");
                                }
                                else if (item is DateTime)
                                {
                                    results.Append(((DateTime)item).ToString("O") + "\t");
                                }
                                else if (item is double || item is float)
                                {
                                    string intString = Convert.ToDouble(item).ToString("R", System.Globalization.CultureInfo.InvariantCulture);
                                    results.Append(intString + "\t");
                                }
                                else
                                {
                                    results.Append(item + "\t");
                                }
                            }
                            results.Remove(results.Length - 1, 1);
                            results.Append(Environment.NewLine);
                        }
                        textBox.Text = results.ToString();
                        Resultspanel.Children.Add(textBox);
                    }
                }
            }

            if (_showResultInGrid && GridPanel.Children.Count > 0)
            {
                resultsTabControl.SelectedIndex = 0;
            }
        }
コード例 #2
0
        private void ParseDataSetResultsToResultsBox(DataSet dataset)
        {
            ClearResults();

            foreach (DataTable table in dataset.Tables)
            {
                this.txtTime.Text = this.txtTime.Text + " / " + table.Rows.Count.ToString() + " rows ";
                var textBox = new TextBox();
                textBox.FontFamily = fontFamiliy;
                textBox.FontSize = fontSize;
                textBox.Foreground = Brushes.Black;
                DockPanel.SetDock(textBox, Dock.Top);
                if (table.Rows.Count == 0)
                {
                    textBox.Text = string.Format("{0} rows affected", table.MinimumCapacity);
                    this.Resultspanel.Children.Add(textBox);
                    resultsTabControl.SelectedIndex = 1;
                }
                else
                {
                    if (showResultInGrid)
                    {
                        if (useClassicGrid)
                        {
                            var grid = BuildPlainGrid(table);
                            DockPanel.SetDock(grid, Dock.Top);
                            this.GridPanel.Children.Add(grid);
                        }
                        else
                        {
                            var grid = new ExtEditControl();
                            grid.SourceTable = table;
                            DockPanel.SetDock(grid, Dock.Top);
                            this.GridPanel.Children.Add(grid);
                        }
                        resultsTabControl.SelectedIndex = 0;
                    }
                    else
                    {
                        this.tab1.Visibility = System.Windows.Visibility.Collapsed;
                        this.tab2.Header = "Results";
                        this.resultsTabControl.SelectedIndex = 1;
                        var results = new StringBuilder();
                        foreach (var column in table.Columns)
                        {
                            results.Append(column + "\t");
                        }
                        results.Remove(results.Length - 1, 1);
                        results.Append(Environment.NewLine);

                        foreach (DataRow row in table.Rows)
                        {
                            foreach (var item in row.ItemArray)
                            {
                                if (item == DBNull.Value)
                                {
                                    if (showNullValuesAsNULL)
                                    {
                                        results.Append("NULL\t");
                                    }
                                    else
                                    {
                                        results.Append("\t");
                                    }
                                }
                                //This formatting is optional (causes perf degradation)
                                else if (item.GetType() == typeof(byte[]) && showBinaryValuesInResult)
                                {
                                    var buffer = (byte[])item;
                                    results.Append("0x");
                                    for (int i = 0; i < buffer.Length; i++)
                                    {
                                        results.Append(buffer[i].ToString("X2", System.Globalization.CultureInfo.InvariantCulture));
                                    }
                                    results.Append("\t");
                                }
                                else if (item is DateTime)
                                {
                                    results.Append(((DateTime)item).ToString("O") + "\t");
                                }
                                else if (item is double || item is float)
                                {
                                    string intString = Convert.ToDouble(item).ToString("R", System.Globalization.CultureInfo.InvariantCulture);
                                    results.Append(intString + "\t");
                                }
                                else
                                {
                                    results.Append(item + "\t");
                                }
                            }
                            results.Remove(results.Length - 1, 1);
                            results.Append(Environment.NewLine);
                        }
                        textBox.Text = results.ToString();
                        this.Resultspanel.Children.Add(textBox);
                    }
                }
            }

            if (showResultInGrid && this.GridPanel.Children.Count > 0)
            {
                resultsTabControl.SelectedIndex = 0;
            }
        }