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 List <string> criaListaTitulos(Palavra p, MarcaUso r)
        {
            List <string> sai = new List <string>
            {
                //cg.descricao,
                r.descricao,
                "Notas Gramaticais",
                "Notas Culturais",
                "Exemplos de uso"
            };

            return(sai);
        }
        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
        }
예제 #4
0
        private void BtnStart_Click(object sender, EventArgs e)
        //NOTE: Usar ponto e vírgula como separador no CSV
        {
            string linha;

            string[] divisor;
            int      v = 0;

            progressBar1.MarqueeAnimationSpeed = 50;
            if (ComboTable.Text != "")
            {
                switch (ComboTable.Text)
                {
                case "Palavra":
                    ptlt = Palavra.ToListTabela();
                    ptlt.RemoveRange(Palavra.ToListTabela().Count - 2, 2);
                    v = ptlt.Count;
                    break;

                case "Marca de Uso":
                    v    = MarcaUso.ToListTabela().Count;
                    ptlt = MarcaUso.ToListTabela();
                    break;

                case "Referência":
                    v    = Referencia.ToListTabela().Count;
                    ptlt = Referencia.ToListTabela();
                    break;

                default:
                    throw new Exception("Não implementado");
                    break;
                }
                try
                {
                    StreamReader leitor = new StreamReader(LblArquivo.Text, Encoding.Default);
                    try
                    {
                        do
                        {
                            linha = leitor.ReadLine();
                            if (linha != "")
                            {
                                divisor = linha.Split(';');
                                //varificar dimensao antes de prosseguir
                                if (divisor.Count() != v)
                                {
                                    InformaDiag.Erro("A quantidade de colunas da entrada é diferente do destino.\nOperação Abortada.");
                                    progressBar1.MarqueeAnimationSpeed = 0;
                                    BtnStart.Enabled = false;
                                    LiberaArquivo(leitor);
                                    return;
                                }

                                for (int i = 0; i < divisor.GetLength(0); i++)
                                {
                                    if (divisor[i] == ptlt.ElementAt(i))
                                    {
                                        dataGridView1.Columns.Add(divisor[i], divisor[i]);
                                    }
                                    else
                                    {
                                        dataGridView1.Columns.Clear();
                                        EnumeraColunasFaltantes(divisor, ptlt);
                                        progressBar1.MarqueeAnimationSpeed = 0;
                                        BtnStart.Enabled = false;
                                        LiberaArquivo(leitor);
                                        return;
                                    }
                                }
                            }
                        } while (linha == "");
                        do //implementar thread
                        {
                            linha = leitor.ReadLine();
                            if (linha != "")
                            {
                                divisor = linha.Split(';');
                                dataGridView1.Rows.Add(divisor);
                            }
                        } while (leitor.Peek() != -1);
                        LiberaArquivo(leitor);
                    }
                    catch (IndexOutOfRangeException) { }
                    catch (EndOfStreamException) { }
                }

                catch (FileLoadException) {
                    return;
                }
                catch (FileNotFoundException) {
                    return;
                }
                catch (IOException)
                {
                    InformaDiag.Erro("O arquivo está inacessível no momento.\nTente novamente mais tarde.");
                    return;
                }
                BtnStart.Enabled   = false;
                BtnProcura.Enabled = false;
                BtnCancela.Enabled = true;
                BtnGrava.Enabled   = true;
                ComboTable.Enabled = false;
                progressBar1.MarqueeAnimationSpeed = 0;
            }
            else
            {
                InformaDiag.Informa("Escolha uma tabela destino");
            }
        }
예제 #5
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);
        }