void PinWindowHandler() { User.SetPin(User.GetPin() + input); String pin = User.GetPin(); int pinlength = pin.Length; if (pinlength < 4) { UpdatePinProgressMidway(pin); } else { WindowSwitcher.PinWindow.PinProgress.Content = "* * * *"; String response = new WebHandler().WebHandle("getBalance", "2131-GHAS-43AS-4A32", "1111"); //String response = new WebHandler().WebHandle("getBalance", User.GetTag(), User.GetPin()); JObject json = JObject.Parse(response); if (json.GetValue("error") != null) { UpdatePinProgress(Colors.Red); User.SetPin(""); } else { UpdatePinProgress(Colors.Green); } Console.WriteLine(response); } }
public static double GetBalance() { if (BALANCE != 0) { return(BALANCE); } JObject json = new WebHandler().GetBalance(); String response = (String)json.GetValue("balance"); double money = double.Parse(response) / 100; BALANCE = money; return(BALANCE); }
private void ConfirmHandler() { if (!User.GetWaitingForCard()) { return; } if (User.GetBalanceInput() == null) { return; } if (User.GetBalanceInput().Length == 0) { return; } WindowSwitcher.OpenPleaseWaitWindow(); double amount = Double.Parse(User.GetBalanceInput()); JObject response = new WebHandler().WithdrawMoney(amount); if (response.GetValue("response") == null) { if (response.GetValue("error") != null) { String error = response.GetValue("error").ToString(); User.SetError(error); WindowSwitcher.OpenErrorOccurredWindow(); return; } } JObject x = (JObject)response.GetValue("transaction"); if ((Boolean)x.GetValue("success")) { WindowSwitcher.OpenThanksGoodbyeWindow(); if (User.GetReceipt()) { new PrintHandler().Print(); } //PlayThanks(); } Console.WriteLine(response.ToString()); }
void PinWindowHandler() { int checkAlsGetal; if (int.TryParse(input, out checkAlsGetal)) { if (User.GetPin().Length != 4) { User.SetPin(User.GetPin() + input); } } if (input.Equals("*")) { if (User.GetPin().Length != 0) { User.SetPin(User.GetPin().Substring(0, User.GetPin().Length - 1)); } } UpdatePinProgress(); if (input.Equals("#")) { if (User.GetPin().Length != 4) { return; } JObject json = new WebHandler().GetBalance(); if (json.GetValue("error") != null) { UpdatePinProgress(Colors.Red); User.SetPin(""); String error = ((String )json.GetValue("error")).ToLower(); if (error.Equals("pin incorrect")) { int triesremaining = 3 - ((int)json.GetValue("tries")); WindowSwitcher.PinWindow.ERROR.Content = ("Nog X poging(en) over").Replace("X", triesremaining + ""); } if (error.Equals("card blocked")) { WindowSwitcher.PinWindow.ERROR.Content = "Uw pas is geblokeerd, neem aub contact op"; Thread thread = new Thread(() => { Thread.Sleep(5000); WindowSwitcher.OpenThanksGoodbyeWindow(); }); //thread.SetApartmentState(ApartmentState.STA); thread.Start(); } WindowSwitcher.PinWindow.ERROR.Visibility = Visibility.Visible; } else { Thread thread = new Thread(() => { UpdatePinProgress(Colors.Green); Thread.Sleep(5000); Application.Current.Dispatcher.Invoke(new Action(() => { WindowSwitcher.PinWindow.ERROR.Visibility = Visibility.Hidden; WindowSwitcher.OpenChoice(); WindowSwitcher.Choice.Show(); })); }); //thread.SetApartmentState(ApartmentState.STA); thread.Start(); } } }
private void TagHandler(string tag) { if (User.GetTag().Length != 0) { if (User.GetTag().Equals(tag)) { InputHandler("TAG CHECK OK"); } Console.WriteLine("SAME TAG PRESENTED"); Application.Current.Dispatcher.Invoke(new Action(() => { if (WindowSwitcher.GetActiveWindow().Title.Equals("MainWindow")) { User.SetTag(""); } })); return; } User.SetTag(tag); Console.WriteLine("TAG: " + tag); JObject json = new WebHandler().GetCardValid(); if (json.GetValue("error") != null) { Console.WriteLine("Connection error!"); Application.Current.Dispatcher.Invoke(new Action(() => { new NoNetwork().Show(); })); return; } Boolean cardExists = (Boolean)json.GetValue("exists"); if (!cardExists) { User.SetError("Deze kaart komt niet voor in onze database"); WindowSwitcher.OpenErrorOccurredWindow(); User.SetTag(""); return; } WindowSwitcher.OpenPinWindow(); int tries = (int)json.GetValue("tries"); if (tries == 3) { Application.Current.Dispatcher.Invoke(new Action(() => { WindowSwitcher.PinWindow.ERROR.Content = "Uw pas is geblokeerd, neem zo snel mogelijk contact op"; WindowSwitcher.PinWindow.ERROR.Visibility = Visibility.Visible; User.inputBlocked = true; })); Thread thread = new Thread(() => { Thread.Sleep(5000); WindowSwitcher.OpenThanksGoodbyeWindow(); }); //thread.SetApartmentState(ApartmentState.STA); thread.Start(); } else if (tries != 0) { UpdateTries(3 - tries); } }