Exemplo n.º 1
0
        private void SetUpStatTab()
        {
            if (_db.Persons.Count() == 0)
            {
                PersonWindow temp = new PersonWindow(this);
                temp.ShowDialog();
            }
            List <Day> list = new List <Day>();

            //Days list
            foreach (ReadyMeal r in _meals)
            {
                Day day = list.Find(x => x.Date == r.Origin.Date);
                if (day == null)
                {
                    list.Add(new Day(r.Origin.Date));
                    day = list.Find(x => x.Date == r.Origin.Date);
                }
                day.ReadyMeals.Add(r);
            }
            list = list.Select(x => x).OrderBy(x => x.Date).ToList();
            //persons for Days list
            Person[] personArray = _db.Persons.Select(x => x).OrderBy(x => x.Date).ToArray();
            int      k           = 0;

            foreach (Day d in list)
            {
                if (k != personArray.Count() - 1)
                {
                    if (d.Date < personArray[k + 1].Date)
                    {
                        d.Person = personArray[k];
                    }
                    else
                    {
                        k++;
                        d.Person = personArray[k];
                    }
                }
                else
                {
                    d.Person = personArray[k];
                }
            }
            list = list.Select(x => x).OrderByDescending(x => x.Date).ToList();
            _days.Clear();
            foreach (Day d in list)
            {
                _days.Add(d);
            }
            //Calculate plans (FOR NOW ONLY 1 PLAN BY PROTEINS)
            foreach (Day d in _days)
            {
                d.CalculateByProteins(1.1f);
            }
            dgDayStat.Items.Refresh();
        }
Exemplo n.º 2
0
 protected override void OnClosing(CancelEventArgs e)
 {
     base.OnClosing(e);
     if (_window.Db.Persons.Count() == 0)
     {
         MessageBox.Show("Aby program działał poprawnie należy dodać przynajmniej jeden wpis do tabeli!", "ORDER 66");
         PersonWindow temp = new PersonWindow(_window);
         temp.ShowDialog();
     }
 }
Exemplo n.º 3
0
        private void btnPerson_Click(object sender, RoutedEventArgs e)
        {
            PersonWindow temp = new PersonWindow(this);

            temp.ShowDialog();
        }