private bool EnviaComando(string query)
        {
            if (ControllerBanco.AbreConexao() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, ControllerBanco.PegaConexao());
                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (MySqlException err) {
                    switch (err.Number)
                    {
                    case (int)MySqlErrorCode.DuplicateKeyEntry:
                        InformaDiag.Erro("O registro já existe. Tente outros valores");
                        break;

                    default:
                        InformaDiag.Erro("Ocorreu um erro e a operação será abortada.");
                        break;
                    }
                    cmd.Dispose();
                    return(false);
                };
                ControllerBanco.FechaConexao();
                cmd.Dispose();
                return(true);
            }
            return(false);
        }
Exemple #2
0
 private int LiberaArquivo(StreamReader f)
 {
     try{
         f.DiscardBufferedData();
         f.Dispose();
     }
     catch (IOException)
     {
         InformaDiag.Erro("Erro ao liberar o arquivo");
         return(1);
     }
     return(0);
 }
 public bool FechaConexao()
 {
     try
     {
         conexao.Close();
         return(true);
     }
     catch (MySqlException ex)
     {
         InformaDiag.Erro(ex.Message);
         return(false);
     }
 }
        private void searchButton_Click(object sender, EventArgs e)
        {
            List <Palavra> lista = new List <Palavra>();
            string         chavePesquisa = searchBox.Text, pesquisa;

            if (chavePesquisa == "")
            {
                InformaDiag.Erro("A caixa de busca não pode estar vazia!");
                return;
            }
            if (chavePesquisa.Contains(" "))
            {
            }
            else
            {
                if (chavePesquisa.EndsWith("ing") || chavePesquisa.EndsWith("ed") || chavePesquisa.EndsWith("ies") || chavePesquisa.EndsWith("es"))
                {
                    InformaDiag.Erro("Entradas em inglês não acessíveis no momento.");
                    return;
                }
                if (chavePesquisa.EndsWith("ar") || chavePesquisa.EndsWith("ir"))
                {
                    //caso suspeitarmos que seja um infinitivo em portugues...
                    pesquisa = "Lema = '" + chavePesquisa + "' AND Idioma = 'PT'";
                    lista    = Palavra.ConverteObject(cRUD.SelecionarTabela(tabelasBd.PALAVRA, Palavra.ToListTabela(true), pesquisa));

                    if (lista.Count >= 1) //Existe somente aquele resultado?
                    {
                        if (lista.Count == 1)
                        {
                            txtResultado.Text = MontaApresentaçãoInfinitivoPt(lista.First());
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        InformaDiag.Erro("Busca não encontrada!");
                    }
                }
                else
                {
                    //caso suspeitarmos que é um verbo flexionado em português
                }
            }
        }
 private void btnSalva_Click(object sender, EventArgs e)
 {
     if (equivDestModificado || ativo.equivalente < 1)
     {
         if (novo)
         {
             InformaDiag.Erro("Selecione uma palavra equivalente dentro dos\nresultados da caixa de pesquisa Verbete Destino!");
             return;
         }
         else
         {
             if (InformaDiag.ConfirmaSN("O valor selecionado no verbete destino foi modificado para um valor inconsistente.\nDeseja continuar com o valor antigo?") == DialogResult.No)
             {
                 return;
             }
         }
     }
     ativo.exemplo           = txtExemplo.Text;
     ativo.exemplo_traduzido = txtExemploTraduzido.Text;
     ativo.DefinirOrdemApresentação((int)txtApresentacao.Value);
     ativo.heterogenerico   = chkHgenerico.Checked;
     ativo.heterotonico     = chkHtonico.Checked;
     ativo.heterossemantico = chkHsemantico.Checked;
     ativo.notasCulturais   = txtCultura.Text;
     ativo.notasGramaticais = txtGramatica.Text;
     if (!novo)
     {
         crud.UpdateLine(tabelasBd.EQUIVALENTE, Equivalente.ToListTabela(), ativo.ToListValores(), "Origem=" + oldEqAt.origem.ToString() + " AND equivalente=" + oldEqAt.equivalente.ToString() + " AND nApresentacao=" + oldEqAt.nOrdem.ToString());
         int tpos = equivO.IndexOf(ativo);
         equivO.RemoveAt(tpos);
         equivO.Insert(tpos, ativo);
     }
     else
     {
         crud.InsereLinha(tabelasBd.EQUIVALENTE, Equivalente.ToListTabela(), ativo.ToListValores());
         equivO.Add(ativo);
         if (equivO.Count > 1)
         {
             AtivaNavegadores();
         }
     }
     InformaDiag.InformaSalvo();
     novo = false;
 }
        private void btnincluir_Click(object sender, EventArgs e)
        {
            //campos não nulos: usuario, senha, nivel de permissão, email e cpf
            if (txtusr.Text == "" || txtpass.Text == "" || txtEmail.Text == "" || txtCpf.Text == "")
            {
                InformaDiag.Erro("Campos obrigatórios não foram preenchidos.");
            }
            else
            {
                bool edicao;
                if (usr.cpf != "")
                {
                    edicao = true;
                }
                else
                {
                    edicao = false;
                }
                usr.usr  = txtusr.Text;
                usr.pass = txtpass.Text;

                usr.permissao = converteAutorizacao();
                usr.email     = txtEmail.Text;
                usr.nome      = txtNome.Text;
                usr.tel       = txtTelefone.Text;
                usr.rsocial   = txtRSoc.Text;
                usr.cpf       = txtCpf.Text;
                usr.contato   = txtContato.Text;
                if (edicao)
                {
                    c.UpdateLine(tabelasBd.USUARIOS, Usuario.ToListTabela(), usr.ToListValores(), "cpf='" + usr.cpf + "'");
                }
                else
                {
                    c.InsereLinha(tabelasBd.USUARIOS, Usuario.ToListTabela(), usr.ToListValores());
                }

                InformaDiag.InformaSalvo();
                LimpaCampo();
            }
        }
 private void btnSalva_Click(object sender, EventArgs e)
 {
     if (txtDesc.Text == "" || txtSigla.Text == "")
     {
         InformaDiag.Erro("Existem campos obrigatórios vazios!");
         return;
     }
     rubrica.descricao = txtDesc.Text;
     rubrica.sigla     = txtSigla.Text;
     if (rubrica.id > 0)
     {
         c.UpdateLine(tabelasBd.MARCAS_USO, MarcaUso.ToListTabela(false), rubrica.ToListValores(), "id=" + rubrica.id.ToString());
     }
     else
     {
         c.InsereLinha(tabelasBd.MARCAS_USO, MarcaUso.ToListTabela(false), rubrica.ToListValores());
     }
     InformaDiag.InformaSalvo();
     LimpaCampos();
     LimpaModel();
 }
Exemple #8
0
 private void btnSalva_Click(object sender, EventArgs e)
 {
     if (txtDesc.Text == "" || txtAno.Text == "" || txtAutor.Text == "" || txtCod.Text == "")
     {
         InformaDiag.Erro("Existem campos obrigatórios vazios!");
         return;
     }
     referencia.Cod       = txtCod.Text;
     referencia.descricao = txtDesc.Text;
     referencia.ano       = int.Parse(txtAno.Text);
     referencia.autor     = txtAutor.Text;
     if (referencia.id > 0)
     {
         c.UpdateLine(tabelasBd.REFERENCIAS, Referencia.ToListTabela(false), referencia.ToListValores(), "Id=" + referencia.id.ToString());
     }
     else
     {
         c.InsereLinha(tabelasBd.REFERENCIAS, Referencia.ToListTabela(false), referencia.ToListValores());
     }
     InformaDiag.InformaSalvo();
     LimpaCampos();
     LimpaModel();
 }
        public bool AbreConexao()
        {
            try
            {
                conexao.Open();
                if (conexao.ConnectionString.Contains("localhost"))
                {
                    InformaDiag.Erro("Banco de testes ativo.");
                }
                return(true);
            }
            catch (MySqlException ex)
            {
                {
                    switch (ex.Number)
                    {
                    case 0:
                        InformaDiag.Erro("Falha ao conectar no servidor de dados.");
                        break;

                    case (int)MySqlErrorCode.NoSuchUser:
                        InformaDiag.Erro("A combinação de usuário e senha não existe. Tente novamente.");
                        break;

                    default:
                        InformaDiag.Erro("Erro " + ex.Code.ToString() + ex.Message);
                        break;
                    }
                }
                return(false);
            }
            catch (InvalidOperationException)
            {
                return(false);
            }
        }
Exemple #10
0
        private void btnSalva_Click(object sender, EventArgs e)
        {
            ativo.exemplo           = txtExemplo.Text;
            ativo.exemplo_traduzido = txtExemploTraduzido.Text;
            ativo.DefinirOrdemApresentação((int)txtApresentacao.Value);
            ativo.PalavraGuia = txtGuia.Text;
            //ativo.heterogenerico = chkHgenerico.Checked;
            //ativo.heterotonico = chkHtonico.Checked;
            //ativo.heterossemantico = chkHsemantico.Checked;
            List <string> fld = Equivalente.ToListTabela();

            fld.Remove("heterotonico");
            fld.Remove("heterogenerico");
            fld.Remove("heterossemantico");

            if (!novo)
            {
                crud.UpdateLine(tabelasBd.EQUIVALENTE, fld, ativo.ToListValores(), "Origem=" + oldEqAt.origem.ToString() + " AND equivalente=" + oldEqAt.equivalente.ToString() + " AND nApresentacao=" + oldEqAt.nOrdem.ToString());
            }
            else
            {
                if (ativo.equivalente < 1)
                {
                    InformaDiag.Erro("Selecione um equivalente na lista de pesquisa.");
                    return;
                }
                else
                {
                    crud.InsereLinha(tabelasBd.EQUIVALENTE, Equivalente.ToListTabela(), ativo.ToListValores());
                    equivO.Add(ativo);
                    AtivaNavegadores();
                }
            }
            InformaDiag.InformaSalvo();
            novo = false;
        }
Exemple #11
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");
            }
        }
