Пример #1
0
        private void SetFINReadOnly(Control ctrl)
        {
            foreach (Control item in ctrl.Controls)
            {
                if (item is DigiwinSelectControl)
                {
                    DigiwinSelectControl c = item as DigiwinSelectControl;
                    c.ReadOnly = true;
                }
                else if (item is DigiwinPickListLookUpEdit)
                {
                    DigiwinPickListLookUpEdit c = item as DigiwinPickListLookUpEdit;
                    c.Properties.ReadOnly = true;
                }
                else if (item is DigiwinTextBox)
                {
                    DigiwinTextBox c = item as DigiwinTextBox;
                    c.ReadOnly = true;
                }
                else if (item is DigiwinCheckBox)
                {
                    DigiwinCheckBox c = item as DigiwinCheckBox;
                    c.Enabled = false;
                }
                else if (item is DigiwinRadioButton)
                {
                    DigiwinRadioButton c = item as DigiwinRadioButton;
                    c.Enabled = false;
                }

                SetFINReadOnly(item);
            }
        }
Пример #2
0
        public static DigiwinSelectControl CreateSelectControl(DependencyObject dataSource, string name, string propertyName, ParaEntity para
                                                               , bool isReadOnly, bool visible, bool allowMultiSelect, int tabeIndex)
        {
            DigiwinSelectControl dsc1 = new DigiwinSelectControl();

            ((System.ComponentModel.ISupportInitialize)(dsc1)).BeginInit();
            dsc1.Name        = name;
            dsc1.SelectStyle = SelectStyle.TwoInOneOpen;
            dsc1.ReadOnly    = isReadOnly;
            dsc1.Visible     = visible;
            dsc1.AllowInput  = false;
            dsc1.AllowOpenWindowInOpenState = false;
            BindingSource bs          = new BindingSource();
            string        hiddenText  = propertyName.Replace("_ID", "_CODE");
            string        displayText = propertyName.Replace("_ID", "_NAME");

            if (dataSource != null)
            {
                bs.DataSource = dataSource.DefaultView;

                dsc1.DataBindings.Add(new Binding("Value", bs, propertyName, true, DataSourceUpdateMode.OnPropertyChanged, Maths.GuidDefaultValue()));
                dsc1.DataBindings.Add(new Binding("HiddenText", bs, hiddenText, true, DataSourceUpdateMode.OnPropertyChanged));
                dsc1.DataBindings.Add(new Binding("DisplayText", bs, displayText, true, DataSourceUpdateMode.OnPropertyChanged));
            }

            GeneralWindowOpener generalWindowOpener = new GeneralWindowOpener();

            generalWindowOpener.Description = null;
            generalWindowOpener.InexactQuery.QueryProjectId = null;
            generalWindowOpener.InexactQuery.QueryTypeKey   = null;
            generalWindowOpener.InexactQuery.ReturnField    = null;
            generalWindowOpener.Name            = null;
            generalWindowOpener.OpenCondition   = null;
            generalWindowOpener.OpenFailMessage = null;
            generalWindowOpener.RelatedType     = RelatedType.BindingField;
            generalWindowOpener.MultiSelect     = allowMultiSelect;
            //if (propertyVM.OpeningPatameters.Count > 0) {
            //    foreach (OpeningParameter parameter in propertyVM.OpeningPatameters) {
            //        generalWindowOpener.OpeningParameters.Add(parameter);
            //    }
            //}

            ReturnExpression returnExpression1 = new ReturnExpression();
            ReturnExpression returnExpression2 = new ReturnExpression();
            ReturnExpression returnExpression3 = new ReturnExpression();
            ReturnExpression returnExpression4 = new ReturnExpression();

            generalWindowOpener.QueryProjectId = para.QueryProjectId;
            generalWindowOpener.QueryTypeKey   = para.QueryTypeKey;

            returnExpression1.Left  = "ActiveObject." + propertyName;
            returnExpression1.Name  = "ActiveObject." + para.PropertyName;
            returnExpression1.Right = "SelectedObjects[0]." + para.TargetEntityPirmaryKeyID;

            returnExpression2.Left  = "ActiveObject." + hiddenText;
            returnExpression2.Name  = "ActiveObject." + para.TargetEntityPirmaryKeyID.Replace("_ID", "_CODE");
            returnExpression2.Right = "SelectedObjects[0]." + para.TargetEntityPirmaryKeyID.Replace("_ID", "_CODE");

            returnExpression3.Left  = "ActiveObject." + displayText;
            returnExpression3.Name  = "ActiveObject." + para.TargetEntityPirmaryKeyID.Replace("_ID", "_NAME");
            returnExpression3.Right = "SelectedObjects[0]." + para.TargetEntityPirmaryKeyID.Replace("_ID", "_NAME");

            returnExpression4.Left  = "ActiveObject." + propertyName + "_RETURN_VALUE";
            returnExpression4.Name  = "ActiveObject." + para.PropertyName + "_RETURN_VALUE";
            returnExpression4.Right = "SelectedObjects[0].RETURN_VALUE";

            generalWindowOpener.ReturnExpressions.Add(returnExpression1);
            generalWindowOpener.ReturnExpressions.Add(returnExpression2);
            generalWindowOpener.ReturnExpressions.Add(returnExpression3);
            generalWindowOpener.ReturnExpressions.Add(returnExpression4);

            generalWindowOpener.ReturnField = para.TargetEntityPirmaryKeyID;
            generalWindowOpener.Shortcut    = System.Windows.Forms.Keys.F2;
            generalWindowOpener.Tip         = para.Tip;
            dsc1.WindowOpeners.Add(generalWindowOpener);
            ((System.ComponentModel.ISupportInitialize)(dsc1)).EndInit();

            return(dsc1);
        }
        /// <summary>
        /// 组建界面
        /// </summary>
        /// <param name="dataSource"></param>
        private void CreateUIView()
        {
            //创建第一行函数列表
            Label firstLbl = ControlUtils.CreateLabel("lbl", "选择函数", false);

            _table.Controls.Add(firstLbl, 0, 0);
            LookUpEdit lookupFun = ControlUtils.CreateLookUpEdit(_dataSource, "Function", "Function", true, 0, null, 0);

            _table.Controls.Add(lookupFun, 1, 0);

            int index = 1;
            int row   = 1;

            foreach (ParaEntity para in CurrentFunction.ParaList)
            {
                //标签
                Label lbl = ControlUtils.CreateLabel("lbl", para.DisplayName, false);
                _table.Controls.Add(lbl, 0, row);

                //条件选项
                DigiwinPickListLookUpEdit condition = ControlUtils.CreatePickList(_dataSource, para.ConditionName, para.ConditionName, "Condition", false, null, 2);
                _table.Controls.Add(condition, 1, row);

                //参数
                #region 控件类型
                if (para.ParaTypeFlag == ParaTypeEnum.DataTime)
                {
                    DigiwinDateTimePicker date = ControlUtils.CreateDateTimePicker(_dataSource, para.Name, para.Name, false, index++);
                    _table.Controls.Add(date, 2, row);
                }
                else if (para.ParaTypeFlag == ParaTypeEnum.PickList)
                {
                    LookUpEdit lookup = ControlUtils.CreateLookUpEdit(_dataSource, para.Name, para.Name, true, 0, null, index++);
                    lookup.Anchor = AnchorStyles.Left;
                    lookup.Width  = 150;
                    GetPickDataSource(para.PickListTypeName, lookup);
                    _table.Controls.Add(lookup, 2, row);
                }
                else if (para.ParaTypeFlag == ParaTypeEnum.SelectControl)
                {
                    DigiwinSelectControl select = ControlUtils.CreateSelectControl(_dataSource, para.Name, para, false, false, index++);
                    select.Anchor = AnchorStyles.Left;
                    select.Width  = 150;
                    _table.Controls.Add(select, 2, row);
                }
                else if (para.ParaTypeFlag == ParaTypeEnum.Decimal)
                {
                    DigiwinTextBox dec = ControlUtils.CreateNumericTextBox(_dataSource, para.Name, para.Name, "0", true, false, 10, index++);
                    dec.Width = 150;
                    _table.Controls.Add(dec, 2, row);
                }
                else if (para.ParaTypeFlag == ParaTypeEnum.String)
                {
                    DigiwinTextBox str = ControlUtils.CreateNumericTextBox(_dataSource, para.Name, para.Name, "0", false, false, 10, index++);
                    str.Width = 150;
                    _table.Controls.Add(str, 2, row);
                }
                else if (para.ParaTypeFlag == ParaTypeEnum.Bool)
                {
                    DigiwinCheckBox chk = ControlUtils.CreateCheckBox(_dataSource, para.Name, para.Name, "", false, true, index++);
                    chk.Width = 50;
                    _table.Controls.Add(chk, 2, row);
                }
                #endregion
                para.Row    = row;
                para.Column = 2;

                row++;
            }
        }