Пример #1
0
        private void txtCodItem_Leave(object sender, EventArgs e)
        {
            if (txtCodItem.Text.Trim() != ".  .")
            {
                try
                {
                    DALConexao cx  = new DALConexao(DadosDaConexao.StringDaConexao);
                    BLLAeB     bll = new BLLAeB(cx);

                    DTOAeB modelo = bll.CarregaModeloAeB(txtCodItem.Text);

                    txtCodItem.Text  = modelo.CodAeb.ToString();
                    txtNomeItem.Text = modelo.NomeAeb.ToString();
                    txtFc.Text       = modelo.Fc.ToString();
                    txtUm.Text       = modelo.UmAeb.ToString();

                    btAddIngrediente.Enabled = true;
                    txtQuant.Enabled         = true;

                    txtQuant.Focus();
                }
                catch
                {
                    MessageBox.Show("Código inválido. Por favor selecione um código existente");
                    btAddIngrediente.Enabled = false;
                    txtQuant.Enabled         = false;
                }
            }
        }
Пример #2
0
        private void AtualizaDgv()
        {
            DALConexao cx  = new DALConexao(DadosDaConexao.StringDaConexao);
            BLLAeB     bll = new BLLAeB(cx);

            dgvItens.DataSource = bll.LocalizarNome(txtNome.Text.Trim());
        }
        private void btSalvar_Click(object sender, EventArgs e)
        {
            DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao);

            DTOAeB dto = new DTOAeB();
            BLLAeB bll = new BLLAeB(cx);

            dto.CodAeb  = txtCod.Text;
            dto.NomeAeb = txtNome.Text;
            dto.UmAeb   = cbUm.Text;

            try
            {
                bll.Incluir(dto);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao salvar o produto. Erro\n" + ex);
            }

            txtCod.Clear();
            txtNome.Clear();
            cbUm.Text = "";


            RecarregadgvLista();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            DALConexao conn = new DALConexao(DadosDaConexao.StringDaConexao);

            DTOAeB dto = new DTOAeB();
            BLLAeB bll = new BLLAeB(conn);

            DataTable tabela;

            if (dgvExcel.Rows.Count > 0)
            {
                for (int i = 0; i < dgvExcel.RowCount; i++)
                {
                    tabela = bll.Localizar(dgvExcel.Rows[i].Cells[0].Value.ToString());

                    if (Convert.ToInt32(tabela.Rows[0][0].ToString()) == 0)
                    {
                        dto.CodAeb = dgvExcel.Rows[i].Cells[0].Value.ToString();

                        dto.NomeAeb = dgvExcel.Rows[i].Cells[1].Value.ToString();

                        dto.UmAeb = dgvExcel.Rows[i].Cells[2].Value.ToString();

                        bll.Incluir(dto);
                    }
                }
            }
            RecarregadgvLista();
            dgvExcel.Rows.Clear();
            MessageBox.Show("Dados salvos com sucesso!");
            panel1.Visible = false;
        }
Пример #5
0
        private void Alterar()
        {
            DTOPratos dto = new DTOPratos();

            DALConexao cx  = new DALConexao(DadosDaConexao.StringDaConexao);
            BLLPratos  bll = new BLLPratos(cx);

            dto.CodPrato         = txtCodigoPrato.Text;
            dto.NomePrato        = txtNome.Text.Trim().ToUpper();
            dto.IdSetor          = Convert.ToInt32(cbSetor.SelectedValue);
            dto.Cat              = Convert.ToInt32(cbCategoria.SelectedValue);
            dto.SubCat           = Convert.ToInt32(cbSubCategoria.SelectedValue);
            dto.RendimentoPrato  = Convert.ToDouble(txtRendimento.Text);
            dto.ModoPreparoPrato = txtPreparo.Text.Trim();
            dto.PesoPrato        = Convert.ToDouble(txtPeso.Text);
            dto.IdUsuario        = idUsuario;
            dto.DescPrato        = txtDescricao.Text.Trim().ToUpper();

            BLLAeB bllaeb = new BLLAeB(cx);
            DTOAeB dtoaeb = new DTOAeB();

            dtoaeb.CodAeb  = dto.CodPrato;
            dtoaeb.NomeAeb = dto.NomePrato;
            dtoaeb.UmAeb   = "KG";
            dtoaeb.Fc      = 0;

            try
            {
                bll.Alterar(dto);
                MessageBox.Show($"Ficha técnica {txtCodigoPrato.Text} - {txtNome.Text} alterada com sucesso.");


                DataTable tabelaAeb;

                tabelaAeb = bllaeb.Localizar(dto.CodPrato);

                if (tabelaAeb.Rows.Count == 0)
                {
                    bllaeb.Incluir(dtoaeb);
                }
                else
                {
                    bllaeb.AlterarPorCod(dtoaeb);
                }


                gbFicha.Enabled        = false;
                gbIngredientes.Enabled = true;
                txtCodItem.Focus();
            }
            catch
            {
                MessageBox.Show("Erro ao alterar Ficha técnica.");
            }
        }
