Ejemplo n.º 1
0
    private void EnsureDataTable()
    {
      if (_outputSet == null && _result != null && tbcOutputView.SelectedTab == pgTableOutput)
      {
        _outputSet = _result.GetDataSet();
        if (_outputSet.Tables.Count > 0)
        {
          dgvItems.AutoGenerateColumns = false;
          dgvItems.DataSource = _outputSet.Tables[0];
          FormatDataGrid(dgvItems);
          pgTableOutput.Text = _outputSet.Tables[0].TableName;

          var i = 1;
          foreach (var tbl in _outputSet.Tables.OfType<DataTable>().Skip(1))
          {
            var pg = new TabPage(tbl.TableName);
            pg.Name = GeneratedPage + i.ToString();
            var grid = new Controls.DataGrid();
            grid.AutoGenerateColumns = false;
            grid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            grid.ContextMenuStrip = this.conTable;
            grid.DataSource = tbl;
            grid.Dock = System.Windows.Forms.DockStyle.Fill;
            grid.Location = new System.Drawing.Point(0, 0);
            grid.Margin = new System.Windows.Forms.Padding(0);
            grid.TabIndex = 0;
            pg.Controls.Add(grid);
            tbcOutputView.TabPages.Add(pg);
            FormatDataGrid(grid);
            i++;
          }
        }
      }
    }
Ejemplo n.º 2
0
    private void EnsureDataTable()
    {
      if (_outputSet == null && _result != null && tbcOutputView.SelectedTab == pgTableOutput)
      {
        _outputSet = _result.GetDataSet();
        if (_outputSet.Tables.Count > 0)
        {
          var errors = _outputSet.Tables.OfType<DataTable>()
            .SelectMany(t => t.GetErrors().Select(r => new TableError()
            {
              Message = r.RowError,
              Table = t.TableName
            }))
            .GroupBy(e => e.Message)
            .Select(g => g.Key
              + " in tables: "
              + g.GroupBy(t => t.Table)
                .Select(t => t.Key + " (" + t.Count() + " row(s))")
                .GroupConcat(", "));

          if (errors.Any())
          {
            using (var dialog = new Dialog.MessageDialog())
            {
              dialog.Message = errors.GroupConcat(Environment.NewLine);
              dialog.OkText = "&Keep Going";
              dialog.Caption = "Validation Error";
              dialog.CaptionColor = System.Drawing.Color.Red;
              dialog.ShowDialog();
            }
          }

          dgvItems.AutoGenerateColumns = false;
          dgvItems.DataSource = _outputSet.Tables[0];
          FormatDataGrid(dgvItems);
          pgTableOutput.Text = _outputSet.Tables[0].TableName;

          var i = 1;
          foreach (var tbl in _outputSet.Tables.OfType<DataTable>().Skip(1))
          {
            var pg = new TabPage(tbl.TableName);
            pg.Name = GeneratedPage + i.ToString();
            var grid = new Controls.DataGrid();
            grid.AutoGenerateColumns = false;
            grid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            grid.ContextMenuStrip = this.conTable;
            grid.DataSource = tbl;
            grid.Dock = System.Windows.Forms.DockStyle.Fill;
            grid.Location = new System.Drawing.Point(0, 0);
            grid.Margin = new System.Windows.Forms.Padding(0);
            grid.TabIndex = 0;
            grid.MouseDoubleClick += Grid_MouseDoubleClick;
            pg.Controls.Add(grid);
            tbcOutputView.TabPages.Add(pg);
            FormatDataGrid(grid);
            i++;
          }
        }
      }
    }