Esempio n. 1
0
        private void change_Click(object sender, RoutedEventArgs e)
        {
            Chek c     = new Chek();
            int  price = 0;

            count.Text = delNotNum(count.Text);
            string[] l      = count.Text.Split('\n');
            int      i      = 0;
            string   titles = "";

            foreach (var listBoxItem in Cheks.Items)
            {
                var item = (Chek)listBoxItem;
                if (l[i] != "0")
                {
                    item.Price = Convert.ToInt32(l[i]) * cena[Array.IndexOf(menu, item.Title)];
                    price     += item.Price;
                }
                else
                {
                    titles += (item.Title + "\n");
                }
                Cheks.Items.Refresh();
                i++;
            }
            string[] t**s = titles.Split('\n');
            for (int j = 0; j < t**s.Length; j++)
            {
                if (Containsind(t**s[j]) != -1)
                {
                    Cheks.Items.RemoveAt(Containsind(t**s[j]));

                    count.Text = count.Text.Replace("\n0\n", "\n");
                    if (count.Text[0] == '0')
                    {
                        count.Text = count.Text.Substring(1, count.Text.Length - 1);
                    }
                    if (count.Text[0] == '\n')
                    {
                        count.Text = count.Text.Substring(1, count.Text.Length - 1);
                    }
                    Cheks.Items.Refresh();
                }
            }

            itog.Text = Convert.ToString(price);
        }
Esempio n. 2
0
        //обработчик добавления блюда в определенном количестве в чек
        private void addd_Click(TextBlock names, TextBlock prices, TextBox counts)
        {
            Chek c     = new Chek();
            int  price = 0;
            int  it    = Convert.ToInt32(itog.Text);

            //проверяем введенное количество блюд, добавляем в чек
            if (counts.Text != "0")
            {
                if (!IsNumber(counts.Text) || counts.Text == "")
                {
                    counts.Text = "1";
                }

                try
                {
                    price = Convert.ToInt32(prices.Text) * Convert.ToInt32(counts.Text);
                }
                catch
                {
                    price = Convert.ToInt32(prices.Text);
                }

                c.Price = Convert.ToInt32(price);
                c.Title = names.Text;
                if (ContainsTitle(names.Text))
                {
                    it = Convert.ToInt32(itog.Text) - Containscena(names.Text);
                    string[] l = count.Text.Split('\n');
                    count.Text = "";
                    for (int i = 0; i < l.Length - 1; i++)
                    {
                        if (i != Containsind(names.Text))
                        {
                            count.Text += l[i] + "\n";
                        }
                    }
                    count.Text += l[l.Length - 1];
                    Cheks.Items.RemoveAt(Containsind(names.Text));
                }
                count.Text += counts.Text + "\n";
                Cheks.Items.Add(c);
                itog.Text = Convert.ToString(it + price);
            }
            else
            if (count3.Text == "0" && ContainsTitle(names.Text))
            {
                it = Convert.ToInt32(itog.Text) - Containscena(names.Text);
                string[] l = count.Text.Split('\n');
                count.Text = "";
                for (int i = 0; i < l.Length - 1; i++)
                {
                    if (i != Containsind(names.Text))
                    {
                        count.Text += l[i] + "\n";
                    }
                }
                count.Text += l[l.Length - 1];
                Cheks.Items.RemoveAt(Containsind(names.Text));
                itog.Text = Convert.ToString(it);
            }
        }