Exemplo n.º 1
0
        private static void DeclararEventos()
        {
            FormEvents.DeclararEventos(BoEventTypes.et_FORM_LOAD, new Dictionary <string, SAPHelper.Form>()
            {
                { ((int)FormTypes.OfertaDeCompra).ToString(), new FormOfertaDeCompra() },
                { ((int)FormTypes.PedidoDeVenda).ToString(), new FormPedidoDeVenda() },
                { ((int)FormTypes.NotaFiscalDeSaida).ToString(), new FormNotaFiscalDeSaida() },
            });

            _sBOApplication.AppEvent  += AppEvent;
            _sBOApplication.ItemEvent += FormEvents.ItemEvent;
        }
        private static void DeclararEventos()
        {
            var eventFilters = new EventFilters();

            eventFilters.Add(BoEventTypes.et_MENU_CLICK);

            try
            {
                #region :: Forms Cadastro Básico

                var formGrupoDeItens        = new FormGrupoDeItens();
                var formConfiguracaoPeneira = new FormConfiguracaoPeneira();
                var formCertificado         = new FormCertificado();
                var formMetodoFinanceiro    = new FormMetodoFinanceiro();
                var formModalidade          = new FormModalidade();
                var formSafra            = new FormSafra();
                var formTipoOperacao     = new FormTipoOperacao();
                var formUnidadeComercial = new FormUnidadeComercial();
                var formParticipante     = new FormParticipante();

                var formsCadastroBasico = new List <SAPHelper.Form>()
                {
                    formGrupoDeItens,
                    formConfiguracaoPeneira,
                    formCertificado,
                    formMetodoFinanceiro,
                    formModalidade,
                    formSafra,
                    formTipoOperacao,
                    formUnidadeComercial,
                    formParticipante
                };

                #endregion


                #region :: Forms Detalhe de Contrato

                var formPreContrato   = new FormPreContrato();
                var formContratoFinal = new FormContratoFinal();

                var formPreContratoAberturaPorPeneira   = new FormPreContratoAberturaPorPeneira();
                var formContratoFinalAberturaPorPeneira = new FormContratoFinalAberturaPorPeneira();

                var formPreContratoDetalheCertificado   = new FormPreContratoDetalheCertificado();
                var formContratoFinalDetalheCertificado = new FormContratoFinalDetalheCertificado();

                var formPreContratoComissoes   = new FormPreContratoComissoes();
                var formContratoFinalComissoes = new FormContratoFinalComissoes();

                var formsDetalheContrato = new List <SAPHelper.Form>()
                {
                    formPreContratoAberturaPorPeneira,
                    formContratoFinalAberturaPorPeneira,

                    formPreContratoDetalheCertificado,
                    formContratoFinalDetalheCertificado,

                    formPreContratoComissoes,
                    formContratoFinalComissoes
                };

                #endregion


                #region :: Form SAP
                var formUsuarios     = new FormUsuarios();
                var formPedidoCompra = new FormPedidoCompra();

                var formsPadraoSAP = new List <SAPHelper.Form>()
                {
                    formUsuarios,
                    formPedidoCompra
                };

                #endregion


                #region :: Grupos de Forms

                var formsVisible = new List <SAPHelper.Form>()
                {
                    formPreContrato, formContratoFinal
                };
                formsVisible.AddRange(formsCadastroBasico);
                formsVisible.AddRange(formsDetalheContrato);

                #endregion


                FormEvents.DeclararEventos(eventFilters, new List <MapEventsToForms>()
                {
                    new MapEventsToForms(BoEventTypes.et_FORM_VISIBLE, formsVisible),
                    new MapEventsToForms(BoEventTypes.et_FORM_LOAD, formsPadraoSAP),
                    new MapEventsToForms(BoEventTypes.et_COMBO_SELECT, new List <SAPHelper.Form>()
                    {
                        formPreContrato,
                        formContratoFinal,
                        formPreContratoComissoes,
                        formContratoFinalComissoes
                    }),
                    new MapEventsToForms(BoEventTypes.et_VALIDATE, new List <SAPHelper.Form>()
                    {
                        formPreContrato,
                        formContratoFinal
                    }),
                    new MapEventsToForms(BoEventTypes.et_CHOOSE_FROM_LIST, new List <SAPHelper.Form>()
                    {
                        formPreContrato,
                        formPreContratoAberturaPorPeneira,
                        formContratoFinal,
                        formContratoFinalAberturaPorPeneira
                    }),
                    new MapEventsToForms(BoEventTypes.et_FORM_DATA_ADD, new List <SAPHelper.Form>()
                    {
                        formPreContrato,
                        formContratoFinal,
                        formCertificado,
                        formMetodoFinanceiro,
                        formModalidade,
                        formSafra,
                        formTipoOperacao,
                        formUnidadeComercial,
                        formParticipante
                    }),
                    new MapEventsToForms(BoEventTypes.et_FORM_DATA_UPDATE, new List <SAPHelper.Form>()
                    {
                        formPreContrato,
                        formContratoFinal,
                        formCertificado,
                        formMetodoFinanceiro,
                        formModalidade,
                        formSafra,
                        formTipoOperacao,
                        formUnidadeComercial,
                        formParticipante
                    }),
                    new MapEventsToForms(BoEventTypes.et_FORM_DATA_LOAD, new List <SAPHelper.Form>()
                    {
                        formPreContrato,
                        formContratoFinal
                    }),
                    new MapEventsToForms(BoEventTypes.et_FORM_CLOSE, new List <SAPHelper.Form>()
                    {
                        formPreContratoDetalheCertificado,
                        formPreContratoComissoes,
                        formContratoFinalDetalheCertificado,
                        formContratoFinalComissoes,
                        formContratoFinal
                    }),
                    new MapEventsToForms(BoEventTypes.et_ITEM_PRESSED, new List <SAPHelper.Form>()
                    {
                        formPreContrato,
                        formContratoFinal,
                        formPreContratoAberturaPorPeneira,
                        formPreContratoDetalheCertificado,
                        formPreContratoComissoes,
                        formContratoFinalAberturaPorPeneira,
                        formContratoFinalDetalheCertificado,
                        formContratoFinalComissoes,
                        formGrupoDeItens,
                        formConfiguracaoPeneira,
                        formPedidoCompra
                    }),
                    new MapEventsToForms(BoEventTypes.et_MATRIX_LINK_PRESSED, new List <SAPHelper.Form>()
                    {
                        formPreContrato,
                        formContratoFinal
                    }),
                    new MapEventsToForms(BoEventTypes.et_DOUBLE_CLICK, new List <SAPHelper.Form>()
                    {
                        formPreContrato,
                        formContratoFinal
                    }),
                });

                var formsAdicionarNovo = new List <SAPHelper.Form>()
                {
                    formPreContrato, formContratoFinal
                };
                formsAdicionarNovo.AddRange(formsCadastroBasico);

                FormEvents.DeclararEventosInternos(EventosInternos.AdicionarNovo, formsAdicionarNovo);
                FormEvents.DeclararEventosInternos(EventosInternos.Pesquisar, new List <SAPHelper.Form>()
                {
                    formPreContrato,
                    formContratoFinal
                });
                FormEvents.DeclararEventosInternos(EventosInternos.Duplicar, formPedidoCompra);
            }
            catch (Exception e)
            {
                Dialogs.PopupError("Erro ao declarar eventos de formulário.\nErro: " + e.Message);
            }

            try
            {
                Global.SBOApplication.SetFilter(eventFilters);
            }
            catch (Exception e)
            {
                Dialogs.PopupError("Erro ao setar eventos declarados da aplicação.\nErro: " + e.Message);
            }

            Global.SBOApplication.AppEvent      += AppEvent;
            Global.SBOApplication.ItemEvent     += FormEvents.ItemEvent;
            Global.SBOApplication.FormDataEvent += FormEvents.FormDataEvent;
            Global.SBOApplication.MenuEvent     += Menu.MenuEvent;
        }