Пример #1
0
        /// <summary>
        /// Allow user to edit the form
        /// </summary>
        /// <returns></returns>

        public static bool Edit(
            QueryColumn qc)
        {
            if (InEdit)
            {
                return(false);                    // prevent reentry via multiple clicks on the edit button
            }
            InEdit = true;

            try
            {
                if (!SS.I.UserInfo.Privileges.CanRetrieveStructures)
                {
                    MessageBoxMx.ShowError("Structure Access Not Authorized");
                    return(false);
                }

                //if (Instance == null) // use single instance
                Instance = new CriteriaStructure();

                Instance.SetupForm(qc);

                DialogResult dr = Instance.ShowDialog(SessionManager.ActiveForm);
                if (dr == DialogResult.OK)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            finally { InEdit = false; }
        }
Пример #2
0
        private void StructureSearch_Click(object sender, EventArgs e)
        {
            QueryColumn qc = new QueryColumn();
            MetaColumn  mc = new MetaColumn();            // create minimal metacolumn with structure type to assoc with qc

            mc.DataType   = MetaColumnType.Structure;
            qc.MetaColumn = mc;

            bool gotCriteria = CriteriaStructure.Edit(qc);

            if (!gotCriteria || qc.Criteria == "")
            {
                return;
            }
            string sid = "";

            for (int si = 1; ; si++)
            {
                sid = "S" + si.ToString();
                if (!LabeledCriteria.Structures.ContainsKey(sid.ToUpper()))
                {
                    break;
                }
            }

            string chime = MoleculeMx.MolfileStringToChimeString(qc.MolString); // get chime string

            LabeledCriteria.Structures[sid.ToUpper()] = chime;                  // store sid & associated chime string
            qc.MolString = chime;
            string sCriteria = MqlUtil.ConvertQueryColumnStructureCriteriaToMql(qc);

            sCriteria = sCriteria.Replace("(ctab,", "(structure_field,");         // required dummy field name
            sCriteria = sCriteria.Replace(chime, "[Edit Structure " + sid + "]"); // substitute surrogate for structure
            sCriteria = sCriteria.Replace("'[", "[");                             // hack fixup
            sCriteria = sCriteria.Replace("]'", "]");

            Instance.InsertCriteria(sCriteria);
        }
Пример #3
0
/// Edit criteria for a query column
/// </summary>
/// <param name="qc"></param>
/// <returns>True if criteria has been successfully edited</returns>

        public static bool EditCriteria(
            QueryColumn qc)
        {
            MetaColumn mc    = qc.MetaColumn;
            Query      Query = qc.QueryTable.Query;
            bool       sameQ = Query == QueriesControl.Instance.CurrentQuery;       // debug

            if (Lex.Contains(qc.MetaColumn.ColumnMap, ToolUtil.ToolParametersColumnMapValue))
            {
                DialogResult dr = ToolHelper.InvokeToolCriteriaEditor(qc);
                return(dr == DialogResult.OK);
            }

            try
            {
                if (!mc.IsSearchable)
                {
                    MessageBoxMx.ShowError("The " + qc.ActiveLabel + " data item is not currently searchable.");
                    return(false);
                }

                if (mc.IsKey)                              // edit key criteria
                {
                    qc.CopyCriteriaFromQueryKeyCriteria(); // be sure qc is in sync with Query.KeyCriteria
                    if (!CriteriaCompoundId.Edit(qc))
                    {
                        return(false);
                    }

                    qc.CopyCriteriaToQueryKeyCritera();                     // update Query.KeyCriteria
                    return(true);
                }

                switch (mc.DataType)
                {
                // Compound Number criteria

                case MetaColumnType.CompoundId:

                    if (!CriteriaCompoundId.Edit(qc))
                    {
                        return(false);
                    }
                    else
                    {
                        break;
                    }

                // Structure criteria

                case MetaColumnType.Structure:
                    if (!CriteriaStructure.Edit(qc))
                    {
                        return(false);
                    }
                    break;

                // Mol. formula criteria

                case MetaColumnType.MolFormula:
                    if (!CriteriaMolFormula.Edit(qc))
                    {
                        return(false);
                    }
                    break;


                // General criteria

                case MetaColumnType.Integer:
                case MetaColumnType.Number:
                case MetaColumnType.QualifiedNo:
                case MetaColumnType.String:
                case MetaColumnType.Date:
                case MetaColumnType.DictionaryId:

                    if (!CriteriaDialog.Edit(qc))
                    {
                        return(false);
                    }
                    else
                    {
                        break;
                    }

                default:
                    MessageBoxMx.ShowError("The " + qc.ActiveLabel + " data item is not currently searchable.");
                    return(false);
                }

                return(true);
            }

            catch (Exception ex)
            {
                string msg = "Unexpected error editing criteria: \r\n\r\n" +
                             DebugLog.FormatExceptionMessage(ex);
                ServicesLog.Message(msg);
                MessageBoxMx.ShowError(msg);
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// Edit Structure Criteria proxy
        /// </summary>
        /// <param name="qc"></param>
        /// <returns></returns>

        public static bool EditStructureCriteria(
            QueryColumn qc)
        {
            return(CriteriaStructure.Edit(qc));
        }