public DataTable PesquisarCodigoBarras(string codigoBarra)
        {
            BD        bd     = null;
            DataTable tabela = EstruturaHistorico();
            int       ingressoID;

            try
            {
                bd         = new BD();
                ingressoID = 0;

                using (IDataReader oDataReader = bd.Consulta("" +
                                                             "SELECT " +
                                                             "   tIngresso.ID " +
                                                             "FROM " +
                                                             "   tIngresso (NOLOCK) " +
                                                             "WHERE " +
                                                             "   (CodigoBarra = '" + codigoBarra + "' OR CodigoBarraCliente='" + codigoBarra + "') " +
                                                             "ORDER BY " +
                                                             "   tIngresso.ID"))
                {
                    if (!oDataReader.Read())
                    {
                        throw new ApplicationException("Código de Barras não encontrado!");
                    }

                    ingressoID = bd.LerInt("ID");

                    if (ingressoID < 1)
                    {
                        throw new ApplicationException("Código de Barras não encontrado!");
                    }

                    Ingresso ingresso = new Ingresso();
                    ingresso.Control.ID = ingressoID;

                    tabela = ingresso.Historico();
                }

                return(AssinaturaBancoIngresso.VerificarSeExisteBancoIngresso(ingressoID, tabela));
            }
            finally
            {
                if (bd != null)
                {
                    bd.Fechar();
                }
            }
        }
Esempio n. 2
0
 // passar o Usuario logado no sistema
 public AssinaturaBancoIngressoLista_B()
 {
     assinaturaBancoIngresso = new AssinaturaBancoIngresso();
 }
        public DataTable PesquisarCodigoIngresso(int apresentacaoSetorID, string codigo)
        {
            BD        bd     = null;
            DataTable tabela = EstruturaHistorico();
            int       ingressoID;

            try
            {
                bd         = new BD();
                ingressoID = 0;

                using (IDataReader oDataReader = bd.Consulta("" +
                                                             "SELECT " +
                                                             "   tIngresso.ID " +
                                                             "FROM " +
                                                             "   tIngresso (NOLOCK) " +
                                                             "WHERE " +
                                                             "   (tIngresso.ApresentacaoSetorID = " + apresentacaoSetorID + ") " +
                                                             "AND " +
                                                             "   (tIngresso.Codigo = '" + codigo + "') " +
                                                             "ORDER BY " +
                                                             "   tIngresso.ID"))
                {
                    if (!oDataReader.Read())
                    {
                        throw new ApplicationException("Código do Ingresso não encontrado!");
                    }

                    ingressoID = bd.LerInt("ID");

                    if (ingressoID < 1)
                    {
                        throw new ApplicationException("Código do Ingresso não encontrado!");
                    }

                    int contadorIngressos = 1;

                    while (oDataReader.Read())
                    {
                        contadorIngressos++;
                    }

                    if (contadorIngressos > 1)
                    {
                        throw new IngressoHistoricoGerenciadorException("Apresentação possui mais de 1 lugar com código " + codigo);
                    }

                    Ingresso ingresso = new Ingresso();
                    ingresso.Control.ID = ingressoID;

                    tabela = ingresso.Historico();
                }

                return(AssinaturaBancoIngresso.VerificarSeExisteBancoIngresso(ingressoID, tabela));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (bd != null)
                {
                    bd.Fechar();
                }
            }
        }