示例#1
0
        private void JoinAnchorComboBox_Properties_Enter(object sender, EventArgs e)
        {
            GetCalcFieldForm();             // get latest values

            CalcField       cf = CalcField;
            CalcFieldColumn cfc;

            HashSet <MetaTable> tableSet = new HashSet <MetaTable>();

            ComboBoxItemCollection items = JoinAnchorComboBox.Properties.Items;

            items.Clear();
            items.Add("(none)");

            for (int ci = 0; ci < cf.CfCols.Count; ci++)
            {
                CalcFieldColumn cfCol = cf.CfCols[ci];
                if (cfCol.MetaColumn == null)
                {
                    continue;
                }
                MetaTable mt = cfCol.MetaColumn.MetaTable;
                if (tableSet.Contains(mt))
                {
                    continue;
                }

                tableSet.Add(mt);
                items.Add(mt.Label);
            }

            return;
        }
示例#2
0
        /// <summary>
        /// Get other values from calc field form checking for errors
        /// </summary>
        /// <returns></returns>

        bool GetCalcFieldForm()
        {
            List <MetaColumn> mcList;

            CalcField       cf  = CalcField;
            CalcFieldColumn cfc = null;

            if (cf.CalcType == CalcTypeEnum.Basic)             // basic CF
            {
                cf.Operation = Operation.Text;

                cf.CfCols.Clear();                 // update
                foreach (CalcFieldColumnControl cfcc in CfColCtls)
                {
                    if (cfcc.FieldSelectorControl.MetaColumn == null)
                    {
                        continue;
                    }

                    cfc            = new CalcFieldColumn();
                    cfc.MetaColumn = cfcc.FieldSelectorControl.MetaColumn;
                    cfc.Function   = cfcc.Function.Text;
                    cfc.Constant   = cfcc.Constant.Text;
                    cf.CfCols.Add(cfc);
                }
            }

            else             // advanced CF
            {
                cf.AdvancedExpr = ParseAdvancedExpr(AdvancedExpr.Text, out mcList);

// Get preclassification result type

                string txt = ResultDataType.Text;
                if (Lex.IsDefined(txt))
                {
                    cf.PreclassificationlResultType = MetaColumn.ParseMetaColumnTypeString(txt);
                }

                else
                {
                    cf.PreclassificationlResultType = MetaColumnType.Number;
                }

// Get anchor table for joins

                cf.CfCols.Clear();
                foreach (MetaColumn mc0 in mcList)
                {
                    cfc            = new CalcFieldColumn();
                    cfc.MetaColumn = mc0;
                    cf.CfCols.Add(cfc);
                }

                cf.OuterJoinRoot = "";
                txt = JoinAnchorComboBox.Text;
                if (Lex.Eq(txt, "(None)"))
                {
                    txt = "";
                }

                if (Lex.IsDefined(txt))
                {
                    for (int ci = 0; ci < cf.CfCols.Count; ci++)
                    {
                        cfc = cf.CfCols[ci];
                        if (Lex.Eq(txt, cfc.MetaColumn.MetaTable.Label))
                        {
                            cf.OuterJoinRoot = cfc.MetaColumn.MetaTable.Name;
                            break;
                        }
                    }
                }
            }

            cf.Description = Description.Text;

            CondFormatRules rules = CondFormatRulesCtl.GetRules();

            if (rules.Count == 0)
            {
                cf.Classification = null;
            }
            else
            {
                cf.Classification       = new CondFormat();
                cf.Classification.Rules = rules;
            }

            try { cf.SetDerivedValuesWithException(); }             // set derived values checking for errors
            catch (Exception ex)
            {
                MessageBoxMx.ShowError(ex.Message);
                return(false);
            }

            return(true);
        }