Beispiel #1
0
        /// <summary>
        /// Obter o valor total da conta do ingresso
        /// </summary>
        /// <returns></returns>
        public override decimal ValorConta(int ingresso)
        {
            try{
                DataTable tabela = new DataTable("Conta");

                //carregar uma lista de comandas desse ingresso
                ComandaLista lista = new ComandaLista();
                lista.FiltroSQL = "VendaID<>0 AND IngressoID=" + ingresso;
                lista.Carregar();

                string ids = lista.ToString();

                if (ids != "")
                {
                    string sql = "SELECT Sum(i.PrecoVenda*i.Quantidade) as Valor " +
                                 "FROM tComanda as c, tComandaItem as i WHERE i.ComandaID in (" + ids + ") AND " +
                                 "c.ID=i.ComandaID";

                    object o = bd.ConsultaValor(sql);

                    decimal valor = (o != null) ? Convert.ToDecimal(o) : 0;

                    return(valor);
                }
                else
                {
                    return(0);
                }
            }catch (Exception ex) {
                throw ex;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Obter os itens de um Ingresso especifico nao pagos
        /// </summary>
        /// <returns></returns>
        public DataTable Conta(int ingresso)
        {
            DataTable    tabela = estruturaItensComanda();                              //carregar uma lista de comandas desse ingresso
            ComandaLista lista  = new ComandaLista();

            lista.FiltroSQL = "IngressoID='" + ingresso + "'";
            lista.Carregar();
            string ids = lista.ToString();

            if (ids != "")
            {
                try{
                    BD     bd  = new BD();
                    string sql =
                        "SELECT     i.ID, i.ProdutoID, p.Nome AS Produto, p.PrecoVenda AS Valor, i.Quantidade, i.ComandaID, c.VendaID " +
                        "FROM       tProduto p INNER JOIN " +
                        "tComandaItem i ON p.ID = i.ProdutoID INNER JOIN " +
                        "tComanda c ON i.ComandaID = c.ID " +
                        "WHERE     (i.ComandaID IN (" + ids + ")) AND (c.VendaID = 0)";
                    bd.Consulta(sql);
                    while (bd.Consulta().Read())
                    {
                        DataRow linha = tabela.NewRow();
                        linha["ID"]         = bd.LerInt("ID");
                        linha["ProdutoID"]  = bd.LerInt("ProdutoID");
                        linha["Produto"]    = bd.LerString("Produto");
                        linha["Quantidade"] = bd.LerInt("Quantidade");
                        linha["Valor"]      = bd.LerDecimal("Valor");
                        tabela.Rows.Add(linha);
                    }
                    bd.Fechar();
                }catch {
                    tabela = null;
                }
            }
            return(tabela);
        }