//------------------------------------------------------------------------------------------------------------------- private void btLocalizar_Click(object sender, EventArgs e) { try { frmConsultaUndMedida frm = new frmConsultaUndMedida(); frm.ShowDialog(); if (frm.codigo >= 0) { BLLUndMedida bll = new BLLUndMedida(); ModeloUndMedida modelo = bll.carregaModelo(frm.codigo); txtCodigo.Text = modelo.umed_cod.ToString(); txtNome.Text = modelo.umed_nome; this.alteraBotoes(3); } frm.Dispose(); }catch (Exception error) { MessageBox.Show(error.Message); } }
//------------------------------------------------------------------------------------------------------------------- private void txtNome_Leave(object sender, EventArgs e) { if (operacao == "inserir") { int r = 0; BLLUndMedida bll = new BLLUndMedida(); r = bll.VerificaUnidadeDeMedida(txtNome.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"; ModeloUndMedida modelo = bll.carregaModelo(r); txtCodigo.Text = modelo.umed_cod.ToString(); txtNome.Text = modelo.umed_nome; //this.alteraBotoes(3); txtNome.Clear(); txtNome.Focus(); } else { txtNome.Clear(); txtNome.Focus(); } } else { txtNome.Clear(); txtNome.Focus(); } } } }