Exemplo n.º 1
0
        public void Initialize()
        {
            //Initialize UI API objects
            Menus              lObjMenus           = null;
            MenuItem           lObjMenuItem        = null;
            MenuCreationParams lObjCreationPackage = null;

            //Get SAP B1 menus
            lObjMenus = UIApplication.GetMenus();

            //Get menu creation params
            lObjCreationPackage = UIApplication.GetMenuCreationParams();

            //Get modules menu of SAP B1 menu
            lObjMenuItem = UIApplication.GetMenus().Item("43520");

            //Add add-on menu
            foreach (Module lObjModule in Menu)
            {
                if (AddModule(lObjModule, lObjMenus, lObjMenuItem, lObjCreationPackage))
                {
                    foreach (Section lObjSection in lObjModule.Sections)
                    {
                        AddSection(lObjModule, lObjSection, lObjMenus, lObjMenuItem, lObjCreationPackage);
                    }
                }
            }
            //Add add-on Form: ReceptionForm Form in the Menu Inventario (3072), Operaciones de stock (43540)
            //bool result = AddForm(lObjMenus, lObjMenuItem, lObjCreationPackage);
        }
Exemplo n.º 2
0
        private bool AddSection(Module pObjModule, Section pObjSection, Menus pObjMenus, MenuItem pObjMenuItem, MenuCreationParams pObjCreationPackage)
        {
            bool lBolResult = false;

            try
            {
                //Get module menu
                pObjMenuItem = UIApplication.GetMenus().Item(pObjModule.UniqueID);

                //Prepare section
                pObjCreationPackage.Type     = SAPbouiCOM.BoMenuType.mt_STRING;
                pObjCreationPackage.UniqueID = pObjSection.UniqueID;
                pObjCreationPackage.String   = pObjSection.String;
                pObjMenus = pObjMenuItem.SubMenus;

                //Add section
                pObjMenus.AddEx(pObjCreationPackage);

                //Update result
                lBolResult = true;
            }
            catch (Exception ex)
            {
                UIApplication.ShowError(string.Format("RegisterSectionException: {0}", ex.Message));
            }

            return(lBolResult);
        }