Пример #6
0
        private void CarregarIngredientesPorCodigo(string cod)
        {
            dgvFicha.Rows.Clear();

            //Linha por linha busca ingrediente com custo
            DALConexao cx  = new DALConexao(DadosDaConexao.StringDaConexao);
            BLLPratos  bll = new BLLPratos(cx);
            DataTable  tabelaIngredientes = bll.ListarIngredientes(txtCodigoPrato.Text);

            BLLAeB    bllaeb = new BLLAeB(cx);
            DataTable tabelaAeb;

            Augoritmos a = new Augoritmos();


            if (tabelaIngredientes.Rows.Count > 0)
            {
                for (int i = 0; i < tabelaIngredientes.Rows.Count; i++)
                {
                    //cod_item, quant_ingrediente

                    tabelaAeb = bllaeb.LocalizarPorCod(tabelaIngredientes.Rows[i][0].ToString());

                    string codIngrediente, nomeingrediente, um;
                    double quant, custoUnit, custoTotal, fc;

                    codIngrediente  = tabelaIngredientes.Rows[i][0].ToString();
                    nomeingrediente = tabelaAeb.Rows[0][0].ToString();
                    um = tabelaAeb.Rows[0][1].ToString();
                    if (string.IsNullOrEmpty(tabelaAeb.Rows[0][2].ToString()))
                    {
                        fc = 0;
                    }
                    else
                    {
                        fc = Convert.ToDouble(tabelaAeb.Rows[0][2]);
                    }

                    quant = Convert.ToDouble(tabelaIngredientes.Rows[i][1]);

                    custoUnit  = a.CustoIngrediente(codIngrediente, Convert.ToInt32(cbUnidade.SelectedValue));
                    custoTotal = custoUnit * quant;


                    String[] V = new string[] { codIngrediente, nomeingrediente, quant.ToString("#,0.0000"), um, fc.ToString("#,0.0000"), custoUnit.ToString("#,0.00"), custoTotal.ToString("#,0.00") };
                    dgvFicha.Rows.Add(V);
                }
                RecalcularCusto();
            }
        }
Пример #7
0
        public void ExcluirPrato(string cod)
        {
            DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao);

            // Exclui prato
            BLLPratos bllp = new BLLPratos(cx);

            try
            {
                bllp.Excluir(cod);
            }
            catch
            {
                throw new Exception("Erro ao excluir Prato!");
            }

            //Exclui ingredientes referentes ao prato
            BLLIngredientes blli = new BLLIngredientes(cx);

            try
            {
                blli.ExcluirPorPrato(cod);
            }
            catch
            {
                throw new Exception("Erro ao excluir Ingrediente!");
            }

            //excluir prato da tabela AEB
            BLLAeB bllaeb = new BLLAeB(cx);

            try
            {
                bllaeb.ExcluirPorCod(cod);
            }
            catch
            {
                throw new Exception("Erro ao excluir Aeb!");
            }

            //Exclui imagem referente ao prato (se houver)
            IncluiFoto(cod, "del");
        }
