private void SubmitAnswerToDB() { INRMainService myMainService = BusinessStaticInstances.GetSingleMainServiceInstance(); InvestigationAnswerInputDto answer = new InvestigationAnswerInputDto() { QuestionId = _questionObj.Id, Question_Type = _questionObj.Type, QuestionSerialNumber = _questionObj.SerialNumber, Answer_Type = currentAnswerType, InvestigationRecordId = (Guid)App.Current.Properties["CurrentRecordId"] }; if (currentChoice == 1) { answer.AnswerValue1 = 1; answer.AnswerValue2 = int.Parse(tb_OptionN.Text); } else { answer.AnswerValue1 = 0; answer.AnswerValue2 = null; } try { myMainService.AddOrUpdateSomeoneInvestigationAnswer(answer); } catch (Exception ex) { MessageBox.Show("出现数据异常:" + ex.Message + ",程序返回首页"); ReturnMainPage(); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { INRDataProcessService myDataProcessService = BusinessStaticInstances.GetSingleDataProcessServiceInstance(); Task task = Task.Factory.StartNew(() => { try { report = myDataProcessService.GetSomeoneRecordStatisticalReport(_recordId); } catch (Exception ex) { MessageBox.Show("查询报告出错:" + ex.Message); this.Close(); } }); WatingWindow waitwindow = new WatingWindow(task); waitwindow.ShowDialog(); textblock_Age.Text = report.Age.ToString(); textblock_BeforeBMI.Text = Math.Round(report.BeforeBMI, 1).ToString(); textblock_BeforeWeight.Text = Math.Round(report.BeforeWeight, 1).ToString(); textblock_BookId.Text = report.HealthBookId; textblock_CurrentWeight.Text = Math.Round(report.CurrentWeight, 1).ToString(); textblock_Height.Text = Math.Round(report.Height, 1).ToString(); textblock_InvestigationTime.Text = report.InvestigationTime.ToString("yyyy-MM-dd"); textblock_Name.Text = report.Name; textblock_Week.Text = report.Week.ToString(); StatisticalReportPage page = new StatisticalReportPage(); page.DataContext = report; frame_Report.Navigate(page); }
private void SubmitAnswerToDB(bool isAnswered) { INRMainService myMainService = BusinessStaticInstances.GetSingleMainServiceInstance(); InvestigationAnswerInputDto answer = new InvestigationAnswerInputDto() { QuestionId = _questionObj.Id, Question_Type = _questionObj.Type, QuestionSerialNumber = _questionObj.SerialNumber, Answer_Type = currentAnswerType, InvestigationRecordId = (Guid)App.Current.Properties["CurrentRecordId"] }; if (isAnswered) { answer.AnswerValue1 = currentFrequency; answer.AnswerValue2 = int.Parse(tb_Intake.Text); } else { answer.AnswerValue1 = null; answer.AnswerValue2 = null; } try { myMainService.AddOrUpdateSomeoneInvestigationAnswer(answer); } catch (Exception ex) { throw ex; } }
private void tb_PrintReport_Click(object sender, RoutedEventArgs e) { Button btn = e.Source as Button; InvestigationRecordViewDto record = btn.Tag as InvestigationRecordViewDto; INRDataProcessService myDataProcessService = BusinessStaticInstances.GetSingleDataProcessServiceInstance(); bool exportResult = false; Exception exportExcepiton = null; Task task = Task.Factory.StartNew(() => { try { myDataProcessService.ExportNutritionalAnalysisReport2Print(record.Id); exportResult = true; } catch (Exception ex) { exportResult = false; exportExcepiton = ex; } }); WatingWindow waitwindow = new WatingWindow(task); waitwindow.ShowDialog(); if (!exportResult) { MessageBox.Show("报告导出失败:" + exportExcepiton.Message); } else { MessageBox.Show("请在Excel中打印报告。\r\n请关闭excel后,再打印下一份报告。"); } }
private void Control_FinishedInputEvent(object sender, EventArgs e) { Guid questionId = (Guid)sender; if (questionId == questionObj.Id) { switch (questionObj.Type) { case QuestionType.Standard: OptionControl_Type1 control1 = grid_Options.Children[0] as OptionControl_Type1; control1.FinishedInputEvent -= Control_FinishedInputEvent; break; case QuestionType.Optional: OptionControl_Type2 control2 = grid_Options.Children[0] as OptionControl_Type2; control2.FinishedInputEvent -= Control_FinishedInputEvent; break; case QuestionType.Choice: OptionControl_Type3 control3 = grid_Options.Children[0] as OptionControl_Type3; control3.FinishedInputEvent -= Control_FinishedInputEvent; break; default: ReturnMainPage(); return; } grid_Options.Children.Clear(); if (questionObj.CurrentProgress < 1) { serialNumber++; LoadQuestionInfo(serialNumber); } else { var task = Task.Factory.StartNew(() => { INRMainService myMainService = BusinessStaticInstances.GetSingleMainServiceInstance(); try { myMainService.FinishSomeoneInvestigationRecord(recordId); } catch (Exception ex) { this.Dispatcher.BeginInvoke(new Action(() => { MessageBox.Show("完成调查发送错误:" + ex.Message); })); } }); WatingWindow waitingWindow = new WatingWindow(task); waitingWindow.ShowDialog(); Frame myframe = App.Current.Properties["MyFrame"] as Frame; myframe.Navigate(new Uri(@"Pages\RecordListPage.xaml", UriKind.Relative)); } } else { MessageBox.Show("发生未知数据错误,程序返回首页"); ReturnMainPage(); } }
private void LoadQuestionInfo(int serialNumber) { try { INRMainService myMainService = BusinessStaticInstances.GetSingleMainServiceInstance(); questionObj = myMainService.GetQuestionViewBySerialNumber(serialNumber, recordId); pb_QuestionProcess.Value = questionObj.CurrentProgress * 100; textblock_FirstCategory.Text = questionObj.FirstCategoryName; textblock_SecondCategory.Text = questionObj.SecondCategoryName; textblock_QuestionDescription.Text = questionObj.Description; switch (questionObj.Type) { case QuestionType.Standard: textblock_FirstCategory.Foreground = new SolidColorBrush(Color.FromRgb(112, 237, 145)); textblock_SecondCategory.Foreground = new SolidColorBrush(Color.FromRgb(112, 237, 145)); textblock_QuestionDescription.Foreground = new SolidColorBrush(Color.FromRgb(112, 237, 145)); pb_QuestionProcess.Foreground = new SolidColorBrush(Color.FromRgb(112, 237, 145)); var control1 = new OptionControl_Type1(questionObj); control1.FinishedInputEvent += Control_FinishedInputEvent; grid_Options.Children.Add(control1); break; case QuestionType.Optional: textblock_FirstCategory.Foreground = new SolidColorBrush(Color.FromRgb(249, 81, 114)); textblock_SecondCategory.Foreground = new SolidColorBrush(Color.FromRgb(249, 81, 114)); textblock_QuestionDescription.Foreground = new SolidColorBrush(Color.FromRgb(249, 81, 114)); pb_QuestionProcess.Foreground = new SolidColorBrush(Color.FromRgb(249, 81, 114)); var control2 = new OptionControl_Type2(questionObj); control2.FinishedInputEvent += Control_FinishedInputEvent; grid_Options.Children.Add(control2); break; case QuestionType.Choice: textblock_FirstCategory.Foreground = new SolidColorBrush(Color.FromRgb(249, 81, 114)); textblock_SecondCategory.Foreground = new SolidColorBrush(Color.FromRgb(249, 81, 114)); textblock_QuestionDescription.Foreground = new SolidColorBrush(Color.FromRgb(249, 81, 114)); pb_QuestionProcess.Foreground = new SolidColorBrush(Color.FromRgb(249, 81, 114)); var control3 = new OptionControl_Type3(questionObj); control3.FinishedInputEvent += Control_FinishedInputEvent; grid_Options.Children.Add(control3); break; default: ReturnMainPage(); return; } } catch (Exception ex) { MessageBox.Show("加载问题失败:" + ex.Message); ReturnMainPage(); } }
private void labelRecordsCount_Loaded(object sender, RoutedEventArgs e) { INRMainService myMainService = BusinessStaticInstances.GetSingleMainServiceInstance(); try { labelRecordsCount.Content = myMainService.GetFinishedInvestigationRecordCount().ToString() + " 份"; } catch (Exception) { labelRecordsCount.Content = "0 份"; } }
private void btn2_Click(object sender, RoutedEventArgs e) { if (cb_Foods.SelectedItem == null) { MessageBox.Show("先选一种食物!"); return; } Foods foods = cb_Foods.SelectedItem as Foods; if (foods == null) { MessageBox.Show("foods转换出错!"); return; } List <FoodNutritionsPostDto> datas = new List <FoodNutritionsPostDto>(); string inputElements = txtInputElements.Text; List <string> ElementsList = inputElements.Split(',').ToList(); if (ElementsList.Count() != 31) { MessageBox.Show("输入错误"); return; } for (int i = 0; i < 30; i++) { FoodNutritionsPostDto newData = new FoodNutritionsPostDto() { FoodId = foods.Id, NutritiveElementId = NutritiveElementIdList[i], Value = (string.IsNullOrEmpty(ElementsList[i + 1]))?0:double.Parse(ElementsList[i + 1]) }; datas.Add(newData); } try { INRDataProcessService myDataService = BusinessStaticInstances.GetSingleDataProcessServiceInstance(); myDataService.CreateFoodNutritionsForTesting(datas); List <Foods> tempsource = cb_Foods.ItemsSource as List <Foods>; tempsource.Remove(foods); cb_Foods.ItemsSource = tempsource; cb_Foods.SelectedIndex = -1; MessageBox.Show("提交成功!"); txtInputElements.Text = string.Empty; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btn_Click(object sender, RoutedEventArgs e) { if (cb_Foods.SelectedItem == null) { MessageBox.Show("先选一种食物!"); return; } Foods foods = cb_Foods.SelectedItem as Foods; if (foods == null) { MessageBox.Show("foods转换出错!"); return; } List <FoodNutritionsPostDto> datas = new List <FoodNutritionsPostDto>(); List <TextBox> listTextBox = GetChildObjects <TextBox>(myWrapPanel, "tb_Element"); foreach (var item in listTextBox) { FoodNutritionsPostDto newData = new FoodNutritionsPostDto() { FoodId = foods.Id, NutritiveElementId = Guid.Parse(item.Tag.ToString()), Value = (string.IsNullOrEmpty(item.Text) ? 0 : double.Parse(item.Text)) }; datas.Add(newData); } try { INRDataProcessService myDataService = BusinessStaticInstances.GetSingleDataProcessServiceInstance(); myDataService.CreateFoodNutritionsForTesting(datas); List <Foods> tempsource = cb_Foods.ItemsSource as List <Foods>; tempsource.Remove(foods); cb_Foods.ItemsSource = tempsource; cb_Foods.SelectedIndex = -1; MessageBox.Show("提交成功!"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btn_Ok_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(tb_Auditor.Text)) { MessageBox.Show("请填写审核人姓名!"); return; } INRMainService myMainService = BusinessStaticInstances.GetSingleMainServiceInstance(); try { myMainService.AuditSomeoneInvestigationRecord(_recordId, tb_Auditor.Text); isOk = true; } catch (Exception ex) { MessageBox.Show("审核出错:" + ex.Message); } this.Close(); }
private void DgUserDataBind() { PageQueryInput <InvestigationRecordQueryConditions> conditions = new PageQueryInput <InvestigationRecordQueryConditions>() { PageSize = myPager.PageSize, PageIndex = myPager.PageIndex, QueryConditions = condition }; try { INRMainService myMainService = BusinessStaticInstances.GetSingleMainServiceInstance(); var result = myMainService.QueryInvestigationRecordListByConditions(conditions); myPager.TotalCount = result.TotalCount; dg_Record.DataContext = result.QueryResult; } catch (Exception ex) { MessageBox.Show(ex.Message); ReturnMainPage(); } }
private void btn_Import_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); //SaveFileDialog sfd = new SaveFileDialog(); ofd.Filter = "Excel文件|*.xlsx"; if (ofd.ShowDialog() == true) { INRDataProcessService myDataProcessService = BusinessStaticInstances.GetSingleDataProcessServiceInstance(); bool importResult = false; Exception exportExcepiton = null; int importCount = 0; int existCount = 0; Task task = Task.Factory.StartNew(() => { try { myDataProcessService.ImportIntakeRecordsExcel(ofd.FileName, out importCount, out existCount); importResult = true; } catch (Exception ex) { importResult = false; exportExcepiton = ex; } }); WatingWindow waitwindow = new WatingWindow(task); waitwindow.ShowDialog(); if (importResult) { MessageBox.Show("已导入" + importCount.ToString() + "条记录,有" + existCount + "条记录已存在,没有导入。"); Page_Loaded(sender, e); } else { MessageBox.Show("导入记录失败:" + exportExcepiton.Message); } } }
private void tb_ExportReport_Click(object sender, RoutedEventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Excel文件|*.xlsx"; Button btn = e.Source as Button; InvestigationRecordViewDto record = btn.Tag as InvestigationRecordViewDto; if (sfd.ShowDialog() == true) { INRDataProcessService myDataProcessService = BusinessStaticInstances.GetSingleDataProcessServiceInstance(); bool exportResult = false; Exception exportExcepiton = null; Task task = Task.Factory.StartNew(() => { try { myDataProcessService.ExportNutritionalAnalysisReport2Excel(record.Id, sfd.FileName); exportResult = true; } catch (Exception ex) { exportResult = false; exportExcepiton = ex; } }); WatingWindow waitwindow = new WatingWindow(task); waitwindow.ShowDialog(); if (exportResult) { MessageBox.Show("已导出" + record.QueueId + "的营养分析报告"); } else { MessageBox.Show("导出失败:" + exportExcepiton.Message); } } }
private void btn_Export_Click(object sender, RoutedEventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Excel文件|*.xlsx"; if (sfd.ShowDialog() == true) { INRDataProcessService myDataProcessService = BusinessStaticInstances.GetSingleDataProcessServiceInstance(); bool exportResult = false; Exception exportExcepiton = null; int exportCount = 0; Task task = Task.Factory.StartNew(() => { try { exportCount = myDataProcessService.ExportNutritionalInvestigationRecords2Excel(condition, sfd.FileName); //exportCount = myDataProcessService.ExportNutritionalResearchReport2Excel(condition, sfd.FileName); exportResult = true; } catch (Exception ex) { exportResult = false; exportExcepiton = ex; } }); WatingWindow waitwindow = new WatingWindow(task); waitwindow.ShowDialog(); if (exportResult) { MessageBox.Show("已导出" + exportCount.ToString() + "条已审核的记录"); } else { MessageBox.Show("导出失败:" + exportExcepiton.Message); } } }
private void buttonBegin_Click(object sender, RoutedEventArgs e) { //App.Current.Properties["CurrentRecordId"] = Guid.Parse("f02a6307-9042-4424-b239-d96efd650a57"); //Frame myframe = App.Current.Properties["MyFrame"] as Frame; //myframe.Navigate(new Uri(@"Pages\QuestionPage.xaml", UriKind.Relative)); if (string.IsNullOrEmpty(textBoxQueueID.Text)) { textBlock_Required1.Visibility = Visibility.Visible; return; } if (string.IsNullOrEmpty(textBoxHealthbookID.Text)) { textBlock_Required2.Visibility = Visibility.Visible; return; } if (string.IsNullOrEmpty(textBoxInvestigatorName.Text)) { textBlock_Required3.Visibility = Visibility.Visible; return; } if (string.IsNullOrEmpty(textBoxName.Text)) { textBlock_Required4.Visibility = Visibility.Visible; return; } if (string.IsNullOrEmpty(textBoxBirthday.Text)) { textBlock_Required5.Visibility = Visibility.Visible; return; } if (string.IsNullOrEmpty(textBoxWeek.Text)) { textBlock_Required6.Visibility = Visibility.Visible; return; } if (string.IsNullOrEmpty(textBoxHeight.Text)) { textBlock_Required7.Visibility = Visibility.Visible; return; } if (string.IsNullOrEmpty(textBoxBeforeWeight.Text)) { textBlock_Required8.Visibility = Visibility.Visible; return; } if (string.IsNullOrEmpty(textBoxCurrentWeight.Text)) { textBlock_Required9.Visibility = Visibility.Visible; return; } if (!textBoxQueueID.Text.IsNumeric()) { MessageBox.Show("队列编码必须为数字"); return; } if (!textBoxHealthbookID.Text.IsNumeric()) { MessageBox.Show("围产保健手册编码必须为数字"); return; } if (!textBoxBirthday.Text.IsDateTime()) { MessageBox.Show("生日应为日期格式"); return; } if (!textBoxWeek.Text.IsNumeric()) { MessageBox.Show("孕周必须为数字"); return; } if (!textBoxHeight.Text.IsFloat()) { MessageBox.Show("身高必须为数字"); return; } if (!textBoxBeforeWeight.Text.IsFloat()) { MessageBox.Show("体重必须为数字"); return; } if (!textBoxCurrentWeight.Text.IsFloat()) { MessageBox.Show("体重必须为数字"); return; } INRMainService myMainService = BusinessStaticInstances.GetSingleMainServiceInstance(); try { NewInvestigationRecordDto newRecord = new NewInvestigationRecordDto() { BeforeWeight = double.Parse(textBoxBeforeWeight.Text), Birthday = DateTime.Parse(textBoxBirthday.Text), CurrentWeight = double.Parse(textBoxCurrentWeight.Text), HealthBookId = textBoxHealthbookID.Text, Height = double.Parse(textBoxHeight.Text), InvestigatorName = textBoxInvestigatorName.Text, Name = textBoxName.Text, QueueId = textBoxQueueID.Text, Week = int.Parse(textBoxWeek.Text) }; Guid myID = myMainService.CreateNewInvestigationRecord(newRecord); App.Current.Properties["CurrentRecordId"] = myID; Frame myframe = App.Current.Properties["MyFrame"] as Frame; myframe.Navigate(new Uri(@"Pages\QuestionPage.xaml", UriKind.Relative), 1); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Page_Loaded(object sender, RoutedEventArgs e) { INRDataProcessService myDataService = BusinessStaticInstances.GetSingleDataProcessServiceInstance(); cb_Foods.ItemsSource = myDataService.GetFoodsList(); }