Esempio n. 1
0
        private void btnRemover_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(txtId.Text) > 0)
            {
                Camadas.MODEL.HQ hq    = new Camadas.MODEL.HQ();
                Camadas.BLL.HQ   bllHQ = new Camadas.BLL.HQ();

                hq.Id__Hq = Convert.ToInt32(txtId.Text);
                DialogResult result;
                result = MessageBox.Show("Deseja remover o produto selecionado",
                                         "Remover produto",
                                         MessageBoxButtons.YesNo,
                                         MessageBoxIcon.Question,
                                         MessageBoxDefaultButton.Button1);

                if (result == DialogResult.Yes)
                {
                    bllHQ.Delete(hq);
                    MessageBox.Show("Produto removido com sucesso!");
                }
                else
                {
                    MessageBox.Show("Remoção não confirmada");
                }

                dtgHQ.DataSource = bllHQ.Select();
                habilitaCampos(false);
            }
            else
            {
                MessageBox.Show("Não há registros para remover!", "Remover");
            }
        }
Esempio n. 2
0
        private void btnGravar_Click(object sender, EventArgs e)
        {
            Camadas.MODEL.HQ hq    = new Camadas.MODEL.HQ();
            Camadas.BLL.HQ   bllHQ = new Camadas.BLL.HQ();

            hq.Id__Hq = Convert.ToInt32(txtId.Text);
            hq.Titulo = txtTitulo.Text;
            hq.Autor  = txtAutor.Text;
            hq.Valor  = Convert.ToDouble(txtValor.Text);

            string msg;

            if (OP == 'I')
            {
                msg = "Deseja confirmar a Inserção dos dados";
            }
            else
            {
                msg = "Deseja confirmar a alteração dos dados";
            }

            DialogResult resp;

            resp = MessageBox.Show(msg, "Gravar",
                                   MessageBoxButtons.OKCancel,
                                   MessageBoxIcon.Question,
                                   MessageBoxDefaultButton.Button1);

            if (resp == DialogResult.OK)
            {
                if (OP == 'I')
                {
                    bllHQ.Insert(hq);
                }
                else
                {
                    bllHQ.Update(hq);
                }
            }

            dtgHQ.DataSource = bllHQ.Select();

            OP = 'X';
            habilitaCampos(false);
        }