コード例 #1
0
        private void txtBuscaCpf_Click(object sender, EventArgs e)
        {
            List <Usuario> resultado = Usuario.ConverteObject(c.SelecionarTabela(tabelasBd.USUARIOS, Usuario.ToListTabela(), "cpf='" + txtCpf.Text + "'"));

            if (resultado.Count > 0)
            {
                usr = resultado.First();
                MostraModel();
            }
            else
            {
                InformaDiag.Informa("Nenhum usuário encontrado.");
            }
        }
コード例 #2
0
 private void BtnGrava_Click(object sender, EventArgs e)
 {
     if (InformaDiag.ConfirmaSN("Você tem certeza que deseja continuar?\n" + "Todos os dados válidos da tabela serão salvos no Banco de Dados!") == DialogResult.Yes)
     {
         if (importador(ComboTable.Text) == 1)
         {
             InformaDiag.Informa("Houveram erros na importação e alguns registros foram ignorados.");
         }
         BtnProcura.Enabled = true;
         LblArquivo.Text    = "Nenhum arquivo selecionado";
         progressBar1.MarqueeAnimationSpeed = 0;
         dataGridView1.Rows.Clear();
         dataGridView1.Columns.Clear();
     }
 }
コード例 #3
0
 private void btnPesquisa_Click(object sender, EventArgs e)
 {
     resultado = Referencia.ConverteObject(c.SelecionarTabela(tabelasBd.REFERENCIAS, Referencia.ToListTabela(true), "Cod='" + txtCodPSQ.Text + "'"));
     if (resultado.Count < 1)
     {
         InformaDiag.Informa("Nenhum resultado encontrado.");
         return;
     }
     referencia = resultado.First();
     MostraModel();
     if (resultado.Count > 1)
     {
         btnAnt.Visible  = true;
         btnProx.Visible = true;
     }
     p = 0;
     txtCod.ReadOnly = true;
 }
コード例 #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 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
        }
コード例 #6
0
        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);
            }
        }