Beispiel #1
0
        /// <summary>
        /// Adding a new SasMap view to an existing query
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>

        public DialogResult ShowInitialViewSetupDialog(
            QueryColumn sasQc,
            Query baseQuery)
        {
            MetaTable    mt;
            QueryColumn  qc = null;
            DialogResult dr;

            AssertMx.IsNotNull(sasQc, "SasQc");
            AssertMx.IsNotNull(SasQuery, "SasMapQuery");

            SasQc     = sasQc;
            BaseQuery = baseQuery;

            Parms = GetParmsFromQueryColumnCriteria(SasQc);

            qc = BaseQuery?.GetFirstKeyColumn();
            if (qc == null)
            {
                qc = QueryTable.GetDefaultRootQueryTable()?.KeyQueryColumn;
            }
            qc = qc.Clone();

            Parms.KeyCriteriaQc = qc;             // assign QC with undefined criteria

            QueryManager  refQm       = (baseQuery.QueryManager as QueryManager);
            List <string> resultsKeys = refQm?.DataTableManager?.ResultsKeys;

            if (resultsKeys != null && resultsKeys.Count > 0)
            {
                string listText = Csv.JoinCsvString(resultsKeys);
                qc.CriteriaDisplay = CidList.FormatAbbreviatedCidListForDisplay(qc, listText);
                qc.Criteria        = qc.MetaColumn.Name + " IN (" + listText + ")";
            }

            Parms.EndpointMc = BaseQuery?.GetFirstResultColumnByPriority(true)?.MetaColumn;             // pick the highest priority result column as the default endpoint

            dr = Edit();
            if (dr == DialogResult.OK)
            {
                StoreParmsInQueryColumnCriteria(Parms, SasQc);
            }

            return(dr);
        }
Beispiel #2
0
        string FormatCidListForDisplay(List <string> cidList)
        {
            string      txt;
            QueryColumn qc = null;

            int count = 0;

            if (cidList != null && cidList.Count > 0)
            {
                count = cidList.Count;
            }
            if (count > 0 && SourceQuery.Tables.Count > 0 && SourceQuery.Tables[0].KeyQueryColumn.MetaColumn.DataType == MetaColumnType.CompoundId)
            {
                qc = SourceQuery.Tables[0].KeyQueryColumn;
                string cidListString = MqlUtil.FormatValueListString(cidList, false);
                txt = CidList.FormatAbbreviatedCidListForDisplay(qc, cidListString);
                return(txt);
            }

            else
            {
                return(count.ToString());
            }
        }
