Exemple #1
0
        public static List <UIFormInfo> GetOrBuildFormEntityList(UnitOfWork session)//Create ddb rows for each Persistent calss
        {
            if (formInfoList == null || formInfoList.Count == 0)
            {
                formInfoList = new List <UIFormInfo>();
                foreach (var item in Enum.GetNames(typeof(CoreLib.MyEnums.FormEntityEnum)))
                {
                    //Search if Table is existed in DB

                    var itemEnum = (CoreLib.MyEnums.FormEntityEnum)Enum.Parse(typeof(CoreLib.MyEnums.FormEntityEnum), item);
                    if (itemEnum == CoreLib.MyEnums.FormEntityEnum.None)
                    {
                        continue;
                    }
                    var dbFrmRow = session.GetObjectByKey <UIFormInfo>((int)itemEnum);
                    if (dbFrmRow == null)
                    {
                        UIFormInfo t = new UIFormInfo(session)
                        {
                            FormEntity     = (int)itemEnum,
                            FormName       = item.ToString(),
                            LinkCaption_en = item.ToString()
                        };
                        t.Save();
                        dbFrmRow = t;
                    }

                    formInfoList.Add(dbFrmRow);
                }
            }

            return(formInfoList);
        }
        public static void BuildNavBarLinks(NavBarControl _navCtrl, DevExpress.Xpo.UnitOfWork _session)
        {
            var infoList = UIFormInfo.GetOrBuildFormEntityList(_session);

            foreach (NavBarItem link in _navCtrl.Items.Where(x => x.Tag != null)) //Tag foreach Link item must have FormEntity Enum value represent Form name
            {
                CoreLib.MyEnums.FormEntityEnum frmName = (CoreLib.MyEnums.FormEntityEnum)link.Tag;
                var dbRow = infoList.Where(x => x.FormEntity == (int)frmName).FirstOrDefault();
                //link.Name = dbRow.FormName;
                link.Caption = dbRow.LinkCaption;

                link.LinkClicked += (s, e) =>
                {
                    var  sender   = (NavBarItem)s;
                    var  linkCode = (CoreLib.MyEnums.FormEntityEnum)sender.Tag;
                    Args _args    = new Args()
                    {
                        Caller = MdiParentForm
                    };
                    OpenLinkToFormEntity(linkCode, _args);
                };
            }
        }