public void Schedule_should_be_populated_correctly_with_multiple_customers()
        {
            List <CustomerPreference> preferences = new()
            {
                new() { Customer = "Jack", Preference = new DayOfTheMonth {
                            Day = 1
                        } },
                new() { Customer = "George", Preference = new DaysOfTheWeek {
                            DaySelection = new() { DayOfWeek.Monday, DayOfWeek.Wednesday }
                        } },
                new() { Customer = "William", Preference = new EveryDay() }
            };

            var schedule = Scheduler.CreateSchedule(preferences, new(start: new DateTime(2020, 1, 1), end: new DateTime(2020, 1, 6)));

            Assert.Contains(new DateTime(2020, 1, 1), schedule.Keys);
            var entry = schedule[new DateTime(2020, 1, 1)];

            Assert.Contains("George", entry);
            Assert.Contains("Jack", entry);
            Assert.Contains("William", entry);
            Assert.Equal(3, entry.Count);

            entry = schedule[new DateTime(2020, 1, 2)];
            Assert.Contains("William", entry);
            Assert.Single(entry);

            entry = schedule[new DateTime(2020, 1, 3)];
            Assert.Contains("William", entry);
            Assert.Single(entry);

            entry = schedule[new DateTime(2020, 1, 4)];
            Assert.Contains("William", entry);
            Assert.Single(entry);

            entry = schedule[new DateTime(2020, 1, 5)];
            Assert.Contains("William", entry);
            Assert.Single(entry);

            entry = schedule[new DateTime(2020, 1, 6)];
            Assert.Contains("George", entry);
            Assert.Contains("William", entry);
            Assert.Equal(2, entry.Count);
        }
    }
Ejemplo n.º 2
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            WorkDB   db = new WorkDB();
            EveryDay ed = new EveryDay();

            foreach (var c in elemAdd)
            {
                if (c.GetType() == typeof(TextBox))
                {
                    if ((c as TextBox).Name == "weight")
                    {
                        ed.weight = Convert.ToDouble((c as TextBox).Text);
                    }
                    if ((c as TextBox).Name == "height")
                    {
                        ed.heiht = Convert.ToDouble((c as TextBox).Text);
                    }
                    if ((c as TextBox).Name == "temperature")
                    {
                        ed.temperature = Convert.ToDouble((c as TextBox).Text);
                    }
                }
                if (c.GetType() == typeof(Slider))
                {
                    if ((c as Slider).Name == "rashes")
                    {
                        ed.rashes = Convert.ToInt16((c as Slider).Value);
                    }
                    if ((c as Slider).Name == "abdominalDistention")
                    {
                        ed.abdominalDistention = Convert.ToInt16((c as Slider).Value);
                    }
                    if ((c as Slider).Name == "play")
                    {
                        ed.playing = Convert.ToInt16((c as Slider).Value);
                    }
                    if ((c as Slider).Name == "cry")
                    {
                        ed.crying = Convert.ToInt16((c as Slider).Value);
                    }
                    if ((c as Slider).Name == "locking")
                    {
                        ed.locking = Convert.ToInt16((c as Slider).Value);
                    }
                    if ((c as Slider).Name == "gas")
                    {
                        ed.gas = Convert.ToInt16((c as Slider).Value);
                    }
                    if ((c as Slider).Name == "diareya")
                    {
                        ed.diareya = Convert.ToInt16((c as Slider).Value);
                    }
                }
                if (c.GetType() == typeof(DatePicker))
                {
                    ed.date = Convert.ToDateTime((c as DatePicker).Date.Date);
                }
                if (c.GetType() == typeof(RichEditBox))
                {
                    string str;
                    (c as RichEditBox).Document.GetText(Windows.UI.Text.TextGetOptions.None, out str);
                    ed.description = str;
                }
            }
            db.InsertEveryDay(ed);
            var dlg = new MessageDialog("Добавление записи завершенно.");

            dlg.ShowAsync();
        }
Ejemplo n.º 3
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     param = e.Parameter as EveryDay;
     base.OnNavigatedTo(e);
 }
