private void TxtEstado_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab)
     {
         TxtSigla.Focus();
     }
 }
Esempio n. 2
0
        private void BtnExcluir_Click(object sender, EventArgs e)
        {
            estado.Sigla = TxtSigla.Text;
            string strExcluir = "DELETE FROM ESTADO WHERE ESTADO = '" + estado.Sigla + "'";

            Conexao.Active(true);
            try
            {
                FbCommand cmd = new FbCommand(strExcluir, Conexao.FbCnn);
                cmd.ExecuteNonQuery();
                limparCampos();
                MessageBox.Show("Estado Excluido.");
                TxtSigla.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 3
0
        protected void BtnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                if (TxtNome.Text.Trim().Equals(String.Empty))
                {
                    TxtNome.Text = "";
                    TxtNome.Focus();
                    throw new CampoNaoInformadoException("Unidade Federativa", "Nome", true);
                }
                if (TxtSigla.Text.Trim().Equals(String.Empty))
                {
                    TxtSigla.Text = "";
                    TxtSigla.Focus();
                    throw new CampoNaoInformadoException("Unidade Federativa", "Sigla", true);
                }

                UnidadeFederativa lUf      = null;
                string            mensagem = "";
                if (Request.QueryString["id"] != null)
                {
                    lUf      = UnidadeFederativaBLL.Instance.BuscarPorId(Convert.ToInt32(Request.QueryString["id"]));
                    mensagem = "Unidade Federativa alterada com sucesso.";
                }
                else
                {
                    lUf      = new UnidadeFederativa();
                    mensagem = "Unidade Federativa cadastrada com sucesso.";
                }

                lUf.Nome  = TxtNome.Text.Trim();
                lUf.Sigla = TxtSigla.Text.Trim();
                UnidadeFederativaBLL.Instance.Persistir(lUf);
                Web.ExibeAlerta(Page, mensagem, "Listar.aspx");
            }
            catch (BusinessException ex)
            {
                Web.ExibeAlerta(Page, ex.Message);
            }
        }
Esempio n. 4
0
 private void limparCampos()
 {
     TxtNomeEstado.Clear();
     TxtSigla.Clear();
     TxtSigla.Focus();
 }
Esempio n. 5
0
 private void DtGridEstados_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     TxtSigla.Text      = DtGridEstados.CurrentRow.Cells[0].Value.ToString();
     TxtNomeEstado.Text = DtGridEstados.CurrentRow.Cells[1].Value.ToString();
     TxtSigla.Focus();
 }