Exemplo n.º 1
0
// CriteriaColRtClickContextMenu events

        private void EditCriteriaMenuItem_Click(object sender, EventArgs e)
        {
            if (CriteriaEditor.EditCriteria(CurrentQc))
            {
                QueryColumn qc = CurrentQc;
                if (qc.MetaColumn.DataType == MetaColumnType.Structure)
                {
                    Render();        // rerender since height of box may have changed
                }
                else                 // simple text value
                {
                    TextEdit te = (TextEdit)CurrentCriteriaControl;
                    if (qc.CriteriaDisplay != "")
                    {
                        te.Text = qc.CriteriaDisplay;
                    }
                    else
                    {
                        te.Text = "";
                    }
                }
            }

            this.Parent.Focus();             // move focus away from any current text control
        }
Exemplo n.º 2
0
/// <summary>
/// Edit the Cids criteris
/// </summary>
/// <returns></returns>

        bool EditCids()
        {
            Query       q;
            QueryTable  qt;
            MetaTable   mt;
            QueryColumn qc;

            mt = MetaTableCollection.GetWithException(Tso.GetSummarizedMetaTableName());

            q  = new Query();
            qt = new QueryTable(q, mt);
            qc = qt.KeyQueryColumn;

            qc.Criteria        = Cids.Text;
            qc.CriteriaDisplay = Cids.Text;
            if (!CriteriaEditor.GetCompoundIdCriteria(qc))
            {
                return(false);
            }
            if (qc.Criteria.StartsWith(" = "))             // make equality look nice
            {
                Cids.Text = qc.CriteriaDisplay;
            }
            else
            {
                Cids.Text = qc.Criteria;
            }

            return(true);
        }
Exemplo n.º 3
0
 private void OK_Click(object sender, EventArgs e)
 {
     LabeledCriteria.Text = Criteria.Text;             // get current text
     if (!CriteriaEditor.ConvertEditableCriteriaToComplex(LabeledCriteria, Query, null))
     {
         return;
     }
     DialogResult = DialogResult.OK;
     return;
 }
Exemplo n.º 4
0
        private void gridView1_MouseDown(object sender, MouseEventArgs e)
        {
            Point p;
            int   ri, ci;

            GridHitInfo ghi = GridView.CalcHitInfo(e.Location);

            if (ghi.Column.AbsoluteIndex != 1)
            {
                return;
            }

            ri = ghi.RowHandle;
            QueryTable       qt       = Query.Tables[ri];
            ContextMenuStrip colPopup = new ContextMenuStrip();

            bool firstLabel = true;

            foreach (QueryColumn qc in qt.QueryColumns)
            {             // get list of allowed field labels/names for each table
                if (!QueryTableControl.QueryColumnVisible(qc) || !qc.MetaColumn.IsSearchable)
                {
                    continue;
                }
                if (firstLabel)
                {
                    firstLabel = false;
                }
                string            label = CriteriaEditor.GetUniqueColumnLabel(qc);
                ToolStripMenuItem mi    = new ToolStripMenuItem(label, null, new System.EventHandler(SelectedField_Click));
                mi.Tag = "T" + (ri + 1);
                colPopup.Items.Add(mi);
            }

            p = e.Location;

            GridViewInfo viewInfo = (GridViewInfo)GridView.GetViewInfo();

            GridCellInfo cellInfo = viewInfo.GetGridCellInfo(ghi.RowHandle, ghi.Column);

            if (cellInfo != null)
            {
                p = new Point(cellInfo.Bounds.Left, cellInfo.Bounds.Bottom);
            }

            colPopup.Show(Instance.TableGrid, p);
        }
