diff --git a/DBClasses.cs b/DBClasses.cs index 81f472c..a78ddb9 100644 --- a/DBClasses.cs +++ b/DBClasses.cs @@ -75,9 +75,10 @@ namespace CryptoCalc public Transaction() { SetDBStrings(); } - public Transaction(string currency, float amount, string type) + public Transaction(int walletID, string currency, float amount, string type) { SaveUnixTimeNow(); + WalletID = walletID; Currency = currency; Amount = amount; TransactionType = type; @@ -120,23 +121,23 @@ namespace CryptoCalc + $"@{nameof(Note)}"; } - public string FullInfo => $"{ Index } { GetLocalTimeFromUnixTime(UnixTime) } { Currency } { Amount } { TransactionType }"; + public string FullInfo => $"{ Index } {WalletID} { GetLocalTimeFromUnixTime(UnixTime) } { Currency } { Amount } { TransactionType }"; public string CreateTable(string walletTableName) { return $"CREATE TABLE IF NOT EXISTS \"{DBTableName}\" (" - + $"\"{nameof(Index)}\" INTEGER NOT NULL UNIQUE," - + $"\"{nameof(WalletID)}\" INTEGER NOT NULL," - + $"\"{nameof(UnixTime)}\" INTEGER NOT NULL," - + $"\"{nameof(Currency)}\" TEXT NOT NULL," - + $"\"{nameof(Amount)}\" REAL NOT NULL," - + $"\"{nameof(TransactionType)}\" TEXT NOT NULL," - + $"\"{nameof(FeeCurrency)}\" TEXT," - + $"\"{nameof(FeeAmount)}\" REAL," - + $"\"{nameof(Platform)}\" TEXT," - + $"\"{nameof(Note)}\" TEXT," - + $"PRIMARY KEY(\"{nameof(Index)}\" AUTOINCREMENT)," + + $"\"{nameof(Index)}\" INTEGER NOT NULL UNIQUE," + + $"\"{nameof(WalletID)}\" INTEGER NOT NULL," + + $"\"{nameof(UnixTime)}\" INTEGER NOT NULL," + + $"\"{nameof(Currency)}\" TEXT NOT NULL," + + $"\"{nameof(Amount)}\" REAL NOT NULL," + + $"\"{nameof(TransactionType)}\" TEXT NOT NULL," + + $"\"{nameof(FeeCurrency)}\" TEXT," + + $"\"{nameof(FeeAmount)}\" REAL," + + $"\"{nameof(Platform)}\" TEXT," + + $"\"{nameof(Note)}\" TEXT," + + $"PRIMARY KEY(\"{nameof(Index)}\" AUTOINCREMENT)," + $"FOREIGN KEY(\"{nameof(WalletID)}\") REFERENCES \"{walletTableName}\"(\"{nameof(Index)}\")" + $"); "; } @@ -165,15 +166,15 @@ namespace CryptoCalc public Wallet() { SetDBStrings(); } - public Wallet(DateTime dateTime, string platform, string name, string currency, float balance, int defaultWallet, string note) + public Wallet(DateTime dateTime, string platform, string name, string currency, string note) { SaveUnixTimeNow(); UnixTimeCreated = GetUnixTime(dateTime); Platform = platform; Name = name; Currency = currency; - Balance = balance; - DefaultWallet = defaultWallet; + Balance = 0; + DefaultWallet = 0; Note = note; SetDBStrings(); @@ -202,15 +203,15 @@ namespace CryptoCalc { return $"CREATE TABLE IF NOT EXISTS \"{DBTableName}\" (" - + $"\"{nameof(Index)}\" INTEGER NOT NULL UNIQUE," - + $"\"{nameof(UnixTime)}\" INTEGER NOT NULL," - + $"\"{nameof(UnixTimeCreated)}\" INTEGER NOT NULL," - + $"\"{nameof(Platform)}\" TEXT," - + $"\"{nameof(Name)}\" TEXT," - + $"\"{nameof(Currency)}\" TEXT NOT NULL," - + $"\"{nameof(Balance)}\" REAL NOT NULL," - + $"\"{nameof(DefaultWallet)}\" INTEGER," - + $"\"{nameof(Note)}\" TEXT," + + $"\"{nameof(Index)}\" INTEGER NOT NULL UNIQUE," + + $"\"{nameof(UnixTime)}\" INTEGER NOT NULL," + + $"\"{nameof(UnixTimeCreated)}\" INTEGER NOT NULL," + + $"\"{nameof(Platform)}\" TEXT," + + $"\"{nameof(Name)}\" TEXT," + + $"\"{nameof(Currency)}\" TEXT NOT NULL," + + $"\"{nameof(Balance)}\" REAL NOT NULL," + + $"\"{nameof(DefaultWallet)}\" INTEGER," + + $"\"{nameof(Note)}\" TEXT," + $"PRIMARY KEY(\"{nameof(Index)}\" AUTOINCREMENT)" + $"); "; } diff --git a/MainWindow.xaml b/MainWindow.xaml index 2e9d41b..29fd908 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -11,7 +11,6 @@