Exemple #12
0
        private int importador(string NomeTabela)
        {
            DataGridViewRow[]  linhas       = new DataGridViewRow[dataGridView1.Rows.Count];
            DataGridViewCell[] cell         = new DataGridViewCell[dataGridView1.ColumnCount];
            List <string>      ValoresLinha = new List <string>();
            string             query        = "";

            switch (NomeTabela)
            {
            case "Palavra":
                NomeTabela = tabelasBd.PALAVRA;
                break;

            case "Marca de Uso":
                NomeTabela = tabelasBd.MARCAS_USO;
                break;

            case "Referência":
                NomeTabela = tabelasBd.REFERENCIAS;
                break;
            }

            progressBar1.MarqueeAnimationSpeed = 50;
            BtnCancela.Enabled = false;
            BtnGrava.Enabled   = false;
            BtnStart.Enabled   = false;
            BtnProcura.Enabled = false;

            try
            {
                dataGridView1.Rows.CopyTo(linhas, 0);
            }
            catch (OutOfMemoryException)
            {
                InformaDiag.Erro("Memória esgotada!\nTente novamente importando menos registros.");
            }

            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
            {
                //pegar uma linha da grade e coloca no ValoresLinha
                linhas[i].Cells.CopyTo(cell, 0);
                for (int j = 0; j < dataGridView1.ColumnCount; j++)
                {
                    ValoresLinha.Add(Convert.ToString(cell[j].Value));
                }

                query       += "(";
                ValoresLinha = SanitizaValores(NomeTabela, ValoresLinha);
                if (ValoresLinha == null)
                {
                    ValoresLinha = new List <string>();
                    query        = query.Remove(query.Count() - 1);
                    continue;
                }
                foreach (string s in ValoresLinha)
                {
                    if (HelperBd.VerificaInt(s))
                    {
                        query += (s + ",");
                    }
                    else
                    {
                        if (HelperBd.VerificaBool(s, out string valor))
                        {
                            query += (valor + ",");
                        }
                        else
                        {
                            query += "'" + s + "',";
                        }
                    }
                }
                query  = query.Remove(query.Count() - 1);
                query += "),";
                ValoresLinha.Clear();
            }
            if (query.Count() > 0)
            {
                query  = query.Remove(query.Count() - 1);
                query += ";";
                if (NomeTabela == tabelasBd.PALAVRA)
                {
                    operacoes.InserirEmMassa(NomeTabela, query, ptlt);
                }
                else
                {
                    operacoes.InserirEmMassa(NomeTabela, query);
                }
                return(0);
            }
            return(1);
        }
        private void btnSalva_Click(object sender, EventArgs e)
        {
            if (txtpalavra.Text == String.Empty)
            {
                InformaDiag.Erro("Palavra não pode ser vazio!");
                return;
            }
            if (ComboClasseGram.SelectedItem == null)
            {
                InformaDiag.Erro("Selecione um valor válido de Classe gramatical!");
                return;
            }
            if (ComboGenero.SelectedItem == null)
            {
                InformaDiag.Erro("Selecione um gênero válido!");
                return;
            }
            if (ComboIdioma.SelectedItem == null)
            {
                InformaDiag.Erro("É obrigatório selecionar um idioma!");
                return;
            }
            string lng;

            p.lema = txtpalavra.Text;

            switch (ComboIdioma.SelectedIndex)
            {
            case 0:
                lng = "PT";
                break;

            case 2:
                lng = "EN";
                break;

            case 1:
                lng = "ES";
                break;

            default:
                lng = "";
                break;
            }
            p.idioma          = lng;
            p.notas_gramatica = txtGramatica.Text;
            p.nota_cultura    = textCultura.Text;
            p.Definicao       = txtDefinicao.Text;
            switch (ComboGenero.SelectedIndex)
            {
            case 0:
                p.Genero = "M";
                break;

            case 1:
                p.Genero = "F";
                break;

            case 2:
                p.Genero = "N";
                break;

            default:
                p.Genero = "S";
                break;
            }
            p.ClasseGram = ComboClasseGram.Text;
            if (p.id <= 0)
            {
                if (crud.InsereLinha(tabelasBd.PALAVRA, Palavra.ToListTabela(), p.ToListValores()) > 0)
                {
                    InformaDiag.Informa("Salvo!");
                    LimpaCampos();
                    LimpaModel();
                }
                else
                {
                    ///CASO HOUVER UMA DUPLICATA, ENTÃO O REGISTRO EXISTENTE NO BANCO DEVE SER CARREGADO NO LUGAR DAS INFORMAÇÕES QUE O USUÁRIO PREENCHEU
                    InformaDiag.Erro("Não foi possível salvar.\nO item caracterizado já existe.");
                    if (InformaDiag.ConfirmaSN("Deseja carregar o registro existente?") == DialogResult.Yes)
                    {
                        p = Palavra.ConverteObject(crud.SelecionarTabela(tabelasBd.PALAVRA, Palavra.ToListTabela(true), "lema='" + p.lema + "' AND ClasseGram='" + p.ClasseGram + "' AND idioma='" + p.idioma + "' AND Genero='" + p.Genero + "'")).First();
                        MostraDados();
                    }
                }
            }
            else
            {
                crud.UpdateLine(tabelasBd.PALAVRA, Palavra.ToListTabela(), p.ToListValores(), "id=" + p.id.ToString());
                InformaDiag.Informa("Salvo!");
                LimpaCampos();
            }
            //Uma excessão pode ser lançda aqui quando os valores das chaves estrangerias forem <1, pois estão refernciando um valor que não existe. Como o int no c# não cabe um NULL, seria melhor não enviar o tal valor que evitamos o problema
        }
        private void searchButton_Click(object sender, EventArgs e)
        {
            if (searchBox.Text != "")
            {
                string filtroquery;
                int    temp;
                switch (filterComboBox.SelectedIndex)
                {
                case 1:
                    filtroquery = "Cod";
                    break;

                default:
                    filtroquery = "lema";
                    break;
                }
                switch (ComboFiltroPrecisao.SelectedIndex)
                {
                case 1:
                    filtroquery += " LIKE '" + searchBox.Text + "%'";
                    break;

                default:
                    filtroquery += "=";
                    if (int.TryParse(searchBox.Text, out temp))
                    {
                        filtroquery += searchBox.Text;
                    }
                    else
                    {
                        filtroquery += "'" + searchBox.Text + "'";
                    }
                    break;
                }
                switch (comboFiltroIdiomas.SelectedIndex)
                {
                case 1:
                    filtroquery += "AND Idioma='PT'";
                    break;

                case 2:
                    filtroquery += "AND Idioma='EN'";
                    break;

                case 3:
                    filtroquery += "AND Idioma='ES'";
                    break;

                default:
                    break;
                }
                if (ComboFiltroPrecisao.Text == "Precisamente")
                {
                    resultados = crud.SelecionarTabela(tabelasBd.PALAVRA, Palavra.ToListTabela(true), "lema='" + searchBox.Text + "'");
                }
                else
                {
                    resultados = crud.SelecionarTabela(tabelasBd.PALAVRA, Palavra.ToListTabela(true), "lema LIKE '%" + searchBox.Text + "%'");
                }
                if (resultados.Count > 0)
                {
                    resPalavra = Palavra.ConverteObject(resultados);
                    p          = resPalavra.First();
                    MostraDados();
                    if (resPalavra.Count == 1)
                    {
                        DesativaNavegadores();
                    }
                    else
                    {
                        AtivaNavegadores();
                        ipal = 0;
                    }
                }
                else
                {
                    InformaDiag.Erro("Nenhum resultado adequado encontrado.");
                }
            }
        }
        private void searchButton_Click(object sender, EventArgs e)
        {
            List <object[]> lista = new List <object[]>();

            if (searchBox.Text == "")
            {
                InformaDiag.Erro("A caixa de busca não pode estar vazia!");
                return;
            }
            string filtro = "";

            switch (filterComboBox.SelectedIndex)
            {
            case 1:
                filtro += "lema LIKE'" + searchBox.Text + "'";
                break;

            case 2:
                //anagrama
                break;

            case 3:
                //filtro += "definicao LIKE '" + searchBox.Text + "'";
                break;

            case 4:
                //exemplo
                break;

            case 5:
                //Heterogenérico
                break;

            case 6:
                //Heterotônico
                break;

            default:
                filtro += "lema='" + searchBox.Text + "'";
                break;
            }
            lista = cRUD.SelecionarTabela("palavra", Palavra.ToListTabela(true), filtro, "ORDER BY lema ASC");
            searchResultsListBox.Items.Clear();
            if (lista.Count > 0)
            {
                try
                {
                    resultadosPalavra.Clear();
                }
                catch (NullReferenceException) {
                    resultadosPalavra = new List <Palavra>();
                }
                List <string> cabecalhos = new List <string>();
                Palavra       temPal     = new Palavra();
                resultadosPalavra = AgrupaResultados(Palavra.ConverteObject(lista), out cabecalhos, out int[] divisores);
                int c = 0, i;
                foreach (string conjunto in cabecalhos)
                {
                    searchResultsListBox.Items.Add(conjunto);
                    for (i = 0; i < divisores[c]; i++)
                    {
                        temPal = resultadosPalavra.ElementAt(i);
                        filtro = temPal.lema + " Acep." + " " + " \"";  //+ temPal.referencia_exemplo + "\"" + "\"" + temPal.ref_ex_tr + "\"" + temPal.referencia_verbete;
                        searchResultsListBox.Items.Add(filtro);
                    }
                    c++;
                }
                searchResultsListBox.Enabled = true;

                similares = Palavra.ConverteObject(cRUD.SelecionarTabela(tabelasBd.PALAVRA, Palavra.ToListTabela(true), "referencia_exemplo LIKE '" + searchBox.Text + "'"));
                if (similares.Count > 0)
                {
                    foreach (Palavra p in similares)
                    {
                        similarListBox.Items.Add(p.lema);
                    }
                }
                else
                {
                    similarListBox.Items.Clear();
                    similarListBox.Items.Add("Não há entradas similares além das pesquisadas.");
                    similarListBox.Enabled = false;
                }
                similarListBox.Enabled = true;
            }
            else
            {
                similarListBox.Items.Clear();
                searchResultsListBox.Items.Add("Nenhum resultado encontrado. Verifique seus critérios de pesquisa!");
                searchResultsListBox.Enabled = false;
                similarListBox.Enabled       = false;
            }
            this.searchResultsListBox.Show();
        }
        private void btnSalva_Click(object sender, EventArgs e)
        {
            bool r;

            if (txtpalavra.Text == String.Empty)
            {
                InformaDiag.Erro("Palavra não pode ser vazio!");
                return;
            }
            if (ComboClasseGram.SelectedItem == null)
            {
                InformaDiag.Erro("Selecione um valor válido de Classe gramatical!");
                return;
            }
            if (ComboGenero.SelectedItem == null)
            {
                InformaDiag.Erro("Selecione um gênero válido!");
                return;
            }
            if (ComboIdioma.SelectedItem == null)
            {
                InformaDiag.Erro("É obrigatório selecionar um idioma!");
                return;
            }
            p.lema      = txtpalavra.Text;
            p.idioma    = PegaSiglaIdioma();
            p.Definicao = txtDefinicao.Text;
            switch (ComboGenero.SelectedIndex)
            {
            case 0:
                p.Genero = "M";
                break;

            case 1:
                p.Genero = "F";
                break;

            case 2:
                p.Genero = "N";
                break;

            case 3:
                p.Genero = "S";
                break;

            case 4:
                p.Genero = "SM";
                break;

            default:
                throw new Exception("Opção não disponível na lista de opções de gênero.");
            }
            if (p.Genero == "N" && p.idioma == "PT")
            {
                InformaDiag.Erro("Gênero inadequado ao idioma.");
                return;
            }
            p.ClasseGram = ComboClasseGram.Text;
            if (comboSinonimo1.Text == "")
            {
                p.Sinonimo1 = 0;
            }
            if (comboSinonimo2.Text == "")
            {
                p.Sinonimo2 = 0;
            }
            p.Sublema = txtSubLema.Text;
            AjustaSinonimos();
            if (p.id <= 0)
            {
                r = crud.InsereLinha(tabelasBd.PALAVRA, Palavra.ToListTabela(), p.ToListValores());
            }
            else
            {
                r = crud.UpdateLine(tabelasBd.PALAVRA, Palavra.ToListTabela(), p.ToListValores(), "id=" + p.id.ToString());
            }
            //Uma excessão pode ser lançda aqui quando os valores das chaves estrangerias forem <1, pois estão refernciando um valor que não existe. Como o int no c# não cabe um NULL, seria melhor não enviar o tal valor que evitamos o problema
            if (r)
            {
                InformaDiag.Informa("Salvo!");
                LimpaCampos();
                LimpaModel();
                btnNovo_Click(sender, e);
            }
        }