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);
        }
Beispiel #2
0
        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 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());
            }
        }
Beispiel #5
0
        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);
                }
            }
        }
Beispiel #6
0
        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);
                }
            }
        }
Beispiel #7
0
        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 Page_Loaded(object sender, RoutedEventArgs e)
        {
            INRDataProcessService myDataService = BusinessStaticInstances.GetSingleDataProcessServiceInstance();

            cb_Foods.ItemsSource = myDataService.GetFoodsList();
        }