Пример #1
0
        private void AddIngrediente()
        {
            double custoUnit  = 0;
            double custoTotal = 0;

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

            Augoritmos a = new Augoritmos();

            custoUnit = a.CustoIngrediente(txtCodItem.Text, Convert.ToInt32(cbUnidade.SelectedValue));

            custoTotal = custoUnit * Convert.ToDouble(txtQuant.Text);

            String[] V = new string[] { txtCodItem.Text, txtNomeItem.Text, txtQuant.Text, txtUm.Text, txtFc.Text, custoUnit.ToString("#,0.00"), custoTotal.ToString("#,0.00") };
            dgvFicha.Rows.Add(V);

            RecalcularCusto();
            txtCodItem.Clear();
            txtNomeItem.Clear();
            txtQuant.Clear();
            txtUm.Clear();
            txtFc.Clear();
            txtCodItem.Focus();
            btAddIngrediente.Enabled = false;
            txtQuant.Enabled         = false;
        }
Пример #2
0
        private void ExportaPdf(bool imagem, string cod, string caminho, int unidade)
        {
            Augoritmos au = new Augoritmos();

            au.paraPDF(imagem, cod, caminho, unidade);

            System.Diagnostics.Process.Start($"{caminho}");
        }
Пример #3
0
        private void btExcluir_Click(object sender, EventArgs e)
        {
            DialogResult d = MessageBox.Show($"Deseja realmente excluir a ficha tédnica {txtNome.Text}?", "ATENÇÃO!", MessageBoxButtons.YesNo);

            if (d.ToString() == "Yes")
            {
                Augoritmos au = new Augoritmos();
                au.ExcluirPrato(txtCodigoPrato.Text);
                zerarPagina();
            }
        }
        private void exportarPdf(bool img)
        {
            FolderBrowserDialog fd = new FolderBrowserDialog();


            Comuns.loading ld = new Comuns.loading();


            try
            {
                if (fd.ShowDialog() == DialogResult.OK)
                {
                    if (dgvFichas.Rows.Count == 1)
                    {
                        ld.SetMessage("Exportando a ficha técnica...\n Por favor, aguarde."); // "Loading data. Please wait..."
                    }
                    else
                    {
                        ld.SetMessage("Exportando as fichas técnicas...\n Por favor, aguarde."); // "Loading data. Please wait..."
                    }

                    ld.TopMost       = true;
                    ld.StartPosition = FormStartPosition.CenterScreen;

                    ld.Show();
                    ld.Refresh();

                    Augoritmos au = new Augoritmos();

                    for (int i = 0; i < dgvFichas.Rows.Count; i++)
                    {
                        au.paraPDF(img, dgvFichas.Rows[i].Cells[0].Value.ToString(), fd.SelectedPath.ToString() + "\\" + dgvFichas.Rows[i].Cells[1].Value.ToString() + ".pdf", Convert.ToInt32(cbUnidade.SelectedValue));
                    }
                    if (dgvFichas.Rows.Count == 1)
                    {
                        ld.Close();
                        MessageBox.Show("Ficha técnica exportada com sucesso.");
                    }
                    else
                    {
                        ld.Close();
                        MessageBox.Show("Fichas técnicas exportada com sucesso.");
                    }
                }
            }
            catch
            {
                ld.Close();
                MessageBox.Show($"Erro ao exportar as fichas técnicas.\nVerifique se não tem algum documento de PDF Aberto ou se a pasta selecionada não está protegida.");
            }
        }
