Example #1
0
        /// <summary>
        /// 设置某个菜单条的可见性
        /// </summary>
        /// <param name="view"></param>
        /// <param name="bVisible">可见性</param>
        /// <param name="barOwnerKey">工具条拥有者标识,单据主工具条不用传值,表格工具条请传表格标识,其它独立工具条请传工具条标识</param>
        public static void SetBarVisible(this IDynamicFormView view, bool bVisible, string barOwnerKey = "")
        {
            if (string.IsNullOrWhiteSpace(barOwnerKey))
            {
                FormAppearance formAppearance = view.LayoutInfo.GetFormAppearance();
                if (((formAppearance.Menu != null) && !string.IsNullOrWhiteSpace(formAppearance.Menu.Id)) && (formAppearance.ShowMenu == 1))
                {
                    foreach (var item in formAppearance.Menu.GetAllBarItems())
                    {
                        view.SetBarItemVisible(item.Key, bVisible, barOwnerKey);
                    }
                }
            }
            else
            {
                EntryEntityAppearance appearance3 = view.LayoutInfo.GetEntryEntityAppearance(barOwnerKey);
                if ((appearance3 != null) && (appearance3.Menu != null))
                {
                    foreach (var item in appearance3.Menu.GetAllBarItems())
                    {
                        view.SetBarItemVisible(item.Key, bVisible, barOwnerKey);
                    }
                }

                ToolBarCtrlAppearance appearance4 = view.LayoutInfo.GetToolbarCtrlAppearances().FirstOrDefault(o => o.Key == barOwnerKey);
                if ((appearance4 != null) && (appearance4.Menu != null))
                {
                    foreach (var item in appearance4.Menu.GetAllBarItems())
                    {
                        view.SetBarItemVisible(item.Key, bVisible, barOwnerKey);
                    }
                }
            }
        }
Example #2
0
        private static FieldAppearance GetNextEditFieldAp(IDynamicFormView view, FieldAppearance fieldAp, int iRow)
        {
            FieldAppearance nextFieldAp = null;

            if (fieldAp != null)
            {
                EntryEntityAppearance entryEntityAp = view.LayoutInfo.GetEntryEntityAppearance(fieldAp.EntityKey);
                if (entryEntityAp != null)
                {
                    DynamicObject rowData       = view.Model.GetEntityDataObject(entryEntityAp.Entity, iRow);
                    int           iStartFindPos = entryEntityAp.Layoutinfo.Appearances.IndexOf(fieldAp);
                    if (iStartFindPos >= 0)
                    {
                        for (int i = iStartFindPos + 1; i < entryEntityAp.Layoutinfo.Appearances.Count; i++)
                        {
                            nextFieldAp = entryEntityAp.Layoutinfo.Appearances[i] as FieldAppearance;
                            if (nextFieldAp == null)
                            {
                                continue;
                            }
                            //跳过不可见或不可编辑的字段
                            if (nextFieldAp.IsLocked(view.OpenParameter.Status) == true ||
                                nextFieldAp.IsVisible(view.OpenParameter.Status) == false)
                            {
                                continue;
                            }

                            //单元格锁定也不填充
                            if (rowData != null && view.StyleManager.GetEnabled(fieldAp, rowData) == false)
                            {
                                continue;
                            }

                            break;
                        }
                    }
                }
            }

            return(nextFieldAp);
        }