public void InsertOrUpdateImage(Patients patients, Templates templates, DateTime templateImportDate, int imageID, string imagePath, string tiNumber) { var IsImageExist = from iie in dde.TemplateImages where iie.Template_ID == templates.Template_ID && iie.TemplateImage_Number == tiNumber && iie.TemplateImage_ImportDate == templateImportDate.Date && iie.Patient_ID == patients.Patient_ID select iie; if (IsImageExist.Count() > 0) { tI = new TemplateImages(); tI = IsImageExist.First(); tI.Image_ID = imageID; tI.Image_Path = imagePath; dde.SaveChanges(); } else { dde.TemplateImages.Add(new TemplateImages() { TemplateImage_Number = tiNumber, Template_ID = templates.Template_ID, TemplateImage_ImportDate = templateImportDate.Date, Image_ID = imageID, Image_Path = imagePath, Patient_ID = patients.Patient_ID }); dde.SaveChanges(); } }
/// <summary> /// 寫入Images(新增圖片) 回傳Image_ID /// </summary> /// <param name="imagePath">圖片名稱(含路徑)</param> /// <param name="imageFileName">圖片名稱</param> /// <param name="imageSize">圖片規格(Original/Small)</param> /// <param name="imageExtension">圖片副檔名</param> /// <param name="registrationID">掛號流水號</param> public int InsertImage(string imagePath, string imageFileName, string imageSize, string imageExtension, int registrationID) { var newImage = new Images { Image_Path = imagePath, Image_FileName = imageFileName, Image_Size = imageSize, Image_Extension = imageExtension, Registration_ID = registrationID }; dde.Images.Add(newImage); dde.SaveChanges(); return(newImage.Image_ID); }
private void Button_OK_Click(object sender, RoutedEventArgs e) { try { if (dde == null) { dde = new DigiDentalEntities(); } Agencys a = (from q in dde.Agencys where q.Agency_Code == svm.Agencys.Agency_Code select q).First(); a.Agency_ViewType = svm.ViewType; a.Agency_ImagePath = svm.ImagePath; a.Agency_WifiCardPath = svm.WifiCardPath; a.Function_ID = svm.StartFunction; dde.SaveChanges(); Agencys = a; DialogResult = true; } catch (Exception ex) { Error_Log.ErrorMessageOutput(ex.ToString()); DialogResult = false; } Close(); }
private void Button_Delete_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("確定刪除已選定的" + lfvm.ImageSelectedCount + "個項目?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { using (var dde = new DigiDentalEntities()) { try { var selectedItemID = from si in lfvm.ShowImages where si.IsSelected == true select si.Image_ID; var deleteItem = (from i in dde.Images where selectedItemID.Contains(i.Image_ID) select i).ToList(); deleteItem.ForEach(i => i.Image_IsEnable = false); dde.SaveChanges(); var selectedItem = from si in lfvm.ShowImages where si.IsSelected == true select si; foreach (ImageInfo ii in selectedItem.ToArray()) { lfvm.ShowImages.Remove(ii); } lfvm.CountImages = ShowImages.Count(); } catch (Exception ex) { Error_Log.ErrorMessageOutput(ex.ToString()); } } } }
private void Button_CategoryAdd_Click(object sender, RoutedEventArgs e) { try { var pc = new PatientCategories() { PatientCategory_Title = textBoxCategoryInput.Text }; dde.PatientCategories.Add(pc); dde.SaveChanges(); pcvm.PatientCategories = dde.PatientCategories.ToList(); textBoxCategoryInput.Text = string.Empty; } catch (Exception ex) { Error_Log.ErrorMessageOutput(ex.ToString()); } }
/// <summary> /// 新增新病患 /// </summary> private void addNewPatient() { //Data from AppStartup if (((Application.Current as App).p).Patient_ID != null) { Patients = (Application.Current as App).p; var isExistPatient = from iep in dde.Patients where iep.Patient_ID == Patients.Patient_ID select iep; if (isExistPatient.Count() == 0) { dde.Patients.Add(Patients); dde.SaveChanges(); } else { Patients = isExistPatient.First(); } } }
private void Image_Drop(object sender, DragEventArgs e) { try { Image img = e.Source as Image; ImageInfo dragImage = new ImageInfo(); dragImage = ((ImageInfo)e.Data.GetData(DataFormats.Text)); pf = new PatientsFolder(Agencys, Patients); if (!Directory.Exists(pf.PatientFullPatientPhotoPath)) { Directory.CreateDirectory(pf.PatientFullPatientPhotoPath); } string newPatientPhotoName = DateTime.Now.ToString("yyyyMMddHHmmssffff") + dragImage.Image_Extension; string newPatientPhotoPath = pf.PatientFullPatientPhotoPath + @"\" + newPatientPhotoName; File.Copy(dragImage.Image_FullPath, newPatientPhotoPath); Thread.Sleep(200); mwvm.PatientPhoto = new LoadBitmapImage().SettingBitmapImage(newPatientPhotoPath, 400); //update database Patients Patient_Photo Patients patients = (from q in dde.Patients where q.Patient_ID == Patients.Patient_ID select q).First(); patients.Patient_Photo = pf.PatientPhotoPath + @"\" + newPatientPhotoName; patients.UpdateDate = DateTime.Now; dde.SaveChanges(); Patients = patients; mwvm.Patients = patients; } catch (Exception ex) { Error_Log.ErrorMessageOutput(ex.ToString()); MessageBox.Show("移動圖片發生錯誤,聯絡資訊人員", "提示", MessageBoxButton.OK, MessageBoxImage.Error); } }
public int CreateRegistrationsAndGetID(Patients Patients, DateTime RegistrationDate) { var queryRegistration = from qr in dde.Registrations where qr.Patient_ID == Patients.Patient_ID && qr.Registration_Date == RegistrationDate.Date select qr; if (queryRegistration.Count() == 0) { var newRegistration = new Registrations { Patient_ID = Patients.Patient_ID, Registration_Date = RegistrationDate }; dde.Registrations.Add(newRegistration); dde.SaveChanges(); Registration_ID = newRegistration.Registration_ID; } else { Registration_ID = queryRegistration.First().Registration_ID; } return(Registration_ID); }
private void Button_Save_Click(object sender, RoutedEventArgs e) { try { if (Patients != null)//編輯 { if (MessageBox.Show("確定修改病患資料<" + pvm.PatientNumber + ">?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { using (var dde = new DigiDentalEntities()) { DateTime updateTime = DateTime.Now; Patients patients = (from p in dde.Patients where p.Patient_ID == Patients.Patient_ID select p).First(); patients.Patient_Number = pvm.PatientNumber; patients.Patient_Name = pvm.PatientName; patients.Patient_IDNumber = pvm.PatientIDNumber; patients.Patient_Birth = pvm.Birth; patients.Patient_Gender = pvm.GenderM; patients.UpdateDate = updateTime; if (IsRemove) { patients.Patient_Photo = null; } else { if (!string.IsNullOrEmpty(ImportPatientPhotoPath)) { PatientsFolder pf = new PatientsFolder(Agencys, patients); if (!Directory.Exists(pf.PatientFullPatientPhotoPath)) { Directory.CreateDirectory(pf.PatientFullPatientPhotoPath); } string extension = Path.GetExtension(ImportPatientPhotoPath).ToUpper(); string newFileName = DateTime.Now.ToString("yyyyMMddHHmmssffff"); File.Copy(ImportPatientPhotoPath, pf.PatientFullPatientPhotoPath + @"\" + newFileName + extension); patients.Patient_Photo = pf.PatientPhotoPath + @"\" + newFileName + extension; } } //寫入分類 List <PatientCategories> PatientCategories = dde.PatientCategories.ToList(); List <PatientCategoryInfo> PatientCategoryInfo = pvm.PatientCategoryInfo.FindAll(pci => pci.IsChecked == true); foreach (PatientCategories pc in PatientCategories) { var queryCheck = PatientCategoryInfo.FindAll(pci => pci.PatientCategory_ID == pc.PatientCategory_ID); if (queryCheck.Count() > 0) { patients.PatientCategories.Remove(pc); patients.PatientCategories.Add(pc); } else { patients.PatientCategories.Remove(pc); } } dde.SaveChanges(); MessageBox.Show("修改完成", "提示", MessageBoxButton.OK, MessageBoxImage.Information); DialogResult = true; Close(); } } } else//新增 { if (MessageBox.Show("確定新增病患<" + pvm.PatientNumber + ">?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { using (var dde = new DigiDentalEntities()) { string newPatientID = GetPatientID(); DateTime newPatientDate = DateTime.Now; //新增病患 Patients patients = new Patients() { Patient_ID = newPatientID, Patient_Number = pvm.PatientNumber, Patient_Name = pvm.PatientName, Patient_IDNumber = pvm.PatientIDNumber, Patient_Birth = pvm.Birth, Patient_Gender = pvm.GenderM, CreateDate = newPatientDate, UpdateDate = newPatientDate }; if (!string.IsNullOrEmpty(ImportPatientPhotoPath)) { PatientsFolder pf = new PatientsFolder(Agencys, patients); if (!Directory.Exists(pf.PatientFullPatientPhotoPath)) { Directory.CreateDirectory(pf.PatientFullPatientPhotoPath); } string extension = Path.GetExtension(ImportPatientPhotoPath).ToUpper(); string newFileName = DateTime.Now.ToString("yyyyMMddHHmmssffff"); File.Copy(ImportPatientPhotoPath, pf.PatientFullPatientPhotoPath + @"\" + newFileName + extension); patients.Patient_Photo = pf.PatientPhotoPath + @"\" + newFileName + extension; } //寫入分類 if (pvm.PatientCategoryInfo != null) { List <PatientCategoryInfo> PatientCategoryInfo = pvm.PatientCategoryInfo.FindAll(pcs => pcs.IsChecked == true); foreach (PatientCategoryInfo pci in PatientCategoryInfo) { PatientCategories patientCategories = (from pc in dde.PatientCategories where pc.PatientCategory_ID == pci.PatientCategory_ID select pc).First(); patients.PatientCategories.Add(patientCategories); } } dde.Patients.Add(patients); dde.SaveChanges(); MessageBox.Show("新增完成", "提示", MessageBoxButton.OK, MessageBoxImage.Information); Close(); } } } } catch (Exception ex) { Error_Log.ErrorMessageOutput(ex.ToString()); } }
private void Window_ContentRendered(object sender, EventArgs e) { try { Status.Text = "伺服器位置確認中..."; Status.Refresh(); //判斷app.config if (!ConfigManage.ReadSetting("Server"))//尚未設置 { InputDialog idServerIP = new InputDialog("請輸入伺服器位置:", "IP"); if (idServerIP.ShowDialog() == true) { //寫入config Server 欄位 string serverIP = idServerIP.Answer; ConfigManage.AddUpdateAppCongig("Server", serverIP); } } Status.Text = "嘗試連接伺服器..."; Status.Refresh(); //連接Server connection if (new ConnectionString().CheckConnection()) { dde = new DigiDentalEntities(); Status.Text = "取得本機資訊..."; Status.Refresh(); //取得本機訊息 //HostName IP string LocalIP = string.Empty; HostName = Dns.GetHostName(); IPHostEntry ipHostEntry = Dns.GetHostEntry(HostName); foreach (IPAddress ip in ipHostEntry.AddressList) { if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { LocalIP = ip.ToString(); } } Status.Text = "確認本機註冊資訊..."; Status.Refresh(); //判斷client 有無資料 var isExistClient = from iec in dde.Clients where iec.Client_HostName == HostName select iec; string VerificationCodeClient = string.Empty; if (isExistClient.Count() > 0)//已註冊//判斷VerificationCode 與Server的狀態 { Status.Text = "本機已註冊..."; Status.Refresh(); VerificationCodeClient = isExistClient.First().Agency_VerificationCode; } else//第一次使用,輸入驗證碼 { Status.Text = "本機尚未註冊..."; Status.Refresh(); InputDialog idVerify = new InputDialog("此台電腦為第一次登入,請輸入產品驗證碼:", "Verify"); if (idVerify.ShowDialog() == true) { VerificationCodeClient = idVerify.Answer; dde.Clients.Add(new Clients { Client_HostName = HostName, Client_IP = LocalIP, Client_IsVerify = true, Agency_VerificationCode = VerificationCodeClient }); dde.SaveChanges(); } } Status.Text = "取得伺服器認證資訊..."; Status.Refresh(); //用驗證碼(VerificationCodeClient)與Agencys確認目前狀態 var checkAgencyStatus = from cas in dde.Agencys where cas.Agency_VerificationCode == VerificationCodeClient select cas; if (checkAgencyStatus.Count() > 0) { Agencys = checkAgencyStatus.First(); bool?IsVerify = Agencys.Agency_IsVerify; bool?IsTry = Agencys.Agency_IsTry; if ((bool)IsVerify) { if ((bool)IsTry) { if (Agencys.Agency_TrialPeriod < DateTime.Now.Date) { MessageBoxTips = "試用期限已到,請聯絡資訊廠商"; } else { MessageBoxStatus = true; MessageBoxTips = "此為試用版本,試用日期至" + ((DateTime)Agencys.Agency_TrialPeriod).ToShortDateString(); Status.Text = "病患資訊確認中..."; Status.Refresh(); //判斷病患 addNewPatient(); ReturnDialogResult = true; } } else { Status.Text = "病患資訊確認中..."; Status.Refresh(); //判斷此病患 addNewPatient(); ReturnDialogResult = true; } } else { MessageBoxTips = "此驗證碼已停用,如欲使用請聯絡資訊廠商"; } } else { MessageBoxTips = "伺服器尚未建立認證"; } //寫入ConnectingLog資訊 addConnectingLog(HostName, LocalIP, MessageBoxTips, ReturnDialogResult); } else { MessageBoxTips = "伺服器連接失敗"; ConfigManage.AddUpdateAppCongig("Server", ""); } //show MessageBox if (ReturnDialogResult) { Status.Text = "成功登入,歡迎使用DigiDental..."; Status.Refresh(); if (MessageBoxStatus)//還在試用期內可以使用 { MessageBox.Show(MessageBoxTips, "提示", MessageBoxButton.OK, MessageBoxImage.Information); } } else { Status.Text = "登入失敗,原因:" + MessageBoxTips; Status.Refresh(); MessageBox.Show(MessageBoxTips, "提示", MessageBoxButton.OK, MessageBoxImage.Stop); } Thread.Sleep(1000); //回傳結果 DialogResult = ReturnDialogResult; } catch (Exception ex) { Error_Log.ErrorMessageOutput(ex.ToString()); DialogResult = ReturnDialogResult; } Thread.Sleep(1000); Close(); }