Example #1
0
        private void Button_Pointofix_Click(object sender, RoutedEventArgs e)
        {
            string PointofixPath = ConfigManage.ReadAppConfig("PointofixPath");

            if (PathCheck.IsFileExist(PointofixPath))
            {
                //如果Pointofix已經執行 先關閉
                Process[] processes = Process.GetProcessesByName("Pointofix");
                if (processes.Length > 0)
                {
                    foreach (Process p in processes)
                    {
                        // 關閉目前程序前先等待 200 毫秒
                        p.WaitForExit(200);
                        p.CloseMainWindow();
                    }
                }
                //啟用Pointofix
                Process pointofix = new Process();
                pointofix.StartInfo.FileName = PointofixPath;
                pointofix.Start();
            }
            else
            {
                MessageBox.Show("尚未找到Pointofix的執行程式,請至設定重新設定");
            }
        }
        public void LoadAllTemplatesImages(ObservableCollection <Templates_Images> observableCollection, Grid grid, int templateImagePixelWidth)
        {
            try
            {
                if (observableCollection.Count() > 0)
                {
                    ProgressDialog progressDialog = new ProgressDialog();
                    progressDialog.Dispatcher.Invoke(() =>
                    {
                        progressDialog.PText    = "圖片載入中( 0 / " + observableCollection.Count() + " )";
                        progressDialog.PMinimum = 0;
                        progressDialog.PValue   = 0;
                        progressDialog.PMaximum = observableCollection.Count();
                        progressDialog.Show();
                    });
                    //multi - thread
                    Task.Factory.StartNew(() =>
                    {
                        foreach (Templates_Images ti in observableCollection)
                        {
                            if (!string.IsNullOrEmpty(ti.Image_Path) && PathCheck.IsFileExist(ti.Image_Path))
                            {
                                grid.Dispatcher.Invoke(() =>
                                {
                                    Image iTarget  = (Image)grid.FindName("Image" + ti.Template_Image_Number);
                                    iTarget.Uid    = ti.Template_Image_ID.ToString();
                                    iTarget.Source = new CreateBitmapImage().BitmapImageShow(ti.Image_Path, templateImagePixelWidth);
                                });
                            }
                            progressDialog.Dispatcher.Invoke(() =>
                            {
                                progressDialog.PValue++;
                                progressDialog.PText = "圖片載入中( " + progressDialog.PValue + " / " + observableCollection.Count() + " )";
                            });
                        }
                    }).ContinueWith(t =>
                    {
                        progressDialog.Dispatcher.Invoke(() =>
                        {
                            progressDialog.PText = "載入完成";
                            progressDialog.Close();
                        });

                        GC.Collect();
                    });
                }
            }
            catch (Exception ex)
            {
                ErrorLog.ErrorMessageOutput(ex.ToString());
                MessageBox.Show("載入樣板圖片發生錯誤", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 private void ToggleButton_Save_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         //診所設定判斷
         Agencys agencys = agencySettingViewModel.Agencys;
         if (PathCheck.IsPathExist(agencys.Agency_ImagePath))
         {
             new TableAgencys().UpdateAgency(agencys, agencys.Agency_ImagePath, agencys.Agency_WifiCardPath, agencys.Agency_ViewType, agencys.Function_ID);
             ReturnDialogResult = true;
         }
         else
         {
             if (MessageBox.Show("您所設定的影像路徑無法使用,可能會導致影像無法存取,是否繼續?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
             {
                 new TableAgencys().UpdateAgency(agencys, agencys.Agency_ImagePath, agencys.Agency_WifiCardPath, agencys.Agency_ViewType, agencys.Function_ID);
                 ReturnDialogResult = true;
             }
         }
         //其他
         string PointofixPath = agencySettingViewModel.Pointofix;
         if (PathCheck.IsFileExist(PointofixPath) || string.IsNullOrEmpty(PointofixPath))
         {
             ConfigManage.AddUpdateAppConfig("PointofixPath", PointofixPath);
             ReturnDialogResult = true;
         }
         else
         {
             if (MessageBox.Show("您所設定的Pointofix的位置不存在,可能會導致該軟體無法使用,是否繼續?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
             {
                 ConfigManage.AddUpdateAppConfig("PointofixPath", PointofixPath);
                 ReturnDialogResult = true;
             }
         }
         string ImageDecodePixel = agencySettingViewModel.ImageDecodePixel;
         ConfigManage.AddUpdateAppConfig("ImageDecodePixel", ImageDecodePixel);
         MessageBox.Show("設定已更改");
     }
     catch (Exception ex)
     {
         MessageBox.Show("儲存設定時發生異常", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
         ErrorLog.ErrorMessageOutput(ex.ToString());
     }
     DialogResult = ReturnDialogResult;
     Close();
 }
Example #4
0
        //編輯
        public PatientSettingViewModel(string windowType, Agencys agencys, Patients patients)
        {
            WindowType = windowType;
            Patients   = patients;

            //設定病患資料
            //載入設定就好,避免多設定
            Patient_Number   = patients.Patient_Number;
            Patient_Name     = patients.Patient_Name;
            Patient_IDNumber = patients.Patient_IDNumber;
            Patient_Gender   = patients.Patient_Gender;
            Patient_Birth    = patients.Patient_Birth;
            if (PathCheck.IsFileExist(agencys.Agency_ImagePath + patients.Patient_Photo))
            {
                Patient_Photo = new CreateBitmapImage().BitmapImageShow(agencys.Agency_ImagePath + patients.Patient_Photo, 400);
            }
            Patient_FirstRegistrationDate = patients.Patient_FirstRegistrationDate == null ? DateTime.Now : (DateTime)patients.Patient_FirstRegistrationDate;
            DateTime lastRegistrationDate = new TableRegistrations().QueryLastRegistrationDate(patients);

            Patient_LastRegistrationDate = lastRegistrationDate == null?Patient_FirstRegistrationDate.ToString("yyyy/MM/dd") : lastRegistrationDate.ToString("yyyy/MM/dd");

            PatientCategoryInfo = new TablePatientCategorys().QueryPatientPatientCategoryInfo(Patients).ToList().FindAll(s => s.IsChecked == true);
        }
        private void Button_Save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (Patients != null)//編輯
                {
                    if (MessageBox.Show("確定修改病患資料<" + patientSettingViewModel.Patient_Number + ">?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        //新的影像路徑
                        string newPatientPhotoPath = null;
                        if (!IsRemove)
                        {
                            //如果沒觸發移除,要判斷有沒有匯入的路徑
                            if (!string.IsNullOrEmpty(ImportPatientPhotoPath))
                            {
                                //有,蓋掉舊圖
                                if (PathCheck.IsFileExist(ImportPatientPhotoPath))
                                {
                                    //病患大頭照路徑
                                    PatientPhotoFolderInfo patientPhotoFolderInfo = PatientFolderSetting.PatientPhotoFolderSetting(Agencys, Patients.Patient_ID);
                                    //建立大頭照路徑
                                    PathCheck.CheckPathAndCreate(patientPhotoFolderInfo.PatientPhotoFullPath);

                                    string extension   = Path.GetExtension(ImportPatientPhotoPath).ToUpper();
                                    string newFileName = DateTime.Now.ToString("yyyyMMddHHmmssffff");

                                    File.Copy(ImportPatientPhotoPath, patientPhotoFolderInfo.PatientPhotoFullPath + @"\" + newFileName + extension);
                                    Thread.Sleep(500);

                                    newPatientPhotoPath = patientPhotoFolderInfo.PatientPhotoPath + @"\" + newFileName + extension;
                                }
                                else
                                {
                                    MessageBox.Show("圖片路徑出現問題", "錯誤", MessageBoxButton.OK, MessageBoxImage.Error);
                                }
                            }
                            else
                            {
                                //沒有,保留原圖
                                newPatientPhotoPath = patientSettingViewModel.Patients.Patient_Photo;
                            }
                        }
                        Patients newPatient = new Patients()
                        {
                            Patient_ID       = patientSettingViewModel.Patients.Patient_ID,
                            Patient_Number   = patientSettingViewModel.Patient_Number,
                            Patient_Name     = patientSettingViewModel.Patient_Name,
                            Patient_Gender   = patientSettingViewModel.Patient_Gender,
                            Patient_Birth    = patientSettingViewModel.Patient_Birth,
                            Patient_IDNumber = patientSettingViewModel.Patient_IDNumber,
                            Patient_Photo    = newPatientPhotoPath,
                            Patient_FirstRegistrationDate = patientSettingViewModel.Patient_FirstRegistrationDate,
                            UpdateDate = DateTime.Now
                        };
                        Patients = tablePatients.UpdatePatients(newPatient);

                        //寫入分類
                        List <PatientCategoryInfo> PatientCategoryInfo = patientSettingViewModel.PatientCategoryInfo.FindAll(pci => pci.IsChecked == true);
                        tablePatientCategorys.InsertPatientsPatientCategorys(Patients, PatientCategoryInfo);

                        MessageBox.Show("修改完成", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                        DialogResult = true;
                        Close();
                    }
                }
                else//新增
                {
                    if (MessageBox.Show("確定新增病患<" + patientSettingViewModel.Patient_Number + ">?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        string newPatientID = GetPatientID();

                        string newPatientPhotoPath = null;
                        if (!string.IsNullOrEmpty(ImportPatientPhotoPath))
                        {
                            if (PathCheck.IsFileExist(ImportPatientPhotoPath))
                            {
                                //病患大頭照路徑
                                PatientPhotoFolderInfo patientPhotoFolderInfo = PatientFolderSetting.PatientPhotoFolderSetting(Agencys, newPatientID);
                                //建立大頭照路徑
                                PathCheck.CheckPathAndCreate(patientPhotoFolderInfo.PatientPhotoFullPath);

                                string extension   = Path.GetExtension(ImportPatientPhotoPath).ToUpper();
                                string newFileName = DateTime.Now.ToString("yyyyMMddHHmmssffff");

                                File.Copy(ImportPatientPhotoPath, patientPhotoFolderInfo.PatientPhotoFullPath + @"\" + newFileName + extension);
                                Thread.Sleep(500);

                                newPatientPhotoPath = patientPhotoFolderInfo.PatientPhotoPath + @"\" + newFileName + extension;
                            }
                            else
                            {
                                MessageBox.Show("圖片路徑出現問題", "錯誤", MessageBoxButton.OK, MessageBoxImage.Error);
                            }
                        }
                        DateTime nowDateTime = DateTime.Now;
                        //新增病患
                        Patients newPatient = new Patients()
                        {
                            Patient_ID       = newPatientID,
                            Patient_Number   = patientSettingViewModel.Patient_Number,
                            Patient_Name     = patientSettingViewModel.Patient_Name,
                            Patient_Gender   = patientSettingViewModel.Patient_Gender,
                            Patient_Birth    = patientSettingViewModel.Patient_Birth,
                            Patient_IDNumber = patientSettingViewModel.Patient_IDNumber,
                            Patient_Photo    = newPatientPhotoPath,
                            Patient_FirstRegistrationDate = patientSettingViewModel.Patient_FirstRegistrationDate,
                            UpdateDate = nowDateTime,
                            CreateDate = nowDateTime
                        };
                        Patients = tablePatients.InsertPatients(newPatient);
                        //寫入分類
                        //寫入分類
                        List <PatientCategoryInfo> PatientCategoryInfo = patientSettingViewModel.PatientCategoryInfo.FindAll(pci => pci.IsChecked == true);
                        if (PatientCategoryInfo.Count() > 0)
                        {
                            tablePatientCategorys.InsertPatientsPatientCategorys(Patients, PatientCategoryInfo);
                        }

                        MessageBox.Show("新增完成", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                        DialogResult = true;
                        Close();
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLog.ErrorMessageOutput(ex.ToString());
                MessageBox.Show("儲存資料發生錯誤", "錯誤", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }