private List <EstruturaSerieItem> PreencherPrecos(int SerieID, Enumerators.TipoPerfil tipoPerfil, int ID, ref bool Alterar) { try { List <EstruturaSerieItem> lstPrecos = new List <EstruturaSerieItem>(); string continuacao = string.Empty; string campos = string.Empty; if (tipoPerfil == Enumerators.TipoPerfil.Regional) { continuacao = @"INNER JOIN tLocal l (NOLOCK) ON l.ID = e.LocalID INNER JOIN tEmpresa em (NOLOCK) ON em.ID = l.EmpresaID"; campos = ", em.RegionalID"; } else { continuacao = @"INNER JOIN tLocal l (NOLOCK) ON l.ID = e.LocalID"; campos = ", l.ID AS LocalID"; } string sql = string.Format( @"SELECT si.ID AS SerieItemID, e.ID as EventoID, e.Nome AS Evento, AP.ID AS ApresentacaoID, ap.Horario, s.Nome AS Setor, s.ID AS SetorID, p.Nome AS Preco, p.ID AS PrecoID, p.Valor AS PrecoValor, si.Promocional, si.QuantidadePorPromocional {0} FROM tSerieItem si (NOLOCK) INNER JOIN tPreco p (NOLOCK) ON p.ID = si.PrecoID INNER JOIN tSetor s (NOLOCK) ON s.ID = si.SetorID INNER JOIN tApresentacao ap (NOLOCK) ON ap.ID = si.ApresentacaoID INNER JOIN tEvento e (NOLOCK) ON e.ID = ap.EventoID {1} WHERE si.SerieID = {2} ORDER BY e.Nome, ap.Horario, s.Nome, p.Nome", campos, continuacao, SerieID); bd.Consulta(sql); while (bd.Consulta().Read()) { lstPrecos.Add(new EstruturaSerieItem() { Acao = Enumerators.TipoAcaoPreco.Manter, SerieItemID = bd.LerInt("SerieItemID"), EventoID = bd.LerInt("EventoID"), Evento = bd.LerString("Evento"), ApresentacaoID = bd.LerInt("ApresentacaoID"), Horario = bd.LerDateTime("Horario").ToString("dddd, dd/MM/yyyy HH:mm"), Setor = bd.LerString("Setor"), SetorID = bd.LerInt("SetorID"), Preco = bd.LerString("Preco"), PrecoID = bd.LerInt("PrecoID"), Valor = bd.LerDecimal("PrecoValor").ToString(), Promocional = bd.LerBoolean("Promocional"), QuantidadePorPromocional = bd.LerInt("QuantidadePorPromocional"), }); if (tipoPerfil == Enumerators.TipoPerfil.Regional) { Alterar &= bd.LerInt("RegionalID") == ID; } else if (tipoPerfil == Enumerators.TipoPerfil.Local) { Alterar &= bd.LerInt("LocalID") == ID; } } return(lstPrecos); } finally { //Não fechar a consulta aqui!!! bd.FecharConsulta(); } }
/// <summary> /// Carregar os dados desta Serie apartir do ID, /// Serão Carregados: Canais Próprios, Canais IR, Disponibilidade Site/CC /// Precos Disponíveis, Preços /// </summary> /// <param name="ID"></param> public EstruturaPreenchimentoSerie CarregarCanaisPrecosFormaPagamento(int SerieID, Enumerators.TipoPerfil tipoPerfil, int ID) { try { bool Alterar = true; EstruturaPreenchimentoSerie ePreenchimentoSerie = this.PreencherCanaisIR(SerieID); ePreenchimentoSerie.lstCanaisDisponiveis = this.PreencherCanais(SerieID); ePreenchimentoSerie.lstPrecosDisponiveis = this.PreencherPrecos(SerieID, tipoPerfil, ID, ref Alterar); ePreenchimentoSerie.lstFormasPagamentoDisponiveis = this.PreencherFormasPagamento(SerieID); ePreenchimentoSerie.HabilitarEdicao = Alterar; return(ePreenchimentoSerie); } finally { bd.Fechar(); } }