Exemplo n.º 1
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();
        }