//------------------------------------------------------------------------------------------------------------------- private void txtCategoria_Leave(object sender, EventArgs e) { if (operacao == "inserir") { int r = 0; BLLCategoria bll = new BLLCategoria(); r = bll.VerificaCategoria(txtCategoria.Text); if (r > 0) { DialogResult d = MessageBox.Show("Já existe um registro com esse valor. Deseja alterar o registro?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (d.ToString() == "Yes") { DialogResult di = MessageBox.Show("Deseja realmente sobreescrever esse registro? Ao aceitar a operação, o registro antes cadastrado será permanentemente deletado!", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (di.ToString() == "Yes") { this.operacao = "alterar"; ModeloCategoria modelo = bll.carregaModelo(r); txtCodigo.Text = modelo.cat_cod.ToString(); txtCategoria.Text = modelo.cat_nome; //this.alteraBotoes(3); } else { txtCategoria.Clear(); txtCategoria.Focus(); } } else { txtCategoria.Clear(); txtCategoria.Focus(); } } } }
//------------------------------------------------------------------------------------------------------------------- private void btLocalizar_Click(object sender, EventArgs e) { try { frmConsultaMarcas frm = new frmConsultaMarcas(); frm.ShowDialog(); if (frm.codigo >= 0) { BLLCategoria bll = new BLLCategoria(); ModeloCategoria modelo = bll.carregaModelo(frm.codigo); txtCodigo.Text = modelo.cat_cod.ToString(); txtCategoria.Text = modelo.cat_nome; this.alteraBotoes(3); } frm.Dispose(); }catch (Exception error) { MessageBox.Show(error.Message); } }