private void standManager_ItemSelectionChangedEvent(Model.TB_StandardInfo selectedItem) { ReferenshList(); if (standManager.SelectedItem != null) { if (standManager.SelectedItem.Tag == -1) { btnAddData.IsEnabled = false; btnDelete.IsEnabled = false; btnExport.IsEnabled = false; btnExportData.IsEnabled = false; btnExportStand.IsEnabled = false; } else { btnDelete.IsEnabled = true; btnExport.IsEnabled = true; btnExportData.IsEnabled = true; btnExportStand.IsEnabled = true; if (standManager.SelectedItem.Stand_Level == 2) { btnAddData.IsEnabled = true; } else { btnAddData.IsEnabled = false; } } } else { btnAddData.IsEnabled = false; } }
private void lbLevel2_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { Model.TB_StandardInfo selectedInfo = (lbLevel2.SelectedValue as Model.TB_StandardInfo); standList.Find(x => x.ID == selectedInfo.ID).IsChecked = !selectedInfo.IsChecked; selectStandInfo2 = selectedInfo; }
private void imgAdd_MouseDown(object sender, MouseButtonEventArgs e) { if (SelectedItemIsImported()) { return; } Model.StandInfoTreeDataModel selectedModel = tree.SelectedItem as Model.StandInfoTreeDataModel; if (selectedModel != null) { Model.TB_StandardInfo info = selectedModel.StandInfo; switch (info.Stand_Level) { case 1: AddOrUpdateLevel2 editWindow2 = new AddOrUpdateLevel2(); editWindow2.Owner = Application.Current.MainWindow; editWindow2.AddSuccessEvent += new RoutedEventHandler(editWindow_AddSuccessEvent); editWindow2.isAdd = true; editWindow2.StandardInfo = info; editWindow2.ShowDialog(); editWindow2.AddSuccessEvent -= new RoutedEventHandler(editWindow_AddSuccessEvent); break; case -1: AddOrUpdateLevel1 editWindow1 = new AddOrUpdateLevel1(); editWindow1.Owner = Application.Current.MainWindow; editWindow1.AddSuccessEvent += new RoutedEventHandler(editWindow_AddSuccessEvent); editWindow1.isAdd = true; editWindow1.StandardInfo = info; editWindow1.ShowDialog(); editWindow1.AddSuccessEvent -= new RoutedEventHandler(editWindow_AddSuccessEvent); break; } } }
//参考值选择改变事件,刷新图表 private void stand_ItemSelectionChangedEvent(Model.TB_StandardInfo selectedItem) { if (stand.SelectedItem != null) { standTestInfoModelList.Clear(); standTestInfoModelList = Caches.Util.AthTestInfoModelUtil.AthTestUtil(refeBLL.GetStandTestInfoModelList(stand.SelectedItem.ID)); RefrenshChart(); } }
private void imgDelete_MouseDown(object sender, MouseButtonEventArgs e) { Model.StandInfoTreeDataModel selectedModel = tree.SelectedItem as Model.StandInfoTreeDataModel; if (selectedModel != null) { if (selectedTreeItem?.StandInfo.Tag == -1)//import stand { if (DSJL.Tools.MessageBoxTool.ShowAskMsgBox("确定删除导入的参考值吗?") == MessageBoxResult.Yes) { try { DSJL.Stand.StandConfig.DeleteStand(selectedModel.StandInfo); selectedModel.ParentModel.Children.Remove(selectedModel); selectedModel = null; } catch (Exception ee) { DSJL.Tools.MessageBoxTool.ShowConfirmMsgBox("删除参考值出错!\r\n" + ee.Message); } } return; } Model.TB_StandardInfo info = selectedModel.StandInfo; if (info.Stand_Level != -1) { //不是选择的全部 if (MessageBox.Show("删除信息将不能恢复,确定要删除该参考值信息吗?", "删除参考值确认", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (standardBLL.Delete(info.ID)) { selectedModel.ParentModel.Children.Remove(selectedModel); selectedModel = null; } else { MessageBox.Show("删除错误!", "系统错误"); } } } } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { standardBLL = new BLL.TB_StandardInfo(); if (treeModelCollection.Count == 0) { rootModel.IsExpanded = true; rootModel.DefaultIcon = "/DSJL;component/Assets/Images/folder.png"; rootModel.OpenedIcon = "/DSJL;component/Assets/Images/folder_opened.png"; rootModel.StandInfo = new Model.TB_StandardInfo() { Stand_Name = "参考值类别", Stand_Level = -1 }; rootModel.IsChecked = true; LoadStandInfo(); } tree.Focus(); selectedItem = null; ItemSelectionChangedEvent(selectedItem); }
private void tree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { if (tree.SelectedItem != null) { Model.StandInfoTreeDataModel selectedModel = e.NewValue as Model.StandInfoTreeDataModel; if (selectedModel != null) { selectedTreeItem = selectedModel; Model.TB_StandardInfo info = selectedModel.StandInfo; //if (info.Stand_Level >= 1)//点击一、二级标准时才触发 //{ selectedItem = info; if (ItemSelectionChangedEvent != null) { ItemSelectionChangedEvent(selectedItem); } //} } } }
private void lbLevel1_SelectionChanged(object sender, SelectionChangedEventArgs e) { Model.TB_StandardInfo selectedLevel1 = lbLevel1.SelectedValue as Model.TB_StandardInfo; List <Model.TB_StandardInfo> standInfoList2 = standList.FindAll(x => x.Stand_ParentID == selectedLevel1.ID); if (standInfoList2.Count > 0 && selectStandInfo2 != null) { Model.TB_StandardInfo findedStandInfo = standInfoList2.Find(x => x.ID == selectStandInfo2.ID); if (findedStandInfo != null) { findedStandInfo.IsChecked = true; } } Binding b = new Binding() { Source = standInfoList2 }; lbLevel2.SetBinding(ListBox.ItemsSourceProperty, b); selectStandInfo1 = selectedLevel1; }
private void btnExport_Click(object sender, RoutedEventArgs e) { List <Model.TB_StandardInfo> checkedStandList = GetCheckedStand(); if (checkedStandList.Count == 0) { DSJL.Tools.MessageBoxTool.ShowConfirmMsgBox("请选择要导出的测试参考值!"); return; } if (DSJL.Tools.ShowFileDialogTool.ShowSaveFileDialog(out exportPath, "", "dsf", "等速肌力参考值导出") == false) { return; } exportPath = exportPath.Substring(0, exportPath.LastIndexOf("\\") + 1); Console.WriteLine("export path is:{0}", exportPath); ProgressWindow window = new ProgressWindow(); window.WindowTilte = "导出参考值进度"; window.MaxValue = checkedStandList.Count; window.MinValue = 0; window.CancleMessage = "确定取消导出吗?"; window.onCancling += Window_onCancling; window.Owner = this; Task task = new Task(() => { int progress = 0; foreach (var item in checkedStandList) { if (isCancleExport) { break; } //1、查询测试信息 List <Model.TestInfoModel> testInfoModelList = Caches.Util.AthTestInfoModelUtil.AthTestUtil(refeBLL.GetStandTestInfoModelList(item.ID)); if (testInfoModelList.Count == 0) { continue; } Model.TestInfoModel avgTestInfoModel = GetAvgTestInfoModel(testInfoModelList); string testInfoModelJson = Newtonsoft.Json.JsonConvert.SerializeObject(avgTestInfoModel); // Console.WriteLine(testInfoModelJson); //2、计算平均值 List <List <XElement> > paramList = DSJL.Export.GenerateCompareResportXml.ComputeAvg(testInfoModelList); string paramJson = Newtonsoft.Json.JsonConvert.SerializeObject(paramList); // Console.WriteLine(paramJson); Dictionary <DataPointsType, List <List <double> > > dataPointsDict = StandardChartCache.GetStandardDataPoints(item, testInfoModelList); List <List <double> > oddavgsd = dataPointsDict[DataPointsType.ODDAvgSD]; List <List <double> > evenavgsd = dataPointsDict[DataPointsType.EVENAVGSD]; string oddavgsdjson = Newtonsoft.Json.JsonConvert.SerializeObject(oddavgsd); string evenavgsdjson = Newtonsoft.Json.JsonConvert.SerializeObject(evenavgsd); // Console.WriteLine(oddavgsdjson); // Console.WriteLine(evenavgsdjson); //3、写入文件 Model.TB_StandardInfo parentStandModel = standList.Find(x => x.ID == item.Stand_ParentID); Model.ExportStandModel exportStandModel = new Model.ExportStandModel(); exportStandModel.ParentName = parentStandModel.Stand_Name; exportStandModel.StandName = item.Stand_Name; exportStandModel.TestModel = avgTestInfoModel; exportStandModel.ParamList = paramList; exportStandModel.OddAvgSD = oddavgsd; exportStandModel.EvenAvgSD = evenavgsd; string standJson = Newtonsoft.Json.JsonConvert.SerializeObject(exportStandModel); standJson = DSJL.Tools.DES.Encrypt(standJson, "cissdsjl"); string filename = string.Format("{0}{1}.dsf", exportPath, item.Stand_Name); StreamWriter sw = new StreamWriter(filename); sw.Write(standJson); sw.Close(); progress++; Dispatcher.BeginInvoke(new Action(() => { window.CurrentValue = progress; })); } DSJL.Tools.MessageBoxTool.ShowConfirmMsgBox("导出完成!"); Dispatcher.BeginInvoke(new Action(() => { window.Close(); this.Close(); })); }); task.Start(); window.ShowDialog(); }
//导出报告 private void btnExportReport_Click(object sender, RoutedEventArgs e) { //foreach (Model.TestInfoModel model in TestInfoModelList) //{ // model.IsChecked = true; //} //RefrenshChart(); try { //生成数据xml对象,供导出报告使用 //string title = "平均曲线对比-" + DateTime.Now.ToString("yyyyMMddHHmmss"); //DSJL.Export.GenerateAvgReportXML garxml = new DSJL.Export.GenerateAvgReportXML(); //garxml.CurrentTitle = "平均曲线对比报告"; //garxml.TestInfoModelList = TestInfoModelList; //System.Xml.Linq.XDocument xdoc = garxml.Generate(); //System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); //fbd.Description = "选择保存报告的位置"; //fbd.ShowNewFolderButton = true; //if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) //{ // //生成平均曲线图片 // DSJL.Export.SaveUIElementToImage.SaveToImage(avgPanel, AppDomain.CurrentDomain.BaseDirectory + "avg.jpg"); // //开始导出 // DSJL.Export.ExportAvgReport exportReport = new DSJL.Export.ExportAvgReport(xdoc); // exportReport.Export(fbd.SelectedPath + "\\" + title + ".pdf"); // //删除平均曲线图片 // File.Delete(AppDomain.CurrentDomain.BaseDirectory + "avg.jpg"); // MessageBox.Show("导出成功!", "系统信息"); //} List <Model.TestInfoModel> testInfoModelList = GetSortedTestInfoModelList(); string pdfFileName = ""; string reportTitle = ""; string standName = ""; DSJL.Export.ExportModeEnum exportMode = DSJL.Export.ExportModeEnum.Mode1; if (rbMode1.IsChecked == true)//互相对比报告 { exportMode = DSJL.Export.ExportModeEnum.Mode1; pdfFileName = "等速肌力互相对比报告(" + DateTime.Now.ToString("yyyyMMddHHmmss") + ")"; reportTitle = "等速肌力互相对比报告"; } else if (rbMode2.IsChecked == true)//与平均曲线对比报告 { exportMode = DSJL.Export.ExportModeEnum.Mode2; pdfFileName = "等速肌力个人与平均曲线报告(" + DateTime.Now.ToString("yyyyMMddHHmmss") + ")"; reportTitle = "等速肌力个人与平均曲线报告"; } else if (rbMode3.IsChecked == true)//与参考值对比报告 { if (stand.SelectedItem == null) { MessageBox.Show("请选择测试参考值!", "系统信息"); return; } else { standName = stand.SelectedItem.Stand_Name; } exportMode = DSJL.Export.ExportModeEnum.Mode3; BLL.TB_StandardInfo standInfoBLL = new BLL.TB_StandardInfo(); Model.TB_StandardInfo parentStandInfo = standInfoBLL.GetModel((int)stand.SelectedItem.Stand_ParentID); foreach (Model.TestInfoModel testInfoModel in testInfoModelList) { pdfFileName += testInfoModel.Ath_Name; } pdfFileName += "与" + parentStandInfo.Stand_Name + stand.SelectedItem.Stand_Name + "对比报告(" + DateTime.Now.ToString("yyyyMMddHHmmss") + ")"; //pdfFileName = "等速肌力个人与参考值对比报告(" + DateTime.Now.ToString("yyyyMMddHHmmss") + ")"; reportTitle = "等速肌力个人与参考值对比报告"; } System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog(); saveFileDialog.AddExtension = true; saveFileDialog.OverwritePrompt = true; saveFileDialog.Title = "选择保存报告的位置"; saveFileDialog.FileName = pdfFileName; saveFileDialog.DefaultExt = "pdf"; saveFileDialog.Filter = "PDF文件(*.pdf)|*.pdf"; if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //生成数据xml对象,供导出报告使用 DSJL.Export.GenerateCompareResportXml garxml = new DSJL.Export.GenerateCompareResportXml(exportMode); garxml.CurrentTitle = reportTitle; garxml.TestInfoModelList = GetSortedTestInfoModelList(); garxml.StandardTestInfoModelList = standTestInfoModelList; garxml.StandName = standName; System.Xml.Linq.XDocument xdoc = garxml.GenerateXDoc(); //生成平均曲线图片 DSJL.Export.SaveUIElementToImage.SaveToImage(avgPanel, AppDomain.CurrentDomain.BaseDirectory + "avg.jpg"); //开始导出 DSJL.Export.ExportCompareReport exportReport = new DSJL.Export.ExportCompareReport(xdoc); exportReport.Export(saveFileDialog.FileName); //删除平均曲线图片 File.Delete(AppDomain.CurrentDomain.BaseDirectory + "avg.jpg"); MessageBox.Show("导出成功!", "系统信息"); } } catch (Exception ee) { MessageBox.Show("导出出错!\r\n" + ee.Message, "系统错误"); } }
private void lbLevel1_SelectionChanged(object sender, SelectionChangedEventArgs e) { Model.TB_StandardInfo selectedLevel1= lbLevel1.SelectedValue as Model.TB_StandardInfo; List<Model.TB_StandardInfo> standInfoList2 = standList.FindAll(x => x.Stand_ParentID == selectedLevel1.ID); if (standInfoList2.Count > 0 && selectStandInfo2 != null) { Model.TB_StandardInfo findedStandInfo = standInfoList2.Find(x => x.ID == selectStandInfo2.ID); if (findedStandInfo != null) { findedStandInfo.IsChecked = true; } } Binding b = new Binding() { Source = standInfoList2 }; lbLevel2.SetBinding(ListBox.ItemsSourceProperty, b); selectStandInfo1 = selectedLevel1; }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (txtName.Text == "") { MessageBox.Show("名称不能为空!", "系统信息"); return; } Model.TB_StandardInfo info = new Model.TB_StandardInfo(); bool result; if (!isAdd) { StandardInfo.Stand_Name = txtName.Text; result = standardInfoBLL.Update(StandardInfo); standardParamsBLL.Update(standardParam); } else { info.Stand_Name = txtName.Text; if (StandardInfo.Stand_Level == -1) { info.Stand_Level = 1; info.Stand_ParentID = 0; } else { info.Stand_Level = 2; info.Stand_ParentID = StandardInfo.ID; } result = standardInfoBLL.Add(info); int maxStandInfoId = standardInfoBLL.GetMaxId(); standardParam.StandID = maxStandInfoId; standardParamsBLL.Add(standardParam); } if (!result) { MessageBox.Show("保存到数据库出错,请稍后重试!", "系统错误"); } else { if (isAdd) { RaiseEvent(new RoutedEventArgs(AddOrUpdateLevel2.AddSuccessRoutedEvent, this)); string desc = "添加成功!\r\n"; if (StandardInfo.Stand_Level == -1) { desc += "是否继续添加参考值类别?"; } else { desc += "是否继续为" + StandardInfo.Stand_Name + "添加子参考值?"; } if (MessageBox.Show(desc, "系统信息", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { standardParam = new Model.TB_StandardParams(); txtName.Text = ""; init(); } else { this.DialogResult = true; this.Close(); } } else { this.DialogResult = true; this.Close(); } } }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (txtName.Text == "") { MessageBox.Show("名称不能为空!","系统信息"); return; } Model.TB_StandardInfo info = new Model.TB_StandardInfo(); bool result; if (!isAdd) { StandardInfo.Stand_Name = txtName.Text; result = standardInfoBLL.Update(StandardInfo); standardParamsBLL.Update(standardParam); } else { info.Stand_Name = txtName.Text; if (StandardInfo.Stand_Level == -1) { info.Stand_Level = 1; info.Stand_ParentID = 0; } else { info.Stand_Level = 2; info.Stand_ParentID = StandardInfo.ID; } result = standardInfoBLL.Add(info); int maxStandInfoId= standardInfoBLL.GetMaxId(); standardParam.StandID = maxStandInfoId; standardParamsBLL.Add(standardParam); } if (!result) { MessageBox.Show("保存到数据库出错,请稍后重试!", "系统错误"); } else { if (isAdd) { RaiseEvent(new RoutedEventArgs(AddOrUpdateLevel2.AddSuccessRoutedEvent, this)); string desc = "添加成功!\r\n"; if (StandardInfo.Stand_Level == -1) { desc += "是否继续添加参考值类别?"; } else { desc += "是否继续为" + StandardInfo.Stand_Name + "添加子参考值?"; } if (MessageBox.Show(desc, "系统信息", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { standardParam = new Model.TB_StandardParams(); txtName.Text = ""; init(); } else { this.DialogResult = true; this.Close(); } } else { this.DialogResult = true; this.Close(); } } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { standardBLL = new BLL.TB_StandardInfo(); if (treeModelCollection.Count==0) { rootModel.IsExpanded = true; rootModel.DefaultIcon = "/DSJL;component/Assets/Images/folder.png"; rootModel.OpenedIcon = "/DSJL;component/Assets/Images/folder_opened.png"; rootModel.StandInfo = new Model.TB_StandardInfo() { Stand_Name = "参考值类别", Stand_Level = -1 }; rootModel.IsChecked = true; LoadStandInfo(); } tree.Focus(); selectedItem = null; ItemSelectionChangedEvent(selectedItem); }
private void tree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) { if (tree.SelectedItem != null) { Model.StandInfoTreeDataModel selectedModel = e.NewValue as Model.StandInfoTreeDataModel; if (selectedModel != null) { selectedTreeItem = selectedModel; Model.TB_StandardInfo info = selectedModel.StandInfo; //if (info.Stand_Level >= 1)//点击一、二级标准时才触发 //{ selectedItem = info; if (ItemSelectionChangedEvent != null) { ItemSelectionChangedEvent(selectedItem); } //} } } }
private void Merge() { DbHelperOleDb.SetDBPath(tempExtrctorPath + "DSJLDB.mdb"); DSJL.BLL.TB_AthleteInfo athBLL = new BLL.TB_AthleteInfo(); DSJL.BLL.TB_StandardInfo standBLL = new BLL.TB_StandardInfo(); DSJL.BLL.TB_StandTestRefe refeBLL = new BLL.TB_StandTestRefe(); DSJL.BLL.TB_TestInfo testInfoBLL = new BLL.TB_TestInfo(); DSJL.BLL.TB_TestManager testManagerBLL = new BLL.TB_TestManager(); List <Model.TB_AthleteInfo> athList = athBLL.GetModelList(""); List <Model.TB_StandardInfo> standList = standBLL.GetModelList(""); List <Model.TB_StandTestRefe> refeList = refeBLL.GetModelList(""); List <Model.TB_TestInfo> testInfoList = testInfoBLL.GetModelList(""); List <Model.TB_TestManager> testManagerList = testManagerBLL.GetModelList(""); DbHelperOleDb.SetDefaultDBPath(); Dictionary <int, int> testManagerDict = new Dictionary <int, int>(); Dictionary <int, int> testInfoDict = new Dictionary <int, int>(); Dictionary <int, int> standDict = new Dictionary <int, int>(); Dictionary <int, int> athDict = new Dictionary <int, int>(); for (int i = 0; i < testManagerList.Count; i++) { Model.TB_TestManager managerModel = testManagerList[i]; if (DbHelperOleDb.Exists("TB_TestManager", "TestName", managerModel.TestName)) { managerModel.TestName = managerModel.TestName + "(1)"; } testManagerBLL.Add(managerModel); int newID = testManagerBLL.GetMaxId(); testManagerDict.Add(managerModel.ID, newID); UpdateMergeState(Percent(i + 1, testManagerList.Count), "正在导入测试项目信息..."); } for (int i = 0; i < standList.Count; i++) { Model.TB_StandardInfo standModel = standList[i]; if (DbHelperOleDb.Exists("Tb_StandardInfo", "Stand_Name", standModel.Stand_Name)) { standModel.Stand_Name = standModel.Stand_Name + "(1)"; } standBLL.Add(standModel); int newID = standBLL.GetMaxId(); standDict.Add(standModel.ID, newID); UpdateMergeState(Percent(i + 1, standList.Count), "正在导入测试参考值信息..."); } for (int i = 0; i < athList.Count; i++) { Model.TB_AthleteInfo athModel = athList[i]; athModel.Ath_TestID = testManagerDict[athModel.Ath_TestID]; string existID = ""; int addResult = athBLL.Add(athModel, out existID); int newID = 0; switch (addResult) { case BLL.TB_AthleteInfo.RepeatAdd: newID = int.Parse(existID); break; case BLL.TB_AthleteInfo.Success: newID = athBLL.GetMaxId(); break; } athDict.Add(athModel.ID, newID); UpdateMergeState(Percent(i + 1, athList.Count), "正在导入受测者信息..."); } for (int i = 0; i < testInfoList.Count; i++) { Model.TB_TestInfo testInfoModel = testInfoList[i]; testInfoModel.Ath_ID = athDict[testInfoModel.Ath_ID]; testInfoBLL.Add(testInfoModel); int newID = testInfoBLL.GetMaxId(); string dataFileFullName = AppPath.XmlDataDirPath + testInfoModel.DataFileName; string oldFileName = testInfoModel.DataFileName; if (File.Exists(dataFileFullName)) { testInfoModel.DataFileName = DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".xml"; } File.Copy(tempExtrctorPath + oldFileName, AppPath.XmlDataDirPath + testInfoModel.DataFileName); testInfoDict.Add(testInfoModel.ID, newID); UpdateMergeState(Percent(i + 1, testInfoList.Count), "正在导入测试信息..."); } for (int i = 0; i < refeList.Count; i++) { Model.TB_StandTestRefe refeModel = refeList[i]; refeModel.StandID = standDict[refeModel.StandID]; refeModel.TestID = testInfoDict[refeModel.TestID]; refeBLL.Add(refeModel); UpdateMergeState(Percent(i + 1, refeList.Count), "正在重设数据关系..."); } Directory.Delete(tempExtrctorPath, true); UpdateMergeState(-2, "数据合并完成"); }