private void HistoryButton(object sender, RoutedEventArgs e)
        {
            using (MyDbContext db = new MyDbContext())
            {
                User    thisUser = db.Users.Find(App.CurrentUser.Id);
                MedCard a        = new MedCard();
                a = db.MedCards.Where(b => b.BDay != null && b.ID == thisUser.Id).FirstOrDefault();
                if (a != null)
                {
                    if (ButtonCloseMenu.Visibility == Visibility.Visible)
                    {
                        ButtonOpenMenu.Visibility  = Visibility.Visible;
                        ButtonCloseMenu.Visibility = Visibility.Collapsed;

                        //GridMain.Children.Clear();
                        GridMain.Children.Add(new HistotyVisitingWindow(this));
                    }
                    else
                    {
                        //GridMain.Children.Clear();
                        GridMain.Children.Add(new HistotyVisitingWindow(this));
                    }
                }
                else
                {
                    MaterialMessageBox.Show("У вас не может быть истории посещений, т.к. вы не заполнили личную карточку ", "Уведомление");
                    if (ButtonCloseMenu.Visibility == Visibility.Visible)
                    {
                        ButtonOpenMenu.Visibility  = Visibility.Visible;
                        ButtonCloseMenu.Visibility = Visibility.Collapsed;
                    }
                }
            }
        }
        private void RecordingButton(object sender, RoutedEventArgs e)
        {
            using (MyDbContext db = new MyDbContext())
            {
                User    thisUser = db.Users.Find(App.CurrentUser.Id);
                MedCard a        = new MedCard();
                a = db.MedCards.Where(b => b.BDay != null && b.ID == thisUser.Id).FirstOrDefault();
                if (a != null)
                {
                    if (ButtonCloseMenu.Visibility == Visibility.Visible)
                    {
                        ButtonOpenMenu.Visibility  = Visibility.Visible;
                        ButtonCloseMenu.Visibility = Visibility.Collapsed;

                        //GridMain.Children.Clear();
                        GridMain.Children.Add(new RecordingWindow(this));
                    }
                    else
                    {
                        //GridMain.Children.Clear();
                        GridMain.Children.Add(new RecordingWindow(this));
                    }
                }
                else
                {
                    MaterialMessageBox.Show("Заполните личную карточку, чтобы записаться к врачу", "Уведомление");
                    if (ButtonCloseMenu.Visibility == Visibility.Visible)
                    {
                        ButtonOpenMenu.Visibility  = Visibility.Visible;
                        ButtonCloseMenu.Visibility = Visibility.Collapsed;
                    }
                }
            }
        }
