示例#1
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            WorkDB  db = new WorkDB();
            Vaccine v  = new Vaccine();
            Doctor  d  = new Doctor();

            BabySitter.DataModel.Action a = new DataModel.Action();
            int      str = -1;
            DateTime dt  = new DateTime();
            string   s   = "";

            foreach (var cc in elemAdd)
            {
                if (cc.GetType() == typeof(ComboBox))
                {
                    str = (cc as ComboBox).SelectedIndex;
                }
                if (cc.GetType() == typeof(DatePicker))
                {
                    dt = (cc as DatePicker).Date.Date;
                }
                if (cc.GetType() == typeof(RichEditBox))
                {
                    (cc as RichEditBox).Document.GetText(Windows.UI.Text.TextGetOptions.None, out s);
                }
                if (cc.GetType() == typeof(Grid))
                {
                    if ((cc as Grid).Name == "vaccine")
                    {
                        foreach (var c in (cc as Grid).Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if ((c as TextBox).Name == "cabinet_v")
                                {
                                    v.cabinet = (c as TextBox).Text;
                                }
                                if ((c as TextBox).Name == "telephone_v")
                                {
                                    v.phone = (c as TextBox).Text;
                                }
                                if ((c as TextBox).Name == "vaccin")
                                {
                                    v.vaccine = (c as TextBox).Text;
                                }
                                if ((c as TextBox).Name == "fio_v")
                                {
                                    v.fio = (c as TextBox).Text;
                                }
                            }
                        }
                    }

                    if ((cc as Grid).Name == "doctor")
                    {
                        foreach (var c in (cc as Grid).Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if ((c as TextBox).Name == "cabinet_d")
                                {
                                    d.cabinet = (c as TextBox).Text;
                                }
                                if ((c as TextBox).Name == "telephone_d")
                                {
                                    d.phone = (c as TextBox).Text;
                                }
                                if ((c as TextBox).Name == "doc")
                                {
                                    d.doctor = (c as TextBox).Text;
                                }
                                if ((c as TextBox).Name == "fio_d")
                                {
                                    v.fio = (c as TextBox).Text;
                                }
                            }
                        }
                    }

                    if ((cc as Grid).Name == "action")
                    {
                        foreach (var c in (cc as Grid).Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if ((c as TextBox).Name == "place")
                                {
                                    a.place = (c as TextBox).Text;
                                }
                            }
                        }
                    }
                }
            }

            if (str == 0)
            {
                db.InsertReminderVaccine(v, dt, s);
                var dlg = new Windows.UI.Popups.MessageDialog("Данные успешно сохранены !");
                dlg.ShowAsync();
                this.Frame.Navigate(typeof(MainPage));
            }
            if (str == 1)
            {
                db.InsertReminderDoctor(d, dt, s);
                var dlg = new Windows.UI.Popups.MessageDialog("Данные успешно сохранены !");
                dlg.ShowAsync();
                this.Frame.Navigate(typeof(MainPage));
            }
            if (str == 2)
            {
                db.InsertReminderAction(a, dt, s);
                var dlg = new Windows.UI.Popups.MessageDialog("Данные успешно сохранены !");
                dlg.ShowAsync();
                this.Frame.Navigate(typeof(MainPage));
            }
        }
