diff --git a/DBClasses.cs b/DBClasses.cs
index 6d939a1..e9ca855 100644
--- a/DBClasses.cs
+++ b/DBClasses.cs
@@ -4,6 +4,15 @@ using System.Text.RegularExpressions;
namespace CryptoCalc
{
+ public enum TransactionTypes
+ {
+ Buy,
+ Sell,
+ Transfer,
+ Mining
+ }
+
+
public interface IDBClasses
{
static string DBName { get; }
@@ -21,8 +30,8 @@ namespace CryptoCalc
public virtual string DBVariables { get; set; }
public string DBSaveDataString => $"({Regex.Replace(DBVariables, "@", "")}) values ({DBVariables})";
- public int Index { get; set; }
- public long UnixTime { get; set; }
+ public long Index { get; set; }
+ public ulong UnixTime { get; set; }
#endregion
@@ -31,20 +40,20 @@ namespace CryptoCalc
public void SaveUnixTimeNow()
{
- UnixTime = (long)DateTime.UtcNow.Subtract(DateTime.UnixEpoch).TotalSeconds;
+ UnixTime = (ulong)DateTime.UtcNow.Subtract(DateTime.UnixEpoch).TotalSeconds;
}
- public static long GetUnixTime(DateTime dateTime)
+ public static ulong GetUnixTime(DateTime dateTime)
{
- return (long)dateTime.Subtract(DateTime.UnixEpoch).TotalSeconds;
+ return (ulong)dateTime.Subtract(DateTime.UnixEpoch).TotalSeconds;
}
- public static DateTime GetUTCTimeFromUnixTime(long unix)
+ public static DateTime GetUTCTimeFromUnixTime(ulong unix)
{
return DateTime.UnixEpoch.AddSeconds(unix).ToUniversalTime();
}
- public static DateTime GetLocalTimeFromUnixTime(long unix)
+ public static DateTime GetLocalTimeFromUnixTime(ulong unix)
{
return DateTime.UnixEpoch.AddSeconds(unix).ToLocalTime();
}
@@ -60,12 +69,12 @@ namespace CryptoCalc
public override string DBVariables { get => base.DBVariables; set => base.DBVariables = value; }
public override string DBTableName => "Transactions";
- public int WalletID { get; set; }
+ public long WalletID { get; set; }
public string Currency { get; set; }
- public decimal Amount { get; set; }
+ public ulong Amount { get; set; }
public string TransactionType { get; set; }
public string FeeCurrency { get; set; }
- public decimal FeeAmount { get; set; }
+ public ulong FeeAmount { get; set; }
public string Platform { get; set; }
public string Note { get; set; }
@@ -75,12 +84,12 @@ namespace CryptoCalc
public Transaction() { SetDBStrings(); }
- public Transaction(int walletID, string currency, decimal amount, string type)
+ public Transaction(long walletID, string currency, decimal amount, string type)
{
SaveUnixTimeNow();
WalletID = walletID;
Currency = currency;
- Amount = amount;
+ Amount = Util.ConvToLong(amount);
TransactionType = type;
Platform = "";
@@ -93,10 +102,10 @@ namespace CryptoCalc
{
SaveUnixTimeNow();
Currency = currency;
- Amount = amount;
+ Amount = Util.ConvToLong(amount);
TransactionType = type;
FeeCurrency = feeCurrency;
- FeeAmount = feeAmount;
+ FeeAmount = Util.ConvToLong(feeAmount);
Platform = "";
Note = "";
@@ -131,10 +140,10 @@ namespace CryptoCalc
+ $"\"{nameof(WalletID)}\" INTEGER NOT NULL,"
+ $"\"{nameof(UnixTime)}\" INTEGER NOT NULL,"
+ $"\"{nameof(Currency)}\" TEXT NOT NULL,"
- + $"\"{nameof(Amount)}\" REAL NOT NULL,"
+ + $"\"{nameof(Amount)}\" INTEGER NOT NULL,"
+ $"\"{nameof(TransactionType)}\" TEXT NOT NULL,"
+ $"\"{nameof(FeeCurrency)}\" TEXT,"
- + $"\"{nameof(FeeAmount)}\" REAL,"
+ + $"\"{nameof(FeeAmount)}\" INTEGER,"
+ $"\"{nameof(Platform)}\" TEXT,"
+ $"\"{nameof(Note)}\" TEXT,"
+ $"PRIMARY KEY(\"{nameof(Index)}\" AUTOINCREMENT),"
@@ -152,11 +161,11 @@ namespace CryptoCalc
public override string DBVariables { get => base.DBVariables; set => base.DBVariables = value; }
public override string DBTableName => "Wallets";
- public long UnixTimeCreated { get; set; }
+ public ulong UnixTimeCreated { get; set; }
public string Platform { get; set; }
public string Name { get; set; }
public string Currency { get; set; }
- public decimal Balance { get; set; }
+ public ulong Balance { get; set; }
public int DefaultWallet { get; set; }
public string Note { get; set; }
@@ -173,7 +182,7 @@ namespace CryptoCalc
Platform = platform;
Name = name;
Currency = currency;
- Balance = 0M;
+ Balance = Util.ConvToLong(0M);
DefaultWallet = 0;
Note = note;
@@ -209,7 +218,7 @@ namespace CryptoCalc
+ $"\"{nameof(Platform)}\" TEXT,"
+ $"\"{nameof(Name)}\" TEXT,"
+ $"\"{nameof(Currency)}\" TEXT NOT NULL,"
- + $"\"{nameof(Balance)}\" REAL NOT NULL,"
+ + $"\"{nameof(Balance)}\" INTEGER NOT NULL,"
+ $"\"{nameof(DefaultWallet)}\" INTEGER,"
+ $"\"{nameof(Note)}\" TEXT,"
+ $"PRIMARY KEY(\"{nameof(Index)}\" AUTOINCREMENT)"
diff --git a/MainWindow.xaml b/MainWindow.xaml
index 29fd908..c1a817d 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -23,6 +23,7 @@
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index f54df46..666cd42 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -110,7 +110,7 @@ namespace CryptoCalc
t.WalletID = selectedWallet.Index;
t.SaveUnixTimeNow();
t.Currency = "SOL";
- t.Amount = Convert.ToDecimal(30 * rand.NextDouble());
+ t.Amount = Util.ConvToLong(30m * (decimal)rand.NextDouble());
t.TransactionType = "BUY";
t.Platform = "Firi";
t.Note = "Test";
@@ -125,7 +125,7 @@ namespace CryptoCalc
w.Platform = "Ledger";
w.Name = "DefaultBTCWallet";
w.Currency = "BTC";
- w.Balance = 0;//Convert.ToSingle(30 * rand.NextDouble());
+ w.Balance = Util.ConvToLong(0);//Convert.ToSingle(30 * rand.NextDouble());
w.DefaultWallet = 1;
w.Note = "Main BTC Wallet";
return w;
diff --git a/Util.cs b/Util.cs
index ddf0b1a..b27e6eb 100644
--- a/Util.cs
+++ b/Util.cs
@@ -8,5 +8,16 @@ namespace CryptoCalc
{
return ConfigurationManager.ConnectionStrings[name].ConnectionString;
}
+
+ public static ulong ConvToLong(decimal value)
+ {
+ //return decimal.ToInt64(value * 1e18M);
+ return decimal.ToUInt64(value * 1e18M);
+ }
+
+ public static decimal ConveToDecimal (ulong value)
+ {
+ return value * 1e-18M;
+ }
}
}