public static string Converter(string numero) { try { string retorno = string.Empty; int algarismoArabico = 0; string algarismoRomano = string.Empty; if (AlgarismoArabico.ValidarStringParaConversao(numero)) { retorno = AlgarismoArabico.ConverterParaAlgarismoRomano(numero); algarismoArabico = Convert.ToInt32(numero); algarismoRomano = retorno; } if (AlgarismoRomano.ValidarStringParaConversao(numero)) { retorno = AlgarismoRomano.ConverterParaAlgarismoArabico(numero); algarismoArabico = Convert.ToInt32(retorno); algarismoRomano = numero; } if (!string.IsNullOrWhiteSpace(retorno)) { Persistencia.Gravar(algarismoArabico, algarismoRomano); } return(retorno); } catch (Exception excecao) { throw excecao; } }
private void btnPesquisar_Click(object sender, EventArgs e) { try { txtResultadoConsulta.Text = string.Empty; if (AlgarismoArabico.ValidarStringParaConversao(txtNumeroPesquisar.Text)) { txtResultadoConsulta.Text = Persistencia.PesquisarAlgarismoRomanoPeloArabico(Convert.ToInt32(txtNumeroPesquisar.Text)); } if (AlgarismoRomano.ValidarStringParaConversao(txtNumeroPesquisar.Text)) { txtResultadoConsulta.Text = Persistencia.PesquisarAlgarismoArabicoPeloRomano(txtNumeroPesquisar.Text); } if (string.IsNullOrWhiteSpace(txtResultadoConsulta.Text)) { MessageBox.Show("Algarismo ainda não convertido"); } } catch (Exception excecao) { throw excecao; } }