Ejemplo n.º 1
0
 public List <string> ListarValores()
 {
     return(new List <string>
     {
         HelperBd.DataAppparaBd(dt),
         p.cpf
     });
 }
Ejemplo n.º 2
0
 public List <string> ListarValores()
 {
     return(new List <string>
     {
         cpf,
         nome,
         HelperBd.DataAppparaBd(dnasc),
         tipoUsuario
     });
 }
Ejemplo n.º 3
0
        public bool UpdateLine(string tabela, List <string> campos, List <string> valores, string filtro)
        {
            string query = "UPDATE " + tabela + " SET ";
            string temp1, temp2, s;

            while (campos.Count > 0)
            {
                temp1  = campos.First();
                temp2  = valores.First();
                query += temp1 + "=";
                if (HelperBd.VerificaInt(temp2))    //na verdade eu tenho que verificar o Controller e o tipo do campo atual
                {
                    query += temp2;
                }
                else
                {
                    if (HelperBd.VerificaBool(temp2, out s))
                    {
                        query += s;
                    }
                    else
                    {
                        query += "'";
                        query += HelperBd.SanitizaString(temp2);
                        query += "'";
                    }
                }
                campos.RemoveAt(0);
                valores.RemoveAt(0);
                if (campos.Count > 0)
                {
                    query += ", ";
                }
            }
            if (filtro != "")
            {
                query += " WHERE " + filtro;
            }
            if (EnviaComando(query))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        public bool InsereLinha(string tabela, List <string> campos, List <string> valores)
        {
            string s;
            string query = "INSERT INTO " + tabela + " (";

            foreach (string item in campos)
            {
                query += item;
                query += ", ";
            }
            query  = query.Remove(query.Length - 2);
            query += ") VALUES(";
            foreach (string item in valores)
            {
                if (HelperBd.VerificaInt(item))   //na verdade eu tenho que verificar o Controller e o tipo do campo atual
                {
                    query += item;
                }
                else
                {
                    if (HelperBd.VerificaBool(item, out s))
                    {
                        query += s;
                    }
                    else
                    {
                        query += "'";
                        query += HelperBd.SanitizaString(item);
                        query += "'";
                    }
                }
                query += ",";
            }
            query  = query.Remove(query.Length - 1);
            query += ")";
            if (EnviaComando(query))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
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);
        }