Пример #1
0
        private EventoResultado CriarEstruturaEvento()
        {
            var evento = new Evento(this.UsuarioID);

            if (InfoFase1.EventoIDComplementar > 0)
            {
                evento.Ler(InfoFase1.EventoIDComplementar);
            }

            evento.Nome.Valor    = InfoFase1.Etapa1.Nome;
            evento.LocalID.Valor = InfoFase1.Etapa1.LocalID;
            evento.ImpressaoCodigoBarra.Valor = true;
            evento.DesabilitaAutomatico.Valor = true;

            evento.ExibeQuantidade.Valor           = false;
            evento.EntregaGratuita.Valor           = false;
            evento.RetiradaBilheteria.Valor        = true;
            evento.HabilitarRetiradaTodosPDV.Valor = true;
            evento.TipoImpressao.Valor             = Configuracao.GetString(Configuracao.Keys.EventoTipoImpressao, ConfigurationManager.AppSettings["ConfigVersion"]);
            evento.TipoCodigoBarra.Valor           = Configuracao.GetString(Configuracao.Keys.EventoTipoCodigoBarra, ConfigurationManager.AppSettings["ConfigVersion"]);

            evento.LimiteMaximoIngressosEvento.Valor = 0;
            evento.VendaSemAlvara.Valor = Configuracao.GetBoolean(Configuracao.Keys.EventoVendaSemAlvara, ConfigurationManager.AppSettings["ConfigVersion"]);

            evento.MapaEsquematicoID.Valor = InfoFase1.Etapa3.MapaEsquematicoId;
            evento.Ativo.Valor             = "T";

            List <int> apresentacoes = null;
            List <GerarEventoEtapa1Fase3Model.SetoresNovo> setores = null;

            this.Resultado.Evento = evento;

            using (BD bd = new BD())
            {
                bd.IniciarTransacao();


                if (InfoFase1.EventoIDComplementar > 0)
                {
                    evento.CompletarCadastro.Valor = 0;

                    if (!evento.Atualizar(bd))
                    {
                        throw new ApplicationException("Erro ao atualizar o evento!");
                    }
                }
                else
                {
                    if (!evento.Inserir(bd))
                    {
                        throw new ApplicationException("Erro ao criar o evento!");
                    }
                }

                apresentacoes = this.InsereApresentacoes(bd);
                setores       = this.InsereSetores(bd, apresentacoes);

                #region Forma de Pagamento Padrão do Evento

                FormaPagamentoEvento forma = new FormaPagamentoEvento(this.UsuarioID);
                FormaPagamento       formaPagamentoPadrao = new FormaPagamento(this.UsuarioID);
                List <int>           listaFormaPagamento  = formaPagamentoPadrao.GetFormasPagamentoPadrao();
                foreach (int FormaPagamentoID in listaFormaPagamento)
                {
                    forma.EventoID.Valor         = this.Resultado.Evento.Control.ID;
                    forma.FormaPagamentoID.Valor = FormaPagamentoID;

                    if (!forma.Inserir(bd))
                    {
                        throw new FormaPagamentoEventoException("Problemas ao inserir a forma de pagamento padrão para o evento.");
                    }
                }

                #endregion


                bd.FinalizarTransacao();

                this.Fluxo.Evento.OK();

                this.Resultado.Apresentacoes = apresentacoes;
                this.Resultado.Setores       = setores;
                this.empresaID       = Local.getEmpresaID(InfoFase1.Etapa1.LocalID, bd);
                evento.LocalID.Valor = InfoFase1.Etapa1.LocalID;
            }



            return(this.Resultado);
        }