Пример #5
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();
            }
        }
        private void dgvFichas_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            Augoritmos au = new Augoritmos();

            if (e.ColumnIndex == 12)
            {
                if (e.RowIndex >= 0)
                {
                    if (permissao >= 3)
                    {
                        DialogResult d = MessageBox.Show("Deseja realmente excluir a ficha técnica de " + dgvFichas.Rows[e.RowIndex].Cells[1].Value.ToString() + "?", "ATENÇÃO!", MessageBoxButtons.YesNo);
                        if (d.ToString() == "Yes")
                        {
                            au.ExcluirPrato(dgvFichas.Rows[e.RowIndex].Cells[0].Value.ToString());
                            CarregaDgv();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Você não tem permissões necessárias para deletar esta ficha técnica.");
                    }
                }
            }


            if (e.ColumnIndex == 11)
            {
                if (e.RowIndex >= 0)
                {
                    if (herdada)
                    {
                        this.fichaSelecionada = dgvFichas.Rows[e.RowIndex].Cells[0].Value.ToString();
                        this.Close();
                    }
                    else
                    {
                        if (permissao >= 3)
                        {
                            CadastroFichas cf = new CadastroFichas(idUsuario, dgvFichas.Rows[e.RowIndex].Cells[0].Value.ToString(), true);
                            cf.ShowDialog();
                            cf.Dispose();
                            CarregaDgv();
                        }
                        else
                        {
                            MessageBox.Show("Você não tem permissões necessárias para editar esta ficha técnica.");
                        }
                    }
                }
            }

            if (e.ColumnIndex == 10)
            {
                if (e.RowIndex >= 0)
                {
                    VisualizaFichaTecnica vf = new VisualizaFichaTecnica(Convert.ToInt32(cbUnidade.SelectedValue), idUsuario, dgvFichas.Rows[e.RowIndex].Cells[0].Value.ToString());
                    vf.ShowDialog();
                    vf.Dispose();
                }
            }
        }
        private void CarregaDgv()
        {
            string busca = $"select p.cod_prato, p.nome_prato,  b.nome_buffet, c.nome_cat, s.nome_scat," +
                           "p.peso_prato, p.rendimento_prato, p.desc_prato from prato p join buffet b on p.id_setor = b.id_buffet " +
                           $"left join categoria c on p.cat = c.id_cat left join subcategoria s on p.subcat = s.id_scat where nome_prato like '%{txtNome.Text}%'";

            if (cbSetor.Text != "")
            {
                busca += $" and id_setor = {Convert.ToInt32(cbSetor.SelectedValue)}";
            }

            if (cbCategoria.Text != "")
            {
                busca += $" and cat = {Convert.ToInt32(cbCategoria.SelectedValue)}";
            }

            if (cbSubCategoria.Text != "")
            {
                busca += $" and subcat = {Convert.ToInt32(cbSubCategoria.SelectedValue)}";
            }

            busca += "order by p.cod_prato;";

            DALConexao  cx      = new DALConexao(DadosDaConexao.StringDaConexao);
            BLLPratos   bll     = new BLLPratos(cx);
            DataTable   tabela  = bll.BuscaFichas(busca);
            DTOCaminhos caminho = new DTOCaminhos();


            //this.dgvFichas.Columns[9].ValueType = typeof(double);

            DataTable dados = new DataTable();

            Image ver  = Image.FromFile(caminho.Icones + "document.png");
            Image edit = Image.FromFile(caminho.Icones + "pencil.png");
            Image del  = Image.FromFile(caminho.Icones + "trash.png");

            dados.Clear();
            dados.Columns.Add("CODIGO");
            dados.Columns.Add("NOME");
            dados.Columns.Add("SETOR");
            dados.Columns.Add("CAT");
            dados.Columns.Add("SCAT");
            dados.Columns.Add("PESO", typeof(double));
            dados.Columns.Add("RENDIMENTO", typeof(double));
            dados.Columns.Add("CUSTO/KG", typeof(double));
            dados.Columns.Add("CUSTO/PORCAO", typeof(double));
            dados.Columns.Add("TOTAL", typeof(double));
            dados.Columns.Add("VER", typeof(System.Drawing.Bitmap));
            dados.Columns.Add("EDT", typeof(System.Drawing.Bitmap));
            dados.Columns.Add("DEL", typeof(System.Drawing.Bitmap));



            DataRow _ravi = dados.NewRow();

            dgvFichas.Visible = false;
            for (int i = 0; i < tabela.Rows.Count; i++)
            {
                string categoria      = "";
                string subcategoria   = "";
                double peso           = 0;
                double rendimento     = 0;
                double custo          = 0;
                double custoPorKg     = 0;
                double custoPorPorcao = 0;

                peso       = Convert.ToDouble(tabela.Rows[i][5]);
                rendimento = Convert.ToDouble(tabela.Rows[i][6]);

                try
                {
                    Augoritmos au = new Augoritmos();
                    custo = au.CalculaCustoFicha(tabela.Rows[i][0].ToString(), Convert.ToInt32(cbUnidade.SelectedValue));
                }

                catch
                {
                }

                if (peso > 0)
                {
                    custoPorKg = custo / peso;
                }

                if (rendimento > 0)
                {
                    custoPorPorcao = custo / rendimento;
                }

                if (!(string.IsNullOrEmpty(tabela.Rows[i][3].ToString())))
                {
                    categoria = tabela.Rows[i][3].ToString();
                }

                if (!(string.IsNullOrEmpty(tabela.Rows[i][4].ToString())))
                {
                    subcategoria = tabela.Rows[i][4].ToString();
                }

                dados.Rows.Add(new object[] { tabela.Rows[i][0].ToString(), tabela.Rows[i][1].ToString(), tabela.Rows[i][2].ToString(), categoria, subcategoria, Convert.ToDouble(Math.Round(peso, 4)), Convert.ToDouble(Math.Round(rendimento, 2)), Convert.ToDouble(Math.Round(custoPorKg, 2)), Convert.ToDouble(Math.Round(custoPorPorcao, 2)), Convert.ToDouble(Math.Round(custo, 2)), ver, edit, del });
            }

            dgvFichas.DataSource = dados;
            dgvFichas.Visible    = true;
            FormatarDGV();
        }
Пример #8
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");
            }
        }
Пример #9
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());
                }
            }
        }