private void MostraRegistroAtivo()
        {
            chkHtonico.Checked    = ativo.heterotonico;
            chkHsemantico.Checked = ativo.heterossemantico;
            chkHgenerico.Checked  = ativo.heterogenerico;

            resP = Palavra.ConverteObject(crud.SelecionarTabela(tabelasBd.PALAVRA, Palavra.ToListTabela(true), "id=" + ativo.equivalente.ToString()));
            comboDestino.Text = resP.First().lema;

            txtApresentacao.Value    = ativo.nOrdem;
            txtExemplo.Text          = ativo.exemplo;
            txtExemploTraduzido.Text = ativo.exemplo_traduzido;

            resRef = Referencia.ConverteObject(crud.SelecionarTabela(tabelasBd.REFERENCIAS, Referencia.ToListTabela(true), "Id=" + ativo.Referencia.ToString()));
            if (resRef.Count > 0)
            {
                comboRef.Text = resRef.First().descricao;
            }

            resRubrica = MarcaUso.ConverteObject(crud.SelecionarTabela(tabelasBd.MARCAS_USO, MarcaUso.ToListTabela(true), "Id=" + ativo.MarcaUso.ToString()));
            if (resRubrica.Count > 0)
            {
                ComboRubrica.Text = resRubrica.First().descricao;
            }
            oldEqAt           = ativo;
            txtCultura.Text   = ativo.notasCulturais;
            txtGramatica.Text = ativo.notasGramaticais;
        }
        private void timerRub_Tick(object sender, EventArgs e)
        {
            string pesquisa;

            pesquisa = ComboRubrica.Text;
            if (ComboRubrica.Items.Count > 0)
            {
                ComboRubrica.Items.Clear();
            }
            if (pesquisa.Length <= 3)
            {
                resRubrica = MarcaUso.ConverteObject(crud.SelecionarTabela(tabelasBd.MARCAS_USO, MarcaUso.ToListTabela(true), "sigla LIKE '" + pesquisa + "%'", "LIMIT 10"));
            }
            else
            {
                resRubrica = MarcaUso.ConverteObject(crud.SelecionarTabela(tabelasBd.MARCAS_USO, MarcaUso.ToListTabela(true), "descricao LIKE '" + pesquisa + "%'", "LIMIT 10"));
            }
            foreach (MarcaUso r in resRubrica)
            {
                ComboRubrica.Items.Add(r.descricao);
            }
            timerRub.Enabled = false; //prevenindo de floodar a combo
        }
예제 #3
0
        private List <string> SanitizaValores(string tabela, List <string> valores)
        { //função para trocar possíveis valores em string por suas respectivas FK
            string saida;

            for (int i = 0; i < valores.Count; i++)
            {
                if (SanitizaString(valores.ElementAt(i), out saida))
                {
                    valores.RemoveAt(i);
                    valores.Insert(i, saida);
                }
            }
            if (tabela == tabelasBd.CONJUGACAO)
            {
                List <string> FKs = new List <string>();
                int           idx, c = 0;
                bool[]        fila = { false, false };
                ///TODO: Ah, enumeradores...
                /////faço issoi para evitar que seja lançada uma exceção e os valores perdidos no cast logo abaixo
                //rubrica
                idx = Palavra.ToListTabela().FindIndex(bs => bs == "Rubrica");
                if (!int.TryParse(valores.ElementAt(idx), out int conv) && (valores.ElementAt(idx) != ""))
                {
                    FKs.Add(valores.ElementAt(idx));
                    valores.RemoveAt(idx);
                    valores.Insert(idx, "0");
                    fila[c] = true;
                }
                c++;
                //referencia
                idx = Palavra.ToListTabela().FindIndex(bs => bs == "referencia_verbete");
                if (!int.TryParse(valores.ElementAt(idx), out conv) && (valores.ElementAt(idx) != ""))
                {
                    FKs.Add(valores.ElementAt(idx));
                    valores.RemoveAt(idx);
                    valores.Insert(idx, "0");
                    fila[c++] = true;
                }
                c++;

                Palavra teste = new Palavra();
                try
                {
                    teste = (Palavra)valores;
                }
                catch (InvalidCastException)
                {
                    LoggerErros(EnumErros.Erro_dados);
                    return(null);
                }
                catch (FormatException)
                {
                    LoggerErros(EnumErros.Erro_dados);
                    return(null);
                }

                List <MarcaUso>      lrub = new List <MarcaUso>();
                List <Referencia>    lref = new List <Referencia>();
                IEnumerator <string> ff   = FKs.GetEnumerator();
                c = 0;
                if (fila[c++])
                {
                    saida = ff.Current;
                    lrub  = MarcaUso.ConverteObject(operacoes.SelecionarTabela(tabelasBd.MARCAS_USO, MarcaUso.ToListTabela(true), "sigla='" + saida + "'"));
                    if (lrub.Count() > 0)
                    {
                        // teste.rubrica = lrub.First().id;
                    }
                    else
                    {
                        return(null);
                    }
                    ff.MoveNext();
                }
                if (fila[c])
                {
                    saida = ff.Current;
                    lref  = Referencia.ConverteObject(operacoes.SelecionarTabela(tabelasBd.REFERENCIAS, Referencia.ToListTabela(true), "Cod='" + saida + "'"));
                    if (lref.Count > 0)
                    {
                        // teste.referencia_verbete = lref.First().id;
                    }
                    else
                    {
                        return(null);
                    }
                }
                valores.Clear();
                valores.AddRange(teste.ToListValores());
            }
            return(valores);
        }