예제 #1
0
        //adds iceCream to ouput text
        private void AddToOutput()
        {
            if (iceCreamNameFound)
            {
                int charLocation = OutputLabel.Text.IndexOf("*", StringComparison.Ordinal);

                if (charLocation == 0 || charLocation == OutputLabel.Text.Length - 1)
                {
                    textBox1.Text = String.Empty;
                    return;
                }

                int    ammount = int.Parse(OutputLabel.Text.Substring(0, charLocation));
                string name    = OutputLabel.Text.Substring(charLocation + 1);

                for (int i = 0; i < ex.getIceCreamList().Count; i++)
                {
                    if (ex.getIceCreamList()[i].getname() == name)
                    {
                        IceCream select = new IceCream(ex.getIceCreamList()[i].getID(), ex.getIceCreamList()[i].getname(), ex.getIceCreamList()[i].gettype());
                        select.setAmount(ammount);
                        selectedData.addToList(select);
                        break;
                    }
                }

                reDrawOutput();
            }
            else
            {
                textBox1.Text = String.Empty;
            }

            canPrint();
        }
예제 #2
0
        //remove from list button
        private void deleteButton_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == string.Empty)
            {
                string s = "Naozaj chcete zmazať všetko?";
                InitializePopup(s);

                if (answer)
                {
                    outputTextBox.Text = string.Empty;
                    selectedData.resetIceCream();
                    answer = false;
                    return;
                }
                else
                {
                    answer = false;
                    return;
                }
            }


            int charLocation = OutputLabel.Text.IndexOf("*", StringComparison.Ordinal);

            int    ammount = int.Parse(OutputLabel.Text.Substring(0, charLocation));
            string name    = OutputLabel.Text.Substring(charLocation + 1);

            for (int i = 0; i < ex.getIceCreamList().Count; i++)
            {
                if (ex.getIceCreamList()[i].getname() == name)
                {
                    IceCream select = new IceCream(ex.getIceCreamList()[i].getID(), ex.getIceCreamList()[i].getname(), ex.getIceCreamList()[i].gettype());
                    select.setAmount(ammount);
                    selectedData.removeFromList(select);
                    break;
                }
            }

            reDrawOutput();
        }