示例#1
0
/// <summary>
/// Validate list of cids
/// </summary>
/// <returns></returns>

        bool ValidateList()
        {
            if (!ValidateNumbers.Checked || RootTable == null)
            {
                return(true);
            }

            DisplayStatusMsg("Validating numbers...");
            string invalidCid = CompoundIdUtil.ValidateList(CidListCtl.Text, RootTable.Name);

            if (!String.IsNullOrEmpty(invalidCid))
            {
                int i2 = Lex.IndexOf(CidListCtl.Text, invalidCid);                 // original position
                if (i2 >= 0)
                {
                    CidListCtl.Select(i2, invalidCid.Length);                     // select bad compound id
                    CidListCtl.Focus();
                }

                string errorMsg = invalidCid + " is an invalid " + RootTable.KeyMetaColumn.Label;
                DisplayStatusMsg(errorMsg);                 // put up error message
                SystemUtil.Beep();
                return(false);
            }

            DisplayStatusMsg("");
            return(true);
        }
示例#2
0
        /// <summary>
        /// Validate the form and build and validate the query
        /// </summary>
        /// <returns></returns>

        bool ValidateFormAndBuildQuery()
        {
            try
            {
                // Retrieve data for a single Cid

                if (CurrentCidCheckEdit.Checked)
                {
                    string cid = CidCtl.Text;
                    cid = CompoundId.Normalize(cid);
                    if (Lex.IsUndefined(cid) || !CompoundIdUtil.Exists(cid))
                    {
                        throw new Exception("Invalid or non-existant :" + RootTable.KeyMetaColumn.Label + ": " + CidCtl.Text);
                    }
                }

                // Retrieve data for related structures

                else if (RelatedStrsCheckEdit.Checked)
                {
                    if (AltForms.Checked || MatchedPairs.Checked ||
                        SmallWorld.Checked || SimilarSearch.Checked || Substructure.Checked)
                    {
                        ;
                    }
                    else
                    {
                        throw new Exception("At least one type of structure search must be specified to find structurally-related compounds");
                    }
                }

                // Retrieve for marked Cids

                else if (MarkedCidsCheckEdit.Checked)
                {
                    // OK
                }

                // Retrieve for all Cids in originating query

                else if (AllCidsCheckEdit.Checked)
                {
                    // OK
                }

                else
                {
                    throw new Exception("A compound retrieval type must be specified");
                }

                int mi = MruListCtl.SelectedIndex;
                if (mi < 0 || mi >= MruListCtl.ItemCount)
                {
                    throw new Exception("You must select a query or data table to use to retrieve related data");
                }

                UpdateSelectedNodesSet();
                Query q = BuildQuery();
                MqlUtil.CheckTableCompatibility(q);
                RelatedCompoundsQuery = q;

                return(true);
            }

            catch (Exception ex)
            {
                MessageBoxMx.ShowError(ex.Message);
                CidCtl.Focus();
                return(false);
            }
        }