87 lines
2.6 KiB
C#
87 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Windows;
|
|
|
|
namespace CryptoCalc
|
|
{
|
|
public partial class MainWindow : Window
|
|
{
|
|
private readonly Random rand = new();
|
|
private List<Transaction> transactions = new();
|
|
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void saveButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Transaction dummy = DummyTransaction();
|
|
DBInteraction.SaveData(ref dummy);
|
|
}
|
|
private void saveWalletButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Wallet dummy = DummyWallet();
|
|
DBInteraction.SaveData(ref dummy);
|
|
}
|
|
|
|
private void saveButtonFromInput_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Transaction rd = new(inputCurrency.Text, Convert.ToSingle(inputAmount.Text), inputType.Text);
|
|
DBInteraction.SaveData(ref rd);
|
|
}
|
|
|
|
private void readButton_click(object sender, RoutedEventArgs e)
|
|
{
|
|
transactions = DBInteraction.LoadTransactions();
|
|
foreach (Transaction x in transactions)
|
|
{
|
|
Debug.WriteLine($"{x.GetLocalTimeFromUnixTime(x.UnixTime)} *** {x.Currency} - {x.Amount}");
|
|
}
|
|
}
|
|
private void searchButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
transactions = DBInteraction.LoadTransactionsOfCurrency(currencyText.Text);
|
|
transactionsFoundListBox.Items.Clear();
|
|
foreach (Transaction x in transactions)
|
|
{
|
|
transactionsFoundListBox.Items.Add(x.FullInfo);
|
|
}
|
|
}
|
|
|
|
private Transaction DummyTransaction()
|
|
{
|
|
Transaction t = new();
|
|
t.SaveUnixTimeNow();
|
|
t.Currency = "SOL";
|
|
t.Amount = Convert.ToSingle(30 * rand.NextDouble());
|
|
t.TransactionType = "BUY";
|
|
t.Platform = "Firi";
|
|
t.Note = "Test";
|
|
return t;
|
|
}
|
|
|
|
private Wallet DummyWallet()
|
|
{
|
|
Wallet w = new();
|
|
w.SaveUnixTimeNow();
|
|
w.UnixTimeCreated = w.GetUnixTime(new DateTime(2018, 10, 1));
|
|
w.Platform = "Ledger";
|
|
w.Name = "TestWallet";
|
|
w.Currency = "SOL";
|
|
w.Balance = Convert.ToSingle(30 * rand.NextDouble());
|
|
w.DefaultWallet = 0;
|
|
w.Note = "Test";
|
|
return w;
|
|
}
|
|
|
|
|
|
private void inputAmount_LostFocus(object sender, RoutedEventArgs e)
|
|
{
|
|
inputAmount.Text = inputAmount.Text.Replace(".", ",");
|
|
}
|
|
|
|
}
|
|
}
|