Пример #8
0
        private void txtCodItem_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F5)
            {
                Forms.CMV.frmConsultaAeB f = new Forms.CMV.frmConsultaAeB(true);
                f.ShowDialog();

                if (f.codigo != "")
                {
                    try
                    {
                        DALConexao cx  = new DALConexao(DadosDaConexao.StringDaConexao);
                        BLLAeB     bll = new BLLAeB(cx);

                        DTOAeB modelo = bll.CarregaModeloAeB(f.codigo);

                        txtCodItem.Text          = modelo.CodAeb.ToString();
                        txtNomeItem.Text         = modelo.NomeAeb.ToString();
                        txtFc.Text               = modelo.Fc.ToString();
                        txtUm.Text               = modelo.UmAeb.ToString();
                        txtQuant.Enabled         = true;
                        btAddIngrediente.Enabled = true;

                        txtQuant.Focus();
                    }
                    catch
                    {
                        MessageBox.Show("Código inválido. Por favor selecione um código existente");
                        btAddIngrediente.Enabled = false;
                    }
                }
                else
                {
                }

                f.Dispose();
            }
        }
Пример #9
0
        private void CarregarIngredientesPorCodigo(string cod)
        {
            dgvDados.Rows.Clear();

            //Linha por linha busca ingrediente com custo
            DALConexao cx  = new DALConexao(DadosDaConexao.StringDaConexao);
            BLLPratos  bll = new BLLPratos(cx);
            DataTable  tabelaIngredientes = bll.ListarIngredientes(cod);

            BLLAeB    bllaeb = new BLLAeB(cx);
            DataTable tabelaAeb;

            Augoritmos a = new Augoritmos();

            double TotalFicha = 0;

            if (tabelaIngredientes.Rows.Count > 0)
            {
                for (int i = 0; i < tabelaIngredientes.Rows.Count; i++)
                {
                    //cod_item, quant_ingrediente

                    tabelaAeb = bllaeb.LocalizarPorCod(tabelaIngredientes.Rows[i][0].ToString());

                    string codIngrediente, nomeingrediente, um;
                    double quant, custoUnit, custoTotal, fc;

                    codIngrediente  = tabelaIngredientes.Rows[i][0].ToString();
                    nomeingrediente = tabelaAeb.Rows[0][0].ToString();
                    um = tabelaAeb.Rows[0][1].ToString();
                    if (string.IsNullOrEmpty(tabelaAeb.Rows[0][2].ToString()))
                    {
                        fc = 0;
                    }
                    else
                    {
                        fc = Convert.ToDouble(tabelaAeb.Rows[0][2]);
                    }

                    quant = Convert.ToDouble(tabelaIngredientes.Rows[i][1]);

                    custoUnit  = a.CustoIngrediente(codIngrediente, unidade);
                    custoTotal = custoUnit * quant;


                    String[] V = new string[] { codIngrediente, nomeingrediente, um, fc.ToString("#,0.0000"), quant.ToString("#,0.0000"), custoUnit.ToString("#,0.00"), custoTotal.ToString("#,0.00") };
                    dgvDados.Rows.Add(V);

                    TotalFicha += custoTotal;
                }

                lbTotal.Text = TotalFicha.ToString("#,0.00");

                if (Convert.ToDouble(lbPeso.Text) > 0)
                {
                    lbTotalKg.Text = (TotalFicha / Convert.ToDouble(lbPeso.Text)).ToString("#,0.00");
                }
                else
                {
                    lbTotalKg.Text = "0,00";
                }

                lbcustoPorcao.Text = (TotalFicha / Convert.ToDouble(lbRendimento.Text)).ToString("#,0.00");
            }
        }
