Beispiel #1
0
        public bool HasAttributeDef(string attrDefName)
        {
            if (attrDefName.Length > 0 && attrDefName[0] == '&')
            {
                SystemIdent ident;
                if (SystemIdentConverter.TryConvert(attrDefName, out ident))
                {
                    return(true);
                }
            }

            return(FindAttributeDef(attrDefName) != null);
        }
Beispiel #2
0
        private void InitComboBox(BizComboBox control, Combo_Box controlData, DocDef def)
        {
            AttrDef attrDef = null;

            if (def != null)
            {
                if (controlData.Attribute_Id != null)
                {
                    attrDef = def.Attributes.FirstOrDefault(a => a.Id == controlData.Attribute_Id);
                }
                if (attrDef == null && controlData.Attribute_Name != null)
                {
                    attrDef =
                        def.Attributes.FirstOrDefault(a => String.Equals(a.Name, controlData.Attribute_Name, StringComparison.OrdinalIgnoreCase));
                }
            }
            control.Rows    = controlData.Rows ?? 0;
            control.IsRadio = controlData.Is_Radio ?? false;
            if (attrDef != null)
            {
                control.AttributeDefId = attrDef.Id;
                control.AttributeName  = attrDef.Name;
            }
            else
            {
                var         attrName = controlData.Attribute_Name ?? String.Empty;
                SystemIdent attrIdent;
                if (SystemIdentConverter.TryConvert(attrName, out attrIdent))
                {
                    control.Ident         = attrIdent;
                    control.AttributeName = attrName;
                    //InitComboBox(control, attrIdent);
                }
            }
            control.DetailAttributeId   = controlData.Detail_Attribute_Id;
            control.DetailAttributeName = controlData.Detail_Attribute_Name;

            /*if (attrDef != null)
             * {
             *  //if (!controlData.Attribute_DefsReference.IsLoaded) controlData.Attribute_DefsReference.Load();
             *
             *  InitComboBox(control, attrDef /*controlData.Attribute_Defs#1#);
             * } */

            InitControl(control, controlData);
            // AddQueryItems(control, controlData); // Вызывает ошибку дублирования QueryItems
        }
Beispiel #3
0
        public BizDataControl CreateEditor(Editor editor, DocDef def)
        {
            BizDataControl result  = null;
            AttrDef        attrDef = null;

            if (def != null)
            {
                if (editor.Attribute_Id != null)
                {
                    attrDef = def.Attributes.FirstOrDefault(a => a.Id == editor.Attribute_Id);
                }
                if (attrDef == null && !String.IsNullOrEmpty(editor.Attribute_Name) && editor.Attribute_Name[0] != '&')
                {
                    attrDef =
                        def.Attributes.FirstOrDefault(
                            a => String.Equals(a.Name, editor.Attribute_Name, StringComparison.OrdinalIgnoreCase));
                }
            }
            if (attrDef != null)
            {
                result = CreateTypeEditor(editor, attrDef);
            }

            /*else
             *  {
             *      if (!editor.Attribute_DefsReference.IsLoaded) editor.Attribute_DefsReference.Load();
             *      if (editor.Attribute_Defs == null) return null;
             *
             *      result = CreateTypeEditor(editor.Attribute_Defs);
             *  }*/

            else
            {
                var attrName = editor.Attribute_Name ?? String.Empty;

                SystemIdent attrIdent;
                if (SystemIdentConverter.TryConvert(attrName, out attrIdent))
                {
                    switch (attrIdent)
                    {
                    case SystemIdent.OrgId:
                    case SystemIdent.OrgName:
                    case SystemIdent.OrgCode:
                    case SystemIdent.State:
//                        case SystemIdent.InState:
                        result = new BizEditText {
                            Ident = attrIdent, ReadOnly = true, AttributeName = attrName
                        };
                        break;

                    case SystemIdent.Id:
                    case SystemIdent.UserId:
                    case SystemIdent.UserName:
                        result = new BizEditText {
                            Ident = attrIdent, ReadOnly = true, AttributeName = attrName
                        };
                        break;

                    case SystemIdent.Created:
                    case SystemIdent.Modified:
                    case SystemIdent.StateDate:
                        result = new BizEditDateTime {
                            Ident = attrIdent, ReadOnly = true, AttributeName = attrName
                        };
                        break;
                    }
                }
            }

            AddChildren(result, editor, def);
            if (result is BizEdit)
            {
                InitEditor((BizEdit)result, editor);
            }
            if (result is BizComboBox)
            {
                InitComboBox(result as BizComboBox, editor, attrDef);
            }

            return(result);
        }