private void Beginscherm_Load(object sender, EventArgs e) { //bool killscreen = true; PinInvoer pinInvoer = new PinInvoer(); Hoofdmenu hoofdmenu = new Hoofdmenu(); ArduinoData arduino = new ArduinoData(); Hash security = new Hash(); Executer executer; Boolean reset = false; Boolean pinCorrect; String[] pasInformation; bool EE = true; //User user; //try //{ while (true) ///Infinite loop so that the program returns here after every cancelation. { while (true) { pinCorrect = false; pasInformation = new String[4]; reset = false; executer = null; String KlantID; String rekeningID; String pasID; HTTPget httpget = new HTTPget(); HTTPpost httppost = new HTTPpost(); while (true) { String s = arduino.getFirstString(); if (s.Contains(",NEWUID")) { pasInformation = s.Split('\n', '\n', '\n'); KlantID = pasInformation[2]; rekeningID = pasInformation[1]; pasID = pasInformation[0]; break; } } if (!httpget.getActiefStand(pasID)) { BlockScreen tmp = new BlockScreen(); break; } pinInvoer.Show(); while (pinCorrect == false) { int insertedDigits = 0; String pincode = ""; Boolean confirmed = false; while (confirmed == false) ///Waits for user input until 4 digits have been submitted. { String input = arduino.getString(); if (checkInput(input) == true && insertedDigits < 4) { pinInvoer.printStar(); pinInvoer.falsepininfo.Visible = false; insertedDigits++; pincode += input.ElementAt(0); } else if (input.Contains("#KEY")) { reset = true; break; } else if (input.Contains("CKEY")) { pinInvoer.clear(); insertedDigits = 0; pincode = ""; } if (insertedDigits == 4) { if (input.Contains("*")) { confirmed = true; } } } pinInvoer.clear(); if (reset == true) { break; } if (pincode == "1337" && EE) //Added easter egg { pinInvoer.pictureBox2.Visible = true; pinInvoer.Refresh(); System.Threading.Thread.Sleep(8000); reset = true; pinInvoer.pictureBox2.Visible = false; break; } if (security.checkHash(rekeningID, pincode) == false) { pinInvoer.falsepininfo.Visible = true; HTTPpost tmp = new HTTPpost(); tmp.Incrementfalsepin(pasID); if (!httpget.getActiefStand(pasID)) { pinInvoer.Close(); } } else { httppost.resetfalsepin(pasID); pinCorrect = true; } } pinInvoer.Hide(); if (reset == true) { break; } hoofdmenu.Show(); executer = new Executer(rekeningID, KlantID, arduino, pasID); while (true) { int choice = arduino.getChoice(); if (choice != 0) { executer.executeChoice(choice); if (executer.getEndOfSession() == true) { hoofdmenu.Hide(); break; } } } } } }
private String biljetSelection(int amount) { String choice = "00,00,00,*"; String option1 = "invalid"; String option2 = "invalid"; String option3 = "invalid"; String option4 = "invalid"; Boolean validInput = false; int selection = 0; int tens = 0; int twenties = 0; int fifties = 0; BiljetScreen selector = new BiljetScreen(); tens = amount / 10; if (stock.checkIfAvailable(tens, twenties, fifties)) { selector.setLabel1(tens.ToString()); if (tens > 9) { option1 = tens.ToString() + ",00,00,*"; } else { option1 = "0" + tens.ToString() + ",00,00,*"; } } if (amount % 20 == 0) { twenties = (amount / 20); tens = 0; fifties = 0; option2 = generateCommand(tens, twenties, fifties); } else { twenties = (amount - (amount % 20)) / 20; tens = 1; fifties = 0; option2 = generateCommand(tens, twenties, fifties); } if (!(option2.Equals("invalid"))) { selector.setLabel2(tens.ToString(), twenties.ToString()); } if (amount >= 50 && amount % 50 == 0) { tens = 0; twenties = 0; fifties = amount / 50; option3 = generateCommand(tens, twenties, fifties); if (!(option3.Equals("invalid"))) { selector.setLabel3(tens.ToString(), fifties.ToString()); } } else if (amount >= 60) { tens = (amount % 50) / 10; twenties = 0; fifties = (amount - (amount % 50)) / 50; option3 = generateCommand(tens, twenties, fifties); if (!(option3.Equals("invalid"))) { selector.setLabel3(tens.ToString(), fifties.ToString()); } if (((amount % 50) % 20) == 0) { twenties = ((amount % 50) % 20) / 20; tens = 0; } else if (amount % 50 == 30) { twenties = 1; tens = 1; } option4 = generateCommand(tens, twenties, fifties); if (!(option4.Equals("invalid"))) { selector.setLabel4(tens.ToString(), twenties.ToString(), fifties.ToString()); } } selector.Show(); if (option1.Equals("invalid") && option2.Equals("invalid") && option3.Equals("invalid") && option4.Equals("invalid")) { selector.showInsufficient(); } else { //Error.show(option1 + " " + option2 + " " + option3 + "" + option4); while (validInput == false) { selection = arduino.getChoice(); if (selection == 1 && !(option1.Equals("invalid"))) { validInput = true; } else if (selection == 2 && !(option2.Equals("invalid"))) { validInput = true; } else if (selection == 3 && !(option3.Equals("invalid"))) { validInput = true; } else if (selection == 5 && !(option4.Equals("invalid"))) { validInput = true; } else if (selection == 4) { cancelled = true; break; } } switch (selection) { case 1: choice = option1; break; case 2: choice = option2; break; case 3: choice = option3; break; case 5: choice = option4; break; } } selector.Hide(); //Error.show(choice); return(choice); }
private String biljetSelection(int amount) { String choice = "00,00,00*"; String option1; String option2; String option3 = "invalid"; String option4 = "invalid*"; int tens = 0; int twenties = 0; int fifties = 0; BiljetScreen selector = new BiljetScreen(); tens = amount / 10; selector.setLabel1(tens.ToString()); if (tens > 9) { option1 = tens.ToString() + ",00,00*"; } else { option1 = "0" + tens.ToString() + ",00,00*"; } if (amount % 20 == 0) { twenties = (amount / 20); tens = 0; option2 = generateCommand(tens, twenties, fifties); } else { twenties = (amount - (amount % 20)) / 20; tens = 1; option2 = generateCommand(tens, twenties, fifties); } selector.setLabel2(tens.ToString(), twenties.ToString()); if (amount >= 50 && amount % 50 == 0) { tens = 0; twenties = 0; fifties = amount / 50; option3 = generateCommand(tens, twenties, fifties); selector.label4.Visible = false; } else if (amount >= 60) { tens = (amount % 50) / 10; twenties = 0; fifties = (amount - (amount % 50)) / 50; selector.setLabel3(tens.ToString(), fifties.ToString()); option3 = generateCommand(tens, twenties, fifties); if (((amount % 50) % 20) == 0) { twenties = ((amount % 50) % 20) / 20; tens = 0; } else if (amount % 50 == 30) { twenties = 1; tens = 1; selector.setLabel4(tens.ToString(), twenties.ToString(), fifties.ToString()); } option4 = generateCommand(tens, twenties, fifties); } selector.Show(); Boolean validInput = false; int selection = 0; while (validInput == false) { selection = arduino.getChoice(); if (selection == 3 && !(option3.Equals("invalid"))) { validInput = true; } else if (selection == 4 && !(option4.Equals("invalid"))) { validInput = true; } else if (selection != 0) { validInput = true; } } switch (selection) { case 1: choice = option1; break; case 2: choice = option2; break; case 3: choice = option3; break; case 5: choice = option4; break; } selector.Hide(); Error.show(choice); return(choice); }
private void Beginscherm_Load(object sender, EventArgs e) { PinInvoer pinInvoer = new PinInvoer(); Hoofdmenu hoofdmenu = new Hoofdmenu(); ArduinoData arduino = new ArduinoData(); Stock stock = new Stock(arduino); Hash security = new Hash(); TransactionManager transactionManager; Boolean reset = false; Boolean pinCorrect; String[] pasInformation; bool EE = true; //User user; try { while (true) ///Infinite loop so that the program returns here after every cancelation. { while (true) { pinCorrect = false; pasInformation = new String[4]; reset = false; transactionManager = null; int KlantID; String rekeningID; String pasID; HTTPget httpget = new HTTPget(); HTTPpost httppost = new HTTPpost(); while (true) { String s = arduino.getFirstString(); if (s.Contains(",NEWUID")) { pasInformation = s.Split('\n', '\n', '\n'); Int32.TryParse(pasInformation[2], out KlantID); rekeningID = pasInformation[1]; pasID = pasInformation[0]; break; } else if (s.Contains("open")) { Cursor.Show(); stock.restock(); } } if (httpget.getActiefStand(pasID) == false) { BlockScreen tmp = new BlockScreen(); break; } pinInvoer.Show(); while (pinCorrect == false) { int insertedDigits = 0; String pincode = ""; Boolean confirmed = false; while (confirmed == false) ///Waits for user input until 4 digits have been submitted. { String input = arduino.getString(); if (checkInput(input) == true && insertedDigits < 4) { pinInvoer.printStar(); pinInvoer.falsepininfo.Visible = false; insertedDigits++; pincode += input.ElementAt(0); } else if (input.Contains("#KEY")) { reset = true; break; } else if (input.Contains("CKEY")) { pinInvoer.clear(); insertedDigits = 0; pincode = ""; } if (insertedDigits == 4) { if (input.Contains("*")) { confirmed = true; } } } pinInvoer.clear(); if (reset == true) { break; } if (pincode == "1337" && EE) //Added easter egg { pinInvoer.pictureBox2.Visible = true; pinInvoer.Refresh(); System.Threading.Thread.Sleep(8000); reset = true; pinInvoer.pictureBox2.Visible = false; break; } if (security.checkHash(rekeningID, pincode) == false) { pinInvoer.falsepininfo.Visible = true; HTTPpost tmp = new HTTPpost(); tmp.Incrementfalsepin(pasID); HTTPget tmp2 = new HTTPget(); if (tmp2.getPinclass(pasID).poging >= 2) { reset = true; } } else { httppost.resetfalsepin(pasID); pinCorrect = true; } } pinInvoer.Hide(); if (reset == true) { break; } hoofdmenu.Show(); transactionManager = new TransactionManager(rekeningID, KlantID, arduino, pasID, stock); while (true) { int choice = arduino.getChoice(); if (choice != 0) { transactionManager.executeChoice(choice); if (transactionManager.getEndOfSession() == true) { hoofdmenu.Hide(); break; } } } } } } catch (Exception) //Made the application safe, as soon as an exception is found, Close everything and show the out of order Form, main thread isnt even running anymore { ErrorScreen error = new ErrorScreen(); List <Form> openForms = new List <Form>(); foreach (Form f in Application.OpenForms) { openForms.Add(f); } foreach (Form f in openForms) { if (f.Name != "ErrorScreen") { f.Close(); } } while (true) { } //Loop forever :) } }
private void Beginscherm_Load(object sender, EventArgs e) { PinInvoer pinInvoer = new PinInvoer(); Hoofdmenu hoofdmenu = new Hoofdmenu(); ArduinoData arduino = new ArduinoData(); Stock stock = new Stock(arduino); Hash security = new Hash(); TransactionManager transactionManager; Boolean reset = false; Boolean pinCorrect; String[] pasInformation; bool EE = true; //User user; try { while (true) ///Infinite loop so that the program returns here after every cancelation. { while (true) { pinCorrect = false; pasInformation = new String[4]; reset = false; transactionManager = null; int KlantID; String rekeningID; String pasID; HTTPget httpget = new HTTPget(); HTTPpost httppost = new HTTPpost(); while (true) { String s = arduino.getFirstString(); if (s.Contains(",NEWUID")) { pasInformation = s.Split('\n', '\n', '\n'); Int32.TryParse(pasInformation[2],out KlantID); rekeningID = pasInformation[1]; pasID = pasInformation[0]; break; } else if (s.Contains("open")) { Cursor.Show(); stock.restock(); } } if (httpget.getActiefStand(pasID) == false) { BlockScreen tmp = new BlockScreen(); break; } pinInvoer.Show(); while (pinCorrect == false) { int insertedDigits = 0; String pincode = ""; Boolean confirmed = false; while (confirmed == false) ///Waits for user input until 4 digits have been submitted. { String input = arduino.getString(); if (checkInput(input) == true && insertedDigits < 4) { pinInvoer.printStar(); pinInvoer.falsepininfo.Visible = false; insertedDigits++; pincode += input.ElementAt(0); } else if (input.Contains("#KEY")) { reset = true; break; } else if (input.Contains("CKEY")) { pinInvoer.clear(); insertedDigits = 0; pincode = ""; } if (insertedDigits == 4) { if (input.Contains("*")) { confirmed = true; } } } pinInvoer.clear(); if (reset == true) { break; } if (pincode == "1337" && EE) //Added easter egg { pinInvoer.pictureBox2.Visible = true; pinInvoer.Refresh(); System.Threading.Thread.Sleep(8000); reset = true; pinInvoer.pictureBox2.Visible = false; break; } if (security.checkHash(rekeningID, pincode) == false) { pinInvoer.falsepininfo.Visible = true; HTTPpost tmp = new HTTPpost(); tmp.Incrementfalsepin(pasID); HTTPget tmp2 = new HTTPget(); if(tmp2.getPinclass(pasID).poging >=2) { reset = true; } } else { httppost.resetfalsepin(pasID); pinCorrect = true; } } pinInvoer.Hide(); if (reset == true) { break; } hoofdmenu.Show(); transactionManager = new TransactionManager(rekeningID, KlantID, arduino, pasID, stock); while (true) { int choice = arduino.getChoice(); if (choice != 0) { transactionManager.executeChoice(choice); if (transactionManager.getEndOfSession() == true) { hoofdmenu.Hide(); break; } } } } } } catch (Exception) //Made the application safe, as soon as an exception is found, Close everything and show the out of order Form, main thread isnt even running anymore { ErrorScreen error = new ErrorScreen(); List<Form> openForms = new List<Form>(); foreach (Form f in Application.OpenForms) openForms.Add(f); foreach (Form f in openForms) { if (f.Name != "ErrorScreen") f.Close(); } while (true) { } //Loop forever :) } }