Пример #10
0
        private void Salvar()
        {
            // Salvar dados da ficha

            DTOPratos  dto = new DTOPratos();
            Augoritmos a   = new Augoritmos();
            DALConexao cx  = new DALConexao(DadosDaConexao.StringDaConexao);
            BLLPratos  bll = new BLLPratos(cx);

            dto.CodPrato         = txtCodigoPrato.Text;
            dto.NomePrato        = txtNome.Text.Trim().ToUpper();
            dto.IdSetor          = Convert.ToInt32(cbSetor.SelectedValue);
            dto.Cat              = Convert.ToInt32(cbCategoria.SelectedValue);
            dto.SubCat           = Convert.ToInt32(cbSubCategoria.SelectedValue);
            dto.RendimentoPrato  = Convert.ToDouble(txtRendimento.Text);
            dto.ModoPreparoPrato = txtPreparo.Text.Trim();
            dto.PesoPrato        = Convert.ToDouble(txtPeso.Text);
            dto.IdUsuario        = idUsuario;
            dto.DescPrato        = txtDescricao.Text.Trim().ToUpper();

            try
            {
                dto.IdPrato = Convert.ToInt32(txtId.Text);
            }
            catch
            {
            }

            //Dados de AEB

            DTOAeB dtoaeb = new DTOAeB();
            BLLAeB bllaeb = new BLLAeB(cx);

            dtoaeb.CodAeb  = dto.CodPrato;
            dtoaeb.NomeAeb = dto.NomePrato;
            dtoaeb.UmAeb   = "KG";
            dtoaeb.Fc      = 0;


            if (operacao == "inserir")
            {
                try
                {
                    bll.Incluir(dto);
                    bllaeb.Incluir(dtoaeb);
                    SalvarIngredientes();

                    a.IncluiFoto(txtCodigoPrato.Text, foto);

                    MessageBox.Show($"Ficha técnica {dto.CodPrato} - {dto.NomePrato} salva com sucesso.");
                    operacao = "consultar";
                    AlteraBotoes();
                }
                catch (Exception e)
                {
                    MessageBox.Show("Erro ao salvar a ficha.\n" + e.ToString());
                }
            }
            else if (operacao == "editar")
            {
                try
                {
                    bll.Alterar(dto);
                    bllaeb.AlterarPorCod(dtoaeb);
                    SalvarIngredientes();

                    a.IncluiFoto(txtCodigoPrato.Text, foto);

                    MessageBox.Show($"Ficha técnica {dto.CodPrato} - {dto.NomePrato} alterada com sucesso.");
                    operacao = "consultar";
                    AlteraBotoes();
                }
                catch (Exception e)
                {
                    MessageBox.Show("Erro ao alterar a ficha.\n" + e.ToString());
                }
            }
        }
