This repository has been archived by the owner on Feb 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add sqlite support. format xaml code.
- Loading branch information
Showing
49 changed files
with
1,314 additions
and
1,318 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data.SQLite; | ||
|
||
namespace LiaoTian_Cup.Helper; | ||
|
||
public class DbHelper | ||
{ | ||
private const string ConnectionString = @"Data Source=./Resources/database.db;"; | ||
|
||
private static readonly SQLiteConnection Conn = new SQLiteConnection(ConnectionString); | ||
|
||
public static List<string> GetColumnData(string tableName, List<string> list) | ||
{ | ||
Conn.Open(); | ||
try | ||
{ | ||
using SQLiteCommand cmd = new SQLiteCommand(Conn); | ||
cmd.CommandText = $"SELECT * FROM {tableName}"; | ||
using SQLiteDataReader reader = cmd.ExecuteReader(); | ||
while (reader.Read()) | ||
{ | ||
var str = Convert.ToString(reader[0]); | ||
list.Add(str); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
throw new Exception(ex.Message); | ||
} | ||
|
||
Conn.Close(); | ||
return list; | ||
} | ||
|
||
public static List<string[]> GetListData(string tableName,int columnCount, List<string[]> list) | ||
{ | ||
Conn.Open(); | ||
try | ||
{ | ||
using SQLiteCommand cmd = new SQLiteCommand(Conn); | ||
cmd.CommandText = $"SELECT * FROM {tableName}"; | ||
using SQLiteDataReader reader = cmd.ExecuteReader(); | ||
while (reader.Read()) | ||
{ | ||
string[] rowStrings = new string[columnCount]; | ||
for (int i = 0; i < columnCount; i++) | ||
{ | ||
rowStrings[i] = Convert.ToString(reader[i]); | ||
} | ||
list.Add(rowStrings); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
throw new Exception(ex.Message); | ||
} | ||
|
||
Conn.Close(); | ||
return list; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.