private void btnAdd_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(this.txtName.Text)) { MessageBox.Show(this, App.Current.FindResource("Message_11").ToString()); this.txtName.Focus(); } else if (this.txtName.Text.IndexOf(';') >= 0 || this.txtName.Text.IndexOf('|') >= 0 ) { MessageBox.Show(this, App.Current.FindResource("Message_29").ToString()); this.txtName.Focus(); } else if (this.txtLicense.Text.IndexOf(';') >= 0 || this.txtLicense.Text.IndexOf('|') >= 0) { MessageBox.Show(this, App.Current.FindResource("Message_29").ToString()); this.txtLicense.Focus(); } else { foreach (var item in _userList) { if (item.Name.Equals(this.txtName.Text)) { MessageBox.Show(this, App.Current.FindResource("Message_12").ToString()); return; } } User user = new User(); user.Name = this.txtName.Text; user.License = this.txtLicense.Text; _userList.Add(user); this.Close(); } }
private void LoadInitConfig() { try { if (File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "Config_bak.ini")) { try { File.Copy(System.AppDomain.CurrentDomain.BaseDirectory + "Config_bak.ini", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini", true); File.Delete(System.AppDomain.CurrentDomain.BaseDirectory + "Config_bak.ini"); } catch { } } if (App.reportSettingModel == null) { App.reportSettingModel = new ReportSettingModel(); App.reportSettingModel.DataBaseFolder = OperateIniFile.ReadIniData("Base", "Data base", "C:\\MEIKData", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); App.reportSettingModel.Version = OperateIniFile.ReadIniData("Base", "Version", "1.0.0", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); App.reportSettingModel.UseDefaultSignature = Convert.ToBoolean(OperateIniFile.ReadIniData("Report", "Use Default Signature", "false", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini")); string doctorNames = OperateIniFile.ReadIniData("Report", "Doctor Names List", "", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); if (!string.IsNullOrEmpty(doctorNames)) { var doctorList = doctorNames.Split(';').ToList<string>(); //doctorList.ForEach(item => App.reportSettingModel.DoctorNames.Add(item)); foreach (var item in doctorList) { User doctorUser = new User(); string[] arr = item.Split('|'); doctorUser.Name = arr[0]; doctorUser.License = arr[1]; App.reportSettingModel.DoctorNames.Add(doctorUser); } } string techNames = OperateIniFile.ReadIniData("Report", "Technician Names List", "", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); if (!string.IsNullOrEmpty(techNames)) { var techList = techNames.Split(';').ToList<string>(); //techList.ForEach(item => App.reportSettingModel.TechNames.Add(item)); foreach (var item in techList) { User techUser = new User(); string[] arr = item.Split('|'); techUser.Name = arr[0]; techUser.License = arr[1]; App.reportSettingModel.TechNames.Add(techUser); } } App.reportSettingModel.ScreenVenue = OperateIniFile.ReadIniData("Report", "Screen Venue", "", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); App.reportSettingModel.NoShowDoctorSignature = Convert.ToBoolean(OperateIniFile.ReadIniData("Report", "Hide Doctor Signature", "false", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini")); App.reportSettingModel.NoShowTechSignature = Convert.ToBoolean(OperateIniFile.ReadIniData("Report", "Hide Technician Signature", "false", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini")); App.reportSettingModel.FtpPath = OperateIniFile.ReadIniData("FTP", "FTP Path", "", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); App.reportSettingModel.FtpUser = OperateIniFile.ReadIniData("FTP", "FTP User", "", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); string ftpPwd = OperateIniFile.ReadIniData("FTP", "FTP Password", "", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); if (!string.IsNullOrEmpty(ftpPwd)) { App.reportSettingModel.FtpPwd = SecurityTools.DecryptText(ftpPwd); } string pagesize = OperateIniFile.ReadIniData("Report", "Print Paper", "Letter", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); pagesize = string.IsNullOrEmpty(pagesize) ? "Letter" : pagesize; App.reportSettingModel.PrintPaper = (PageSize)Enum.Parse(typeof(PageSize), pagesize,true); App.reportSettingModel.MailAddress = OperateIniFile.ReadIniData("Mail", "My Mail Address", "", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); App.reportSettingModel.ToMailAddress = OperateIniFile.ReadIniData("Mail", "To Mail Address", "", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); App.reportSettingModel.MailSubject = OperateIniFile.ReadIniData("Mail", "Mail Subject", "", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); App.reportSettingModel.MailBody = OperateIniFile.ReadIniData("Mail", "Mail Content", "", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); App.reportSettingModel.MailHost = OperateIniFile.ReadIniData("Mail", "Mail Host", "", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); App.reportSettingModel.MailPort = Convert.ToInt32(OperateIniFile.ReadIniData("Mail", "Mail Port", "25", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini")); App.reportSettingModel.MailUsername = OperateIniFile.ReadIniData("Mail", "Mail Username", "", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); string mailPwd = OperateIniFile.ReadIniData("Mail", "Mail Password", "", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); if (!string.IsNullOrEmpty(mailPwd)) { App.reportSettingModel.MailPwd = SecurityTools.DecryptText(mailPwd); } App.reportSettingModel.MailSsl = Convert.ToBoolean(OperateIniFile.ReadIniData("Mail", "Mail SSL", "false", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini")); App.reportSettingModel.DeviceNo = OperateIniFile.ReadIniData("Device", "Device No", "000", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); //加载操作模式 string filePath = System.AppDomain.CurrentDomain.BaseDirectory + "mode.dat"; if (File.Exists(filePath)) { string modeStr = SecurityTools.DecryptTextFromFile(filePath); if (string.IsNullOrEmpty(modeStr)) { modeStr = "Technician"; } App.reportSettingModel.DeviceType = (int)Enum.Parse(typeof(DeviceType), modeStr, true); } else { string deviceType = OperateIniFile.ReadIniData("Device", "Device Type", "1", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); if (string.IsNullOrEmpty(deviceType)) { App.reportSettingModel.DeviceType = 1; } else { App.reportSettingModel.DeviceType = Convert.ToInt32(deviceType); } if (App.reportSettingModel.DeviceType == 1) { SecurityTools.EncryptTextToFile("Technician", filePath); } else if (App.reportSettingModel.DeviceType == 3) { SecurityTools.EncryptTextToFile("Admin", filePath); } else { SecurityTools.EncryptTextToFile("Doctor", filePath); } } App.reportSettingModel.RecordDate = OperateIniFile.ReadIniData("Data", "Record Date", "", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini"); } } catch (Exception ex) { MessageBox.Show(this, App.Current.FindResource("Message_20").ToString() + " " + ex.Message); } }
public ExaminationReportPage(object data): this() { mouseHook.MouseUp += new System.Windows.Forms.MouseEventHandler(mouseHook_MouseUp); //mouseHook.MouseMove += new System.Windows.Forms.MouseEventHandler(mouseHook_MouseMove); try { this.person = data as Person; if (this.person == null) { MessageBox.Show(this, "Please select a patient."); this.Close(); } else { string dataFile = FindUserReportData(person.ArchiveFolder); if (string.IsNullOrEmpty(dataFile)) { dataFile = dataFolder + System.IO.Path.DirectorySeparatorChar + person.Code + ".dat"; } //string dataFile = dataFolder + System.IO.Path.DirectorySeparatorChar + person.Code + ".dat"; if (File.Exists(dataFile)) { try { this.shortFormReportModel = SerializeUtilities.Desrialize<ShortFormReport>(dataFile); } catch (Exception exec1) { } if (shortFormReportModel.DataSignImg != null) { this.dataSignImg.Source = ImageTools.GetBitmapImage(shortFormReportModel.DataSignImg); } } else { shortFormReportModel.DataUserCode = person.Code; bool defaultSign = Convert.ToBoolean(OperateIniFile.ReadIniData("Report", "Use Default Signature", "false", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini")); if (defaultSign) { string imgFile = AppDomain.CurrentDomain.BaseDirectory + "/Signature/temp.jpg"; if (File.Exists(imgFile)) { this.dataSignImg.Source = ImageTools.GetBitmapImage(imgFile); //dataScreenShotImg.Source = GetBitmapImage(AppDomain.CurrentDomain.BaseDirectory + "/Images/BigIcon.png"); } } } if ("en-US".Equals(App.local)) { shortFormReportModel.DataScreenDate = DateTime.ParseExact("20" + person.Code.Substring(0, 6), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).ToString("MM/dd/yyyy"); } else { shortFormReportModel.DataScreenDate = DateTime.ParseExact("20" + person.Code.Substring(0, 6), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).ToString("yyyy年MM月dd日"); } shortFormReportModel.DataClientNum = person.ClientNumber; shortFormReportModel.DataName = person.SurName; shortFormReportModel.DataAge = person.Age + ""; shortFormReportModel.DataAddress = person.Address; shortFormReportModel.DataHeight = person.Height; shortFormReportModel.DataWeight = person.Weight; shortFormReportModel.DataMobile = person.Mobile; shortFormReportModel.DataEmail = person.Email; shortFormReportModel.DataScreenLocation = person.ScreenVenue; this.reportDataGrid.DataContext = this.shortFormReportModel; //以下是添加处理操作员和医生的名字的选择项 User doctorUser = new User(); if (!string.IsNullOrEmpty(shortFormReportModel.DataDoctor)) { doctorUser.Name = shortFormReportModel.DataDoctor; doctorUser.License = shortFormReportModel.DataDoctorLicense; } else { if(!string.IsNullOrEmpty(this.person.DoctorName)){ doctorUser.Name = this.person.DoctorName; doctorUser.License = this.person.DoctorLicense; shortFormReportModel.DataDoctor = this.person.DoctorName; shortFormReportModel.DataDoctorLicense = this.person.DoctorLicense; } } this.dataDoctor.ItemsSource = App.reportSettingModel.DoctorNames; if(!string.IsNullOrEmpty(doctorUser.Name)){ for (int i = 0; i < App.reportSettingModel.DoctorNames.Count; i++) { var item=App.reportSettingModel.DoctorNames[i]; if (doctorUser.Name.Equals(item.Name) && (string.IsNullOrEmpty(doctorUser.License)==string.IsNullOrEmpty(item.License)||doctorUser.License==item.License)) { this.dataDoctor.SelectedIndex = i; break; } } //如果没有找到匹配的用户 if (this.dataDoctor.SelectedIndex == -1) { App.reportSettingModel.DoctorNames.Add(doctorUser); this.dataDoctor.SelectedIndex = App.reportSettingModel.DoctorNames.Count - 1; } } User techUser = new User(); if (!string.IsNullOrEmpty(shortFormReportModel.DataMeikTech)) { techUser.Name = shortFormReportModel.DataMeikTech; techUser.License = shortFormReportModel.DataTechLicense; } else { if (!string.IsNullOrEmpty(this.person.TechName)) { techUser.Name = this.person.TechName; techUser.License = this.person.TechLicense; shortFormReportModel.DataMeikTech = this.person.TechName; shortFormReportModel.DataTechLicense = this.person.TechLicense; } } //this.dataMeikTech.ItemsSource = App.reportSettingModel.TechNames; //if (!string.IsNullOrEmpty(techUser.Name)) //{ // for (int i = 0; i < App.reportSettingModel.TechNames.Count; i++) // { // var item = App.reportSettingModel.TechNames[i]; // if (techUser.Name.Equals(item.Name) && (string.IsNullOrEmpty(techUser.License) == string.IsNullOrEmpty(item.License) || techUser.License == item.License)) // { // this.dataMeikTech.SelectedIndex = i; // break; // } // } // //如果没有找到匹配的用户 // if (this.dataMeikTech.SelectedIndex == -1) // { // App.reportSettingModel.TechNames.Add(techUser); // this.dataMeikTech.SelectedIndex = App.reportSettingModel.TechNames.Count - 1; // } //} } } catch (Exception ex) { MessageBox.Show(this, ex.Message); } }
public SummaryReportPage(object data): this() { try { this.person = data as Person; if (this.person == null) { MessageBox.Show(this, App.Current.FindResource("Message_8").ToString()); this.Close(); } else { string dataFile = FindUserReportData(person.ArchiveFolder); if (string.IsNullOrEmpty(dataFile)) { dataFile = dataFolder + System.IO.Path.DirectorySeparatorChar + person.Code + ".dat"; } if ("en-US".Equals(App.local)) { dataScreenDate.FormatString = "MMMM d, yyyy"; dataSignDate.FormatString = "MMMM d, yyyy"; } else { dataScreenDate.FormatString = "yyyy年MM月dd日"; dataSignDate.FormatString = "yyyy年MM月dd日"; } //string dataFile = dataFolder + System.IO.Path.DirectorySeparatorChar + person.Code + ".dat"; if(File.Exists(dataFile)){ ////序列化xaml //using (FileStream fs = new FileStream(dataFolder+"/"+person.Code+".dat", FileMode.Open)) //{ // var scrollViewer = XamlReader.Load(fs) as ScrollViewer; // this.reportPage = scrollViewer; //} this.shortFormReportModel=SerializeUtilities.Desrialize<ShortFormReport>(dataFile); if (shortFormReportModel.DataScreenShotImg != null) { this.dataScreenShotImg.Source = ImageTools.GetBitmapImage(shortFormReportModel.DataScreenShotImg); } if (shortFormReportModel.DataSignImg != null) { this.dataSignImg.Source = ImageTools.GetBitmapImage(shortFormReportModel.DataSignImg); } } else { shortFormReportModel.DataUserCode = person.Code; shortFormReportModel.DataName = person.SurName; shortFormReportModel.DataAge = person.Age + ""; shortFormReportModel.DataScreenDate = DateTime.Parse(person.RegMonth + "/" + person.RegDate + "/" + person.RegYear).ToLongDateString(); shortFormReportModel.DataSignDate = DateTime.Today.ToLongDateString(); bool defaultSign = Convert.ToBoolean(OperateIniFile.ReadIniData("Report", "Use Default Signature", "false", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini")); if (defaultSign) { string imgFile = AppDomain.CurrentDomain.BaseDirectory + "/Signature/temp.jpg"; if (File.Exists(imgFile)) { dataSignImg.Source = ImageTools.GetBitmapImage(imgFile); //dataScreenShotImg.Source = GetBitmapImage(AppDomain.CurrentDomain.BaseDirectory + "/Images/BigIcon.png"); } } } this.reportDataGrid.DataContext = this.shortFormReportModel; //以下是添加处理操作员和医生的名字的选择项 User doctorUser = new User(); if (!string.IsNullOrEmpty(shortFormReportModel.DataDoctor)) { doctorUser.Name = shortFormReportModel.DataDoctor; doctorUser.License = shortFormReportModel.DataDoctorLicense; } else { if (!string.IsNullOrEmpty(this.person.DoctorName)) { doctorUser.Name = this.person.DoctorName; doctorUser.License = this.person.DoctorLicense; shortFormReportModel.DataDoctor = this.person.DoctorName; shortFormReportModel.DataDoctorLicense = this.person.DoctorLicense; } } this.dataDoctor.ItemsSource = App.reportSettingModel.DoctorNames; if (!string.IsNullOrEmpty(doctorUser.Name)) { for (int i = 0; i < App.reportSettingModel.DoctorNames.Count; i++) { var item = App.reportSettingModel.DoctorNames[i]; if (doctorUser.Name.Equals(item.Name) && (string.IsNullOrEmpty(doctorUser.License) == string.IsNullOrEmpty(item.License) || doctorUser.License == item.License)) { this.dataDoctor.SelectedIndex = i; break; } } //如果没有找到匹配的用户 if (this.dataDoctor.SelectedIndex == -1) { App.reportSettingModel.DoctorNames.Add(doctorUser); this.dataDoctor.SelectedIndex = App.reportSettingModel.DoctorNames.Count - 1; } } User techUser = new User(); if (!string.IsNullOrEmpty(shortFormReportModel.DataMeikTech)) { techUser.Name = shortFormReportModel.DataMeikTech; techUser.License = shortFormReportModel.DataTechLicense; } else { if (!string.IsNullOrEmpty(this.person.TechName)) { techUser.Name = this.person.TechName; techUser.License = this.person.TechLicense; shortFormReportModel.DataMeikTech = this.person.TechName; shortFormReportModel.DataTechLicense = this.person.TechLicense; } } this.dataMeikTech.ItemsSource = App.reportSettingModel.TechNames; if (!string.IsNullOrEmpty(techUser.Name)) { for (int i = 0; i < App.reportSettingModel.TechNames.Count; i++) { var item = App.reportSettingModel.TechNames[i]; if (techUser.Name.Equals(item.Name) && (string.IsNullOrEmpty(techUser.License) == string.IsNullOrEmpty(item.License) || techUser.License == item.License)) { this.dataMeikTech.SelectedIndex = i; break; } } //如果没有找到匹配的用户 if (this.dataMeikTech.SelectedIndex == -1) { App.reportSettingModel.TechNames.Add(techUser); this.dataMeikTech.SelectedIndex = App.reportSettingModel.TechNames.Count - 1; } } } } catch (Exception ex) { MessageBox.Show(this, ex.Message); } }