public List <EstruturaEventoPontoDeVenda> Salvar(List <EstruturaEventoPontoDeVenda> lista) { try { int eventoID = lista[0].EventoID; Evento oEvento = new Evento(this.Control.UsuarioID); oEvento.Ler(eventoID); //Ta tudo disponível if (lista.Where(c => !c.Disponivel).Count() == 0) { oEvento.HabilitarRetiradaTodosPDV.Valor = true; this.RemoverTudoPorEvento(eventoID); } else if (lista.Where(c => c.Disponivel).Count() == 0) { this.RemoverTudoPorEvento(eventoID); oEvento.HabilitarRetiradaTodosPDV.Valor = false; } else { foreach (var item in lista) { //Não existe e está disponível if (item.ID == 0 && item.Disponivel) { this.EventoID.Valor = item.EventoID; this.PontoDeVendaID.Valor = item.PontoDeVendaID; this.Inserir(); item.ID = this.Control.ID; this.Limpar(); } //Existe e não está disponivel else if (item.ID > 0 && !item.Disponivel) { this.Excluir(item.ID); item.ID = 0; item.Disponivel = false; } } oEvento.HabilitarRetiradaTodosPDV.Valor = false; } oEvento.Atualizar(); return(lista); } finally { } }
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); }