From 7fb6d59c1ca1e621b95f7ec16564e8da2aef5744 Mon Sep 17 00:00:00 2001 From: kuei <110316104@gms.tcu.edu.tw> Date: Wed, 4 Sep 2024 09:42:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E8=B3=87=E6=96=99=E5=BA=AB?= =?UTF-8?q?=E9=80=A3=E6=8E=A5=EF=BC=8Ctestdb->care(HistoricalPage)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/HistoricalRecord.dart | 40 +++++++++++++++++++-------------------- lib/PersonalInfo.dart | 4 ++-- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/lib/HistoricalRecord.dart b/lib/HistoricalRecord.dart index 8c41f84..20f18e5 100644 --- a/lib/HistoricalRecord.dart +++ b/lib/HistoricalRecord.dart @@ -29,20 +29,20 @@ class _HistoricalRecordState extends State { print('connect'); final conn = await MySQLConnection.createConnection( - //host: '203.64.84.154', - host: '10.0.2.2', + host: '203.64.84.154', + //host: '10.0.2.2', //127.0.0.1 10.0.2.2 - port: 3306, + port: 33061, userName: 'root', - //password: 'Topic@2024', - password: '0000', - //databaseName: 'care', //testdb - databaseName: 'testdb', + password: 'Topic@2024', + //password: '0000', + databaseName: 'care', //testdb + //databaseName: 'testdb', ); await conn.connect(); try { - var result = await conn.execute('SELECT * FROM users'); + var result = await conn.execute('SELECT HomeElderFall.*, HomeElder.heName FROM HomeElderFall JOIN HomeElder ON HomeElderFall.heId = HomeElder.heId;'); print('Result: ${result.length} rows found.'); if (result.rows.isEmpty) { @@ -51,14 +51,12 @@ class _HistoricalRecordState extends State { setState(() { _results = result.rows .map((row) => { - 'id': row.colAt(0), - 'name': row.colAt(1), - 'age': row.colAt(2), - 'gender': row.colAt(3), - 'phone': row.colAt(4), - 'email': row.colAt(5), - 'password': row.colAt(2) - }) + '長者ID': row.colAt(0),//去裝資料庫的行數 + '姓名': row.colAt(8), + '跌倒時間': row.colAt(1), + '跌倒原因': row.colAt(2), + '跌倒地點': row.colAt(7), + }) .toList(); }); } @@ -93,12 +91,12 @@ class _HistoricalRecordState extends State { itemCount: _results.length, itemBuilder: (context, index) { return ListTile( - title: Text(_results[index]['name']), + title: Text(_results[index]['姓名']), subtitle: Text( - 'age: ${_results[index]['age']}, ' - 'gender: ${_results[index]['gender']}, ' - 'phone: ${_results[index]['phone']}, ' - 'email: ${_results[index]['email']}', + '長者ID: ${_results[index]['長者ID']}\n, ' + '跌倒時間: ${_results[index]['跌倒時間']}\n, ' + '跌倒原因: ${_results[index]['跌倒原因']}\n, ' + '跌倒地點: ${_results[index]['跌倒地點']}\n', ), ); }, diff --git a/lib/PersonalInfo.dart b/lib/PersonalInfo.dart index c315467..067bea0 100644 --- a/lib/PersonalInfo.dart +++ b/lib/PersonalInfo.dart @@ -80,7 +80,7 @@ class _PersonalInfoState extends State { } void _saveChanges() async { - /*final conn = await MySQLConnection.createConnection( + final conn = await MySQLConnection.createConnection( host: '203.64.84.154', port: 33061, userName: 'root', @@ -88,7 +88,7 @@ class _PersonalInfoState extends State { databaseName: 'care', ); - await conn.connect();*/ + await conn.connect(); try { await conn.execute(