Exemplo n.º 1
0
 private void frmProduto_Load(object sender, EventArgs e)
 {
     PADARIA.BLL.CategoriaBLL categoria = new PADARIA.BLL.CategoriaBLL();
     PADARIA.BLL.ProdutoBLL   dalProd   = new PADARIA.BLL.ProdutoBLL();
     cmbCategoria.DisplayMember = "nome";
     cmbCategoria.ValueMember   = "id";
     cmbCategoria.DataSource    = categoria.select();
     cmbCategoria.SelectedItem  = null;
     dtGrdProduto.DataSource    = "";
     dtGrdProduto.DataSource    = dalProd.select();
 }
Exemplo n.º 2
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            PADARIA.MODEL.Categoria categoria = new PADARIA.MODEL.Categoria();
            categoria.nome = txtNome.Text;

            PADARIA.BLL.CategoriaBLL dalCat = new PADARIA.BLL.CategoriaBLL();

            if (lblIdValor.Text == "" || lblIdValor.Text == null)
            {
                if ((txtNome.Text == "" || txtNome.Text == null))
                {
                    MessageBox.Show("Não são permitidos campos vazios");
                }
                else
                {
                    dalCat.insert(categoria);
                }
            }
            else
            {
                if ((txtNome.Text == "" || txtNome.Text == null))
                {
                    MessageBox.Show("Não são permitidos campos vazios");
                }
                else
                {
                    categoria.id = Convert.ToInt32(lblIdValor.Text);
                    dalCat.update(categoria);
                }
            }


            dtGrdCategoria.DataSource = "";
            dtGrdCategoria.DataSource = dalCat.select();
            pnlCategoria.Visible      = !pnlCategoria.Visible;
            dtGrdCategoria.Visible    = !dtGrdCategoria.Visible;
            txtNome.Text         = "";
            lblIdValor.Text      = "";
            btnExcluir.Enabled   = false;
            lblId.Visible        = false;
            lblIdValor.Visible   = false;
            btnAdicionar.Enabled = true;
        }
Exemplo n.º 3
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            int idCategoria = Convert.ToInt32(lblIdValor.Text);

            DialogResult resposta = MessageBox.Show("Deseja excluir a categoria" + txtNome.Text + "?", "Exclusão de categorias",
                                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            PADARIA.BLL.CategoriaBLL dalCat = new PADARIA.BLL.CategoriaBLL();
            if (resposta == DialogResult.Yes)
            {
                dalCat.delete(idCategoria);
                dtGrdCategoria.DataSource = "";
                dtGrdCategoria.DataSource = dalCat.select();
                pnlCategoria.Visible      = !pnlCategoria.Visible;
                dtGrdCategoria.Visible    = !pnlCategoria.Visible;
                txtNome.Text         = "";
                lblIdValor.Text      = "";
                btnExcluir.Enabled   = false;
                lblId.Visible        = false;
                lblIdValor.Visible   = false;
                btnAdicionar.Enabled = true;
            }
        }
Exemplo n.º 4
0
 private void frmCategorias_Load(object sender, EventArgs e)
 {
     PADARIA.BLL.CategoriaBLL dalCat = new PADARIA.BLL.CategoriaBLL();
     dtGrdCategoria.DataSource = "";
     dtGrdCategoria.DataSource = dalCat.select();
 }