示例#2
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            delToast();

            WorkDB  db = new WorkDB();
            Vaccine v  = new Vaccine();
            Doctor  d  = new Doctor();

            BabySitter.DataModel.Action a = new DataModel.Action();
            int      str = -1;
            DateTime dt  = new DateTime();
            DateTime t   = new DateTime();
            string   s   = "";

            foreach (var cc in elemEdit)
            {
                if (cc.GetType() == typeof(ComboBox))
                {
                    str = (cc as ComboBox).SelectedIndex;
                }
                if (cc.GetType() == typeof(DatePicker))
                {
                    dt = (cc as DatePicker).Date.Date;
                }
                if (cc.GetType() == typeof(TimePicker))
                {
                    dt = Convert.ToDateTime(String.Format("{0:dd/MM/yyyy} {1:t}", dt.Date.Date, (cc as TimePicker).Time));
                }
                if (cc.GetType() == typeof(RichEditBox))
                {
                    (cc as RichEditBox).Document.GetText(Windows.UI.Text.TextGetOptions.None, out s);
                }
                if (cc.GetType() == typeof(Grid))
                {
                    if ((cc as Grid).Name == "vaccine")
                    {
                        foreach (var c in (cc as Grid).Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if ((c as TextBox).Name == "cabinet_v")
                                {
                                    v.cabinet = (c as TextBox).Text;
                                }
                                if ((c as TextBox).Name == "telephone_v")
                                {
                                    v.phone = (c as TextBox).Text;
                                }
                                if ((c as TextBox).Name == "vaccin")
                                {
                                    v.vaccine = (c as TextBox).Text;
                                }
                                if ((c as TextBox).Name == "fio_v")
                                {
                                    v.fio = (c as TextBox).Text;
                                }
                            }
                        }
                    }

                    if ((cc as Grid).Name == "doctor")
                    {
                        foreach (var c in (cc as Grid).Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if ((c as TextBox).Name == "cabinet_d")
                                {
                                    d.cabinet = (c as TextBox).Text;
                                }
                                if ((c as TextBox).Name == "telephone_d")
                                {
                                    d.phone = (c as TextBox).Text;
                                }
                                if ((c as TextBox).Name == "doc")
                                {
                                    d.doctor = (c as TextBox).Text;
                                }
                                if ((c as TextBox).Name == "fio_d")
                                {
                                    d.fio = (c as TextBox).Text;
                                }
                            }
                        }
                    }

                    if ((cc as Grid).Name == "action")
                    {
                        foreach (var c in (cc as Grid).Children)
                        {
                            if (c.GetType() == typeof(TextBox))
                            {
                                if ((c as TextBox).Name == "place")
                                {
                                    a.place = (c as TextBox).Text;
                                }
                            }
                        }
                    }
                }
            }
            if (param.stype == "Прививка")
            {
                db.DeleteReminderV(param.type);
            }
            if (param.stype == "Мероприятие")
            {
                db.DeleteReminderA(param.type);
            }
            if (param.stype == "Прием врача")
            {
                db.DeleteReminderD(param.type);
            }

            if (str == 0)
            {
                //   db.DeleteReminderV(param.type);
                db.UpdateReminderV(v, dt, s, param);
                param.stype = "Прививка";
                createToast();
                var dlg = new Windows.UI.Popups.MessageDialog("Данные успешно сохранены !");
                dlg.ShowAsync();
                this.Frame.Navigate(typeof(MainPage));
            }
            if (str == 1)
            {
                //  db.DeleteReminderD(param.type);
                db.UpdateReminderD(d, dt, s, param);
                param.stype = "Прием врача";
                createToast();
                var dlg = new Windows.UI.Popups.MessageDialog("Данные успешно сохранены !");
                dlg.ShowAsync();
                this.Frame.Navigate(typeof(MainPage));
            }
            if (str == 2)
            {
                //   db.DeleteReminderA(param.type);
                if (geo.Latitude != 0.0 && geo.Longitude != 0.0)
                {
                    a.Latitude  = geo.Latitude;
                    a.Longitude = geo.Longitude;
                }
                db.UpdateReminderA(a, dt, s, param);
                param.stype = "Мероприятие";
                createToast();
                var dlg = new Windows.UI.Popups.MessageDialog("Данные успешно сохранены !");
                dlg.ShowAsync();
                this.Frame.Navigate(typeof(MainPage));
            }
        }
        private async void Add_Click(object sender, RoutedEventArgs e)
        {
            string str;

            description.Document.GetText(Windows.UI.Text.TextGetOptions.None, out str);
            DateTime dt = Convert.ToDateTime(String.Format("{0:dd/MM/yyyy} {1:t}", date.Date.Date, time.Time));
            WorkDB   db = new WorkDB();

            if (stype.SelectedIndex == 0)
            {
                Vaccine vac = new Vaccine();
                vac.cabinet = cabinet_v.Text;
                vac.phone   = telephone_v.Text;
                vac.vaccine = vaccin.Text;
                vac.fio     = fio_v.Text;

                db.InsertReminderVaccine(vac, dt, str);
            }
            if (stype.SelectedIndex == 1)
            {
                Doctor doct = new Doctor();
                doct.cabinet = cabinet_d.Text;
                doct.doctor  = doc.Text;
                doct.fio     = fio_d.Text;
                doct.phone   = telephone_d.Text;

                db.InsertReminderDoctor(doct, dt, str);
            }
            if (stype.SelectedIndex == 2)
            {
                DataModel.Action act = new DataModel.Action();
                act.place = place.Text;


                act.Latitude  = geo.Latitude;
                act.Longitude = geo.Longitude;

                db.InsertReminderAction(act, dt, str);
            }

            // Set up the notification text.
            var toastXml = Windows.UI.Notifications.ToastNotificationManager.GetTemplateContent(Windows.UI.Notifications.ToastTemplateType.ToastText02);
            var strings  = toastXml.GetElementsByTagName("text");

            strings[0].AppendChild(toastXml.CreateTextNode((stype.SelectedIndex == 0 ? "Прививка" : stype.SelectedIndex == 1 ? "Прием врача" : "Мероприятие")));
            strings[1].AppendChild(toastXml.CreateTextNode("Время: " + dt.ToString()));

            // Create the toast notification object.
            try
            {
                var           toast = new Windows.UI.Notifications.ScheduledToastNotification(toastXml, dt);
                ToastNotifier not   = ToastNotificationManager.CreateToastNotifier();
                var           v     = not.GetScheduledToastNotifications();
                not.AddToSchedule(toast);
            }
            catch (Exception ex)
            {
            }
            var dlg = new MessageDialog("Данные успешно сохранены !");

            dlg.ShowAsync();
            this.Frame.Navigate(typeof(MainPage));
        }