Example #3
0
 //вывод информации
 void ShowInfo()
 {
     try
     {
         using (MyDbContext db = new MyDbContext())
         {
             User thisUser = db.Users.Find(App.CurrentUser.Id);
             MedCardNumber.Content = "№ " + thisUser.Id.ToString();
             MedCard a = new MedCard();
             a = db.MedCards.Where(b => b.ID == thisUser.Id).FirstOrDefault();
             if (a != null)
             {
                 Name_textbox.Text       = db.MedCards.Find(thisUser.Id).Name.Trim();
                 Surname_textbox.Text    = db.MedCards.Find(thisUser.Id).Surname.Trim();
                 Patronymic_textbox.Text = db.MedCards.Find(thisUser.Id).Patronymic.Trim();
                 Gender.Text             = db.MedCards.Find(thisUser.Id).Gender.Trim();
                 Bday_textbox.Text       = db.MedCards.Find(thisUser.Id).BDay.ToShortDateString();
                 City_textbox.Text       = db.MedCards.Find(thisUser.Id).City.Trim();
                 Street_textbox.Text     = db.MedCards.Find(thisUser.Id).Street.Trim();
                 House_textbox.Text      = Convert.ToString(db.MedCards.Find(thisUser.Id).House);
                 Housing.Text            = db.MedCards.Find(thisUser.Id).Housing.Trim();
                 Flat_textbox.Text       = db.MedCards.Find(thisUser.Id).Flat.Trim();
                 PathImage              = db.MedCards.Find(thisUser.Id).Image;
                 AdMainImage.Source     = new BitmapImage(new Uri(PathImage, UriKind.Absolute));
                 Border.BorderThickness = new Thickness(0);
             }
             else
             {
                 MaterialMessageBox.Show("Заполните личную карточку", "Уведомление");
             }
         }
     }
     catch (Exception) { }
 }
        //вывод информации
        void ShowInfo()
        {
            try
            {
                using (MyDbContext db = new MyDbContext())
                {
                    card = db.MedCards.Where(b => b.ID == userr.Id).FirstOrDefault();
                    if (card != null)
                    {
                        Name_textbox.Text       = db.MedCards.Find(userr.Id).Name.Trim();
                        Surname_textbox.Text    = db.MedCards.Find(userr.Id).Surname.Trim();
                        Patronymic_textbox.Text = db.MedCards.Find(userr.Id).Patronymic.Trim();
                        Gender.Text             = db.MedCards.Find(userr.Id).Gender.Trim();
                        Bday_textbox.Text       = db.MedCards.Find(userr.Id).BDay.ToShortDateString();
                        City_textbox.Text       = db.MedCards.Find(userr.Id).City.Trim();
                        Street_textbox.Text     = db.MedCards.Find(userr.Id).Street.Trim();
                        House_textbox.Text      = Convert.ToString(db.MedCards.Find(userr.Id).House);
                        Housing.Text            = db.MedCards.Find(userr.Id).Housing.Trim();
                        Flat_textbox.Text       = db.MedCards.Find(userr.Id).Flat.Trim();
                        PathImage              = db.MedCards.Find(userr.Id).Image;
                        AdMainImage.Source     = new BitmapImage(new Uri(PathImage, UriKind.Absolute));
                        Border.BorderThickness = new Thickness(0);
                    }

                    //var users = (from user in db.Users
                    //             select user).ToList();
                }
            }
            catch (Exception) { }
        }
        //Сохранение/Изменение
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (MyDbContext db = new MyDbContext())
                {
                    MedCard test = db.MedCards.FirstOrDefault(p => p.ID == userr.Id);

                    if (Bday_textbox.SelectedDate <= DateTime.Now.Date && Bday_textbox.SelectedDate > DateTime.Now.AddYears(-150).Date)
                    {
                        if (test == null)
                        {
                            MedCard card = new MedCard();
                            card.ID         = userr.Id;
                            card.Name       = Name_textbox.Text;
                            card.Surname    = Surname_textbox.Text;
                            card.Patronymic = Patronymic_textbox.Text;
                            card.Gender     = Gender.Text;
                            card.BDay       = DateTime.ParseExact(Bday_textbox.Text, "dd.MM.yyyy",
                                                                  System.Globalization.CultureInfo.InvariantCulture);
                            card.City    = City_textbox.Text;
                            card.Street  = Street_textbox.Text;
                            card.House   = Convert.ToInt32(House_textbox.Text);
                            card.Housing = Housing.Text;
                            card.Flat    = Flat_textbox.Text;
                            card.Image   = PathImage;
                            db.MedCards.AddRange(new List <MedCard> {
                                card
                            });
                            db.SaveChanges();
                            MaterialMessageBox.Show("Сохранение/Изменение прошло успешна", "Уведомление");
                        }
                        else
                        {
                            db.MedCards.Find(userr.Id).Name       = Name_textbox.Text.Trim();
                            db.MedCards.Find(userr.Id).Surname    = Surname_textbox.Text.Trim();
                            db.MedCards.Find(userr.Id).Patronymic = Patronymic_textbox.Text.Trim();
                            db.MedCards.Find(userr.Id).Gender     = Gender.Text.Trim();
                            db.MedCards.Find(userr.Id).BDay       = DateTime.ParseExact(Bday_textbox.Text, "dd.MM.yyyy",
                                                                                        System.Globalization.CultureInfo.InvariantCulture);
                            db.MedCards.Find(userr.Id).City    = City_textbox.Text.Trim();
                            db.MedCards.Find(userr.Id).Street  = Street_textbox.Text.Trim();
                            db.MedCards.Find(userr.Id).House   = Convert.ToInt32(House_textbox.Text);
                            db.MedCards.Find(userr.Id).Housing = Housing.Text.Trim();
                            db.MedCards.Find(userr.Id).Flat    = Flat_textbox.Text.Trim();
                            db.MedCards.Find(userr.Id).Image   = PathImage;
                            AdMainImage.Source = new BitmapImage(new Uri(PathImage, UriKind.Absolute));
                            db.SaveChanges();
                            MaterialMessageBox.Show("Сохранение/Изменение прошло успешна", "Уведомление");
                        }
                    }
                    else
                    {
                        MaterialMessageBox.Show("Некорретная дата, попробуйте ещё раз", "Уведомление");
                        Bday_textbox.Text = "";
                    }
                }
            }
            catch (Exception ex) { MaterialMessageBox.Show("Упс.. Что-то пошло не так", "Уведомление"); }
        }
 public EditViewModel(int id, int client_id, string weight, string recommend, string height, string problems, string bodytype)
 {
     // инициализация для автозаполнения контролов и последующего неоходимого изменения
     medCard_field = new MedCard()
     {
         BodyType = bodytype, Client_Id = client_id, Height = height, Id = id, Problems = problems, Recommend = recommend, Weight = weight
     };
 }
Example #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            MedCard medCard = db.MedCardSet.Find(id);

            db.MedCardSet.Remove(medCard);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public AdminOpenCardPacient(User user) : this()
 {
     userr = user;
     MedCardNumber.Content = "№ " + userr.Id.ToString();
     using (MyDbContext db = new MyDbContext())
     {
         card = db.MedCards.Where(b => b.ID == userr.Id).FirstOrDefault();
     }
     ShowInfo();
 }