Exemplo n.º 5
0
        private void CtComplexCriteria_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)             // right button ContextMenu
            {
                Point p = new Point(e.X, e.Y);
                CriteriaComplexRtClickContextMenu.Show(CtComplexCriteria, p);
            }

            else
            {
                if (CriteriaComplex.Edit(Query))
                {
                    LabeledCriteria labeledCriteria = CriteriaEditor.ConvertComplexCriteriaToEditable(Query, false);
                    RichTextBox     coloredCriteria = CriteriaEditor.ColorCodeCriteria(labeledCriteria.Text, Query);
                    CtComplexCriteria.Rtf = coloredCriteria.Rtf;
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Complex criteria editor
        ///
        /// Editing complex criteria involves several steps including the following:
        ///  1. ConvertSimpleCriteriaToComplex (MqlUtil) - Initial conversion to set up complex criteria
        ///  2. ConvertComplexCriteriaToEditable - Convert raw complex criteria into a more editable form
        ///  3. ConvertEditableCriteriaToComplex - Convert editable format back to raw format checking for basic errors
        ///  4. ConvertComplexCriteriaToSimple (MqlUtil) - Convert back to simple format, may be loss of criteria
        /// </summary>
        /// <param name="q"></param>
        /// <returns></returns>

        public static bool Edit(
            Query q)
        {
            if (Instance == null)
            {
                Instance = new CriteriaComplex();
            }
            Instance.Query = q;

            QueryTable qt;
            MoleculeMx cs;

            DataTable dt = BuildTableGridList(q);

            Instance.TableGrid.DataSource = dt;

            Instance.LabeledCriteria = CriteriaEditor.ConvertComplexCriteriaToEditable(q, true);
            RichTextBox coloredCriteria   = CriteriaEditor.ColorCodeCriteria(Instance.LabeledCriteria.Text, q);
            string      formattedCriteria = coloredCriteria.Rtf;

            Instance.Criteria.Rtf = formattedCriteria;

            if (coloredCriteria.Text.Length == 1)
            {             // if single starter char then position cursor at start
                Instance.Criteria.SelectionStart  = 0;
                Instance.Criteria.SelectionLength = 0;
            }

            DialogResult dr = Instance.ShowDialog(SessionManager.ActiveForm);

            if (dr == DialogResult.OK)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Edit the Cids criteris
        /// </summary>
        /// <returns></returns>

        bool EditCids()
        {
            QueryColumn qc = QueryColumn;

            AssertMx.IsNotNull(qc, "QueryColumn");

            if (!CriteriaEditor.GetCompoundIdCriteria(qc))
            {
                return(false);
            }

            if (Lex.IsDefined(qc.CriteriaDisplay))
            {
                Cids.Text = qc.CriteriaDisplay;
            }

            else
            {
                Cids.Text = qc.Criteria;
            }

            return(true);
        }
Exemplo n.º 8
0
        internal void Render()
        {
            Query q             = Query;
            int   criteriaCount = 0;

            if (q == null || q.Tables.Count <= 0)
            {
                return;
            }
            //if (q.Tables.Count <= 0 || !SS.I.ShowCriteriaTab) return;

            Rendering = true;
            Clear();
            CriteriaTabYPos = 0;

            bool shownKeyCriteria = false;
            int  summarizable = 0, summarized = 0;

            for (int ti = 0; ti < q.Tables.Count; ti++)
            {
                QueryTable qt = q.Tables[ti];
                string     txt;
                bool       shownTableLabel = false;

                if (qt.MetaTable.SummarizedExists)
                {
                    summarizable++;
                }
                if (qt.MetaTable.UseSummarizedData)
                {
                    summarized++;
                }

                if (q.LogicType == QueryLogicType.Complex)
                {
                    continue;                     // if complex logic don't show simple criteria
                }
                if (qt.MetaTable.IgnoreCriteria)
                {
                    continue;                     // skip if criteria should be ignored
                }
                foreach (QueryColumn qc in qt.QueryColumns)
                {
                    if (qc.IsKey)
                    {
                        if (shownKeyCriteria)
                        {
                            continue;                                           // skip if already shown
                        }
                        shownKeyCriteria = true;
                    }

                    else if (qc.Criteria == "" && !qc.ShowOnCriteriaForm)
                    {
                        continue;
                    }

                    if (qc.MetaColumn.IsDatabaseSetColumn)
                    {
                        continue;                                                        // don't show db list
                    }
                    if (!shownTableLabel)
                    {
                        shownTableLabel = true;
                        if (!qt.MetaTable.IsRootTable || ti > 0)
                        {
                            AddCriteriaTabTableLabel(qt);
                        }
                    }

                    if (qc.MetaColumn.DataType == MetaColumnType.Structure)
                    {
                        AddCriteriaTabStructureItem(qc);
                        criteriaCount++;
                    }

                    else                     // other column types
                    {
                        if (qc.IsKey)
                        {
                            txt = q.KeyCriteriaDisplay;
                        }

                        else
                        {
                            txt = qc.CriteriaDisplay;
                            if (txt != "")
                            {
                                if (qc.FilterSearch && !qc.FilterRetrieval)
                                {
                                    txt += " (Search only)";
                                }
                                else if (!qc.FilterSearch && qc.FilterRetrieval)
                                {
                                    txt += " (Retrieve only)";
                                }
                                else if (!qc.FilterSearch && !qc.FilterRetrieval)
                                {
                                    txt += " (Disabled)";
                                }
                            }
                        }

                        AddCriteriaTabItem(qc, txt);
                        if (qc.IsKey)
                        {
                            criteriaCount++;
                        }
                    }
                }
            }

            if (q.LogicType == QueryLogicType.Complex)
            {             // convert & show complex logic
                AddComplexCriteriaPanel();
                LabeledCriteria labeledCriteria = CriteriaEditor.ConvertComplexCriteriaToEditable(q, false);
                RichTextBox     coloredCriteria = CriteriaEditor.ColorCodeCriteria(labeledCriteria.Text, q);
                CtComplexCriteria.Rtf = coloredCriteria.Rtf;

                MenuComplexApplyCriteriaToRetrieval.Checked = q.FilterResults;
            }

            AddCriteriaLogicPanel(q.LogicType);                      // add criteria type panel
            AddQueryDescription(q.UserObject.Description.TrimEnd()); // add description panel
            Rendering = false;
            return;
        }