Esempio n. 1
0
        private void btnRemover_Click(object sender, EventArgs e)
        {
            string msg;

            if (lblId.Text != string.Empty)
            {
                msg = "Confirma Remoção do Fabricante " + txtNome.Text + "?";
                DialogResult resp;
                resp = MessageBox.Show(msg, "Remover", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                if (resp == DialogResult.Yes)
                {
                    int id = Convert.ToInt32(lblId.Text);
                    Camadas.BLL.Fabricante   bllFabricante = new Camadas.BLL.Fabricante();
                    Camadas.Model.Fabricante fabricante    = new Camadas.Model.Fabricante();
                    fabricante.Id = id;
                    bllFabricante.Delete(fabricante);
                    dgvFabricante.DataSource = "";
                    dgvFabricante.DataSource = bllFabricante.Select();
                }
            }
            else
            {
                msg = "Não há registro para remoção...";
                MessageBox.Show(msg, "Remover", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            limparCampos();
            Habilitar(false);
        }
Esempio n. 2
0
        private void RecuperarDadosFabricante()
        {
            Camadas.BLL.Fabricante          bllFabricante = new Camadas.BLL.Fabricante();
            List <Camadas.Model.Fabricante> lstFabr       = new List <Camadas.Model.Fabricante>();

            lstFabr = bllFabricante.SelectById(Convert.ToInt32(txtIdFrabr.Text));
            if (lstFabr != null)
            {
                fabricante = lstFabr[0];
            }
            else
            {
                MessageBox.Show("Fornecedor não encontrado");
            }
        }
Esempio n. 3
0
        private void btnGrvar_Click(object sender, EventArgs e)
        {
            Camadas.BLL.Fabricante   bllFabricante = new Camadas.BLL.Fabricante();
            Camadas.Model.Fabricante fabricante    = new Camadas.Model.Fabricante();
            int id = Convert.ToInt32(lblId.Text);

            string msg = "";

            if (id == -1)
            {
                msg = "Confirma Inclusao dos Dados?";
            }
            else
            {
                msg = "Confirma Atualização dos Dados?";
            }

            DialogResult resp;

            resp = MessageBox.Show(msg, "Gravar", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
            if (resp == DialogResult.Yes)
            {
                fabricante.Id       = id;
                fabricante.Nome     = txtNome.Text;
                fabricante.CNPJ     = txtCnpj.Text;
                fabricante.Telefone = txtTelefone.Text;
                fabricante.Endereco = txtEndereco.Text;
                fabricante.Bairro   = txtBairro.Text;
                fabricante.Cidade   = txtCidade.Text;
                fabricante.UF       = txtUf.Text;
                fabricante.CEP      = txtCep.Text;
                fabricante.Email    = txtEmail.Text;
                if (id == -1)
                {
                    bllFabricante.Insert(fabricante);
                }
                else
                {
                    bllFabricante.Update(fabricante);
                }
            }
            dgvFabricante.DataSource = "";
            dgvFabricante.DataSource = bllFabricante.Select();
            limparCampos();
            Habilitar(false);
        }