Example #9
0
 public ActionResult Edit([Bind(Include = "Id")] MedCard medCard)
 {
     if (ModelState.IsValid)
     {
         db.Entry(medCard).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(medCard));
 }
Example #10
0
        public ActionResult Create([Bind(Include = "Id")] MedCard medCard)
        {
            if (ModelState.IsValid)
            {
                db.MedCardSet.Add(medCard);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(medCard));
        }
Example #11
0
        // GET: MedCards/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MedCard medCard = db.MedCardSet.Find(id);

            if (medCard == null)
            {
                return(HttpNotFound());
            }
            return(View(medCard));
        }
Example #12
0
        private void buttonRemove_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // check patient was chosen in list
                if (datagridPatiens.SelectedItems.Count <= 0)
                {
                    return;
                }

                // get selected patient
                User    pacient = datagridPatiens.SelectedItem as User;
                MedCard card    = new MedCard();
                // show confirmation message box

                if (MessageBox.Show($"Вы уверенны, что хотите удалить {pacient.FirstName + " " + pacient.Surname} ?",
                                    "Подтвердите", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    using (MyDbContext db = new MyDbContext())
                    {
                        // save position to restore
                        int selectedIndex = datagridPatiens.SelectedIndex;
                        pacient = db.Users.FirstOrDefault(p => p.Id == pacient.Id);
                        card    = db.MedCards.FirstOrDefault(p => p.ID == pacient.Id);
                        // find patient in db
                        if (card == null)
                        {
                            db.Users.Remove(pacient);
                        }
                        else
                        {
                            db.Users.Remove(pacient);
                            db.MedCards.Remove(card);
                        }

                        // save
                        db.SaveChanges();
                        // update data grid list
                        fillDataFromDBtoDatagrid();
                        // scroll patient list to the previous position
                        //datagridPatiens.ScrollIntoView(datagridPatiens.Items[Math.Min(selectedIndex, datagridPatiens.Items.Count - 1)]);
                        // popup notification
                        MaterialMessageBox.Show("Пациент удалён");
                    }
                }
            }
            catch (Exception ex) { }
        }
Example #13
0
        //подтверждение посещения
        private void ConfirmVisited_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                User pacient = datagridPatiens.SelectedItem as User;
                using (MyDbContext db = new MyDbContext())
                {
                    // check patient was chosen in list
                    if (datagridPatiens.SelectedItems.Count <= 0)
                    {
                        return;
                    }

                    MedCard card = new MedCard();
                    card = db.MedCards.Where(b => b.ID == pacient.Id).FirstOrDefault();
                    if (card != null)
                    {
                        // open add patient window with filled fields
                        ConfirmUsersVisiting addEditWindow = new ConfirmUsersVisiting(datagridPatiens.SelectedItem as User);
                        addEditWindow.Title = "Graphics";

                        // update data grid if patient was changed
                        if (addEditWindow.ShowDialog() == true)
                        {
                            // save position to restore
                            int selectedIndex = datagridPatiens.SelectedIndex;

                            fillDataFromDBtoDatagrid();
                            // focus on the changed patient from saved position
                            datagridPatiens.SelectedIndex = selectedIndex;
                            // scroll patient list to the changed patient
                            datagridPatiens.ScrollIntoView(datagridPatiens.SelectedItem);
                            // popup notification
                        }
                    }
                    else
                    {
                        MaterialMessageBox.Show("У этого пользователя не может быть посещений, т.к. нету личной карточки", "Уведомление");
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Example #14
0
        //открыть карту пациента
        private void Clicl_OpenCardPacient(object sender, RoutedEventArgs e)
        {
            try
            {
                User pacient = datagridPatiens.SelectedItem as User;
                using (MyDbContext db = new MyDbContext())
                {
                    // check patient was chosen in list
                    if (datagridPatiens.SelectedItems.Count <= 0)
                    {
                        return;
                    }

                    MedCard card = new MedCard();
                    card = db.MedCards.Where(b => b.ID == pacient.Id).FirstOrDefault();

                    // open add patient window with filled fields
                    AdminOpenCardPacient addEditWindow = new AdminOpenCardPacient(datagridPatiens.SelectedItem as User);

                    // update data grid if patient was changed
                    if (addEditWindow.ShowDialog() == true)
                    {
                        // save position to restore
                        int selectedIndex = datagridPatiens.SelectedIndex;

                        fillDataFromDBtoDatagrid();
                        // focus on the changed patient from saved position
                        datagridPatiens.SelectedIndex = selectedIndex;
                        // scroll patient list to the changed patient
                        datagridPatiens.ScrollIntoView(datagridPatiens.SelectedItem);
                        // popup notification
                    }
                }
            }
            catch (Exception)
            {
            }
        }