Beispiel #1
0
        public DiagnosisViewModel()
        {
            DownloadDiagnosings();

            EditDiagnos = new DelegateCommand(() =>
            {
                editoradd = false;
                selectedDiagnos?.BeginEdit();

                var w         = new DiagnosisEdit();
                w.DataContext = this;
                w.ShowDialog();
            }, () => selectedDiagnos != null);


            AddDiagnos = new DelegateCommand(() =>
            {
                editoradd = true;

                Diagnosis diagnosis = new Diagnosis();
                SelectedDiagnos     = diagnosis;

                var w         = new DiagnosisEdit();
                w.DataContext = this;
                w.ShowDialog();
            });

            SaveDiagnos = new DelegateCommand(() =>
            {
                if (editoradd == true)
                {
                    context.Diagnosis.Add(selectedDiagnos);

                    context.SaveChanges();

                    Diagnosings.Add(SelectedDiagnos);
                }
                else
                {
                    context.Entry(SelectedDiagnos).State = EntityState.Modified;
                    context.SaveChanges();
                }
            });

            RemoveDiagnos = new DelegateCommand(() =>
            {
                if (MessageBox.Show("Удалить?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    context.Entry(selectedDiagnos).State = EntityState.Deleted;
                    context.SaveChanges();
                    Diagnosings.Remove(selectedDiagnos);
                }
                else
                {
                    return;
                }
            }, () => selectedDiagnos != null);

            CanselEdit = new DelegateCommand(() =>
            {
                if (editoradd == false)
                {
                    if (selectedDiagnos == null)
                    {
                        return;
                    }
                    SelectedDiagnos.CancelEdit();
                }
                else
                {
                    return;
                }
            });
        }
Beispiel #2
0
        public EmployeeViewModel()
        {
            DownloadEmployees();

            FilterCollectionView.Filter = i =>
            {
                if (_searchKey == "" || _searchKey == null)
                {
                    return(true);
                }
                if (string.IsNullOrEmpty(FilterString))
                {
                    return(true);
                }
                if (_searchKey == "Фамилия")
                {
                    Employee m = i as Employee;
                    return(m.Surname.ToString().StartsWith(FilterString));
                }
                if (_searchKey == "Имя")
                {
                    Employee m = i as Employee;
                    return(m.Name.ToString().StartsWith(FilterString));
                }
                if (_searchKey == "Отчество")
                {
                    Employee m = i as Employee;
                    return(m.Patronymic.ToString().StartsWith(FilterString));
                }
                if (_searchKey == "Город")
                {
                    Employee m = i as Employee;
                    return(m.City.ToString().StartsWith(FilterString));
                }
                if (_searchKey == "Улица")
                {
                    Employee m = i as Employee;
                    return(m.Street.ToString().StartsWith(FilterString));
                }
                if (_searchKey == "Дом")
                {
                    Employee m = i as Employee;
                    return(m.Home.ToString().StartsWith(FilterString));
                }
                if (_searchKey == "Должность")
                {
                    Employee m = i as Employee;
                    return(m.Post.Name.ToString().StartsWith(FilterString));
                }
                else
                {
                    return(true);
                }
            };

            EditEmployee = new DelegateCommand(() =>
            {
                editoradd = false;
                selectedEmployee?.BeginEdit();

                var w         = new EmployeeEdit();
                w.DataContext = this;
                w.ShowDialog();
            }, () => selectedEmployee != null);


            AddEmployee = new DelegateCommand(() =>
            {
                editoradd = true;

                Employee employee = new Employee();
                SelectedEmployee  = employee;

                var w         = new EmployeeEdit();
                w.DataContext = this;
                w.ShowDialog();
            });

            SaveEmployee = new DelegateCommand(() =>
            {
                if (editoradd == true)
                {
                    currentPost = context.Post.Find(selectedEmployee.Post.Id);

                    context.Employee.Add(selectedEmployee);

                    context.SaveChanges();

                    Employees.Add(SelectedEmployee);
                }
                else
                {
                    currentPost = context.Post.Find(selectedEmployee.Post.Id);
                    context.Entry(selectedEmployee).State = EntityState.Modified;
                    context.SaveChanges();
                }
            });

            RemoveEmployee = new DelegateCommand(() =>
            {
                if (MessageBox.Show("Удалить?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    context.Entry(selectedEmployee).State = EntityState.Deleted;
                    Employees.Remove(selectedEmployee);
                    context.SaveChanges();
                }
                else
                {
                    return;
                }
            }, () => selectedEmployee != null);

            CanselEdit = new DelegateCommand(() =>
            {
                if (editoradd == false)
                {
                    if (selectedEmployee == null)
                    {
                        return;
                    }
                    SelectedEmployee.CancelEdit();
                }
                else
                {
                    return;
                }
            });
        }
Beispiel #3
0
        public MedicamentViewModel()
        {
            DownloadMedicaments();

            EditMedicament = new DelegateCommand(() =>
            {
                editoradd = false;
                selectedMedicament?.BeginEdit();

                var w         = new MedicamentEdit();
                w.DataContext = this;
                w.ShowDialog();
            }, () => selectedMedicament != null);


            AddMedicament = new DelegateCommand(() =>
            {
                editoradd = true;

                Medicament medicament = new Medicament();
                SelectedMedicament    = medicament;

                var w         = new MedicamentEdit();
                w.DataContext = this;
                w.ShowDialog();
            });

            SaveMedicament = new DelegateCommand(() =>
            {
                if (editoradd == true)
                {
                    context.Medicament.Add(selectedMedicament);

                    context.SaveChanges();

                    Medicaments.Add(SelectedMedicament);
                }
                else
                {
                    context.Entry(SelectedMedicament).State = EntityState.Modified;
                    context.SaveChanges();
                }
            });

            RemoveMedicament = new DelegateCommand(() =>
            {
                if (MessageBox.Show("Удалить?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    context.Entry(selectedMedicament).State = EntityState.Deleted;
                    context.SaveChanges();
                    Medicaments.Remove(selectedMedicament);
                }
                else
                {
                    return;
                }
            }, () => selectedMedicament != null);

            CanselEdit = new DelegateCommand(() =>
            {
                if (editoradd == false)
                {
                    if (selectedMedicament == null)
                    {
                        return;
                    }
                    SelectedMedicament.CancelEdit();
                }
                else
                {
                    return;
                }
            });
        }
Beispiel #4
0
        public MedRecordViewModel(Employee employee)
        {
            DownloadMedRecords();
            currentemployee = employee;

            FilterCollectionView.Filter = i =>
            {
                if (_searchKey == "" || _searchKey == null)
                {
                    return(true);
                }
                if (string.IsNullOrEmpty(FilterString))
                {
                    return(true);
                }
                if (_searchKey == "Фамилия")
                {
                    MedRecord m = i as MedRecord;
                    return(m.Surname.ToString().StartsWith(FilterString));
                }
                if (_searchKey == "Имя")
                {
                    MedRecord m = i as MedRecord;
                    return(m.Name.ToString().StartsWith(FilterString));
                }
                if (_searchKey == "Отчество")
                {
                    MedRecord m = i as MedRecord;
                    return(m.Patronymic.ToString().StartsWith(FilterString));
                }
                if (_searchKey == "Город")
                {
                    MedRecord m = i as MedRecord;
                    return(m.City.ToString().StartsWith(FilterString));
                }
                if (_searchKey == "Улица")
                {
                    MedRecord m = i as MedRecord;
                    return(m.Street.ToString().StartsWith(FilterString));
                }
                if (_searchKey == "Дом")
                {
                    MedRecord m = i as MedRecord;
                    return(m.Home.ToString().StartsWith(FilterString));
                }
                else
                {
                    return(true);
                }
            };

            EditMedRecord = new DelegateCommand(() =>
            {
                editoradd = false;
                selectedMedRecord?.BeginEdit();

                var w         = new MedRecordEdit();
                w.DataContext = this;
                w.ShowDialog();
            }, () => selectedMedRecord != null);


            AddMedRecord = new DelegateCommand(() =>
            {
                editoradd = true;

                MedRecord NewMedRecord = new MedRecord();
                SelectedMedRecord      = NewMedRecord;

                var w         = new MedRecordEdit();
                w.DataContext = this;
                w.ShowDialog();
            });

            SaveMedRecord = new DelegateCommand(() =>
            {
                if (editoradd == true)
                {
                    context.MedRecord.Add(selectedMedRecord);

                    context.SaveChanges();

                    MedRecords.Add(SelectedMedRecord);
                }
                else
                {
                    context.Entry(selectedMedRecord).State = EntityState.Modified;
                    context.SaveChanges();
                }
            });

            RemoveMedRecord = new DelegateCommand(() =>
            {
                if (MessageBox.Show("Удалить?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    context.Entry(selectedMedRecord).State = EntityState.Deleted;
                    MedRecords.Remove(selectedMedRecord);
                    context.SaveChanges();
                }
                else
                {
                    return;
                }
            }, () => selectedMedRecord != null);

            CanselEdit = new DelegateCommand(() =>
            {
                if (editoradd == false)
                {
                    if (selectedMedRecord == null)
                    {
                        return;
                    }
                    SelectedMedRecord.CancelEdit();
                }
                else
                {
                    return;
                }
            });

            MedRecordOpen = new DelegateCommand(() =>
            {
                MedRecordOpenViewModel viewmodel = new MedRecordOpenViewModel(SelectedMedRecord, currentemployee);
                var w         = new OpenMedRecord();
                w.DataContext = viewmodel;
                w.ShowDialog();
            }, () => currentemployee.Post.Name == "Врач" || currentemployee.Post.Name == "Администратор");
        }
Beispiel #5
0
        public MedRecordOpenViewModel(MedRecord medRecord, Employee employee)
        {
            currentMedRecord = medRecord;
            currentEmployee  = employee;

            DownloadXrays(medRecord);
            DownloadVisiting(medRecord);
            Diagnosings = DiagnosisViewModel.DiagnosisTake();
            Medicaments = MedicamentViewModel.MedicamentsTake();

            EditXrays = new DelegateCommand(() =>
            {
                editoradd = false;

                selectedXrays?.BeginEdit();
                var w         = new XraysEdit();
                w.DataContext = this;
                w.ShowDialog();
            }, () => selectedXrays != null);


            AddXrays = new DelegateCommand(() =>
            {
                editoradd = true;

                Xrays xrays   = new Xrays();
                SelectedXrays = xrays;

                var w         = new XraysEdit();
                w.DataContext = this;
                w.Show();
            });

            SaveXrays = new DelegateCommand(() =>
            {
                if (editoradd == true)
                {
                    selectedXrays.IdMedRecord = currentMedRecord.Id;

                    context.Xrays.Add(selectedXrays);

                    context.SaveChanges();

                    Photos.Add(SelectedXrays);
                }
                else
                {
                    context.Entry(selectedXrays).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }, () => selectedXrays.Photo != null);

            RemoveXrays = new DelegateCommand(() =>
            {
                if (MessageBox.Show("Удалить?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    context.Entry(selectedXrays).State = EntityState.Deleted;
                    Photos.Remove(selectedXrays);
                    context.SaveChanges();
                }
                else
                {
                    return;
                }
            }, () => selectedXrays != null);

            CanselXrays = new DelegateCommand(() =>
            {
                if (editoradd == false)
                {
                    if (selectedXrays == null)
                    {
                        return;
                    }
                    SelectedXrays.CancelEdit();
                }
                else
                {
                    return;
                }
            });

            AddImage = new DelegateCommand(() =>
            {
                OpenFileDialog dlg   = new OpenFileDialog();
                dlg.InitialDirectory = "";
                dlg.Filter           = "Image files (*.jpg,*.png,*.bmp)|*.jpg;*.png;*.bmp|All Files (*.*)|*.*";
                if (dlg.ShowDialog() == true)
                {
                    string selectedFileName = dlg.FileName;
                    selectedXrays.Photo     = ConvertImageToByteArray(selectedFileName);
                    SaveXrays.RaiseCanExecuteChanged();
                }
            });

            #region Visiting

            EditVisiting = new DelegateCommand(() =>
            {
                editoradd = false;

                var w         = new VisitingEdit();
                w.DataContext = this;
                w.ShowDialog();
            }, () => selectedVisiting != null);


            AddVisiting = new DelegateCommand(() =>
            {
                editoradd = true;

                Visiting visiting = new Visiting();
                SelectedVisiting  = visiting;

                var w         = new VisitingEdit();
                w.DataContext = this;
                w.Show();
            });

            SaveVisiting = new DelegateCommand(() =>
            {
                if (editoradd == true)
                {
                    selectedVisiting.IDEmployee  = currentEmployee.Id;
                    selectedVisiting.IDMedRecord = currentMedRecord.Id;

                    currentMedRecord  = context.MedRecord.Find(currentMedRecord.Id);
                    currentEmployee   = context.Employee.Find(currentEmployee.Id);
                    currentMedicament = context.Medicament.Find(selectedVisiting.IDMedicament);
                    currentDiagnosis  = context.Diagnosis.Find(selectedVisiting.IDDiagnosis);
                    //Diagnosings = DiagnosisViewModel.DiagnosisTake();
                    //Medicaments = MedicamentViewModel.MedicamentsTake();

                    context.Visiting.Add(selectedVisiting);

                    context.SaveChanges();

                    Visitings.Add(SelectedVisiting);
                }
                else
                {
                    currentMedRecord  = context.MedRecord.Find(currentMedRecord.Id);
                    currentEmployee   = context.Employee.Find(currentEmployee.Id);
                    currentMedicament = context.Medicament.Find(selectedVisiting.IDMedicament);
                    currentDiagnosis  = context.Diagnosis.Find(selectedVisiting.IDDiagnosis);

                    context.Entry(selectedVisiting).State = EntityState.Modified;
                    context.SaveChanges();
                }
            });


            RemoveVisiting = new DelegateCommand(() =>
            {
                if (MessageBox.Show("Удалить?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    context.Entry(selectedVisiting).State = EntityState.Deleted;
                    Visitings.Remove(selectedVisiting);
                    context.SaveChanges();
                }
                else
                {
                    return;
                }
            }, () => selectedVisiting != null);

            CanselVisiting = new DelegateCommand(() =>
            {
                if (editoradd == false)
                {
                    if (selectedVisiting == null)
                    {
                        return;
                    }
                    SelectedVisiting.CancelEdit();
                }
                else
                {
                    return;
                }
            });

            ExportVisiting = new DelegateCommand(() =>
            {
                try
                {
                    Microsoft.Office.Interop.Excel.Application exApp = new Microsoft.Office.Interop.Excel.Application();

                    Workbook workbook = exApp.Workbooks.Add(Type.Missing);

                    Worksheet workSheet = (Worksheet)exApp.ActiveSheet;

                    workSheet.Cells[1, 1] = "ФИО пациента";
                    workSheet.Cells[1, 2] = "ФИО врача";
                    workSheet.Cells[1, 3] = "Дата";
                    workSheet.Cells[1, 4] = "Жалобы";
                    workSheet.Cells[1, 5] = "Начало болезни";
                    workSheet.Cells[1, 6] = "Текущее состояние";
                    workSheet.Cells[1, 7] = "Дополнительно";
                    workSheet.Cells[1, 8] = "Медикамент";
                    workSheet.Cells[1, 9] = "Диагноз";

                    int rowExcel = 2;

                    foreach (var item in Visitings)
                    {
                        workSheet.Cells[rowExcel, "A"] = item.MedRecord.Surname + item.MedRecord.Name + item.MedRecord.Patronymic;
                        workSheet.Cells[rowExcel, "B"] = item.Employee.Surname + item.Employee.Name + item.Employee.Patronymic;
                        workSheet.Cells[rowExcel, "C"] = item.Date;
                        workSheet.Cells[rowExcel, "D"] = item.Complaints;
                        workSheet.Cells[rowExcel, "E"] = item.StartDisease;
                        workSheet.Cells[rowExcel, "F"] = item.StatePraesens;
                        workSheet.Cells[rowExcel, "G"] = item.Additionally;
                        workSheet.Cells[rowExcel, "H"] = item.Medicament.Name;
                        workSheet.Cells[rowExcel, "I"] = item.Diagnosis.Name;

                        ++rowExcel;
                    }

                    //workbook.Close();
                    exApp.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(exApp);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Ошибка записи в Excel");
                }
            });
            #endregion
        }