BillSplitter.AppDelegate.Calculate C# (CSharp) Метод

Calculate() приватный Метод

private Calculate ( ) : void
Результат void
        private void Calculate()
        {
            decimal total = 0.0m;
            decimal wine = 0.0m;

            int pax = drinkers + nondrinkers;

            labelSplit.Text = "-";
            labelSplit2.Text = "-";
            if (pax > 0)
            {
                string totalText = textfieldTotal.Text==""?"0":textfieldTotal.Text;
                string wineText = textfieldWine.Text==""?"0":textfieldWine.Text;

                if (decimal.TryParse(totalText, out total))
                {
                    if (decimal.TryParse(wineText, out wine))
                    {
                        decimal foodeach = (total - wine) / pax;
                        if (foodeach > 0)
                        {
                            labelTotal.Text = "$ " + total.ToString("#.00");
                            if (drinkers > 0)
                            {
                                labelSplit.Text = (foodeach + wine/drinkers).ToString("#.00");
                            }
                            else
                            {  // if no drinkers, add the wine back into the bill
                                foodeach = (total) / pax;
                            }

                            if (nondrinkers > 0)
                            {
                                labelSplit2.Text = (foodeach/nondrinkers).ToString("#.00");
                            }
                        }
                        else Console.WriteLine("cannot be negative " + foodeach);
                    }
                }
            }
        }