Ejemplo n.º 1
0
        public static MetaColumn Show(
            string prompt,
            string title,
            Query q,
            MetaColumn mc)
        {
            FieldSelectorDialog fsd = new FieldSelectorDialog();

            fsd.Text        = title;
            fsd.Prompt.Text = prompt;

            fsd.FSC.Query      = q;
            fsd.FSC.MetaColumn = mc;

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

            if (dr == DialogResult.OK)
            {
                return(fsd.FSC.MetaColumn);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Select a standard calculated field
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void StandardCalcMenuItem_Click(object sender, EventArgs e)
        {
            CalcField cf2 = null;
            string    title;
            int       i1;

            ToolStripMenuItem ci = (ToolStripMenuItem)sender;             // item clicked on

            if (String.IsNullOrEmpty(ci.Text))
            {
                return;
            }

            string standardCalcName = ci.Text;

            for (i1 = 0; i1 < StandardCalculatedFields.Count; i1++)
            {
                cf2 = StandardCalculatedFields[i1];
                if (Lex.Eq(cf2.UserObject.Name, standardCalcName))
                {
                    break;
                }
            }

            if (i1 >= StandardCalculatedFields.Count)
            {
                throw new Exception("Unrecognized standard calculation: " + standardCalcName);
            }

            CalcField = cf2.Clone();

            SetupForm();             // display new content

            title = "Edit Calculated Field";
            string cfName = cf2.UserObject.Name;

            i1 = cfName.IndexOf(" (");
            if (i1 > 0)
            {
                cfName = cfName.Substring(0, i1);
            }
            title += " - " + cfName;
            Text   = title;

            if (UoIn.Id <= 0)
            {
                UoIn.Name = cfName;                           // substitute name if not saved yet
            }
            if (!String.IsNullOrEmpty(cf2.Prompt))            // prompt the user
            {
                MetaColumn mc = FieldSelectorDialog.Show(cf2.Prompt, "Input Parameter",
                                                         QueriesControl.Instance.CurrentQuery, null);

                if (mc == null)
                {
                    return;
                }

                else if (CalcField.CalcType == CalcTypeEnum.Basic)
                {
                    CalcField.Column1.MetaColumn = mc;
                }

                else
                {
                    CalcField.AdvancedExpr =
                        Lex.Replace(CalcField.AdvancedExpr, "user_input_metatable.metacolumn", mc.MetaTable.Name + "." + mc.Name);
                }

                SetupForm();
            }
        }