Пример #1
0
        public bool GetExistsUser(NovaContaModel nc)
        {
            try
            {
                string        sql = "SELECT * FROM Usuarios WHERE Usuario = @Usuario";
                SQLiteCommand cmd = new SQLiteCommand(sql);
                cmd.Connection = AbreConexao();
                cmd.Parameters.Add(new SQLiteParameter("@Usuario", nc.usuario));
                SQLiteDataReader dr = cmd.ExecuteReader();
                int rows            = 0;
                while (dr.Read())
                {
                    rows++;
                }

                if (rows > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                FecharConexao();
            }
        }
Пример #2
0
        public bool Add(NovaContaModel nc)
        {
            try
            {
                string        sql = "INSERT INTO Usuarios(Usuario, Senha) VALUES (@Usuario, @Senha)";
                SQLiteCommand cmd = new SQLiteCommand(sql);
                cmd.Connection = AbreConexao();
                cmd.Parameters.Add(new SQLiteParameter("@Usuario", nc.usuario));
                cmd.Parameters.Add(new SQLiteParameter("@Senha", nc.senha));
                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                FecharConexao();
            }
        }