Example #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); }
        }
Example #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();
        }
Example #3
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); }
        }