Ejemplo n.º 1
0
        private void filterToolStripButton_Click(object sender, EventArgs e)
        {
            if (!CanContinue())
            {
                return;
            }
            using (FilterDialog filterDialog = new FilterDialog(this.filter.Clone())) {
                FormExtensions.DownPositionate(filterDialog, filterToolStripButton, this);
                if (filterDialog.ShowDialog(this) == DialogResult.OK)
                {
                    TableFilter lastGood = this.filter;
                    this.filter = filterDialog.Filter;

                    if (IsFiltered)
                    {
                        this.currentPage = 0;
                        this.filterToolStripButton.Checked = true;
                    }
                    else
                    {
                        this.filterToolStripButton.Checked = false;
                    }
                    this.filterToolStripButton.ToolTipText = IsFiltered ? filter.ToString() : "Filter";

                    try {
                        this.UpdateDataSet();
                    } catch (Exception ex) {
                        this.filter = lastGood;
                        MessageBox.Show(this, ex.Message, this.Text, MessageBoxButtons.OK);
                        this.UpdateDataSet();
                    }
                }
                else
                {
                    if (this.refreshDataNeeded)
                    {
                        this.UpdateDataSet();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void openDataWithFilterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var tableNode = (TableNode)treeView.SelectedNode;

            if (tableNode != null)
            {
                var table = tableNode.Table;
                var key   = table.Database.Name + '.' + table.Name;

                using (FilterDialog filterDialog = new FilterDialog(new TableFilter(table))) {
                    filterDialog.Text          = "Open with filter: " + key;
                    filterDialog.ControlBox    = true;
                    filterDialog.ShowIcon      = false;
                    filterDialog.StartPosition = FormStartPosition.CenterParent;
                    if (filterDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        var filter   = filterDialog.Filter;
                        var document = new TableDocument(table, filter);
                        document.Text = key;
                        document.Show(this.DockPanel);
                    }
                }
            }
        }