コード例 #1
0
ファイル: MenuManager.cs プロジェクト: radtek/UGRS_Full
        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);
        }
コード例 #2
0
        private void setMenuItems()
        {
            Menus menus = AppContext.SBOApplication.Menus;

            MenuCreationParams creationParams = AppContext.SBOApplication.CreateObject(BoCreatableObjectType.cot_MenuCreationParams);

            SAPbouiCOM.MenuItem menuItem = AppContext.SBOApplication.Menus.Item("43520");
            menus = menuItem.SubMenus;

            //Se agrega menu de add-on <<linea de Creditos>>
            if (AppContext.SBOApplication.Menus.Exists("Facturas"))
            {
                AppContext.SBOApplication.Menus.RemoveEx("Facturas");
            }

            creationParams.Type     = SAPbouiCOM.BoMenuType.mt_POPUP;
            creationParams.UniqueID = "Facturas";
            creationParams.String   = "Facturas";
            creationParams.Enabled  = true;
            creationParams.Position = 1;
            menus.AddEx(creationParams);

            //Se agrega submenu de formulario <<Aumento de Creditos>>
            menuItem                = AppContext.SBOApplication.Menus.Item("Facturas");
            menus                   = menuItem.SubMenus;
            creationParams.Type     = SAPbouiCOM.BoMenuType.mt_STRING;
            creationParams.UniqueID = "FacturasDoc";
            creationParams.String   = "Facturas Documentos";
            menus.AddEx(creationParams);
        }
コード例 #3
0
        /// <summary>
        /// Create menu when rihgt click in matrix
        /// menu Add Row and Delete Row
        public void RightClickEvent_AltItem(ref ContextMenuInfo eventInfo, ref bool bubbleEvent)
        {
            Form oForm = oSBOApplication.Forms.ActiveForm;

            if (eventInfo.BeforeAction == true && eventInfo.ItemUID == "mt_1")
            {
                MenuItem           oMenuItem         = null;
                Menus              oMenus            = null;
                MenuCreationParams oCreateionPackage = null;

                try
                {
                    oCreateionPackage = oSBOApplication.CreateObject(BoCreatableObjectType.cot_MenuCreationParams);


                    oCreateionPackage.Type     = BoMenuType.mt_STRING;
                    oCreateionPackage.UniqueID = "AltItemAdd";
                    oCreateionPackage.Position = 1;
                    oCreateionPackage.String   = "Add Row";
                    oCreateionPackage.Enabled  = true;

                    oMenuItem = oSBOApplication.Menus.Item("1280");
                    oMenus    = oMenuItem.SubMenus;
                    oMenus.AddEx(oCreateionPackage);


                    oCreateionPackage = oSBOApplication.CreateObject(BoCreatableObjectType.cot_MenuCreationParams);


                    oCreateionPackage.Type     = BoMenuType.mt_STRING;
                    oCreateionPackage.UniqueID = "AltItemDel";
                    oCreateionPackage.Position = 2;
                    oCreateionPackage.String   = "Delete Row";
                    oCreateionPackage.Enabled  = true;

                    oMenuItem = oSBOApplication.Menus.Item("1280");
                    oMenus    = oMenuItem.SubMenus;
                    oMenus.AddEx(oCreateionPackage);
                }
                catch (Exception ex)
                {
                    oSBOApplication.MessageBox(ex.Message);
                }
                finally
                {
                    Utils.releaseObject(oMenuItem);
                    Utils.releaseObject(oMenus);
                    Utils.releaseObject(oCreateionPackage);
                }

                GeneralVariables.iDelRow = eventInfo.Row;
            }
            else
            {
                oSBOApplication.Menus.RemoveEx("AltItemAdd");
                oSBOApplication.Menus.RemoveEx("AltItemDel");
            }
            Utils.releaseObject(oForm);
        }
コード例 #4
0
        public MenuItem Add(string parentID, MenuCreationParams menuParams)
        {
            var subMenu = _app.SBOApplication.Menus.Item(parentID).SubMenus;

            try {
                return(subMenu.AddEx(menuParams));
            }
            catch (COMException) {
                return(subMenu.Item(menuParams.UniqueID));
            }
        }
コード例 #5
0
ファイル: MenuManager.cs プロジェクト: radtek/UGRS_Full
        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);
        }
コード例 #6
0
ファイル: MenuManager.cs プロジェクト: radtek/UGRS_Full
        //private bool AddForm(Menus pObjMenus, MenuItem pObjMenuItem, MenuCreationParams pObjCreationPackage)
        //{
        //    bool lBolResult = false;
        //    try
        //    {
        //        SAPbouiCOM.Menus lObjMenus = null;
        //        lObjMenus = pObjMenus.Item(6).SubMenus.Item(7).SubMenus.Item(4).SubMenus;
        //        pObjCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING;
        //        pObjCreationPackage.UniqueID = "ReceptionForm";
        //        pObjCreationPackage.String = "Recepción de Alimento";
        //        //pObjCreationPackage.Image = ;
        //        pObjCreationPackage.Position = lObjMenus.Count + 1;
        //        lObjMenus.AddEx(pObjCreationPackage);

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

        private bool AddModule(Module pObjModule, Menus pObjMenus, MenuItem pObjMenuItem, MenuCreationParams pObjCreationPackage)
        {
            bool lBolResult = false;

            try
            {
                //Prepare module
                pObjCreationPackage.Type     = BoMenuType.mt_POPUP;
                pObjCreationPackage.UniqueID = pObjModule.UniqueID;
                pObjCreationPackage.String   = pObjModule.String;
                pObjCreationPackage.Enabled  = pObjModule.Enable;
                pObjCreationPackage.Image    = pObjModule.Image;
                pObjCreationPackage.Position = pObjModule.Position;
                pObjMenus = pObjMenuItem.SubMenus;

                //Add module
                pObjMenus.AddEx(pObjCreationPackage);

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

            return(lBolResult);
        }