Beispiel #1
0
        public void MenuStripDB(Form Parent, MenuStrip MnuStrip)
        {
            MnuStrip = new MenuStrip();
            Parent.Controls.Add(MnuStrip);
            transacoes = new List <FuncaoSubMenu>();
            Usuario usuario = UtilObject.Deserialize <Usuario>("\\usuarios.dat");

            if (usuario != null)
            {
                FuncoesMenu = FuncaoMenuDAO.FindByUsuario(usuario.Bname);

                if (FuncoesMenu != null && FuncoesMenu.Count > 0)
                {
                    for (int i = 0; i < FuncoesMenu.Count; i++)
                    {
                        FuncaoMenu FncMenu = FuncoesMenu[i];

                        ToolStripMenuItem item = new ToolStripMenuItem(FncMenu.Menu)
                        {
                            Name = FncMenu.Menu,
                            Text = FncMenu.Descricao
                        };

                        if (FncMenu.FuncoesSubMenu != null && FncMenu.FuncoesSubMenu.Count > 0)
                        {
                            for (int j = 0; j < FncMenu.FuncoesSubMenu.Count; j++)
                            {
                                FuncaoSubMenu sub = FncMenu.FuncoesSubMenu[j];
                                if (sub.Superior == "")
                                {
                                    ToolStripMenuItem ItemAux = new ToolStripMenuItem
                                    {
                                        Name = sub.SubMenu,
                                        Text = sub.Descricao
                                    };
                                    item.DropDownItems.Add(ItemAux);
                                }
                                else
                                {
                                    SetToolsMenu(item.DropDownItems, sub);
                                }
                            }

                            MnuStrip.Items.Add(item);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void SetToolsMenu(ToolStripItemCollection menus, FuncaoSubMenu sub)
        {
            foreach (object obj in menus)
            {
                if (obj.GetType().Equals(typeof(ToolStripMenuItem)))
                {
                    ToolStripMenuItem subMenu = (ToolStripMenuItem)obj;

                    if (subMenu.Name == sub.Superior)
                    {
                        ToolStripMenuItem ItemMenu = (ToolStripMenuItem)subMenu;
                        if (sub.Acao != null && sub.Acao != "")
                        {
                            ToolStripMenuItem SSMenu = new ToolStripMenuItem(sub.Acao.ToString(), null,
                                                                             new EventHandler(ChildClick))
                            {
                                Name = sub.Acao,
                                Text = sub.Descricao
                            };
                            ItemMenu.DropDownItems.Add(SSMenu);
                            if (sub.Transacao != "")
                            {
                                transacoes.Add(sub);
                            }
                        }
                        else
                        {
                            ToolStripMenuItem SSMenu = new ToolStripMenuItem
                            {
                                Name = sub.SubMenu,
                                Text = sub.Descricao
                            };
                            ItemMenu.DropDownItems.Add(SSMenu);
                            if (sub.Transacao != "")
                            {
                                transacoes.Add(sub);
                            }
                        }
                    }
                    else if (subMenu.HasDropDownItems)
                    {
                        SetToolsMenu(subMenu.DropDownItems, sub);
                    }
                }
            }
        }
Beispiel #3
0
        public void CallTransacao(Principal Parent, string transacao)
        {
            Boolean tcode = false;

            this.FormPrincipal.Cursor = Cursors.WaitCursor;

            for (int i = 0; i < transacoes.Count; i++)
            {
                if (transacoes[i].Transacao == transacao)
                {
                    tcode = true;
                    break;
                }
            }

            if (tcode)
            {
                FuncaoSubMenu SubMenu = SubMenuDAO.FindByTransacao(transacao);
                if (SubMenu != null)
                {
                    if (SubMenu.Acao.ToString() != "")
                    {
                        foreach (Form form in this.FormPrincipal.MdiChildren)
                        {
                            form.Close();
                        }
                        Form frmShow = (Form)GetInstance(SubMenu.Acao.ToString());
                        frmShow.MdiParent   = Parent;
                        frmShow.WindowState = FormWindowState.Maximized;
                        int x = 1;
                        int y = 2;
                        frmShow.Location          = new Point(x, y);
                        frmShow.ControlBox        = false;
                        this.FormPrincipal.Cursor = Cursors.Default;
                        frmShow.Show();
                        frmShow.Focus();
                    }
                }
            }
            else
            {
                this.FormPrincipal.Cursor = Cursors.Default;
                Parent.exibirMessage(actionErr, "Transação " + transacao + " não existe!", "E");
            }
        }