Beispiel #3
0
        private void OK_Click(object sender, EventArgs e)
        {
            int    CnCount;
            string listName, listText, errMsg = "", tok, cidLo, cidHi, cid = null, cid2 = null;

            QueryColumn qc = Qc;
            MetaColumn  mc = qc.MetaColumn;
            MetaTable   mt = mc.MetaTable;

            // Perform validity check on form

            // Equality

            if (EQ.Checked)
            {
                tok = Cid.Text.ToUpper();

                if (tok == "")
                {
                    XtraMessageBox.Show("Single compound value is missing", UmlautMobius.String, MessageBoxButtons.OK, MessageBoxIcon.None);
                    Cid.Focus();
                    return;
                }

                if (SS.I.ValidateCompoundIds)
                {
                    if (tok == "")
                    {
                        errMsg = "You must supply a " + qc.ActiveLabel;
                    }

                    else if (RootTable.IsStructureDatabaseRootTable(mt.Root))
                    {
                        if (!CompoundId.IsValidForDatabase(tok, mt))
                        {
                            errMsg = tok + " is not a valid " + qc.ActiveLabel;
                        }

                        else
                        {
                            cid    = CompoundId.Normalize(tok, mt);
                            tok    = CompoundId.Format(cid, mt);
                            errMsg = "";
                        }
                    }

                    else
                    {
                        cid    = tok;                      // use as is
                        errMsg = "";                       // no error
                    }

                    if (errMsg != "")
                    {
                        MessageBoxMx.Show(errMsg, UmlautMobius.String, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
                qc.CriteriaDisplay = "= " + tok;
                qc.Criteria        = mc.Name + " = " + Lex.AddSingleQuotes(cid);
                CnCount            = 1;
            }

// List

            else if (InList.Checked)
            {
                listText = CidListString.Trim();
                if (listText == "")
                {
                    XtraMessageBox.Show("The list must contain one or more items", UmlautMobius.String, MessageBoxButtons.OK, MessageBoxIcon.None);
                    if (CidListDisplayIsEditable())
                    {
                        CidListDisplay.Focus();
                    }
                    return;
                }

                qc.CriteriaDisplay = CidList.FormatAbbreviatedCidListForDisplay(qc, listText);

                qc.Criteria = mc.Name + " IN (" + listText + ")";
            }

// Current list

            else if (TempList.Checked)
            {
                qc.CriteriaDisplay = "In temporary list: " + TempListName.Text;
                qc.Criteria        = mc.Name + " IN LIST " + UserObject.TempFolderNameQualified + TempListName.Text;
                CnCount            = SessionManager.CurrentResultKeysCount;
            }

// Saved list

            else if (SavedList.Checked)
            {
                if (ListName.Text.Trim() == "")
                {
                    XtraMessageBox.Show("A list name must be supplied", UmlautMobius.String, MessageBoxButtons.OK, MessageBoxIcon.None);
                    ListName.Focus();
                    return;
                }

                string internalName = ResolveSavedListUo();
                if (internalName == null)
                {
                    return;
                }

                qc.CriteriaDisplay = "In list: " + SavedListUo.Name;
                qc.Criteria        = mc.Name + " IN LIST " + Lex.AddSingleQuotes("CNLIST_" + SavedListUo.Id.ToString()); // quote list name
                CnCount            = 1;                                                                                  // may be larger
            }

// Between

            else if (Between.Checked)
            {
                cidLo = CidLo.Text.Trim();
                cidHi = CidHi.Text.Trim();
                if (cidLo == "" || cidHi == "")
                {
                    XtraMessageBox.Show("Between value is missing", UmlautMobius.String, MessageBoxButtons.OK, MessageBoxIcon.None);
                    if (CidLo.Text.Trim() == "")
                    {
                        CidLo.Focus();
                    }
                    else if (CidHi.Text.Trim() == "")
                    {
                        CidHi.Focus();
                    }
                    return;
                }

                if (SS.I.ValidateCompoundIds)
                {
                    errMsg = "";
                    if (cidLo == "")
                    {
                        errMsg = "You must supply a " + qc.ActiveLabel;
                    }

                    else
                    {
                        if (!CompoundId.IsValidForDatabase(cidLo, mt))
                        {
                            errMsg = cidLo + " is not a valid " + qc.ActiveLabel;
                        }
                        else
                        {
                            cid   = CompoundId.Normalize(cidLo, mt);
                            cidLo = CompoundId.Format(cid);
                        }
                    }
                    if (errMsg != "")
                    {
                        MessageBoxMx.Show(errMsg, UmlautMobius.String, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }

                else
                {
                    cid = cidLo;                  // use as is
                }
                if (SS.I.ValidateCompoundIds)
                {
                    errMsg = "";
                    if (cidHi == "")
                    {
                        errMsg = "You must supply a " + qc.ActiveLabel;
                    }

                    else
                    {
                        if (!CompoundId.IsValidForDatabase(cidHi, mt))
                        {
                            errMsg = cidHi + " is not a valid " + qc.ActiveLabel;
                        }
                        else
                        {
                            cid2  = CompoundId.Normalize(cidHi, mt);
                            cidHi = CompoundId.Format(cid2);
                        }
                    }

                    if (errMsg != "")
                    {
                        MessageBoxMx.Show(errMsg, UmlautMobius.String, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }

                else
                {
                    cid2 = cidHi;                  // use as is
                }
                qc.CriteriaDisplay = "Between " + cidLo + " and " + cidHi;
                qc.Criteria        = mc.Name + " BETWEEN " + Lex.AddSingleQuotes(cid) + " AND " + Lex.AddSingleQuotes(cid2);
            }

            else if (None.Checked)
            {
                qc.CriteriaDisplay = "";
                qc.Criteria        = "";
                CnCount            = 0;
            }

            DialogResult = DialogResult.OK;
//			this.Hide();
        }
Beispiel #4
0
/// <summary>
/// Set the display form of the list
/// </summary>

        void SetCidListDisplay()
        {
            string txt = CidList.FormatAbbreviatedCidListForDisplay(Qc, CidListString);

            CidListDisplay.Text = txt;
        }