Ejemplo n.º 4
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            WorkDB   db = new WorkDB();
            EveryDay ed = param;

            ed.id = param.id;
            foreach (var c in elemEdit)
            {
                if (c.GetType() == typeof(TextBox))
                {
                    if ((c as TextBox).Name == "weight")
                    {
                        if ((c as TextBox).Text != "")
                        {
                            ed.weight = Convert.ToDouble((c as TextBox).Text);
                        }
                        else
                        {
                            new MessageDialog("Поле вес должно быть заполнено.").ShowAsync();
                            return;
                        }
                    }
                    if ((c as TextBox).Name == "height")
                    {
                        if ((c as TextBox).Text != "")
                        {
                            ed.heiht = Convert.ToDouble((c as TextBox).Text);
                        }
                        else
                        {
                            new MessageDialog("Поле рост должно быть заполнено.").ShowAsync();
                            return;
                        }
                    }
                    if ((c as TextBox).Name == "temperature")
                    {
                        if ((c as TextBox).Text != "")
                        {
                            ed.temperature = Convert.ToDouble((c as TextBox).Text);
                        }
                        else
                        {
                            new MessageDialog("Поле температура должно быть заполнено.").ShowAsync();
                            return;
                        }
                    }
                }
                if (c.GetType() == typeof(Slider))
                {
                    if ((c as Slider).Name == "rashes")
                    {
                        ed.rashes = Convert.ToInt16((c as Slider).Value);
                    }
                    if ((c as Slider).Name == "abdominalDistention")
                    {
                        ed.abdominalDistention = Convert.ToInt16((c as Slider).Value);
                    }
                    if ((c as Slider).Name == "play")
                    {
                        ed.playing = Convert.ToInt16((c as Slider).Value);
                    }
                    if ((c as Slider).Name == "cry")
                    {
                        ed.crying = Convert.ToInt16((c as Slider).Value);
                    }
                    if ((c as Slider).Name == "locking")
                    {
                        ed.locking = Convert.ToInt16((c as Slider).Value);
                    }
                    if ((c as Slider).Name == "gas")
                    {
                        ed.gas = Convert.ToInt16((c as Slider).Value);
                    }
                    if ((c as Slider).Name == "diareya")
                    {
                        ed.diareya = Convert.ToInt16((c as Slider).Value);
                    }
                }
                if (c.GetType() == typeof(DatePicker))
                {
                    ed.date = Convert.ToDateTime((c as DatePicker).Date.Date);
                }
                if (c.GetType() == typeof(RichEditBox))
                {
                    string str;
                    (c as RichEditBox).Document.GetText(Windows.UI.Text.TextGetOptions.None, out str);
                    ed.description = str;
                }
            }
            db.UpdateEveryDay(ed);
            var dlg = new MessageDialog("Сохранение записи завершенно.");

            dlg.ShowAsync();
            this.Frame.Navigate(typeof(MainPage));
        }
Ejemplo n.º 5
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            string   mess = "";
            EveryDay ed   = new EveryDay();

            ed.abdominalDistention = (Int16)abdominalDistention.Value;
            ed.crying = (Int16)crying.Value;
            ed.date   = date.Date.Date;
            string str;

            description.Document.GetText(Windows.UI.Text.TextGetOptions.None, out str);
            ed.description = str;
            ed.diareya     = (Int16)diareya.Value;
            ed.gas         = (Int16)gaz.Value;
            if (height.Text != "")
            {
                ed.heiht = Convert.ToDouble(height.Text);
            }
            else
            {
                new Windows.UI.Popups.MessageDialog("Поле рост должно быть заполнено.").ShowAsync();
                return;
            }
            ed.locking = (Int16)locking.Value;
            ed.playing = (Int16)playing.Value;
            ed.rashes  = (Int16)rashes.Value;
            if (temperature.Text != "")
            {
                ed.temperature = Convert.ToDouble(temperature.Text);
            }
            else
            {
                new Windows.UI.Popups.MessageDialog("Поле температура должно быть заполнено.").ShowAsync();
                return;
            }
            if (weight.Text != "")
            {
                ed.weight = Convert.ToDouble(weight.Text);
            }
            else
            {
                new Windows.UI.Popups.MessageDialog("Поле вес должно быть заполнено.").ShowAsync();
                return;
            }
            ed.id_child = CurrentChild.id;

            WorkDB db = new WorkDB();

            try
            {
                db.InsertEveryDay(ed);
            }
            catch (Exception ex)
            {
                mess = ("Возникла ошибка при сохранении. Повторите попытку!");
            }
            if (mess == "")
            {
                var dlg = new Windows.UI.Popups.MessageDialog("Данные успешно сохранены !");
                dlg.ShowAsync();
                this.Frame.Navigate(typeof(MainPage));
            }
            else
            {
                var dlg = new Windows.UI.Popups.MessageDialog(str);
                dlg.ShowAsync();
                this.Frame.Navigate(typeof(MainPage));
            }
        }