Save as string test

This did not work well
This commit is contained in:
Stedd 2022-02-13 13:49:44 +01:00
parent 6469960b9c
commit 6d8bf44077
3 changed files with 16 additions and 13 deletions

View File

@ -1,4 +1,5 @@
using System;
using System.Globalization;
using System.Text.RegularExpressions;
namespace CryptoCalc
@ -71,10 +72,10 @@ namespace CryptoCalc
public long WalletID { get; set; }
public string Currency { get; set; }
public ulong Amount { get; set; }
public string Amount { get; set; }
public string TransactionType { get; set; }
public string FeeCurrency { get; set; }
public ulong FeeAmount { get; set; }
public string FeeAmount { get; set; }
public string Platform { get; set; }
public string Note { get; set; }
@ -84,12 +85,12 @@ namespace CryptoCalc
public Transaction() { SetDBStrings(); }
public Transaction(long walletID, string currency, decimal amount, string type)
public Transaction(long walletID, string currency, string amount, string type)
{
SaveUnixTimeNow();
WalletID = walletID;
Currency = currency;
Amount = Util.ConvToLong(amount);
Amount = amount;
TransactionType = type;
Platform = "";
@ -98,14 +99,14 @@ namespace CryptoCalc
SetDBStrings();
}
public Transaction(string currency, decimal amount, string type, string feeCurrency, decimal feeAmount)
public Transaction(string currency, string amount, string type, string feeCurrency, string feeAmount)
{
SaveUnixTimeNow();
Currency = currency;
Amount = Util.ConvToLong(amount);
Amount = amount.ToString(CultureInfo.InvariantCulture);
TransactionType = type;
FeeCurrency = feeCurrency;
FeeAmount = Util.ConvToLong(feeAmount);
FeeAmount = feeAmount.ToString(CultureInfo.InvariantCulture);
Platform = "";
Note = "";
@ -130,7 +131,7 @@ namespace CryptoCalc
+ $"@{nameof(Note)}";
}
public string FullInfo => $"{ Index } {WalletID} { GetLocalTimeFromUnixTime(UnixTime) } { Currency } { Amount } { TransactionType }";
public string FullInfo => $"{ Index } {WalletID} { GetLocalTimeFromUnixTime(UnixTime) } { Currency } { decimal.Parse(Amount, CultureInfo.InvariantCulture) } { TransactionType }";
public string CreateTable(string walletTableName)
{
@ -140,10 +141,10 @@ namespace CryptoCalc
+ $"\"{nameof(WalletID)}\" INTEGER NOT NULL,"
+ $"\"{nameof(UnixTime)}\" INTEGER NOT NULL,"
+ $"\"{nameof(Currency)}\" TEXT NOT NULL,"
+ $"\"{nameof(Amount)}\" INTEGER NOT NULL,"
+ $"\"{nameof(Amount)}\" TEXT NOT NULL,"
+ $"\"{nameof(TransactionType)}\" TEXT NOT NULL,"
+ $"\"{nameof(FeeCurrency)}\" TEXT,"
+ $"\"{nameof(FeeAmount)}\" INTEGER,"
+ $"\"{nameof(FeeAmount)}\" TEXT,"
+ $"\"{nameof(Platform)}\" TEXT,"
+ $"\"{nameof(Note)}\" TEXT,"
+ $"PRIMARY KEY(\"{nameof(Index)}\" AUTOINCREMENT),"
@ -218,7 +219,7 @@ namespace CryptoCalc
+ $"\"{nameof(Platform)}\" TEXT,"
+ $"\"{nameof(Name)}\" TEXT,"
+ $"\"{nameof(Currency)}\" TEXT NOT NULL,"
+ $"\"{nameof(Balance)}\" INTEGER NOT NULL,"
+ $"\"{nameof(Balance)}\" TEXT NOT NULL,"
+ $"\"{nameof(DefaultWallet)}\" INTEGER,"
+ $"\"{nameof(Note)}\" TEXT,"
+ $"PRIMARY KEY(\"{nameof(Index)}\" AUTOINCREMENT)"

View File

@ -49,7 +49,7 @@ namespace CryptoCalc
new Transaction(
selectedWallet.Index,
inputCurrency.Text,
Convert.ToDecimal(inputAmount.Text),
inputAmount.Text,
inputType.Text
)
);
@ -110,7 +110,7 @@ namespace CryptoCalc
t.WalletID = selectedWallet.Index;
t.SaveUnixTimeNow();
t.Currency = "SOL";
t.Amount = Util.ConvToLong(30m * (decimal)rand.NextDouble());
t.Amount = (30m * (decimal)rand.NextDouble()).ToString();
t.TransactionType = "BUY";
t.Platform = "Firi";
t.Note = "Test";
@ -135,6 +135,7 @@ namespace CryptoCalc
private void inputAmount_LostFocus(object sender, RoutedEventArgs e)
{
inputAmount.Text = inputAmount.Text.Replace(".", ",");
//inputAmount.Text = inputAmount.Text.Replace(",", ".");
}
private void currencyText_LostFocus(object sender, RoutedEventArgs e)

View File

@ -19,5 +19,6 @@ namespace CryptoCalc
{
return value * 1e-18M;
}
}
}