public void CashOut() { Console.WriteLine("Podaj kwote jaką chcesz wypłacić[zł](np. 250,53): "); string sAmount = Console.ReadLine(); if (Double.TryParse(sAmount, out double Amount)) { double Balance = SQLMethods.GetBalance(UserId); if (Amount <= Balance) { if (Amount > 0) { Console.WriteLine("Dodaj opis do transakcji: "); string description = "Wypłata. " + Console.ReadLine(); SQLMethods.SqlTransaction(-Amount, description, UserId); Console.WriteLine("Wypłacono: " + String.Format("{0:N2}", Amount) + " zł"); Console.WriteLine("Opis: " + description); } else { Console.WriteLine("Kwota musi być większa od 0!"); } } else { Console.WriteLine("Niewystarczająco funduszy!"); } } else { Console.WriteLine("Błędnie podana kwota!"); } Console.ReadKey(); }
static void LogIn() { Console.WriteLine("Podaj nazwe użytkownika: "); userName = Console.ReadLine(); Console.WriteLine("Podaj hasło: "); password = Console.ReadLine(); if (SQLMethods.LogIn(userName, password)) { Console.WriteLine("Logowanie udane!"); userId = SQLMethods.GetUserId(userName); if (userId != -1) { acc = new BankAccount(userName, userId); } else { Console.WriteLine("Nie znaleziono konta!"); Console.ReadKey(); } } else { Console.WriteLine("Nie znaleziono konta!"); Console.ReadKey(); } }
static void SignIn() { Console.Clear(); Console.WriteLine("Stwórz konto bankowe!"); Console.WriteLine("Podaj nazwe użytkownika: "); userName = Console.ReadLine(); if (!SQLMethods.CheckAcc(userName)) { Console.WriteLine("Podaj hasło: "); password = Console.ReadLine(); SQLMethods.NewAcc(userName, password); userId = SQLMethods.GetUserId(userName); if (userId != -1) { acc = new BankAccount(userName, userId); } else { Console.WriteLine("Wystąpił błąd podczas zakładania konta!"); Console.ReadKey(); } } else { Console.WriteLine("Takie konto już istnieje!"); Console.ReadKey(); } }
public void ShowBalance() { double Balance = SQLMethods.GetBalance(UserId); Console.WriteLine("Bilans Twojego konta wynosi: " + String.Format("{0:N2}", Balance) + " zł"); if (Balance > 0) { Console.WriteLine("Średniawka, ale może na bułki wystarczy ;)"); } Console.WriteLine("Wciśnij przycisk aby powrócić do menu"); Console.ReadKey(); }
public void StartTransaction() { Console.WriteLine("Podaj Numer konta do przelewu: "); string stoUserId = Console.ReadLine(); int toUserId; if (Int32.TryParse(stoUserId, out toUserId)) { if (SQLMethods.CheckAccById(toUserId)) { Console.WriteLine("Podaj kwote jaką chcesz przelać[zł](np. 250,53): "); string sAmount = Console.ReadLine(); if (Double.TryParse(sAmount, out double Amount)) { double Balance = SQLMethods.GetBalance(UserId); if (Amount <= Balance) { if (Amount > 0) { Console.WriteLine("Dodaj opis do transakcji: "); string description = Console.ReadLine(); string fdescription = "Przelew wychodzący na konto numer: " + toUserId.ToString() + " Opis: " + description; string tdescription = "Przelew przychodzący z konta numer: " + UserId.ToString() + " Opis: " + description; SQLMethods.TransferCash(UserId, toUserId, Amount, fdescription, tdescription); Console.WriteLine("Przelano: " + String.Format("{0:N2}", Amount) + " zł Na konto numer: " + toUserId.ToString()); Console.WriteLine("Opis: " + description); } else { Console.WriteLine("Kwota musi być większa od 0!"); } } else { Console.WriteLine("Niewystarczająco funduszy!"); } } else { Console.WriteLine("Błędnie podana kwota!"); } } else { Console.WriteLine("Takie konto nie istnieje!"); } } else { Console.WriteLine("Błędnie wpisany numer konta"); } Console.ReadKey(); }
public void ShowTransactions() { allTransactions = SQLMethods.GetTransactions(UserId); foreach (Transaction tr in allTransactions) { Console.WriteLine("Transakcja numer: " + tr.number().ToString()); Console.WriteLine("Kwota transakcji: " + String.Format("{0:N2}", tr.amount()) + " zł"); Console.WriteLine("Data transakcji: " + tr.date()); Console.WriteLine("Opis transakcji: " + tr.notes()); } Console.ReadKey(); }
public BankAccount(string name, int userId) { Owner = name; UserId = userId; allTransactions = SQLMethods.GetTransactions(UserId); }