CryptoCalc/DBClasses.cs

196 lines
5.7 KiB
C#

using System;
using System.Text.RegularExpressions;
namespace CryptoCalc
{
public interface IDBClasses
{
string DBVariables { get; set; }
string DBTableName { get; }
string DBSaveDataString { get; }
}
public class DBClasses : IDBClasses
{
#region Publics
public virtual string DBVariables { get; set; }
public virtual string DBTableName => throw new NotImplementedException();
public string DBSaveDataString => $"({Regex.Replace(DBVariables, "@", "")}) values ({DBVariables})";
public int Index { get; set; }
public int Year { get; set; }
public int Month { get; set; }
public int Day { get; set; }
public int Hour { get; set; }
public int Minute { get; set; }
public int Second { get; set; }
public string DateTimeString { get; set; }
#endregion
#region Functions
public void SaveDateTime()
{
Year = DateTime.Now.Year;
Month = DateTime.Now.Month;
Day = DateTime.Now.Day;
Hour = DateTime.Now.Hour;
Minute = DateTime.Now.Minute;
Second = DateTime.Now.Second;
DateTimeString = DateTime.Now.ToString();
}
#endregion
}
public class Transaction : DBClasses
{
#region Publics
public override string DBVariables { get => base.DBVariables; set => base.DBVariables = value; }
public override string DBTableName => "Transactions";
public string Currency { get; set; }
public float Amount { get; set; }
public string TransactionType { get; set; }
public string FeeCurrency { get; set; }
public float FeeAmount { get; set; }
public string Platform { get; set; }
public string Note { get; set; }
#endregion
#region Constructors
public Transaction() { SetDBStrings(); }
public Transaction(string _currency, float _amount, string _type)
{
SaveDateTime();
Currency = _currency;
Amount = _amount;
TransactionType = _type;
Platform = "";
Note = "";
SetDBStrings();
}
public Transaction(string _currency, float _amount, string _type, string _feeCurrency, float _feeAmount)
{
SaveDateTime();
Currency = _currency;
Amount = _amount;
TransactionType = _type;
FeeCurrency = _feeCurrency;
FeeAmount = _feeAmount;
Platform = "";
Note = "";
SetDBStrings();
}
#endregion
#region Functions
private void SetDBStrings()
{
DBVariables =
$"@{nameof(Year)},"
+ $"@{nameof(Month)},"
+ $"@{nameof(Day)},"
+ $"@{nameof(Hour)},"
+ $"@{nameof(Minute)},"
+ $"@{nameof(Second)},"
+ $"@{nameof(DateTimeString)},"
+ $"@{nameof(Currency)},"
+ $"@{nameof(Amount)},"
+ $"@{nameof(TransactionType)},"
+ $"@{nameof(FeeCurrency)},"
+ $"@{nameof(FeeAmount)},"
+ $"@{nameof(Platform)},"
+ $"@{nameof(Note)}";
}
public string FullInfo => $"{ Index.ToString() } { DateTimeString } { Currency } { Amount } { TransactionType }";
#endregion
}
public class Wallet : DBClasses
{
#region Publics
public override string DBVariables { get => base.DBVariables; set => base.DBVariables = value; }
public override string DBTableName => "Wallets";
public int CreationYear { get; set; }
public int CreationMonth { get; set; }
public int CreationDay { get; set; }
public string Platform { get; set; }
public string Name { get; set; }
public string Currency { get; set; }
public float Balance { get; set; }
public int DefaultWallet { get; set; }
public string Notes { get; set; }
#endregion
#region Constructors
public Wallet() { SetDBStrings(); }
public Wallet(int _year, int _month, int _day, string _platform, string _name, string _currency, float _balance, int _default, string _note)
{
SaveDateTime();
CreationYear = _year;
CreationMonth = _month;
CreationDay = _day;
Platform = _platform;
Name = _name;
Currency = _currency;
Balance = _balance;
DefaultWallet = _default;
Notes = _note;
SetDBStrings();
}
#endregion
#region Functions
private void SetDBStrings()
{
DBVariables =
$"@{nameof(Year)},"
+ $"@{nameof(Month)},"
+ $"@{nameof(Day)},"
+ $"@{nameof(Hour)},"
+ $"@{nameof(Minute)},"
+ $"@{nameof(Second)},"
+ $"@{nameof(DateTimeString)},"
+ $"@{nameof(CreationYear)},"
+ $"@{nameof(CreationMonth)},"
+ $"@{nameof(CreationDay)},"
+ $"@{nameof(Platform)},"
+ $"@{nameof(Name)},"
+ $"@{nameof(Currency)},"
+ $"@{nameof(Balance)},"
+ $"@{nameof(DefaultWallet)},"
+ $"@{nameof(Notes)}";
}
//public string FullInfo => $"{ Index.ToString() } { DateTimeString } { Currency } { Amount } { TransactionType }";
#endregion
}
}