//------------------------------------------------------------------------------------------------------------------- private void txtSubCategoria_Leave(object sender, EventArgs e) { if (operacao == "inserir") { int r = 0; BLLSubCategoria bll = new BLLSubCategoria(); r = bll.VerificaSubCategoria(txtSubCategoria.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"; ModeloSubCategoria modelo = bll.carregaModelo(r); txtSubCodigo.Text = modelo.scat_cod.ToString(); txtSubCategoria.Text = modelo.scat_nome; //this.alteraBotoes(3); } else { txtSubCategoria.Clear(); txtSubCategoria.Focus(); } } else { txtSubCategoria.Clear(); txtSubCategoria.Focus(); } } } }
//------------------------------------------------------------------------------------------------------------------- private void btLocalizar_Click(object sender, EventArgs e) { try { frmConsultaCor frm = new frmConsultaCor(); frm.ShowDialog(); if (frm.codigo >= 0) { BLLSubCategoria bll = new BLLSubCategoria(); ModeloSubCategoria modelo = bll.carregaModelo(frm.codigo); txtSubCodigo.Text = modelo.scat_cod.ToString(); txtSubCategoria.Text = modelo.scat_nome; cbCategoria.SelectedValue = modelo.cat_cod; this.alteraBotoes(3); } frm.Dispose(); }catch (Exception error) { MessageBox.Show(error.Message); } }