Compare commits
8 Commits
39aa1eff9b
...
5b80b0c177
Author | SHA1 | Date |
---|---|---|
|
5b80b0c177 | |
|
0e218f3da5 | |
|
eb7ef0821f | |
|
64a1334f1e | |
|
457aeb4eca | |
|
9ef6358089 | |
|
6d8bf44077 | |
|
6469960b9c |
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.31515.178
|
VisualStudioVersion = 16.0.31515.178
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CryptoCalc", "CryptoCalc.csproj", "{E83CB079-DF59-452D-9FA3-F5736553DC07}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CryptoCalc", "CryptoCalc.csproj", "{E83CB079-DF59-452D-9FA3-F5736553DC07}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
@ -11,10 +11,10 @@ Global
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{E83CB079-DF59-452D-9FA3-F5736553DC07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{E83CB079-DF59-452D-9FA3-F5736553DC07}.Debug|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E83CB079-DF59-452D-9FA3-F5736553DC07}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{E83CB079-DF59-452D-9FA3-F5736553DC07}.Debug|Any CPU.Build.0 = Release|Any CPU
|
||||||
{E83CB079-DF59-452D-9FA3-F5736553DC07}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{E83CB079-DF59-452D-9FA3-F5736553DC07}.Release|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{E83CB079-DF59-452D-9FA3-F5736553DC07}.Release|Any CPU.Build.0 = Release|Any CPU
|
{E83CB079-DF59-452D-9FA3-F5736553DC07}.Release|Any CPU.Build.0 = Debug|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
94
DBClasses.cs
94
DBClasses.cs
|
@ -1,28 +1,45 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace CryptoCalc
|
namespace CryptoCalc
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public enum TransactionTypes
|
||||||
|
{
|
||||||
|
Buy,
|
||||||
|
Sell,
|
||||||
|
Transfer,
|
||||||
|
Mining
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public interface IDBClasses
|
public interface IDBClasses
|
||||||
{
|
{
|
||||||
|
|
||||||
static string DBName { get; }
|
static string DBName { get; }
|
||||||
string DBTableName { get; }
|
string DBTableName { get; }
|
||||||
string DBVariables { get; set; }
|
string DBVariables { get; }
|
||||||
string DBSaveDataString { get; }
|
string DBSaveDataString { get; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DBClasses : IDBClasses
|
public class DBClasses : IDBClasses
|
||||||
{
|
{
|
||||||
|
#region Protected
|
||||||
|
|
||||||
|
protected string dbVariables;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Publics
|
#region Publics
|
||||||
public static string DBName => "CryptoCalc";
|
public static string DBName => "CryptoCalc";
|
||||||
public virtual string DBTableName { get; }
|
public virtual string DBTableName { get; }
|
||||||
public virtual string DBVariables { get; set; }
|
public string DBVariables => dbVariables;
|
||||||
public string DBSaveDataString => $"({Regex.Replace(DBVariables, "@", "")}) values ({DBVariables})";
|
public string DBSaveDataString => $"({Regex.Replace(dbVariables, "@", "")}) values ({dbVariables})";
|
||||||
|
|
||||||
public int Index { get; set; }
|
public long Index { get; set; }
|
||||||
public long UnixTime { get; set; }
|
public ulong UnixTime { get; set; }
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -31,20 +48,20 @@ namespace CryptoCalc
|
||||||
|
|
||||||
public void SaveUnixTimeNow()
|
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();
|
return DateTime.UnixEpoch.AddSeconds(unix).ToUniversalTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DateTime GetLocalTimeFromUnixTime(long unix)
|
public static DateTime GetLocalTimeFromUnixTime(ulong unix)
|
||||||
{
|
{
|
||||||
return DateTime.UnixEpoch.AddSeconds(unix).ToLocalTime();
|
return DateTime.UnixEpoch.AddSeconds(unix).ToLocalTime();
|
||||||
}
|
}
|
||||||
|
@ -57,15 +74,16 @@ namespace CryptoCalc
|
||||||
{
|
{
|
||||||
|
|
||||||
#region Publics
|
#region Publics
|
||||||
public override string DBVariables { get => base.DBVariables; set => base.DBVariables = value; }
|
|
||||||
public override string DBTableName => "Transactions";
|
public override string DBTableName => "Transactions";
|
||||||
|
|
||||||
public int WalletID { get; set; }
|
public long WalletID { get; set; }
|
||||||
public string Currency { get; set; }
|
public string Currency { get; set; }
|
||||||
public decimal Amount { get; set; }
|
public long Amount { get; set; }
|
||||||
|
public ulong AmountDecimal { get; set; }
|
||||||
public string TransactionType { get; set; }
|
public string TransactionType { get; set; }
|
||||||
public string FeeCurrency { get; set; }
|
public string FeeCurrency { get; set; }
|
||||||
public decimal FeeAmount { get; set; }
|
public long FeeAmount { get; set; }
|
||||||
|
public ulong FeeAmountDecimal { get; set; }
|
||||||
public string Platform { get; set; }
|
public string Platform { get; set; }
|
||||||
public string Note { get; set; }
|
public string Note { get; set; }
|
||||||
|
|
||||||
|
@ -75,12 +93,26 @@ namespace CryptoCalc
|
||||||
|
|
||||||
public Transaction() { SetDBStrings(); }
|
public Transaction() { SetDBStrings(); }
|
||||||
|
|
||||||
public Transaction(int walletID, string currency, decimal amount, string type)
|
public Transaction(long walletID, string currency, decimal amount, string type)
|
||||||
{
|
{
|
||||||
SaveUnixTimeNow();
|
SaveUnixTimeNow();
|
||||||
WalletID = walletID;
|
WalletID = walletID;
|
||||||
Currency = currency;
|
Currency = currency;
|
||||||
Amount = amount;
|
(Amount, AmountDecimal) = Util.SplitDecimal(amount);
|
||||||
|
TransactionType = type;
|
||||||
|
|
||||||
|
Platform = "";
|
||||||
|
Note = "";
|
||||||
|
|
||||||
|
SetDBStrings();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Transaction(DateTime dateTime, long walletID, string currency, decimal amount, string type)
|
||||||
|
{
|
||||||
|
UnixTime = GetUnixTime(dateTime);
|
||||||
|
WalletID = walletID;
|
||||||
|
Currency = currency;
|
||||||
|
(Amount, AmountDecimal) = Util.SplitDecimal(amount);
|
||||||
TransactionType = type;
|
TransactionType = type;
|
||||||
|
|
||||||
Platform = "";
|
Platform = "";
|
||||||
|
@ -93,10 +125,10 @@ namespace CryptoCalc
|
||||||
{
|
{
|
||||||
SaveUnixTimeNow();
|
SaveUnixTimeNow();
|
||||||
Currency = currency;
|
Currency = currency;
|
||||||
Amount = amount;
|
(Amount, AmountDecimal) = Util.SplitDecimal(amount);
|
||||||
TransactionType = type;
|
TransactionType = type;
|
||||||
FeeCurrency = feeCurrency;
|
FeeCurrency = feeCurrency;
|
||||||
FeeAmount = feeAmount;
|
(FeeAmount, FeeAmountDecimal) = Util.SplitDecimal(feeAmount);
|
||||||
Platform = "";
|
Platform = "";
|
||||||
Note = "";
|
Note = "";
|
||||||
|
|
||||||
|
@ -109,19 +141,21 @@ namespace CryptoCalc
|
||||||
|
|
||||||
private void SetDBStrings()
|
private void SetDBStrings()
|
||||||
{
|
{
|
||||||
DBVariables =
|
dbVariables =
|
||||||
$"@{nameof(WalletID)},"
|
$"@{nameof(WalletID)},"
|
||||||
+ $"@{nameof(UnixTime)},"
|
+ $"@{nameof(UnixTime)},"
|
||||||
+ $"@{nameof(Currency)},"
|
+ $"@{nameof(Currency)},"
|
||||||
+ $"@{nameof(Amount)},"
|
+ $"@{nameof(Amount)},"
|
||||||
|
+ $"@{nameof(AmountDecimal)},"
|
||||||
+ $"@{nameof(TransactionType)},"
|
+ $"@{nameof(TransactionType)},"
|
||||||
+ $"@{nameof(FeeCurrency)},"
|
+ $"@{nameof(FeeCurrency)},"
|
||||||
+ $"@{nameof(FeeAmount)},"
|
+ $"@{nameof(FeeAmount)},"
|
||||||
|
+ $"@{nameof(FeeAmountDecimal)},"
|
||||||
+ $"@{nameof(Platform)},"
|
+ $"@{nameof(Platform)},"
|
||||||
+ $"@{nameof(Note)}";
|
+ $"@{nameof(Note)}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string FullInfo => $"{ Index } {WalletID} { GetLocalTimeFromUnixTime(UnixTime) } { Currency } { Amount } { TransactionType }";
|
public string FullInfo => $"{ Index } {WalletID} { GetLocalTimeFromUnixTime(UnixTime) } { Currency } { Util.CombineDecimal(Amount, AmountDecimal) } { TransactionType }";
|
||||||
|
|
||||||
public string CreateTable(string walletTableName)
|
public string CreateTable(string walletTableName)
|
||||||
{
|
{
|
||||||
|
@ -131,10 +165,12 @@ namespace CryptoCalc
|
||||||
+ $"\"{nameof(WalletID)}\" INTEGER NOT NULL,"
|
+ $"\"{nameof(WalletID)}\" INTEGER NOT NULL,"
|
||||||
+ $"\"{nameof(UnixTime)}\" INTEGER NOT NULL,"
|
+ $"\"{nameof(UnixTime)}\" INTEGER NOT NULL,"
|
||||||
+ $"\"{nameof(Currency)}\" TEXT NOT NULL,"
|
+ $"\"{nameof(Currency)}\" TEXT NOT NULL,"
|
||||||
+ $"\"{nameof(Amount)}\" REAL NOT NULL,"
|
+ $"\"{nameof(Amount)}\" INTEGER NOT NULL,"
|
||||||
|
+ $"\"{nameof(AmountDecimal)}\" INTEGER NOT NULL,"
|
||||||
+ $"\"{nameof(TransactionType)}\" TEXT NOT NULL,"
|
+ $"\"{nameof(TransactionType)}\" TEXT NOT NULL,"
|
||||||
+ $"\"{nameof(FeeCurrency)}\" TEXT,"
|
+ $"\"{nameof(FeeCurrency)}\" TEXT,"
|
||||||
+ $"\"{nameof(FeeAmount)}\" REAL,"
|
+ $"\"{nameof(FeeAmount)}\" INTEGER,"
|
||||||
|
+ $"\"{nameof(FeeAmountDecimal)}\" INTEGER,"
|
||||||
+ $"\"{nameof(Platform)}\" TEXT,"
|
+ $"\"{nameof(Platform)}\" TEXT,"
|
||||||
+ $"\"{nameof(Note)}\" TEXT,"
|
+ $"\"{nameof(Note)}\" TEXT,"
|
||||||
+ $"PRIMARY KEY(\"{nameof(Index)}\" AUTOINCREMENT),"
|
+ $"PRIMARY KEY(\"{nameof(Index)}\" AUTOINCREMENT),"
|
||||||
|
@ -149,14 +185,14 @@ namespace CryptoCalc
|
||||||
public class Wallet : DBClasses
|
public class Wallet : DBClasses
|
||||||
{
|
{
|
||||||
#region Publics
|
#region Publics
|
||||||
public override string DBVariables { get => base.DBVariables; set => base.DBVariables = value; }
|
|
||||||
public override string DBTableName => "Wallets";
|
public override string DBTableName => "Wallets";
|
||||||
|
|
||||||
public long UnixTimeCreated { get; set; }
|
public ulong UnixTimeCreated { get; set; }
|
||||||
public string Platform { get; set; }
|
public string Platform { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Currency { get; set; }
|
public string Currency { get; set; }
|
||||||
public decimal Balance { get; set; }
|
public long Balance { get; set; }
|
||||||
|
public ulong BalanceDecimal { get; set; }
|
||||||
public int DefaultWallet { get; set; }
|
public int DefaultWallet { get; set; }
|
||||||
public string Note { get; set; }
|
public string Note { get; set; }
|
||||||
|
|
||||||
|
@ -173,7 +209,7 @@ namespace CryptoCalc
|
||||||
Platform = platform;
|
Platform = platform;
|
||||||
Name = name;
|
Name = name;
|
||||||
Currency = currency;
|
Currency = currency;
|
||||||
Balance = 0M;
|
(Balance, BalanceDecimal) = Util.SplitDecimal(0);
|
||||||
DefaultWallet = 0;
|
DefaultWallet = 0;
|
||||||
Note = note;
|
Note = note;
|
||||||
|
|
||||||
|
@ -186,13 +222,14 @@ namespace CryptoCalc
|
||||||
|
|
||||||
private void SetDBStrings()
|
private void SetDBStrings()
|
||||||
{
|
{
|
||||||
DBVariables =
|
dbVariables =
|
||||||
$"@{nameof(UnixTime)},"
|
$"@{nameof(UnixTime)},"
|
||||||
+ $"@{nameof(UnixTimeCreated)},"
|
+ $"@{nameof(UnixTimeCreated)},"
|
||||||
+ $"@{nameof(Platform)},"
|
+ $"@{nameof(Platform)},"
|
||||||
+ $"@{nameof(Name)},"
|
+ $"@{nameof(Name)},"
|
||||||
+ $"@{nameof(Currency)},"
|
+ $"@{nameof(Currency)},"
|
||||||
+ $"@{nameof(Balance)},"
|
+ $"@{nameof(Balance)},"
|
||||||
|
+ $"@{nameof(BalanceDecimal)},"
|
||||||
+ $"@{nameof(DefaultWallet)},"
|
+ $"@{nameof(DefaultWallet)},"
|
||||||
+ $"@{nameof(Note)}";
|
+ $"@{nameof(Note)}";
|
||||||
}
|
}
|
||||||
|
@ -209,7 +246,8 @@ namespace CryptoCalc
|
||||||
+ $"\"{nameof(Platform)}\" TEXT,"
|
+ $"\"{nameof(Platform)}\" TEXT,"
|
||||||
+ $"\"{nameof(Name)}\" TEXT,"
|
+ $"\"{nameof(Name)}\" TEXT,"
|
||||||
+ $"\"{nameof(Currency)}\" TEXT NOT NULL,"
|
+ $"\"{nameof(Currency)}\" TEXT NOT NULL,"
|
||||||
+ $"\"{nameof(Balance)}\" REAL NOT NULL,"
|
+ $"\"{nameof(Balance)}\" INTEGER NOT NULL,"
|
||||||
|
+ $"\"{nameof(BalanceDecimal)}\" INTEGER NOT NULL,"
|
||||||
+ $"\"{nameof(DefaultWallet)}\" INTEGER,"
|
+ $"\"{nameof(DefaultWallet)}\" INTEGER,"
|
||||||
+ $"\"{nameof(Note)}\" TEXT,"
|
+ $"\"{nameof(Note)}\" TEXT,"
|
||||||
+ $"PRIMARY KEY(\"{nameof(Index)}\" AUTOINCREMENT)"
|
+ $"PRIMARY KEY(\"{nameof(Index)}\" AUTOINCREMENT)"
|
||||||
|
|
|
@ -10,19 +10,20 @@
|
||||||
<TabControl x:Name="tabControl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
<TabControl x:Name="tabControl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||||
<TabItem Header="Debug">
|
<TabItem Header="Debug">
|
||||||
<Grid Background="#FFE5E5E5" Width="Auto" Height="Auto">
|
<Grid Background="#FFE5E5E5" Width="Auto" Height="Auto">
|
||||||
<Button x:Name="saveButton" Content="Save Random" Margin="0,10,37,0" Click="saveButton_Click" FontSize="20" HorizontalAlignment="Right" Width="239" Height="38" VerticalAlignment="Top"/>
|
<Button x:Name="saveButton" Content="Save Random" Margin="0,10,37,0" Click="SaveRandomTransactionButton_Click" FontSize="20" HorizontalAlignment="Right" Width="239" Height="38" VerticalAlignment="Top"/>
|
||||||
<Button x:Name="readButton" Content="PrintToConsole" Margin="0,53,37,0" Click="readButton_click" FontSize="20" Height="36" VerticalAlignment="Top" HorizontalAlignment="Right" Width="239"/>
|
<Button x:Name="readButton" Content="PrintToConsole" Margin="0,53,37,0" Click="PrintToConsoleButton_click" FontSize="20" Height="36" VerticalAlignment="Top" HorizontalAlignment="Right" Width="239"/>
|
||||||
<Button x:Name="saveButton_fromInput" Content="Save Data" Margin="0,0,37,10" VerticalAlignment="Bottom" Height="39" Click="saveButtonFromInput_Click" FontSize="20" HorizontalAlignment="Right" Width="239"/>
|
<Button x:Name="saveButton_fromInput" Content="Save Data" Margin="0,0,37,10" VerticalAlignment="Bottom" Height="39" Click="SaveTransactionButton_Click" FontSize="20" HorizontalAlignment="Right" Width="239"/>
|
||||||
<TextBox x:Name="inputCurrency" Margin="0,0,60,125" TextWrapping="Wrap" Text="BTC" Height="27" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="120" LostFocus="inputCurrency_LostFocus"/>
|
<TextBox x:Name="inputCurrency" Margin="0,0,60,125" TextWrapping="Wrap" Text="BTC" Height="27" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="120" LostFocus="InputCurrency_LostFocus"/>
|
||||||
<Label x:Name="label" Content="Currency" HorizontalAlignment="Right" Margin="0,0,185,125" Width="69" Height="27" VerticalAlignment="Bottom"/>
|
<Label x:Name="label" Content="Currency" HorizontalAlignment="Right" Margin="0,0,185,125" Width="69" Height="27" VerticalAlignment="Bottom"/>
|
||||||
<TextBox x:Name="inputAmount" Margin="0,0,60,94" TextWrapping="Wrap" Text="1,3141592" LostFocus="inputAmount_LostFocus" Height="27" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="120"/>
|
<TextBox x:Name="inputAmount" Margin="0,0,60,94" TextWrapping="Wrap" Text="1,3141592" LostFocus="InputAmount_LostFocus" Height="27" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="120"/>
|
||||||
<Label x:Name="label_Copy" Content="Amount" HorizontalAlignment="Right" Margin="0,0,185,94" Width="69" Height="27" VerticalAlignment="Bottom"/>
|
<Label x:Name="label_Copy" Content="Amount" HorizontalAlignment="Right" Margin="0,0,185,94" Width="69" Height="27" VerticalAlignment="Bottom"/>
|
||||||
<TextBox x:Name="inputType" Margin="0,0,60,62" TextWrapping="Wrap" Text="BUY" Height="27" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="120"/>
|
<TextBox x:Name="inputType" Margin="0,0,60,62" TextWrapping="Wrap" Text="BUY" Height="27" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="120"/>
|
||||||
<Label x:Name="label_Copy1" Content="Type" HorizontalAlignment="Right" Margin="0,0,185,62" Width="69" Height="27" VerticalAlignment="Bottom"/>
|
<Label x:Name="label_Copy1" Content="Type" HorizontalAlignment="Right" Margin="0,0,185,62" Width="69" Height="27" VerticalAlignment="Bottom"/>
|
||||||
<Label x:Name="currencyLablel" Content="Currency" HorizontalAlignment="Left" Margin="27,16,0,0" VerticalAlignment="Top" Height="32"/>
|
<Label x:Name="currencyLablel" Content="Currency" HorizontalAlignment="Left" Margin="27,16,0,0" VerticalAlignment="Top" Height="32"/>
|
||||||
<ListBox x:Name="transactionsFoundListBox" Margin="27,66,331,10"/>
|
<ListBox x:Name="transactionsFoundListBox" Margin="27,66,331,10"/>
|
||||||
<TextBox x:Name="currencyText" HorizontalAlignment="Left" Margin="89,21,0,0" Text="SOL" TextWrapping="Wrap" VerticalAlignment="Top" Width="75" Height="22" LostFocus="currencyText_LostFocus"/>
|
<TextBox x:Name="currencyText" HorizontalAlignment="Left" Margin="89,21,0,0" Text="SOL" TextWrapping="Wrap" VerticalAlignment="Top" Width="75" Height="22" LostFocus="CurrencyText_LostFocus"/>
|
||||||
<Button x:Name="searchButton" Content="Search" HorizontalAlignment="Left" Margin="169,20,0,0" VerticalAlignment="Top" Click="searchButton_Click" Height="25" Width="55"/>
|
<Button x:Name="searchButton" Content="Search" HorizontalAlignment="Left" Margin="169,20,0,0" VerticalAlignment="Top" Click="ShowTransactionsOfCurrencyButton_Click" Height="25" Width="55"/>
|
||||||
|
<DatePicker x:Name="insertTransactionDatePicker" HorizontalAlignment="Right" Margin="0,0,60,157" VerticalAlignment="Bottom" Width="120" FirstDayOfWeek="Monday" SelectedDateFormat="Short"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="Overview">
|
<TabItem Header="Overview">
|
||||||
|
@ -30,10 +31,10 @@
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="Wallets">
|
<TabItem Header="Wallets">
|
||||||
<Grid Background="#FFE5E5E5">
|
<Grid Background="#FFE5E5E5">
|
||||||
<ListBox x:Name="listBox_Wallets" Margin="0,278,37,258" SelectionChanged="listBox_Wallets_SelectionChanged" HorizontalAlignment="Right" Width="239"/>
|
<ListBox x:Name="listBox_Wallets" Margin="0,278,37,258" SelectionChanged="ListBox_Wallets_SelectionChanged" HorizontalAlignment="Right" Width="239"/>
|
||||||
<Button x:Name="show_Wallets" Content="Show Wallets" HorizontalAlignment="Right" Margin="0,240,37,0" VerticalAlignment="Top" Click="show_Wallets_Click" Width="239" Height="28"/>
|
<Button x:Name="show_Wallets" Content="Show Wallets" HorizontalAlignment="Right" Margin="0,240,37,0" VerticalAlignment="Top" Click="Show_Wallets_Click" Width="239" Height="28"/>
|
||||||
<Button x:Name="saveRandomWalletButton" Content="Save Random Wallet" Margin="0,38,37,0" Click="saveRandomWalletButton_Click" FontSize="20" HorizontalAlignment="Right" Width="239" Height="38" VerticalAlignment="Top"/>
|
<Button x:Name="saveRandomWalletButton" Content="Save Random Wallet" Margin="0,38,37,0" Click="SaveRandomWalletButton_Click" FontSize="20" HorizontalAlignment="Right" Width="239" Height="38" VerticalAlignment="Top"/>
|
||||||
<Button x:Name="saveWalletButton" Content="Save Wallet" Margin="45,125,0,0" Click="saveWalletButton_Click" FontSize="20" Height="38" VerticalAlignment="Top" HorizontalAlignment="Left" Width="239"/>
|
<Button x:Name="saveWalletButton" Content="Save Wallet" Margin="45,125,0,0" Click="SaveWalletButton_Click" FontSize="20" Height="38" VerticalAlignment="Top" HorizontalAlignment="Left" Width="239"/>
|
||||||
<TextBox x:Name="inputWalletName" HorizontalAlignment="Left" Margin="135,269,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="149" Height="31"/>
|
<TextBox x:Name="inputWalletName" HorizontalAlignment="Left" Margin="135,269,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="149" Height="31"/>
|
||||||
<Label x:Name="label1" Content="Name" HorizontalAlignment="Left" Height="31" Margin="34,269,0,0" VerticalAlignment="Top" Width="96"/>
|
<Label x:Name="label1" Content="Name" HorizontalAlignment="Left" Height="31" Margin="34,269,0,0" VerticalAlignment="Top" Width="96"/>
|
||||||
<TextBox x:Name="inputWalletPlatform" HorizontalAlignment="Left" Margin="135,235,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="149" Height="31" RenderTransformOrigin="0.354,-0.643"/>
|
<TextBox x:Name="inputWalletPlatform" HorizontalAlignment="Left" Margin="135,235,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="149" Height="31" RenderTransformOrigin="0.354,-0.643"/>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
@ -32,30 +33,31 @@ namespace CryptoCalc
|
||||||
walletDB.ExecuteQuery(genericW, genericW.CreateTable());
|
walletDB.ExecuteQuery(genericW, genericW.CreateTable());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveButton_Click(object sender, RoutedEventArgs e)
|
private void SaveRandomTransactionButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
transactionDB.SaveData(DummyTransaction());
|
transactionDB.SaveData(DummyTransaction());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveRandomWalletButton_Click(object sender, RoutedEventArgs e)
|
private void SaveRandomWalletButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
walletDB.SaveData(DummyWallet());
|
walletDB.SaveData(DummyWallet());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveButtonFromInput_Click(object sender, RoutedEventArgs e)
|
private void SaveTransactionButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
transactionDB.SaveData
|
transactionDB.SaveData
|
||||||
(
|
(
|
||||||
new Transaction(
|
new Transaction(
|
||||||
|
(DateTime)insertTransactionDatePicker.SelectedDate,
|
||||||
selectedWallet.Index,
|
selectedWallet.Index,
|
||||||
inputCurrency.Text,
|
inputCurrency.Text,
|
||||||
Convert.ToDecimal(inputAmount.Text),
|
Convert.ToDecimal(inputAmount.Text, CultureInfo.InvariantCulture),
|
||||||
inputType.Text
|
inputType.Text
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveWalletButton_Click(object sender, RoutedEventArgs e)
|
private void SaveWalletButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
walletDB.SaveData(
|
walletDB.SaveData(
|
||||||
new Wallet(
|
new Wallet(
|
||||||
|
@ -68,16 +70,16 @@ namespace CryptoCalc
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readButton_click(object sender, RoutedEventArgs e)
|
private void PrintToConsoleButton_click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
string query = $"select * from {genericT.DBTableName}";
|
string query = $"select * from {genericT.DBTableName}";
|
||||||
IEnumerable<Transaction> transactions = transactionDB.ReturnQuery(genericT, query);
|
IEnumerable<Transaction> transactions = transactionDB.ReturnQuery(genericT, query);
|
||||||
foreach (Transaction t in transactions)
|
foreach (Transaction t in transactions)
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"{DBClasses.GetLocalTimeFromUnixTime(t.UnixTime)} *** {t.Currency} - {t.Amount}");
|
Debug.WriteLine($"{DBClasses.GetLocalTimeFromUnixTime(t.UnixTime)} *** {t.Currency} - {Util.CombineDecimal(t.Amount, t.AmountDecimal)}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void searchButton_Click(object sender, RoutedEventArgs e)
|
private void ShowTransactionsOfCurrencyButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
string query = $"SELECT * from {genericT.DBTableName} WHERE {nameof(genericT.Currency)}=\'{currencyText.Text}\'";
|
string query = $"SELECT * from {genericT.DBTableName} WHERE {nameof(genericT.Currency)}=\'{currencyText.Text}\'";
|
||||||
IEnumerable<Transaction> transactions = transactionDB.ReturnQuery(genericT, query);
|
IEnumerable<Transaction> transactions = transactionDB.ReturnQuery(genericT, query);
|
||||||
|
@ -88,7 +90,7 @@ namespace CryptoCalc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void show_Wallets_Click(object sender, RoutedEventArgs e)
|
private void Show_Wallets_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
selectedWallet = null;
|
selectedWallet = null;
|
||||||
walletList.Clear();
|
walletList.Clear();
|
||||||
|
@ -110,7 +112,7 @@ namespace CryptoCalc
|
||||||
t.WalletID = selectedWallet.Index;
|
t.WalletID = selectedWallet.Index;
|
||||||
t.SaveUnixTimeNow();
|
t.SaveUnixTimeNow();
|
||||||
t.Currency = "SOL";
|
t.Currency = "SOL";
|
||||||
t.Amount = Convert.ToDecimal(30 * rand.NextDouble());
|
(t.Amount, t.AmountDecimal) = Util.SplitDecimal(Convert.ToDecimal(30m * (decimal)rand.NextDouble()));
|
||||||
t.TransactionType = "BUY";
|
t.TransactionType = "BUY";
|
||||||
t.Platform = "Firi";
|
t.Platform = "Firi";
|
||||||
t.Note = "Test";
|
t.Note = "Test";
|
||||||
|
@ -132,23 +134,24 @@ namespace CryptoCalc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void inputAmount_LostFocus(object sender, RoutedEventArgs e)
|
private void InputAmount_LostFocus(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
inputAmount.Text = inputAmount.Text.Replace(".", ",");
|
//inputAmount.Text = inputAmount.Text.Replace(".", ",");
|
||||||
|
inputAmount.Text = inputAmount.Text.Replace(",", ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void currencyText_LostFocus(object sender, RoutedEventArgs e)
|
private void CurrencyText_LostFocus(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
currencyText.Text = currencyText.Text.ToUpper();
|
currencyText.Text = currencyText.Text.ToUpper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void inputCurrency_LostFocus(object sender, RoutedEventArgs e)
|
private void InputCurrency_LostFocus(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
inputCurrency.Text = inputCurrency.Text.ToUpper();
|
inputCurrency.Text = inputCurrency.Text.ToUpper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void listBox_Wallets_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
private void ListBox_Wallets_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (listBox_Wallets.Items.Count > 0)
|
if (listBox_Wallets.Items.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
24
Util.cs
24
Util.cs
|
@ -4,9 +4,33 @@ namespace CryptoCalc
|
||||||
{
|
{
|
||||||
public class Util
|
public class Util
|
||||||
{
|
{
|
||||||
|
private static readonly decimal lowestUnit = 1e18m;
|
||||||
|
|
||||||
public static string GetConnectionString(string name = "Default")
|
public static string GetConnectionString(string name = "Default")
|
||||||
{
|
{
|
||||||
return ConfigurationManager.ConnectionStrings[name].ConnectionString;
|
return ConfigurationManager.ConnectionStrings[name].ConnectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ulong ConvToULong(decimal value)
|
||||||
|
{
|
||||||
|
return decimal.ToUInt64(value * lowestUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static decimal ConvToDecimal(ulong value)
|
||||||
|
{
|
||||||
|
return value / lowestUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static (long wholeNumber, ulong fractionNumber) SplitDecimal(decimal value)
|
||||||
|
{
|
||||||
|
long w = (long)value;
|
||||||
|
ulong f = ConvToULong((value % 1));
|
||||||
|
return (w, f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static decimal CombineDecimal(long amount, ulong amountDecimal)
|
||||||
|
{
|
||||||
|
return amount + ConvToDecimal(amountDecimal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue