Example #1
0
        public void Form1_Load(object sender, EventArgs e)
        {
            //int rekID = Convert.ToInt32(getRekID());
            //Error.show("HOMESCREEN Form1_Load INFO" + "\nRekeningID string: " + getRekID() + "\nRekeningID int: " + rekID + "\nKlantID: " + getKlantID() + "\npasID: " + getPasID());
            this.Refresh();

            Executer exec = new Executer(rekeningID, klantID, ad, pasID);

            while (true)
            {
                String input = ad.getString();
                if (input.Contains("AKEY") || input.Contains("BKEY") || input.Contains("CKEY") || input.Contains("#KEY"))
                {
                    String caseSwitch = input;    // CAN ONLY BE A, B, C or #

                    switch (caseSwitch)
                    {
                    case "AKEY":     //Geld opnemen
                        new Opnemen().Show();
                        Thread.Sleep(1);
                        this.Close();
                        break;

                    case "BKEY":     //Saldo opvragen
                        new Saldo().Show();
                        Thread.Sleep(1);
                        this.Close();
                        break;

                    case "CKEY":     //Snel 70 euro
                        amount = 70;
                        if (berekener(amount) == true)
                        {
                            adc.makePort("COM5");
                            httppost.UpdateBalans(Home.rekeningID, (exec.saldo - amount * 100));
                            adc.dispense(amount);
                            new DankU().Show();
                            Thread.Sleep(1);
                            this.Close();
                        }
                        else
                        {
                            label2.Text = "Kan niet gedispensed worden.";
                            System.Threading.Thread.Sleep(500);
                            label2.Text = "";
                        }
                        break;

                    case "#KEY":     //stoppen
                        new Stoppen().Show();
                        Thread.Sleep(1);
                        this.Close();
                        break;
                    }
                }
            }
        }
Example #2
0
        private void Form4_Load(object sender, EventArgs e)
        {
            ArduinoData           ad       = new ArduinoData();
            HTTPget               httpget  = new HTTPget();
            HTTPpost              httppost = new HTTPpost();
            Executer              exec     = new Executer(Home.rekeningID, Home.klantID, ad, Home.pasID);
            ArduinoDispenserClass adc      = new ArduinoDispenserClass();
            Home home = new Home();


            aanwzChker();

            int amount;

            //int rekID = Convert.ToInt32(Home.rekeningID);
            pasID   = Home.pasID;
            klantID = Home.klantID;
            while (true)
            {
                String input = ad.getString();
                if (input.Contains("1KEY") || input.Contains("3KEY") || input.Contains("4KEY") || input.Contains("6KEY") || input.Contains("7KEY") || input.Contains("#KEY"))
                {
                    String caseString = input;
                    switch (caseString)
                    {
                    case "1KEY":     //10 euro
                        amount = 10;
                        if (home.berekener(amount) == true)
                        {
                            adc.makePort("COM5");
                            httppost.UpdateBalans(Home.rekeningID, (exec.saldo - amount * 100));
                            adc.dispense(amount);
                            new Bon(amount, klantID, Home.rekeningID).Show();
                            Thread.Sleep(1);
                            this.Close();
                        }
                        else
                        {
                            label2.Text = "Kan niet gedispensed worden.";
                            System.Threading.Thread.Sleep(500);
                            label2.Text = "";
                        }
                        break;

                    case "3KEY":     //20 euro
                        amount = 20;
                        if (home.berekener(amount) == true)
                        {
                            adc.makePort("COM5");
                            httppost.UpdateBalans(Home.rekeningID, (exec.saldo - amount * 100));
                            adc.dispense(amount);
                            new Bon(amount, klantID, Home.rekeningID).Show();
                            Thread.Sleep(1);
                            this.Close();
                        }
                        else
                        {
                            label2.Text = "Kan niet gedispensed worden.";
                            System.Threading.Thread.Sleep(500);
                            label2.Text = "";
                        }
                        break;

                    case "4KEY":     //50 euro
                        amount = 50;
                        if (home.berekener(amount) == true)
                        {
                            adc.makePort("COM5");
                            httppost.UpdateBalans(Home.rekeningID, (exec.saldo - amount * 100));
                            adc.dispense(amount);
                            new Bon(amount, klantID, Home.rekeningID).Show();
                            Thread.Sleep(1);
                            this.Close();
                        }
                        else
                        {
                            label2.Text = "Kan niet gedispensed worden.";
                            System.Threading.Thread.Sleep(500);
                            label2.Text = "";
                        }
                        break;

                    case "6KEY":     //70 euro
                        amount = 70;
                        if (home.berekener(amount) == true)
                        {
                            adc.makePort("COM5");
                            httppost.UpdateBalans(Home.rekeningID, (exec.saldo - amount * 100));
                            adc.dispense(amount);
                            new Bon(amount, klantID, Home.rekeningID).Show();
                            Thread.Sleep(1);
                            this.Close();
                        }
                        else
                        {
                            label2.Text = "Kan niet gedispensed worden.";
                            System.Threading.Thread.Sleep(500);
                            label2.Text = "";
                        }
                        break;

                    case "7KEY":     //bedrag invoer
                        new Bedraginvoer().Show();
                        Thread.Sleep(1);
                        this.Close();
                        break;

                    case "#KEY":     //afbreken
                        new Stoppen().Show();
                        Thread.Sleep(1);
                        this.Close();
                        break;
                    }
                }
            }
        }
Example #3
0
        private void Form3_Load(object sender, EventArgs e)
        {
            label3.Hide();
            label4.Visible = false;
            string                pasID;
            string                klantID;
            ArduinoData           arduino   = new ArduinoData();
            PinInvoer             pinInvoer = new PinInvoer();
            HTTPget               httpget   = new HTTPget();
            HTTPpost              httppost  = new HTTPpost();
            Executer              exec      = new Executer(Home.rekeningID, Home.klantID, arduino, Home.pasID);
            ArduinoDispenserClass adc       = new ArduinoDispenserClass();
            //adc.makePort("COM5");
            //String caseString = arduino.getString();

            int amount;

            //int rekID = Convert.ToInt32(Home.rekeningID);
            pasID   = Home.pasID;
            klantID = Home.klantID;

            string ssaldo = Convert.ToString(exec.saldo);
            //Error.show(ssaldo);

            int    bedrag       = 0;
            String bedragString = "";
            String input;

            while (true)
            {
                input = arduino.getString();

                if (!input.Contains("NEWUID") && (input.Contains("1") || input.Contains("2") || input.Contains("3") || input.Contains("4KEY") || input.Contains("5KEY") || input.Contains("6KEY") || input.Contains("7KEY") || input.Contains("8KEY") || input.Contains("9KEY") || input.Contains("0KEY"))) //!input.Contains("*") || !input.Contains("$") || !input.Contains("A") || !input.Contains("B") || !input.Contains("C") || !input.Contains("#") ||
                {
                    this.Refresh();
                    bedragString += input.ElementAt(0);
                }

                Int32.TryParse(bedragString, out bedrag);
                setDisplay(bedragString);

                int checker = bedrag % 10;


                switch (input)
                {
                case "*KEY":
                    this.Refresh();
                    amount = bedrag * 100;
                    if (checker != 0)
                    {
                        bedragString = "";
                        setDisplay(bedragString);
                        this.Refresh();
                        break;
                    }
                    else if (amount > exec.saldo)
                    {
                        bedragString = "";
                        setDisplay(bedragString);
                        this.Refresh();
                        break;
                    }
                    else if (amount < 10)
                    {
                        bedragString = "";
                        setDisplay(bedragString);
                        this.Refresh();
                        break;
                    }
                    else if (amount > 20000)
                    {
                        bedragString = "";
                        setDisplay(bedragString);
                        this.Refresh();
                        break;
                    }
                    else
                    {
                        adc.makePort("COM5");
                        this.Refresh();
                        httppost.UpdateBalans(Home.rekeningID, (exec.saldo - amount));
                        adc.dispense(amount / 100);
                        new Bon(amount, klantID, Home.rekeningID).Show();
                        Thread.Sleep(1);
                        this.Close();
                        break;
                    }

                case "CKEY":                                         //press 2x c for clear or c+*?? bug

                    bedragString = "";
                    setDisplay(bedragString);
                    this.Refresh();                                  // USED TO RESET BEDRAGSTRING TO null WHEN CLEARED
                    break;

                case "#KEY":     // stoppen
                    new Stoppen().Show();
                    Thread.Sleep(1);
                    this.Close();
                    break;
                }
            }
        }