diff --git a/App.config b/App.config
index 9933ea0..d64670c 100644
--- a/App.config
+++ b/App.config
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/CryptoCalc.csproj b/CryptoCalc.csproj
index 44bc49b..c173c4f 100644
--- a/CryptoCalc.csproj
+++ b/CryptoCalc.csproj
@@ -7,7 +7,14 @@
-
+
+
+
+
+
+
+ PreserveNewest
+
diff --git a/MainWindow.xaml b/MainWindow.xaml
index 5a0c684..2803651 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -7,7 +7,8 @@
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
-
+
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index a5aa202..83ec521 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -14,50 +14,51 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using System.IO;
-using System.Text.Json;
namespace CryptoCalc
{
///
/// Interaction logic for MainWindow.xaml
///
+ ///
+
public partial class MainWindow : Window
{
private readonly Random rand = new();
- private readonly JsonSerializerOptions jsonOptions = new();
-
+ private List transactions = new();
+
public MainWindow()
{
InitializeComponent();
- jsonOptions.WriteIndented = true;
}
private void saveButton_Click(object sender, RoutedEventArgs e)
{
- Debug.WriteLine("asdf");
+ Transaction t = new();
+ t.Date_Year = DateTime.Today.Year;
+ t.Date_Month = DateTime.Today.Month;
+ t.Date_Day = DateTime.Today.Day;
+ t.Time_Hour = DateTime.Today.Hour;
+ t.Time_Minute = DateTime.Today.Minute;
+ t.Time_Second = DateTime.Today.Second;
+ t.DateTimeString = DateTime.Now.ToString();
+ t.CryptoCurrency = "ETH";
+ t.Amount = (float)rand.NextDouble();
+ t.TransactionType = "WITHDRAWAL";
+ t.Service = "MiraiEx";
+ t.Comment = "Test";
- var weatherForecast = new WeatherForecast
+ SqliteDataAccess.SaveTransaction(t);
+ }
+
+ private void readButton_click(object sender, RoutedEventArgs e)
+ {
+ transactions = SqliteDataAccess.LoadTransactions();
+ foreach (var x in transactions)
{
- Date = DateTime.Parse("2019-08-01"),
- TemperatureCelsius = rand.Next(0,100),
- Summary = "Hot"
-
- };
-
- string fileName = "asdf.json";
- string jsonString = JsonSerializer.Serialize(weatherForecast, jsonOptions);
- File.AppendAllText(fileName, jsonString);
-
- Debug.WriteLine(File.ReadAllText(fileName));
+ Debug.WriteLine(x.Date_Year);
+ }
+ //Debug.WriteLine(transactions.Date_Year.ToString());
}
}
-
-
- public class WeatherForecast
- {
- public DateTimeOffset Date { get; set; }
- public int TemperatureCelsius { get; set; }
- public string Summary { get; set; }
- }
-
}
diff --git a/SqliteDataAccess.cs b/SqliteDataAccess.cs
new file mode 100644
index 0000000..79bf0b1
--- /dev/null
+++ b/SqliteDataAccess.cs
@@ -0,0 +1,41 @@
+using Dapper;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Data.SQLite;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CryptoCalc
+{
+ class SqliteDataAccess
+ {
+ public static List LoadTransactions()
+ {
+ using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
+ {
+ var output = cnn.Query("select Date_Year from RawData", new DynamicParameters());
+ Debug.WriteLine("Loaded DB data");
+ return output.ToList();
+
+ }
+ }
+
+ public static void SaveTransaction(Transaction transaction)
+ {
+ using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
+ {
+ cnn.Execute("insert into RawData (Date_Year, Date_Month, Date_Day, Time_Hour, Time_Minute, Time_Second, DateTimeString, CryptoCurrency, Amount, TransactionType, Service, Comment) values (@Date_Year, @Date_Month, @Date_Day, @Time_Hour, @Time_Minute, @Time_Second, @DateTimeString, @CryptoCurrency, @Amount, @TransactionType, @Service, @Comment)", transaction);
+ Debug.WriteLine("Saved DB data");
+ }
+ }
+
+ private static string LoadConnectionString(string id = "Default")
+ {
+ return ConfigurationManager.ConnectionStrings[id].ConnectionString;
+ }
+ }
+}
diff --git a/Transaction.cs b/Transaction.cs
new file mode 100644
index 0000000..a7332ba
--- /dev/null
+++ b/Transaction.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CryptoCalc
+{
+ class Transaction
+ {
+ public int Index { get; set; }
+ public int Date_Year { get; set; }
+ public int Date_Month { get; set; }
+ public int Date_Day { get; set; }
+ public int Time_Hour { get; set; }
+ public int Time_Minute { get; set; }
+ public int Time_Second { get; set; }
+ public string DateTimeString { get; set; }
+ public string CryptoCurrency { get; set; }
+ public float Amount { get; set; }
+ public string TransactionType { get; set; }
+ public string Service{ get; set; }
+ public string Comment { get; set; }
+
+
+ }
+}
diff --git a/data.db b/data.db
index 740e635..c61e201 100644
Binary files a/data.db and b/data.db differ