Пример #11
0
        public void paraPDF(bool img, string codigoP, string caminho, int unidade)
        {
            DALConexao cx     = new DALConexao(DadosDaConexao.StringDaConexao);
            BLLPratos  bllp   = new BLLPratos(cx);
            DataTable  tabela = bllp.LocalizarPorCod(codigoP);

            DTOCaminhos dto = new DTOCaminhos();

            string nomePrato, codigo, desc, preparo, imagem, nome_cat, nome_setor, nome_scat;
            double rendimento, peso, total, totalKg, totalPorcao;
            int    id_setor, id_cat, id_subcat;

            // Preenche dados da Ficha
            codigo      = codigoP;
            nomePrato   = tabela.Rows[0][1].ToString();
            desc        = tabela.Rows[0][8].ToString();
            preparo     = tabela.Rows[0][6].ToString();
            rendimento  = Convert.ToDouble(tabela.Rows[0][5]);
            peso        = Convert.ToDouble(tabela.Rows[0][7]);
            id_setor    = Convert.ToInt32(tabela.Rows[0][2]);
            id_cat      = Convert.ToInt32(tabela.Rows[0][3]);
            id_subcat   = Convert.ToInt32(tabela.Rows[0][4]);
            imagem      = "";
            nome_setor  = "";
            nome_cat    = "";
            nome_scat   = "";
            total       = CalculaCustoFicha(codigoP, unidade);
            totalKg     = 0;
            totalPorcao = 0;

            if (peso > 0)
            {
                totalKg = total / peso;
            }

            if (rendimento > 0)
            {
                totalPorcao = total / rendimento;
            }


            if (File.Exists(dto.FT + codigoP + ".jpg") && img)
            {
                imagem = (dto.FT + codigoP + ".jpg");
            }

            //Carrega setor, categoria e subcategoria

            BLLBuffet bllsetor    = new BLLBuffet(cx);
            DataTable tabelasetor = bllsetor.localizarPorId(id_setor);

            nome_setor = tabelasetor.Rows[0][0].ToString();

            BLLCategoria bllcat    = new BLLCategoria(cx);
            DataTable    tabelacat = bllcat.localizarPorId(id_cat);

            if (tabelacat.Rows.Count > 0)
            {
                nome_cat = tabelacat.Rows[0][0].ToString();
            }


            BLLSubCategoria bllscat    = new BLLSubCategoria(cx);
            DataTable       tabelascat = bllscat.localizarPorId(id_subcat);

            if (tabelascat.Rows.Count > 0)
            {
                nome_scat = tabelascat.Rows[0][0].ToString();
            }


            //Exportar para pdf

            iTextSharp.text.Font Titulo    = FontFactory.GetFont("Segoe UI Light", 15, BaseColor.BLACK);
            iTextSharp.text.Font subtitulo = FontFactory.GetFont("Verdana", 8, 1, BaseColor.BLACK);
            iTextSharp.text.Font texto     = FontFactory.GetFont("Segoe UI", 8, BaseColor.BLACK);


            Document doc = new Document(iTextSharp.text.PageSize.A4, 5, 5, 30, 30);

            PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream($"{caminho}", FileMode.Create));

            doc.Open();

            float larguraTotal = 550;

            float largura1 = 0.11f;
            float largura2 = 0.38f;
            float largura3 = 0.08f;
            float largura4 = 0.1f;
            float largura5 = 0.1f;
            float largura6 = 0.12f;
            float largura7 = 0.12f;

            largura1 *= larguraTotal;
            largura2 *= larguraTotal;
            largura3 *= larguraTotal;
            largura4 *= larguraTotal;
            largura5 *= larguraTotal;
            largura6 *= larguraTotal;
            largura7 *= larguraTotal;

            BaseColor CSTitulo        = BaseColor.GRAY;
            BaseColor linhaAlternada0 = BaseColor.WHITE;
            BaseColor linhaAlternada1 = BaseColor.LIGHT_GRAY;


            PdfPTable table = new PdfPTable(7);

            table.DefaultCell.Phrase = new Phrase()
            {
                Font = texto
            };
            table.TotalWidth  = larguraTotal;
            table.PaddingTop  = 0;
            table.LockedWidth = true;
            float[] widths = new float[] { largura1, largura2, largura3, largura4, largura5, largura6, largura7 };
            table.SetWidths(widths);

            if (imagem != "")

            {
                iTextSharp.text.Image pic = iTextSharp.text.Image.GetInstance(dto.FT + codigoP + ".jpg");

                float largura = 200;
                float alturai = 0.0f;
                float alturaNova;
                alturai    = pic.Height;
                alturaNova = (largura * alturai) / pic.Width;
                pic.ScaleAbsolute(largura, alturaNova);

                PdfPCell foto = new PdfPCell(pic);

                foto.Colspan             = 7;
                foto.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                foto.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                table.AddCell(foto);
            }


            PdfPCell cell = new PdfPCell(new Phrase($"{nomePrato} ({codigoP}) ", new iTextSharp.text.Font(Titulo)));

            cell.Colspan = 6;
            cell.Rowspan = 6;


            cell.FixedHeight         = 40f;
            cell.HorizontalAlignment = 1; //0=esquerda, 1 = centro, 2=direita
            cell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(cell);

            float altura = 15f;

            PdfPCell tctotal = new PdfPCell(new Phrase("CUSTO TOTAL", new iTextSharp.text.Font(subtitulo)));

            tctotal.BackgroundColor = (CSTitulo);

            tctotal.FixedHeight         = altura;
            tctotal.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            tctotal.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(tctotal);


            PdfPCell ctotal = new PdfPCell(new Phrase(total.ToString("#0,0.00"), new iTextSharp.text.Font(texto)));

            ctotal.FixedHeight         = altura;
            ctotal.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            ctotal.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(ctotal);

            PdfPCell tckg = new PdfPCell(new Phrase("CUSTO/Kg", new iTextSharp.text.Font(subtitulo)));

            tckg.BackgroundColor = (CSTitulo);

            tckg.FixedHeight         = altura;
            tckg.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            tckg.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(tckg);

            PdfPCell ckg = new PdfPCell(new Phrase(totalKg.ToString("#0,0.00"), new iTextSharp.text.Font(texto)));

            ckg.FixedHeight         = altura;
            ckg.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            ckg.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(ckg);

            PdfPCell tcporcao = new PdfPCell(new Phrase("CUSTO/PORÇÃO", new iTextSharp.text.Font(subtitulo)));

            tcporcao.BackgroundColor = (CSTitulo);

            tcporcao.FixedHeight         = altura;
            tcporcao.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            tcporcao.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(tcporcao);

            PdfPCell cporcao = new PdfPCell(new Phrase(totalPorcao.ToString("#0,0.00"), new iTextSharp.text.Font(texto)));

            cporcao.FixedHeight         = altura;
            cporcao.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cporcao.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(cporcao);

            altura = 20f;

            PdfPCell tsetor = new PdfPCell(new Phrase("SETOR", new iTextSharp.text.Font(subtitulo)));

            tsetor.BackgroundColor = (CSTitulo);

            tsetor.FixedHeight         = altura;
            tsetor.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            tsetor.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(tsetor);

            PdfPCell tcategoria = new PdfPCell(new Phrase("CATEGORIZAÇÃO", new iTextSharp.text.Font(subtitulo)));

            tcategoria.BackgroundColor = (CSTitulo);

            tcategoria.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            tcategoria.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            tcategoria.FixedHeight         = altura;
            tcategoria.Colspan             = 4;
            table.AddCell(tcategoria);

            PdfPCell tpeso = new PdfPCell(new Phrase("PESO", new iTextSharp.text.Font(subtitulo)));

            tpeso.BackgroundColor = (CSTitulo);

            tpeso.FixedHeight         = altura;
            tpeso.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            tpeso.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(tpeso);

            PdfPCell trendimento = new PdfPCell(new Phrase("RENDIMENTO", new iTextSharp.text.Font(subtitulo)));

            trendimento.BackgroundColor = (CSTitulo);

            trendimento.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            trendimento.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cell.FixedHeight = altura;
            table.AddCell(trendimento);


            altura = 15;

            PdfPCell setor = new PdfPCell(new Phrase(nome_setor, texto));

            setor.FixedHeight         = altura;
            setor.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
            setor.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(setor);

            string categorias = "";

            if (nome_cat != "")
            {
                categorias = nome_cat;
            }
            if (nome_scat != "")
            {
                if (nome_cat == "")
                {
                    categorias += nome_scat;
                }
                else
                {
                    categorias += ", " + nome_scat;
                }
            }

            PdfPCell categoria = new PdfPCell(new Phrase(categorias, texto));

            categoria.FixedHeight         = altura;
            categoria.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
            categoria.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            categoria.Colspan             = 4;
            table.AddCell(categoria);

            PdfPCell pesopdf = new PdfPCell(new Phrase(peso.ToString("#,0.0000"), texto));

            pesopdf.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
            pesopdf.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            pesopdf.FixedHeight         = altura;
            table.AddCell(pesopdf);

            PdfPCell rendimentoPdf = new PdfPCell(new Phrase(rendimento.ToString("#0,0.00"), texto));

            rendimentoPdf.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
            rendimentoPdf.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            rendimentoPdf.FixedHeight         = altura;
            table.AddCell(rendimentoPdf);

            altura = 20;

            PdfPCell cod = new PdfPCell(new Phrase("CODIGO", new iTextSharp.text.Font(subtitulo)));

            cod.BackgroundColor = (CSTitulo);

            cod.FixedHeight         = altura;
            cod.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cod.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(cod);

            PdfPCell item = new PdfPCell(new Phrase("ITEM", new iTextSharp.text.Font(subtitulo)));

            item.BackgroundColor = (CSTitulo);

            item.FixedHeight         = altura;
            item.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            item.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            table.AddCell(item);

            PdfPCell fc = new PdfPCell(new Phrase("FC", new iTextSharp.text.Font(subtitulo)));

            fc.BackgroundColor = (CSTitulo);

            fc.FixedHeight         = altura;
            fc.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            fc.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            table.AddCell(fc);

            PdfPCell um = new PdfPCell(new Phrase("U.M.", new iTextSharp.text.Font(subtitulo)));

            um.BackgroundColor = (CSTitulo);

            um.FixedHeight         = altura;
            um.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            um.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            table.AddCell(um);


            PdfPCell quant = new PdfPCell(new Phrase("QUANT.", new iTextSharp.text.Font(subtitulo)));

            quant.BackgroundColor = (CSTitulo);

            quant.FixedHeight         = altura;
            quant.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            quant.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            table.AddCell(quant);

            PdfPCell unit = new PdfPCell(new Phrase("$UNIT", new iTextSharp.text.Font(subtitulo)));

            unit.BackgroundColor = (CSTitulo);

            unit.FixedHeight         = altura;
            unit.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            unit.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            table.AddCell(unit);

            PdfPCell totalpdf = new PdfPCell(new Phrase("$TOTAL", new iTextSharp.text.Font(subtitulo)));

            totalpdf.BackgroundColor = (CSTitulo);

            totalpdf.FixedHeight         = altura;
            totalpdf.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            totalpdf.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            table.AddCell(totalpdf);

            altura = 15;

            PdfPCell linha = new PdfPCell();

            linha.FixedHeight         = altura;
            linha.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
            linha.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;


            //Linha por linha busca ingrediente com custo
            BLLPratos bll = new BLLPratos(cx);
            DataTable tabelaIngredientes = bll.ListarIngredientes(codigoP);

            BLLAeB    bllaeb = new BLLAeB(cx);
            DataTable tabelaAeb;


            string codIngrediente, nomeingrediente, uniMedida;
            double quantidade, custoUnit, custoTotal, correcao;


            if (tabelaIngredientes.Rows.Count > 0)
            {
                for (int i = 0; i < tabelaIngredientes.Rows.Count; i++)
                {
                    //cod_item, quant_ingrediente

                    tabelaAeb = bllaeb.LocalizarPorCod(tabelaIngredientes.Rows[i][0].ToString());


                    codIngrediente  = tabelaIngredientes.Rows[i][0].ToString();
                    nomeingrediente = tabelaAeb.Rows[0][0].ToString();
                    uniMedida       = tabelaAeb.Rows[0][1].ToString();

                    if (string.IsNullOrEmpty(tabelaAeb.Rows[0][2].ToString()))
                    {
                        correcao = 0;
                    }
                    else
                    {
                        correcao = Convert.ToDouble(tabelaAeb.Rows[0][2]);
                    }

                    quantidade = Convert.ToDouble(tabelaIngredientes.Rows[i][1]);

                    custoUnit  = CustoIngrediente(codIngrediente, unidade);
                    custoTotal = custoUnit * quantidade;


                    //add linhas

                    if (i % 2 > 0)
                    {
                        linha.BackgroundColor = (linhaAlternada1);
                    }
                    else
                    {
                        linha.BackgroundColor = (linhaAlternada0);
                    }

                    linha.Phrase = new Phrase(codIngrediente, texto);
                    table.AddCell(linha);

                    linha.Phrase = new Phrase(nomeingrediente, texto);
                    table.AddCell(linha);

                    linha.Phrase = new Phrase(correcao.ToString("#,0.00"), texto);
                    table.AddCell(linha);

                    linha.Phrase = new Phrase(uniMedida, texto);
                    table.AddCell(linha);

                    linha.Phrase = new Phrase(quantidade.ToString(), texto);
                    table.AddCell(linha);

                    linha.Phrase = new Phrase(custoUnit.ToString("#,0.00"), texto);
                    table.AddCell(linha);

                    linha.Phrase = new Phrase(custoTotal.ToString("#,0.00"), texto);
                    table.AddCell(linha);
                }
            }


            PdfPCell tModoPreparo = new PdfPCell(new Phrase("MODO DE PREPARO", new iTextSharp.text.Font(subtitulo)));

            tModoPreparo.BackgroundColor     = (CSTitulo);
            tModoPreparo.Colspan             = 7;
            tModoPreparo.FixedHeight         = 20f;
            tModoPreparo.HorizontalAlignment = 1; //0=esquerda, 1 = centro, 2=direita
            tModoPreparo.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            table.AddCell(tModoPreparo);

            PdfPCell ModoPreparo = new PdfPCell(new Phrase(preparo, texto));

            ModoPreparo.Colspan = 7;

            ModoPreparo.HorizontalAlignment = PdfPCell.ALIGN_JUSTIFIED;

            table.AddCell(ModoPreparo);


            doc.Add(table);

            doc.Close();
        }