Ejemplo n.º 1
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Reminders reminder = new Reminders();

                reminder.note       = listMed.Text;
                reminder.dateStart  = DateTime.Parse(dateStart_box.Text);
                reminder.dateFinish = DateTime.Parse(dateFinish_box.Text);
                reminder.time       = DateTime.Parse(time_box.Text);

                reminder.UserId = MainClass.ID;

                using (DBToHealth db = new DBToHealth())
                {
                    db.Reminders.Add(reminder);
                    db.SaveChanges();
                }

                MessageBox.Show("Напоминание сохранено!");

                MainClass.MW.frame.NavigationService.Navigate(new Uri("Pages/Therapy.xaml", UriKind.Relative));
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Ejemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            using (DBToHealth db = new DBToHealth())
            {
                var userInfo = db.UserInfo.FirstOrDefault(p => p.UserId == MainClass.ID);
                userInfo.weight = int.Parse(Weight.Text);
                db.Entry(userInfo);
                db.SaveChanges();
            }

            MainClass.MW.frame.NavigationService.Navigate(new Uri("Therapy.xaml", UriKind.Relative));
            this.Close();
        }
Ejemplo n.º 3
0
        public Medicament()
        {
            InitializeComponent();

            using (DBToHealth db = new DBToHealth())
            {
                var medicament = db.Medicaments;

                foreach (Medicaments p in medicament)
                {
                    listMed.Items.Add(p.medName);
                }
            }
        }
Ejemplo n.º 4
0
        private async void Timer_ElapsedAsync(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                using (DBToHealth db = new DBToHealth())
                {
                    var reminders = db.Reminders.Where(p => p.UserId == MainClass.ID && p.fulfillment == 0).OrderBy(p => p.time);
                    reminders.First();

                    foreach (Reminders p in reminders)
                    {
                        if ((DateTime.Parse(p.dateStart.ToShortDateString()) <= dt) && (dt <= DateTime.Parse(p.dateFinish.ToShortDateString())))
                        {
                            DateTime now = DateTime.Parse(DateTime.Now.ToShortTimeString());

                            if (DateTime.Parse(p.time.ToShortTimeString()) == now)
                            {
                                if (MessageBox.Show(p.note, "", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                                {
                                    var reminder = db.Reminders.Find(p.RemindersId);
                                    reminder.fulfillment = -1;

                                    db.Entry(reminder).State = System.Data.Entity.EntityState.Modified;

                                    MessageBox.Show("Не выполнено!");

                                    break;
                                }
                                else
                                {
                                    var reminder = db.Reminders.Find(p.RemindersId);
                                    reminder.fulfillment = 1;

                                    db.Entry(reminder).State = System.Data.Entity.EntityState.Modified;

                                    MessageBox.Show("Выполнено!");

                                    break;
                                }
                            }
                        }
                    }
                    await db.SaveChangesAsync();

                    Timer_ElapsedAsync(sender, e);
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Ejemplo n.º 5
0
        public Profile()
        {
            InitializeComponent();

            using (DBToHealth db = new DBToHealth())
            {
                UserInfo userInfo = db.UserInfo.FirstOrDefault(p => p.UserId == MainClass.ID);

                name.Text   = userInfo.name;
                email.Text  = userInfo.email;
                bday.Text   = userInfo.bday.ToShortDateString();
                gender.Text = userInfo.gender;
                height.Text = userInfo.height.ToString();
                weight.Text = userInfo.weight.ToString();
            }
        }
Ejemplo n.º 6
0
        public Today()
        {
            InitializeComponent();

            List <Reminders> rp = new List <Reminders>();

            using (DBToHealth db = new DBToHealth())
            {
                var r = db.Reminders.Where(p => p.UserId == MainClass.ID && p.dateStart <= dt && dt <= p.dateFinish);

                foreach (Reminders u in r)
                {
                    rp.Add(u);
                }
            }
            noteGrid.ItemsSource = rp;
        }
Ejemplo n.º 7
0
        public Journal()
        {
            InitializeComponent();
            PointLabel = chartPoint =>
                         string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);

            using (DBToHealth db = new DBToHealth())
            {
                var dones = db.Reminders.Where(p => p.UserId == MainClass.ID && p.fulfillment == 1).Select(p => p);
                var skipp = db.Reminders.Where(p => p.UserId == MainClass.ID && p.fulfillment == -1).Select(p => p);
                done.Values = new ChartValues <int>(new List <int> {
                    dones.Count()
                });
                skipped.Values = new ChartValues <int>(new List <int> {
                    skipp.Count()
                });
            }
            DataContext = this;
        }
Ejemplo n.º 8
0
        private void enterButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string logins    = Log.Text;
                string passwords = Password.Password;

                using (DBToHealth db = new DBToHealth())
                {
                    User user = db.Users.FirstOrDefault(p => p.login == logins);

                    if (user == null)
                    {
                        MessageBox.Show("");
                        return;
                    }
                    if (user.password == passwords)
                    {
                        User person = db.Users.FirstOrDefault(p => p.login == logins);

                        MainWindow mainWindow = new MainWindow();
                        mainWindow.Show();
                        MainClass.ID = person.UserId;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Неверный пароль!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 9
0
        private void registrationButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                User user = new User();

                user.login    = box_nick.Text;
                user.password = box_password.Password;

                UserInfo userInfo = new UserInfo();

                userInfo.name   = box_name.Text;
                userInfo.email  = box_email.Text;
                userInfo.bday   = DateTime.Parse(box_bday.Text);
                userInfo.gender = box_gender.Text;
                userInfo.height = int.Parse(box_height.Text);
                userInfo.weight = int.Parse(box_weight.Text);

                user.userInfo = userInfo;


                using (DBToHealth db = new DBToHealth())
                {
                    db.Users.Add(user);
                    db.UserInfo.Add(userInfo);
                    db.SaveChanges();
                }

                MessageBox.Show("Вы зарегистрированы!");

                Login login = new Login();
                login.Show();
                this.Close();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }