Ejemplo n.º 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;
                }
            }
        }
        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;
        }
Ejemplo n.º 4
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.");
            }
        }
Ejemplo n.º 5
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();
            }
        }
Ejemplo n.º 6
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());
                }
            }
        }