Browse Source

Merge branch 'master' of https://github.com/zhuyf8899/Laola_questionaire

张亚会 5 years ago
parent
commit
c31467bae6

+ 105 - 78
WpfTest1/MainWindow.xaml

@@ -11,7 +11,7 @@
         Title="劳拉" Height="725" Width="1366"
         ShowTitleBar="True"
         ShowIconOnTitleBar="True"
-
+        PreviewKeyDown="processGrid_KeyDown"
         WindowStartupLocation="CenterScreen"
         WindowState = "Normal" Loaded="MetroWindow_Loaded"
         >
@@ -34,25 +34,8 @@
         </Style>
         <Style  TargetType="{x:Type TabItem}" x:Key="darkItem" >
             <Setter Property="Controls:ControlsHelper.HeaderFontSize" Value="20"/>
-            <!--
-            <Setter Property="Foreground" Value="White"></Setter>
-            <Setter Property="Width" Value="114"></Setter>
-            <Setter Property="Height" Value="39"></Setter>
-            <Setter Property="BorderBrush" Value="#CC00FF"></Setter>
-            <Style.Triggers>
-                <Trigger Property="TabItem.IsSelected" Value="True">
-                    <Setter Property="Background" Value="#4D5667"></Setter>
-                </Trigger>
-            </Style.Triggers>
-            BasedOn="{StaticResource MetroTabItem}"-->
         </Style>
         <Style BasedOn="{StaticResource MetroLabel}" TargetType="{x:Type Label}" x:Key="whiteLabel" >
-            <!--<Setter Property="Foreground" Value="White"></Setter>
-            <Setter Property="Width" Value="114"></Setter>
-            <Setter Property="Height" Value="39"></Setter>
-            <Setter Property="FontSize" Value="20"></Setter>
-            <Setter Property="FontWeight" Value="13"></Setter>
-            //change the "Value" to your required size-->
         </Style>
     </Controls:MetroWindow.Resources>
     <Controls:MetroWindow.RightWindowCommands>
@@ -74,12 +57,12 @@
             </Button>
         </Controls:WindowCommands>
     </Controls:MetroWindow.RightWindowCommands>
-    <Grid x:Name="mainWndGrid" Background="#FFFFFF" >
+    <Grid x:Name="mainWndGrid" Background="#FFFFFF">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="395*"/>
             <ColumnDefinition Width="959*"/>
         </Grid.ColumnDefinitions>
-        <TabControl x:Name="tabControlGeneral"  HorizontalAlignment="Left" Height="694" VerticalAlignment="Top" Width="1358" SelectionChanged="tabControlGeneral_SelectionChanged" Grid.ColumnSpan="2" Controls:TabControlHelper.Underlined="TabPanel" >
+        <TabControl x:Name="tabControlGeneral"  HorizontalAlignment="Left" Height="694" VerticalAlignment="Top" Width="1358" SelectionChanged="tabControlGeneral_SelectionChanged" Grid.ColumnSpan="2" Controls:TabControlHelper.Underlined="TabPanel">
             <TabItem Header="首页" Style="{StaticResource smallHeader}" x:Uid="1000">
                 <Grid  Margin="-1,-1,-1,-1">
                     <Grid.Background>
@@ -113,44 +96,44 @@
                             </DataTemplate>
                         </Button.ContentTemplate>
                     </Button>
-                    <Button x:Name="buttonHomePageMeasureFunction" Content="Button" HorizontalAlignment="Left" Margin="699,178,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#008b7b">
+                    <Button x:Name="buttonHomePageFilterFunction" Content="Button" HorizontalAlignment="Left" Margin="699,178,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#008b7b" Click="buttonHomePageFilterFunction_Click">
                         <Button.ContentTemplate>
                             <DataTemplate>
                                 <StackPanel>
                                     <Rectangle Fill="#ffffff" Width="80" Height="80">
                                         <Rectangle.OpacityMask>
-                                            <VisualBrush Visual="{StaticResource appbar_medical_pulse}" Stretch="Fill" />
+                                            <VisualBrush Visual="{StaticResource appbar_clipboard_paper_check}" Stretch="Fill" />
                                         </Rectangle.OpacityMask>
                                     </Rectangle>
-                                    <TextBlock Text="检测操作"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
+                                    <TextBlock Text="快速筛查"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
                                 </StackPanel>
                             </DataTemplate>
                         </Button.ContentTemplate>
                     </Button>
-                    <Button x:Name="buttonHomePageHistoryRecord" Content="Button" HorizontalAlignment="Left" Margin="886,178,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#daa520">
+                    <Button x:Name="buttonHomePageEvaluationFunction" Content="Button" HorizontalAlignment="Left" Margin="886,178,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#daa520" Click="buttonHomePageEvaluationFunction_Click">
                         <Button.ContentTemplate>
                             <DataTemplate>
                                 <StackPanel>
                                     <Rectangle Fill="#ffffff" Width="80" Height="80">
                                         <Rectangle.OpacityMask>
-                                            <VisualBrush Visual="{StaticResource appbar_journal}" Stretch="Fill" />
+                                            <VisualBrush Visual="{StaticResource appbar_magnify_browse}" Stretch="Fill" />
                                         </Rectangle.OpacityMask>
                                     </Rectangle>
-                                    <TextBlock Text="历史记录"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
+                                    <TextBlock Text="详细评估"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
                                 </StackPanel>
                             </DataTemplate>
                         </Button.ContentTemplate>
                     </Button>
-                    <Button x:Name="buttonHomePageReport" Content="Button" HorizontalAlignment="Left" Margin="315,359,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#9370db" Click="buttonHomePageReport_Click">
+                    <Button x:Name="buttonHomeHistoryRecords" Content="Button" HorizontalAlignment="Left" Margin="315,359,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#9370db" Click="buttonHomeHistoryRecords_Click">
                         <Button.ContentTemplate>
                             <DataTemplate>
                                 <StackPanel>
                                     <Rectangle Fill="#ffffff" Width="80" Height="80">
                                         <Rectangle.OpacityMask>
-                                            <VisualBrush Visual="{StaticResource appbar_newspaper}" Stretch="Fill" />
+                                            <VisualBrush Visual="{StaticResource appbar_window_restore}" Stretch="Fill" />
                                         </Rectangle.OpacityMask>
                                     </Rectangle>
-                                    <TextBlock Text="检测报告"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
+                                    <TextBlock Text="历史报告"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
                                 </StackPanel>
                             </DataTemplate>
                         </Button.ContentTemplate>
@@ -161,7 +144,7 @@
                                 <StackPanel>
                                     <Rectangle Fill="#ffffff" Width="80" Height="80">
                                         <Rectangle.OpacityMask>
-                                            <VisualBrush Visual="{StaticResource appbar_settings}" Stretch="Fill" />
+                                            <VisualBrush Visual="{StaticResource appbar_cogs}" Stretch="Fill" />
                                         </Rectangle.OpacityMask>
                                     </Rectangle>
                                     <TextBlock Text="系统设置"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
@@ -169,16 +152,16 @@
                             </DataTemplate>
                         </Button.ContentTemplate>
                     </Button>
-                    <Button x:Name="buttonHomePageDataTransfer" Content="Button" HorizontalAlignment="Left" Margin="699,359,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#008080" >
+                    <Button x:Name="buttonHomePageDataTransfer" Content="Button" HorizontalAlignment="Left" Margin="699,359,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#008080" Click="buttonHomePageDataTransfer_Click">
                         <Button.ContentTemplate>
                             <DataTemplate>
                                 <StackPanel>
                                     <Rectangle Fill="#ffffff" Width="80" Height="80">
                                         <Rectangle.OpacityMask>
-                                            <VisualBrush Visual="{StaticResource appbar_share}" Stretch="Fill" />
+                                            <VisualBrush Visual="{StaticResource appbar_information_circle}" Stretch="Fill" />
                                         </Rectangle.OpacityMask>
                                     </Rectangle>
-                                    <TextBlock Text="数据传输"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
+                                    <TextBlock Text="关于程序"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
                                 </StackPanel>
                             </DataTemplate>
                         </Button.ContentTemplate>
@@ -197,7 +180,7 @@
                             </DataTemplate>
                         </Button.ContentTemplate>
                     </Button>
-                    <Label x:Name="labelHomepageCversion" Content="编译日期:20190726" HorizontalAlignment="Left" Margin="594,109,0,0" VerticalAlignment="Top" Foreground="White"/>
+                    <Label x:Name="labelHomepageCversion" Content="编译版本:20200301" HorizontalAlignment="Left" Margin="594,109,0,0" VerticalAlignment="Top" Foreground="White"/>
                 </Grid>
             </TabItem>
             <TabItem Header="用户管理" Style="{StaticResource smallHeader}" >
@@ -212,7 +195,6 @@
                     </TabItem>
                 </TabControl>
             </TabItem>
-
             <!--快筛-->
             <TabItem Header="筛查" Style="{StaticResource smallHeader}" >
                 <TabControl x:Name="tabFilter" HorizontalAlignment="Left" Height="645" Width="1338" Margin="10,-5,0,0" VerticalAlignment="Top" >
@@ -222,26 +204,98 @@
                             <Button x:Name="buttonFilterSelectPatient" IsEnabled="True" Content="开始测试" HorizontalAlignment="Left" Margin="41,531,0,0" VerticalAlignment="Top" Width="240" Height="36" FontSize="15" Click="buttonFilterSelectPatient_Click"/>
                         </Grid>
                     </TabItem>
-                    <TabItem  Header="筛查流程" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
-                        <Grid Background="White" Margin="0,0,0,0">
-                            
-                            <Button x:Name="buttonAbortFilter" Content="中止筛查" HorizontalAlignment="Left" Margin="1150,35,0,0" VerticalAlignment="Top" Width="132" Height="50" FontSize="18" Background="#FFB92424" Foreground="White" Click="buttonAbortFilter_Click"/>
-                            <Label x:Name="labelGong" Content="共" HorizontalAlignment="Left" Margin="490,36,0,0" VerticalAlignment="Top" FontSize="30"/>
-                            <Label x:Name="labelFilterNumberofTotalQuestions" Content="XXX" HorizontalAlignment="Left" Margin="530,36,0,0" VerticalAlignment="Top" FontSize="30"/>
-                            <Label x:Name="labelTi" Content="题,当前第" HorizontalAlignment="Left" Margin="600,36,0,0" VerticalAlignment="Top" FontSize="30"/>
-                            <Label x:Name="labelFilterNumberofCurrentQuestion" Content="XXX" HorizontalAlignment="Left" Margin="760,36,0,0" VerticalAlignment="Top" FontSize="30"/>
-                            <Label x:Name="labelTi2" Content="题" HorizontalAlignment="Left" Margin="830,36,0,0" VerticalAlignment="Top" FontSize="30"/>
+                    <TabItem  Header="筛查流程" Style="{StaticResource smallerHeader}"  IsEnabled="False">
+                        <Grid x:Name="filterProcessGrid" Background="White" Margin="0,0,0,0">
+                            <Label x:Name="labelGong" Content="共" HorizontalAlignment="Left" Margin="90,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelFilterNumberofTotalQuestions" Content="XXX" HorizontalAlignment="Left" Margin="110,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelTi" Content="题,当前第" HorizontalAlignment="Left" Margin="150,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelFilterNumberofCurrentQuestion" Content="XXX" HorizontalAlignment="Left" Margin="240,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelTi2" Content="题" HorizontalAlignment="Left" Margin="280,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelFilterQuestionTitle" Content="[问题的标题,大约需要30个汉字,所以空间需要够]" HorizontalAlignment="Left" Margin="90,36,0,0" VerticalAlignment="Top" FontSize="30"/>
                             <TextBlock x:Name="textBlockFilterQuetionContent" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,90,0,0" TextWrapping="Wrap" Text="Here is the question content." Height="200" Width="1150" FontSize="20"/>
                             <Grid x:Name="gridFilterSelection" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,300,0,0" Width="1150" Height="200" ></Grid>
                             <Button x:Name="buttonFilterPrevious" Content="上一题" HorizontalAlignment="Left" Margin="424,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonFilterPrevious_Click" />
                             <Button x:Name="buttonFilterNext" Content="下一题" HorizontalAlignment="Left" Margin="784,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonFilterNext_Click" />
                             <Button x:Name="buttonSubmitFilter" Content="提交" HorizontalAlignment="Left" Margin="604,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Background="#FF317602" Foreground="White" IsEnabled="False" Click="buttonSubmitFilter_Click"/>
+                            <Button x:Name="buttonAbortFilter" Content="中止筛查" HorizontalAlignment="Left" Margin="1150,550,0,0" VerticalAlignment="Top" Width="132" Height="50" FontSize="18" Background="#FFB92424" Foreground="White" Click="buttonAbortFilter_Click"/>
+                        </Grid>
+                    </TabItem>
+                    <TabItem  Header="筛查报告" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
+                        <Grid Background="White" Margin="0,0,0,0">
+                            <Label x:Name="labelPDF" Content="该报告已在第三方软件中打开" HorizontalAlignment="Left" Margin="543,133,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Button x:Name="buttonFilterBackToSelectUser" Content="开始新的筛查" HorizontalAlignment="Left" Margin="500,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonFilterBackToSelectUser_Click" />
+                            <Button x:Name="buttonFilterBackToHome" Content="回到首页" HorizontalAlignment="Left" Margin="700,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonFilterBackToHome_Click" />
                         </Grid>
                     </TabItem>
                 </TabControl>
 
             </TabItem>
-
+            <!--评估-->
+            <TabItem Header="评估" Style="{StaticResource smallHeader}" >
+                <TabControl x:Name="tabEvaluation" HorizontalAlignment="Left" Height="645" Width="1338" Margin="10,-5,0,0" VerticalAlignment="Top" >
+                    <TabItem  Header="选择用户" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
+                        <Grid Background="White" Margin="0,0,0,0">
+                            <my:selectUser x:Name="selectUserevaluation" Margin="0,0,0,0"/>
+                            <Button x:Name="buttonEvaluationSelectPatient" IsEnabled="True" Content="开始测试" HorizontalAlignment="Left" Margin="41,531,0,0" VerticalAlignment="Top" Width="240" Height="36" FontSize="15" Click="buttonEvaluationSelectPatient_Click"/>
+                        </Grid>
+                    </TabItem>
+                    <TabItem  Header="评估流程" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
+                        <Grid Background="White" Margin="0,0,0,0">
+                            <Label x:Name="labelTiE" Content="当前第" HorizontalAlignment="Left" Margin="94,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelQuestionNumberofCurrentQuestion" Content="XXX" HorizontalAlignment="Left" Margin="150,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelTi2E" Content="题" HorizontalAlignment="Left" Margin="190,10,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Label x:Name="labelEvaluationQuestionTitle" Content="[问题的标题,大约需要30个汉字,所以空间需要够]" HorizontalAlignment="Left" Margin="90,36,0,0" VerticalAlignment="Top" FontSize="30"/>
+                            <TextBlock x:Name="textBlockEvaluationQuetionContent" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,90,0,0" TextWrapping="Wrap" Text="Here is the question content." Height="200" Width="1150" FontSize="20"/>
+                            <Grid x:Name="gridEvaluationSelection" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="94,300,0,0" Width="1150" Height="200" ></Grid>
+                            <Button x:Name="buttonEvaluationPrevious" Content="上一题" HorizontalAlignment="Left" Margin="424,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonEvaluationPrevious_Click" />
+                            <Button x:Name="buttonEvaluationNext" Content="下一题" HorizontalAlignment="Left" Margin="784,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" IsEnabled="False" Click="buttonEvaluationNext_Click" />
+                            <Button x:Name="buttonSubmitEvaluation" Content="提交" HorizontalAlignment="Left" Margin="604,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Background="#FF317602" Foreground="White" IsEnabled="False" Click="buttonSubmitEvaluation_Click"/>
+                            <Button x:Name="buttonAbortEvaluation" Content="中止评估" HorizontalAlignment="Left" Margin="1150,550,0,0" VerticalAlignment="Top" Width="132" Height="50" FontSize="18" Background="#FFB92424" Foreground="White" Click="buttonAbortEvaluation_Click"/>
+                        </Grid>
+                    </TabItem>
+                    <TabItem  Header="评估报告" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
+                        <Grid Background="White" Margin="0,0,0,0">
+                            <Label x:Name="labelPDFE" Content="该报告已在第三方软件中打开" HorizontalAlignment="Left" Margin="543,133,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Button x:Name="buttonEvaluationBackToSelectUser" Content="开始新的评估" HorizontalAlignment="Left" Margin="500,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonEvaluationBackToSelectUser_Click" />
+                            <Button x:Name="buttonEvaluationBackToHome" Content="回到首页" HorizontalAlignment="Left" Margin="700,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonEvaluationBackToHome_Click" />
+                        </Grid>
+                    </TabItem>
+                </TabControl>
+            </TabItem>
+            <!--历史报告-->
+            <TabItem Header="历史报告" Style="{StaticResource smallHeader}" >
+                <TabControl x:Name="tabHistoryRecords" HorizontalAlignment="Left" Height="645" Width="1338" Margin="10,-5,0,0" VerticalAlignment="Top" >
+                    <TabItem  Header="选择病例" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
+                        <Grid Background="White" Margin="0,0,0,0">
+                            <my:selectUser x:Name="selectUserHistory" Margin="0,0,0,0"/>
+                            <Button x:Name="buttonHistorySelectPatient" IsEnabled="True" Content="选择该病例" HorizontalAlignment="Left" Margin="41,531,0,0" VerticalAlignment="Top" Width="240" Height="36" FontSize="15" Click="buttonHistorySelectPatient_Click"/>
+                        </Grid>
+                    </TabItem>
+                    <TabItem  Header="选择记录" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
+                        <Grid Background="White" Margin="0,0,0,0">
+                            <DataGrid x:Name="dataGridRecords" AutoGenerateColumns="False" IsReadOnly="True"  HorizontalAlignment="Left" Margin="299,10,0,0" VerticalAlignment="Top" Height="603" Width="1039" Loaded="LoadDoctorDataGrid" MouseDoubleClick="dataGridRecords_MouseDoubleClick">
+                                <DataGrid.Columns>
+                                    <DataGridTextColumn Header="报告编号" Binding="{Binding r_id}" Width="180"/>
+                                    <DataGridTextColumn Header="报告类型" Binding="{Binding r_type_d}" Width="150"/>
+                                    <DataGridTextColumn Header="生成时间" Binding="{Binding r_time}" Width="180"/>
+                                    <DataGridTextColumn Header="已生成次数" Binding="{Binding r_count}" Width="120"/>
+                                </DataGrid.Columns>
+                            </DataGrid>
+                            <Button x:Name="buttonRegenerateReport" FontSize="18" Content="生成该报告" HorizontalAlignment="Left" Margin="26,40,0,0" VerticalAlignment="Top" Width="236" Height="38" Click="buttonRegenerateReport_Click"/>
+                            <Button x:Name="buttonHistoryBack" FontSize="18" Content="返回上一级" HorizontalAlignment="Left" Margin="26,98,0,0" VerticalAlignment="Top" Width="236" Height="38" Click="buttonHistoryBackToSelectUser_Click"/>
+                        </Grid>
+                    </TabItem>
+                    <TabItem  Header="评估报告" Style="{StaticResource smallerHeader}"  IsEnabled="False" >
+                        <Grid Background="White" Margin="0,0,0,0">
+                            <Label x:Name="labelPDFH" Content="该报告已在第三方软件中打开" HorizontalAlignment="Left" Margin="543,133,0,0" VerticalAlignment="Top" FontSize="18"/>
+                            <Button x:Name="buttonHistoryBackToSelectUser" Content="重新选择病例" HorizontalAlignment="Left" Margin="400,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonHistoryBackToSelectUser_Click" />
+                            <Button x:Name="buttonHistoryBackToSelectRecord" Content="返回上一级" HorizontalAlignment="Left" Margin="600,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonHistoryBackToSelectRecord_Click" />
+                            <Button x:Name="buttonHistoryBackToHome" Content="回到首页" HorizontalAlignment="Left" Margin="800,550,0,0" VerticalAlignment="Top" Width="130" Height="50" FontSize="18" Click="buttonHistoryBackToHome_Click" />
+                        </Grid>
+                    </TabItem>
+                </TabControl>
+            </TabItem>
+            <!--系统设置-->
             <TabItem Header="系统设置" x:Name="tabitemDoctorSetting" Style="{StaticResource smallHeader}">
                 <TabControl x:Name="tabControlSystemSetting" HorizontalAlignment="Left" Height="645" Margin="10,-5,0,0" VerticalAlignment="Top" Width="1338" SelectionChanged="tabControlSystemSetting_SelectionChanged">
                     <TabItem Header="医师账户管理" Style="{StaticResource smallerHeader}" >
@@ -263,47 +317,20 @@
                             <Button x:Name="buttonChangeDoctorPWD" FontSize="18" Content="修改医师密码" HorizontalAlignment="Left" Margin="26,154,0,0" VerticalAlignment="Top" Width="236" Height="38" Click="buttonChangeDoctorPWD_Click"/>
                         </Grid>
                     </TabItem>
-                    <!--<TabItem Header="常用语编辑" Style="{StaticResource smallerHeader}" >
-                        <Grid x:Name="Seeting_PasswordManagent" Background="White" Margin="0,0,0,0">
-                            <Grid.ColumnDefinitions>
-                                <ColumnDefinition Width="71*"/>
-                                <ColumnDefinition Width="1165*"/>
-                            </Grid.ColumnDefinitions>
-                            <DataGrid x:Name="dataGridCommlang" AutoGenerateColumns="False" IsReadOnly="True" HorizontalAlignment="Left" Margin="228,10,0,0" VerticalAlignment="Top" Height="626" Width="914" Grid.Column="1" Loaded="commlangGrid_Loaded" MouseDoubleClick="dataGridCommlang_MouseDoubleClick">
-                                <DataGrid.Columns>
-                                    <DataGridTextColumn Header="编号" Binding="{Binding id}" Width="90"/>
-                                    <DataGridTextColumn Header="内容" Binding="{Binding content}" Width="500"/>
-                                    <DataGridTextColumn Header="简单描述" Binding="{Binding describe}" Width="200"/>
-                                </DataGrid.Columns>
-                            </DataGrid>
-                            <Button x:Name="buttonAddCommlang" FontSize="18" Content="新增常用语" HorizontalAlignment="Left" Margin="26,40,0,0" VerticalAlignment="Top" Width="236" Height="38" Grid.ColumnSpan="2" Click="buttonAddCommlang_Click"/>
-                            <Button x:Name="buttonChangeCommlang" FontSize="18" Content="修改常用语" HorizontalAlignment="Left" Margin="26,102,0,0" VerticalAlignment="Top" Width="236" Height="38" Grid.ColumnSpan="2" Click="buttonChangeCommlang_Click"/>
-                            <Button x:Name="buttonDeleteCommlang" FontSize="18" Content="删除常用语" HorizontalAlignment="Left" Margin="26,162,0,0" VerticalAlignment="Top" Width="236" Height="38" Grid.ColumnSpan="2" Click="buttonDeleteCommlang_Click"/>
-
-                        </Grid>
-                    </TabItem>-->
-                    <TabItem Header="软件激活管理及其他设置" Style="{StaticResource smallerHeader}" >
+                    <TabItem Header="其他设置" Style="{StaticResource smallerHeader}" >
                         <Grid>
-                            <GroupBox x:Name="groupBoxRegisterInfo" Header="软件激活信息" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="113" Width="1314">
+                            <GroupBox x:Name="groupBoxRegisterInfo" Header="医疗机构信息" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="113" Width="1314">
                                 <Grid>
-                                    <Label x:Name="label3_Copy3" Content="激活状态:已激活           授权于:" HorizontalAlignment="Left" Margin="10,15,0,0" VerticalAlignment="Top" FontSize="18"/>
-                                    <Label x:Name="labelOrganizationName" Content="[机构名称]" HorizontalAlignment="Left" Margin="300,15,0,0" VerticalAlignment="Top" FontSize="18"/>
-                                    <Button x:Name="buttonModifyRegisterInfo" Content="使用其他激活码激活此程序..." HorizontalAlignment="Left" Margin="931,15,0,0" VerticalAlignment="Top" Width="242" Height="34" FontSize="16" Click="buttonModifyRegisterInfo_Click"/>
+                                    <TextBox x:Name="textBoxOrganizationName" HorizontalAlignment="Left" FontSize="18" Height="36" Margin="10,20,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="500" />
+                                    <Button x:Name="buttonModifyRegisterInfo" Content="更新医疗机构名称" HorizontalAlignment="Left" Margin="931,15,0,0" VerticalAlignment="Top" Width="242" Height="34" FontSize="16" Click="buttonModifyRegisterInfo_Click"/>
                                 </Grid>
                             </GroupBox>
                             <GroupBox x:Name="groupBoxDocSetting" Header="其他设置" HorizontalAlignment="Left" Margin="10,128,0,0" VerticalAlignment="Top" Height="150" Width="1314">
                                 <Grid>
-                                    <RadioButton x:Name="radioButtonBP_mmhg" GroupName="bp_unit" Content="mmHg" HorizontalAlignment="Left" Margin="105,10,0,0" VerticalAlignment="Top"/>
-                                    <RadioButton x:Name="radioButtonBP_kpa" GroupName="bp_unit" Content="kPa" HorizontalAlignment="Left" Margin="181,10,0,0" VerticalAlignment="Top"/>
-                                    <Label x:Name="label6" Content="血压显示单位:" HorizontalAlignment="Left" Margin="10,8,0,0" VerticalAlignment="Top"/>
-                                    <Button x:Name="buttonSaveDocSetting" Content="保存设置(重启后生效)" HorizontalAlignment="Left" Margin="254,6,0,0" VerticalAlignment="Top" Width="124" Click="buttonSaveDocSetting_Click"/>
-                                    <Label x:Name="label66" Content="数据库整理(以节约存储空间):" HorizontalAlignment="Left" Margin="10,50,0,0" VerticalAlignment="Top"/>
+                                    <Label x:Name="label66" Content="数据库清理(以节约存储空间):" HorizontalAlignment="Left" Margin="10,50,0,0" VerticalAlignment="Top"/>
                                     <Button x:Name="buttonOptmizeDatabase" Content="点击整理" HorizontalAlignment="Left" Margin="254,50,0,0" VerticalAlignment="Top" Width="124" Click="buttonOptmizeDatabase_Click"/>
-                                    <Label x:Name="label666" Content="清空所有已生成的PDF诊断报告:" HorizontalAlignment="Left" Margin="400,50,0,0" VerticalAlignment="Top"/>
+                                    <Label x:Name="label666" Content="清理缓存文件:" HorizontalAlignment="Left" Margin="400,50,0,0" VerticalAlignment="Top"/>
                                     <Button x:Name="buttonDeleteAllPdfReport" Content="点击清空" HorizontalAlignment="Left" Margin="600,50,0,0" VerticalAlignment="Top" Width="124" Click="buttonDeleteFiles_Click"/>
-                                    <Label x:Name="label6666" Content="清空所有已生成的导出波形文件:" HorizontalAlignment="Left" Margin="800,50,0,0" VerticalAlignment="Top"/>
-                                    <Button x:Name="buttonDeleteAllCSVWave" Content="点击清空" HorizontalAlignment="Left" Margin="1000,50,0,0" VerticalAlignment="Top" Width="124" Click="buttonDeleteFiles_Click"/>
-
                                 </Grid>
                             </GroupBox>
                         </Grid>

+ 689 - 155
WpfTest1/MainWindow.xaml.cs

@@ -10,6 +10,7 @@ using System.Data;
 using WpfTest1.SQLite;
 using WpfTest1.Toolkits;
 using LitJson;
+using System.ComponentModel;
 
 namespace WpfTest1
 {
@@ -27,16 +28,24 @@ namespace WpfTest1
         //double lowBp;                                         //BP界面低压
         DateTime lastSettingLogin;                              //上一次在系统设置界面登陆的时间
         public Toolkits.Config cfg;                //从数据库取配置的类
-        #endregion
 
-        #region 优化系统效率参数
         Patient filterPatient;
+        Patient evaluationPatient;
+        Patient historyPatient;
+        Record filterReportForEvaluation;
+        bool flagEvaluationWithoutFilter = true;
         List<QuestionAnswerPair> filterQuestionaire = new List<QuestionAnswerPair>();
         List<QuestionAnswerPair> evaluationQuestionaire = new List<QuestionAnswerPair>();
         List<UserSelection> filterUserSelection = new List<UserSelection>();
-        List<UserSelection> evaluation = new List<UserSelection>();
+        List<UserSelection> evaluationUserSelection = new List<UserSelection>();
+        string resultsFilter;
+        string resultsEvaluation;
         int currentFilterCount = 0;
-        
+        int currentEvaluationCount = 0;
+        List<Record> recordsFromOnePatient;
+        BindingList<Record> bindingRecords;
+        Dictionary<string, int> mapKeyToDigit = new Dictionary<string, int>();
+
         #endregion
 
         public MainWindow()
@@ -47,25 +56,17 @@ namespace WpfTest1
             //绑定三个selectUser的父类
             //selectUserMeasure.setMainWindow(this);
             selectUserPatientManagent.setMainWindow(this);
-            //selectUserHistory.setMainWindow(this);
-
+            selectUserfilter.setMainWindow(this);
+            selectUserevaluation.setMainWindow(this);
+            selectUserHistory.setMainWindow(this);
+            textBoxOrganizationName.Text = cfg.organization_name;
         }
 
         #region 初始化与系统调用部分
 
         //初始化全部组件后需要先输入医生密码才能进入
-        //async 
         private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
         {   
-            //Thread.Sleep(2000);
-            //首先验证注册机制
-            
-            bool registerSuccess = cfg.CheckRegisterCode();
-            if (!registerSuccess)
-            {
-                SmallDialogs.RegisterCode rc = new SmallDialogs.RegisterCode(this,cfg,true);
-                rc.ShowDialog();
-            }
             //之后测试登陆
             SmallDialogs.LoginWindow lw = new SmallDialogs.LoginWindow(this);
             lw.ShowDialog();
@@ -81,6 +82,8 @@ namespace WpfTest1
             }
             loadQuestionaire(filterQuestionaire, "filter");
             loadQuestionaire(evaluationQuestionaire, "evaluation");
+            labelHomepageCversion.Content = "编译日期:" + Toolkits.Constants.compileDate;
+            
         }
 
         private void loadQuestionaire(List<QuestionAnswerPair> oneQuestionaire, string type = "filter")
@@ -89,12 +92,99 @@ namespace WpfTest1
             List<Question> questions = SQLite.SQLiteModel.getQuestions(type);
             foreach (Question oneQuestion in questions)
             {
-                List<Answer> answers = SQLite.SQLiteModel.getAnswersByQid(oneQuestion.q_id.ToString());
+                List<Answer> answers = SQLite.SQLiteModel.getAnswersByQid(oneQuestion.q_id);
                 QuestionAnswerPair temp = new QuestionAnswerPair(oneQuestion, answers);
                 oneQuestionaire.Add(temp);
             }
         }
 
+        /// <summary>
+        /// 筛查或评估流程页面识别快捷键的操作
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void processGrid_KeyDown(object sender, KeyEventArgs e)
+        {
+            //System.Console.WriteLine(String.Format("KeyDown detected. {0} is detected.", e.Key.ToString()));
+            if (tabControlGeneral.SelectedIndex == 2 && tabFilter.SelectedIndex == 1)
+            {
+                //筛查流程中
+                if (e.Key == Key.N && buttonFilterNext.IsEnabled)
+                {
+                    buttonFilterNext_Click(sender, (RoutedEventArgs)e);
+                    return;
+                }
+                if (e.Key == Key.P && buttonFilterPrevious.IsEnabled)
+                {
+                    buttonFilterPrevious_Click(sender, (RoutedEventArgs)e);
+                    return;
+                }
+                if (e.Key == Key.E)
+                {
+                    buttonAbortFilter_Click(sender, (RoutedEventArgs)e);
+                    return;
+                }
+                if(e.Key == Key.S && buttonSubmitFilter.IsEnabled)
+                {
+                    buttonSubmitFilter_Click(sender, (RoutedEventArgs)e);
+                    return;
+                }
+                if (Constants.keyboardToDigit.ContainsKey(e.Key.ToString()))
+                {
+                    int numInput = Constants.keyboardToDigit[e.Key.ToString()];
+                    try
+                    {
+                        RadioButton rbTemp = (RadioButton)gridFilterSelection.Children[numInput - 1];
+                        rbTemp.IsChecked = true;
+                        radioButtonFilter_Checked(rbTemp, e);
+                    }
+                    catch (Exception)
+                    {
+                        return;
+                    }
+                    
+                    return;
+                }
+            }
+            else if(tabControlGeneral.SelectedIndex == 3 && tabEvaluation.SelectedIndex == 1)
+            {
+                //评估流程中
+                if (e.Key == Key.N && buttonEvaluationNext.IsEnabled)
+                {
+                    buttonEvaluationNext_Click(sender, (RoutedEventArgs)e);
+                    return;
+                }
+                if (e.Key == Key.E)
+                {
+                    buttonAbortEvaluation_Click(sender, (RoutedEventArgs)e);
+                    return;
+                }
+                if (e.Key == Key.S && buttonSubmitEvaluation.IsEnabled)
+                {
+                    buttonSubmitEvaluation_Click(sender, (RoutedEventArgs)e);
+                    return;
+                }
+                if (Constants.keyboardToDigit.ContainsKey(e.Key.ToString()))
+                {
+                    int numInput = Constants.keyboardToDigit[e.Key.ToString()];
+                    try
+                    {
+                        RadioButton rbTemp = (RadioButton)gridEvaluationSelection.Children[numInput - 1];
+                        rbTemp.IsChecked = true;
+                        radioButtonEvaluation_Checked(rbTemp, e);
+                    }
+                    catch (Exception)
+                    {
+                        return;
+                    }
+                }
+            }
+            else
+            {
+                return;
+            }
+        }
+
         #endregion
 
         #region 首页功能
@@ -117,18 +207,35 @@ namespace WpfTest1
             tabControlGeneral.SelectedIndex = 1;
         }
 
+        private void buttonHomePageFilterFunction_Click(object sender, RoutedEventArgs e)
+        {
+            tabControlGeneral.SelectedIndex = 2;
+        }
+
+        private void buttonHomePageEvaluationFunction_Click(object sender, RoutedEventArgs e)
+        {
+            tabControlGeneral.SelectedIndex = 3;
+        }
+
         //首页--检测报告
-        private void buttonHomePageReport_Click(object sender, RoutedEventArgs e)
+        private void buttonHomeHistoryRecords_Click(object sender, RoutedEventArgs e)
         {
-            //buttonResultOpenDirHistory_Click(this, e);
+            tabControlGeneral.SelectedIndex = 4;
         }
 
         //首页--系统设置
         private void buttonHomePageSystemSettings_Click(object sender, RoutedEventArgs e)
         {
-            tabControlGeneral.SelectedIndex = 2;
+            tabControlGeneral.SelectedIndex = 5;
+        }
+
+        //关于程序
+        private void buttonHomePageDataTransfer_Click(object sender, RoutedEventArgs e)
+        {
+            SmallDialogs.AboutBox ab = new SmallDialogs.AboutBox();
+            ab.Show();
         }
-       
+
         //首页--操作帮助
         private void buttonHomePageHelp_Click(object sender, RoutedEventArgs e)
         {
@@ -270,6 +377,9 @@ namespace WpfTest1
         private void buttonAbortFilter_Click(object sender, RoutedEventArgs e)
         {
             filterUserSelection.Clear();
+            filterPatient = null;
+            resultsFilter = "";
+
             currentFilterCount = 0;
             buttonFilterPrevious.IsEnabled = false;
             buttonFilterNext.IsEnabled = false;
@@ -341,6 +451,7 @@ namespace WpfTest1
         {
             labelFilterNumberofTotalQuestions.Content = filterQuestionaire.Count.ToString();
             labelFilterNumberofCurrentQuestion.Content = currentIndex.ToString();
+            labelFilterQuestionTitle.Content = filterQuestionaire[currentIndex - 1].question.q_title;
             textBlockFilterQuetionContent.Text = filterQuestionaire[currentIndex - 1].question.q_content;
             int countOptions = filterQuestionaire[currentIndex - 1].answers.Count;
             gridFilterSelection.Children.Clear();
@@ -355,7 +466,7 @@ namespace WpfTest1
                     oneOption.IsChecked = true;
                 else
                     oneOption.IsChecked = false;
-                oneOption.Content = filterQuestionaire[currentIndex - 1].answers[i].a_content;
+                oneOption.Content = String.Format("[选项{0}]:{1}", i+1, filterQuestionaire[currentIndex - 1].answers[i].a_content) ;
                 oneOption.Checked += radioButtonFilter_Checked;
                 oneOption.GroupName = "filterOption";
                 oneOption.FontSize = 18;
@@ -381,27 +492,559 @@ namespace WpfTest1
         /// <param name="e">默认</param>
         private void buttonSubmitFilter_Click(object sender, RoutedEventArgs e)
         {
-            MessageBoxResult dr = MessageBox.Show("确定提交吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+            int inserted_r_id;
+            resultsFilter = JsonMapper.ToJson(filterUserSelection);
+            //MessageBox.Show(results);
+            try
+            {
+                inserted_r_id = SQLiteModel.insertRecord(1, filterPatient.p_id, loginDoctor.id, 0, DateTime.Now, 0, resultsFilter);
+                SQLiteModel.UpdatePatientDataWithLastDate(filterPatient.p_id, "p_last_filter_time", DateTime.Now);
+            }
+            catch (Exception err)
+            {
+                MessageBox.Show("储存筛查报告错误\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误");
+                return;
+            }
+            MessageBoxResult dr = MessageBox.Show("保存筛查结果成功,是否生成报告?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
             if (dr == MessageBoxResult.OK)
             {
-                string results = JsonMapper.ToJson(filterUserSelection);
-                //MessageBox.Show(results);
                 try
                 {
-                    SQLiteModel.insertRecord(1, filterPatient.p_id, loginDoctor.id, 0, DateTime.Now, 0, results);
-                    SQLiteModel.UpdatePatientDataWithLastDate(filterPatient.p_id, "p_last_filter_time", DateTime.Now);
+                    Record targetRecord = SQLiteModel.getRecordByID(inserted_r_id);
+                    ReportGenerater.generateReport(1, filterPatient, loginDoctor, targetRecord, cfg.organization_name);
+                    SQLiteModel.plusOneCountOnRecordByRid(inserted_r_id);
                 }
                 catch (Exception err)
                 {
-                    MessageBox.Show("储存筛查报告错误\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误");
+                    MessageBox.Show("报告生成异常,可能是这份报告当前已被打开无法写入,请尝试关闭该报告后重试。\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误");
                     return;
                 }
-                MessageBox.Show("保存成功", "提示");
+                tabFilter.SelectedIndex = 2;
+            }
+            else
+            {
                 buttonAbortFilter_Click(sender, e);
             }
             return;
         }
 
+        /// <summary>
+        /// 返回至选择用户页
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonFilterBackToSelectUser_Click(object sender, RoutedEventArgs e)
+        {
+            buttonAbortFilter_Click(sender, e);
+        }
+
+        /// <summary>
+        /// 返回至选择首页
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonFilterBackToHome_Click(object sender, RoutedEventArgs e)
+        {
+            buttonAbortFilter_Click(sender, e);
+            tabControlGeneral.SelectedIndex = 0;
+        }
+
+        #endregion
+
+        #region 评估功能
+
+        /// <summary>
+        /// 点击开始评估后触发的事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        public void buttonEvaluationSelectPatient_Click(object sender, RoutedEventArgs e)
+        {
+            //基本逻辑如下:先找七天内与病例相匹配的筛查记录,如果有,那么要取出结果一题一题比对
+            //如果没有,那么应当把筛查题进行加载处理
+            try
+            {
+                var target = (DataRowView)this.selectUserevaluation.dataGrid.SelectedItem;
+                evaluationPatient = SQLite.SQLiteModel.getPatientById(target["p_id"].ToString());
+            }
+            catch (Exception err)
+            {
+                MessageBox.Show("请选择一个病例进行修改\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "警告");
+                return;
+            }
+            if (evaluationPatient == null)
+            {
+                MessageBox.Show("数据库加载异常", "错误");
+                return;
+            }
+            try
+            {
+                loadQuestionaire(filterQuestionaire, "filter");
+                evaluationQuestionaire.Clear();
+                filterUserSelection.Clear();
+                evaluationUserSelection.Clear();
+                //这里尝试加载用户的筛查记录
+                filterReportForEvaluation = SQLiteModel.getLatestXTypeRecordInYDays(evaluationPatient.p_id, 1, 7);
+                if(filterReportForEvaluation == null)
+                {
+                    flagEvaluationWithoutFilter = true;
+                    foreach (QuestionAnswerPair qa in filterQuestionaire)
+                    {
+                        filterUserSelection.Add(new UserSelection(qa.question.q_id, 0));
+                    }
+                }
+                else
+                {
+                    var jsonUserSelections = filterReportForEvaluation.r_selection;
+                    filterUserSelection = JsonMapper.ToObject<List<UserSelection>>(jsonUserSelections);
+                    flagEvaluationWithoutFilter = false;
+                }
+                
+            }
+            catch (Exception err)
+            {
+                MessageBox.Show("筛查题目加载失败\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误");
+                return;
+            }
+            if (filterQuestionaire.Count == 0)
+            {
+                MessageBox.Show("筛查题目加载失败\r\n数据库中无有效问卷", "错误");
+                return;
+            }
+            if (flagEvaluationWithoutFilter)
+            {
+                MessageBox.Show("发现该病例一周内未进行初筛,评估过程中将自动进行初筛。","提示");
+            }
+            else
+            {
+                MessageBox.Show("发现该病例于"+ filterReportForEvaluation.r_time.ToString("yyyy-MM-dd HH:mm:ss") +"进行过初筛,评估过程中将使用此初筛结果。", "提示");
+            }
+            currentFilterCount = 1;
+            currentEvaluationCount = 1;
+            evaluationQuestionaire.Add(filterQuestionaire[currentFilterCount - 1]);
+            evaluationUserSelection.Add(filterUserSelection[currentFilterCount - 1]);
+            tabEvaluation.SelectedIndex += 1;
+            checkStatusEvaluation();
+        }
+
+        /// <summary>
+        /// 加载currentIndex的评估题目功能
+        /// </summary>
+        /// <param name="currentIndex">需要显示题目的题号</param>
+        private void loadQuestionViewEvaluation(int currentIndex)
+        {
+            labelQuestionNumberofCurrentQuestion.Content = currentIndex.ToString();
+            labelEvaluationQuestionTitle.Content = evaluationQuestionaire[currentIndex - 1].question.q_title;
+            textBlockEvaluationQuetionContent.Text = evaluationQuestionaire[currentIndex - 1].question.q_content;
+            int countOptions = evaluationQuestionaire[currentIndex - 1].answers.Count;
+            gridEvaluationSelection.Children.Clear();
+            for (int i = 0; i < countOptions; ++i)
+            {
+                RadioButton oneOption = new RadioButton();
+                oneOption.Height = 30;
+                oneOption.HorizontalAlignment = HorizontalAlignment.Left;
+                oneOption.VerticalAlignment = VerticalAlignment.Top;
+                oneOption.Margin = new Thickness(i / 5 * 200, i % 5 * 40, 0, 0);
+                if (evaluationUserSelection[currentIndex - 1].a_id == evaluationQuestionaire[currentIndex - 1].answers[i].a_id)
+                    oneOption.IsChecked = true;
+                else
+                    oneOption.IsChecked = false;
+                oneOption.Content = String.Format("[选项{0}]:{1}", i + 1, evaluationQuestionaire[currentIndex - 1].answers[i].a_content);
+               oneOption.Checked += radioButtonEvaluation_Checked;
+               oneOption.GroupName = "evaluationOption";
+               oneOption.FontSize = 18;
+               oneOption.Name = "rbe" + evaluationQuestionaire[currentIndex - 1].answers[i].a_id.ToString();
+               gridEvaluationSelection.Children.Add(oneOption);
+            }
+        }
+
+        /// <summary>
+        /// 检查当前答题状态,判断是否需要跳过该题和控制加载题目的功能,能够维护userselection和questionaire
+        /// </summary>
+        private void checkStatusEvaluation()
+        {
+            if(!flagEvaluationWithoutFilter && evaluationQuestionaire[currentEvaluationCount-1].question.q_type == 1)
+            {
+                //有预加载的筛查报告且当前问题是一道筛查题
+                Answer aTemp = SQLiteModel.getAnswerById(filterUserSelection[currentFilterCount - 1].a_id);
+                if (aTemp == null || aTemp.next_q_id == 0)
+                {
+                    if(currentFilterCount == filterQuestionaire.Count)
+                    {
+                        //当前所有题目都已经做完了
+                        buttonEvaluationNext.IsEnabled = false;
+                        bool allQuestionAreSeleceted = true;
+                        foreach (UserSelection us in evaluationUserSelection)
+                        {
+                            if (us.a_id == 0)
+                                allQuestionAreSeleceted = false;
+                        }
+                        //经过检查可以提交
+                        buttonSubmitEvaluation.IsEnabled = allQuestionAreSeleceted;
+                    }
+                    else
+                    {
+                        //还有剩下的筛选题没有过
+                        QuestionAnswerPair qaPairEvaluation = filterQuestionaire[currentFilterCount];
+                        //当前元素后面的题目和选项都清空
+                        for (int i = evaluationQuestionaire.Count - 1; i > currentEvaluationCount - 1; --i)
+                        {
+                            evaluationQuestionaire.RemoveAt(i);
+                            evaluationUserSelection.RemoveAt(i);
+                        }
+                        evaluationQuestionaire.Add(qaPairEvaluation);
+                        evaluationUserSelection.Add(filterUserSelection[currentFilterCount]);
+                        //再刷新一次
+                        ++currentFilterCount;
+                        ++currentEvaluationCount;
+                        checkStatusEvaluation();
+                    }
+
+                }
+                else
+                {
+                    //否则还有评估题没做
+                    Question aEvaluationQuestion = SQLiteModel.getQuestionById(aTemp.next_q_id);
+                    List<Answer> answersToTheEvaluation = SQLiteModel.getAnswersByQid(aEvaluationQuestion.q_id);
+                    QuestionAnswerPair qaPairEvaluation = new QuestionAnswerPair(aEvaluationQuestion, answersToTheEvaluation);
+                    //当前元素后面的题目和选项都清空
+                    for(int i= evaluationQuestionaire.Count - 1; i > currentEvaluationCount - 1; --i)
+                    {
+                        evaluationQuestionaire.RemoveAt(i);
+                        evaluationUserSelection.RemoveAt(i);
+                    }
+                    evaluationQuestionaire.Add(qaPairEvaluation);
+                    evaluationUserSelection.Add(new UserSelection(aEvaluationQuestion.q_id, 0));
+                    //再刷新一次
+                    ++currentEvaluationCount;
+                    checkStatusEvaluation();
+                }
+            }
+            else
+            {
+                //其他情况:没有预加载的筛选题或者有预加载的筛选题但是是一道评估题
+                loadQuestionViewEvaluation(currentEvaluationCount);
+                buttonEvaluationNext.IsEnabled = false;
+                buttonSubmitEvaluation.IsEnabled = false;
+            }
+        }
+
+        /// <summary>
+        /// 评估单选选项被选中的触发事件,主要是修改内存中的选择和判断下一题及提交按钮是否可用
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void radioButtonEvaluation_Checked(object sender, RoutedEventArgs e)
+        {
+            //首先,记录该选择
+            RadioButton oneSelection = (RadioButton)sender;
+            evaluationUserSelection[currentEvaluationCount - 1].a_id = Convert.ToInt32(oneSelection.Name.Substring(3));
+            if (flagEvaluationWithoutFilter && evaluationQuestionaire[currentEvaluationCount-1].question.q_type ==1)
+            {
+                filterUserSelection[currentFilterCount - 1].a_id = Convert.ToInt32(oneSelection.Name.Substring(3));
+            }
+            //MessageBox.Show(filterUserSelection[currentFilterCount - 1].a_id.ToString());
+            Answer oneAnswer = SQLiteModel.getAnswerById(evaluationUserSelection[currentEvaluationCount - 1].a_id);
+            if(currentFilterCount == filterQuestionaire.Count && oneAnswer.next_q_id == 0)
+            {
+                //后面没有题目了,可以提交
+                buttonEvaluationNext.IsEnabled = false;
+                bool allQuestionAreSeleceted = true;
+                foreach (UserSelection us in evaluationUserSelection)
+                {
+                    if (us.a_id == 0)
+                        allQuestionAreSeleceted = false;
+                }
+                //经过检查可以提交
+                buttonSubmitEvaluation.IsEnabled = allQuestionAreSeleceted;
+            }
+            else
+            {
+                //否则可以做下一题
+                buttonEvaluationNext.IsEnabled = true;
+                buttonSubmitEvaluation.IsEnabled = false;
+            }
+            
+        }
+
+        /// <summary>
+        /// (未实现)评估过程中点击上一题的触发事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonEvaluationPrevious_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        /// <summary>
+        /// 点击评估页下一题后触发的事件,主要是判断接下来加载哪一题
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonEvaluationNext_Click(object sender, RoutedEventArgs e)
+        {
+            //先看看后面有没有进退阶题目了
+            Answer oneAnswer = SQLiteModel.getAnswerById(evaluationUserSelection[currentEvaluationCount - 1].a_id);
+            if(oneAnswer.next_q_id!= 0)
+            {
+                //还有后续题目
+                Question aEvaluationQuestion = SQLiteModel.getQuestionById(oneAnswer.next_q_id);
+                List<Answer> answersToTheEvaluation = SQLiteModel.getAnswersByQid(aEvaluationQuestion.q_id);
+                QuestionAnswerPair qaPairEvaluation = new QuestionAnswerPair(aEvaluationQuestion, answersToTheEvaluation);
+                //当前元素后面的题目和选项都清空
+                for (int i = evaluationQuestionaire.Count - 1; i > currentEvaluationCount - 1; --i)
+                {
+                    evaluationQuestionaire.RemoveAt(i);
+                    evaluationUserSelection.RemoveAt(i);
+                }
+                evaluationQuestionaire.Add(qaPairEvaluation);
+                evaluationUserSelection.Add(new UserSelection(aEvaluationQuestion.q_id, 0));
+                //再刷新一次
+                ++currentEvaluationCount;
+                checkStatusEvaluation();
+            }
+            else
+            {
+                //否则跳到下一个筛选题上面
+                QuestionAnswerPair qaPairEvaluation = filterQuestionaire[currentFilterCount];
+                //当前元素后面的题目和选项都清空
+                for (int i = evaluationQuestionaire.Count - 1; i > currentEvaluationCount - 1; --i)
+                {
+                    evaluationQuestionaire.RemoveAt(i);
+                    evaluationUserSelection.RemoveAt(i);
+                }
+                evaluationQuestionaire.Add(qaPairEvaluation);
+                evaluationUserSelection.Add(filterUserSelection[currentFilterCount]);
+                //再刷新一次
+                ++currentFilterCount;
+                ++currentEvaluationCount;
+                checkStatusEvaluation();
+            }
+        }
+
+        /// <summary>
+        /// 点击评估页提交后触发的事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonSubmitEvaluation_Click(object sender, RoutedEventArgs e)
+        {
+            int inserted_r_id;
+            resultsFilter = JsonMapper.ToJson(filterUserSelection);
+            resultsEvaluation = JsonMapper.ToJson(evaluationUserSelection);
+            try
+            {
+                int tempRId;
+                if (flagEvaluationWithoutFilter)
+                {
+                    tempRId = SQLiteModel.insertRecord(1, evaluationPatient.p_id, loginDoctor.id, 0, DateTime.Now, 0, resultsFilter);
+                    SQLiteModel.UpdatePatientDataWithLastDate(evaluationPatient.p_id, "p_last_filter_time", DateTime.Now);
+                }
+                else
+                {
+                    tempRId = filterReportForEvaluation.r_id;
+                }
+                inserted_r_id = SQLiteModel.insertRecord(2, evaluationPatient.p_id, loginDoctor.id, tempRId, DateTime.Now, 0, resultsEvaluation);
+                SQLiteModel.UpdatePatientDataWithLastDate(evaluationPatient.p_id, "p_last_evaluation_time", DateTime.Now);
+            }
+            catch (Exception err)
+            {
+                MessageBox.Show("储存筛查报告错误\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误");
+                return;
+            }
+            MessageBoxResult dr = MessageBox.Show("保存成功,是否生成报告?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+            if (dr == MessageBoxResult.OK)
+            {
+                try
+                {
+                    Record targetRecord = SQLiteModel.getRecordByID(inserted_r_id);
+                    SQLiteModel.plusOneCountOnRecordByRid(inserted_r_id);
+                    ReportGenerater.generateReport(2, evaluationPatient, loginDoctor, targetRecord, cfg.organization_name);
+                }
+                catch (Exception err)
+                {
+                    MessageBox.Show("报告生成异常,可能是这份报告当前已被打开无法写入,请尝试关闭该报告后重试。\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误");
+                    return;
+                }
+
+                tabEvaluation.SelectedIndex = 2;
+            }
+            else
+            {
+                buttonAbortEvaluation_Click(sender, e);
+            }
+            return;
+        }
+
+        /// <summary>
+        /// 点击评估页中止评估后触发的事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonAbortEvaluation_Click(object sender, RoutedEventArgs e)
+        {
+            //清理相关变量
+            filterQuestionaire.Clear();
+            filterUserSelection.Clear();
+            evaluationQuestionaire.Clear();
+            evaluationUserSelection.Clear();
+            flagEvaluationWithoutFilter = true;
+            filterReportForEvaluation = null;
+            evaluationPatient = null;
+            resultsFilter = "";
+            resultsEvaluation = "";
+
+            currentFilterCount = 0;
+            currentEvaluationCount = 0;
+            //buttonFilterPrevious.IsEnabled = false;
+            buttonEvaluationNext.IsEnabled = false;
+            buttonSubmitEvaluation.IsEnabled = false;
+
+            tabEvaluation.SelectedIndex = 0;
+        }
+
+        /// <summary>
+        /// 返回至选择用户页
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonEvaluationBackToSelectUser_Click(object sender, RoutedEventArgs e)
+        {
+            buttonAbortEvaluation_Click(sender, e);
+        }
+
+        /// <summary>
+        /// 返回至选择首页
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonEvaluationBackToHome_Click(object sender, RoutedEventArgs e)
+        {
+            buttonAbortEvaluation_Click(sender, e);
+            tabControlGeneral.SelectedIndex = 0;
+        }
+
+        #endregion
+
+        #region 历史记录
+
+        /// <summary>
+        /// 点击选择病例查看其历史记录后触发的事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        public void buttonHistorySelectPatient_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                var target = (DataRowView)this.selectUserHistory.dataGrid.SelectedItem;
+                historyPatient = SQLiteModel.getPatientById(Convert.ToString(target["p_id"]));
+                recordsFromOnePatient = SQLiteModel.getRecordsByPid(Convert.ToInt32(target["p_id"]));
+            }
+            catch (Exception err)
+            {
+                MessageBox.Show("请选择一个病例进行修改\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "警告");
+                return;
+            }
+            if (recordsFromOnePatient == null || historyPatient == null)
+            {
+                MessageBox.Show("数据库加载异常", "错误");
+                return;
+            }
+
+            try
+            {
+                bindingRecords = new BindingList<Record>(recordsFromOnePatient);
+                dataGridRecords.ItemsSource = bindingRecords;
+            }
+            catch(Exception err)
+            {
+                MessageBox.Show("数据库加载异常\r\n调试信息:\r\n"+err.StackTrace, "错误");
+                return;
+            }
+            tabHistoryRecords.SelectedIndex = 1;
+        }
+
+        /// <summary>
+        /// 在选择记录页面,点击返回上一级触发的事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonHistoryBackToSelectUser_Click(object sender, RoutedEventArgs e)
+        {
+            recordsFromOnePatient.Clear();
+            tabHistoryRecords.SelectedIndex = 0;
+        }
+
+        /// <summary>
+        /// 由历史记录相关页面返回至首页的事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonHistoryBackToHome_Click(object sender, RoutedEventArgs e)
+        {
+            recordsFromOnePatient.Clear();
+            tabHistoryRecords.SelectedIndex = 0;
+            tabControlGeneral.SelectedIndex = 0;
+        }
+
+        /// <summary>
+        /// 点击生成报告的页面
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonRegenerateReport_Click(object sender, RoutedEventArgs e)
+        {
+            Record targetRecord;
+            try
+            {
+                var target = this.dataGridRecords.SelectedItem as Record;
+                targetRecord = SQLiteModel.getRecordByID(Convert.ToInt32(target.r_id));
+            }
+            catch (Exception err)
+            {
+                MessageBox.Show("请选择一个记录进行生成\r\n" + err.StackTrace, "提示");
+                return;
+            }
+            if (targetRecord == null)
+            {
+                MessageBox.Show("数据库加载异常", "错误");
+                return;
+            }
+            try
+            {
+                ReportGenerater.generateReport(targetRecord.r_type, historyPatient, loginDoctor, targetRecord, cfg.organization_name);
+                SQLiteModel.plusOneCountOnRecordByRid(targetRecord.r_id);
+            }
+            catch(Exception err)
+            {
+                MessageBox.Show("报告生成异常,可能是这份报告当前已被打开无法写入,请尝试关闭该报告后重试。\r\n调试信息:\r\n" + err.StackTrace, "错误");
+                return;
+            }
+            tabHistoryRecords.SelectedIndex = 2;
+        }
+
+        /// <summary>
+        /// 从报告生成页点击返回上一页的事件
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonHistoryBackToSelectRecord_Click(object sender, RoutedEventArgs e)
+        {
+            tabHistoryRecords.SelectedIndex = 1;
+        }
+
+        /// <summary>
+        /// 双击报告也要生成报告的功能
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void dataGridRecords_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            buttonRegenerateReport_Click(sender, e);
+        }
+
         #endregion
 
         #region 系统设置
@@ -615,122 +1258,25 @@ namespace WpfTest1
         }
         #endregion
 
-        #region 常用语编辑
-        /*
-        //系统设置--常用语编辑
-        private void commlangGrid_Loaded(object sender, RoutedEventArgs e)
-        {
-            LoadCommlangDataGrid();
-        }
-        public void LoadCommlangDataGrid()
-        {
-            //连接字符串
-            string Connstr = "Data Source=" + System.Environment.CurrentDirectory + "\\Junde.db3"; ;
-            //连接对象
-            System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection(Connstr);
-            //Sql语句
-            string selectCmd = "SELECT * FROM CommonWords LIMIT 100";
-            con.Open();
-            da = new System.Data.SQLite.SQLiteDataAdapter(selectCmd, con);
-            ds = new DataSet();
-            da.Fill(ds);
+        #region 其他设置
 
-            dataGridCommlang.ItemsSource = ds.Tables[0].DefaultView;
-            con.Close();
-        }
-        //新增常用语
-        private void buttonAddCommlang_Click(object sender, RoutedEventArgs e)
-        {
-            AddCommonWords a_new_commonword = new AddCommonWords(this);
-            a_new_commonword.Show();
-        }
-        //编辑常用语
-        private void buttonChangeCommlang_Click(object sender, RoutedEventArgs e)
-        {
-            try
-            {
-                var target = (DataRowView)this.dataGridCommlang.SelectedItem;
-                //MessageBox.Show(target["id"].ToString());
-                ModifyCommonWords modify_one = new ModifyCommonWords(this, target["id"].ToString());
-                modify_one.Show();
-            }
-            catch (Exception err)
-            {
-                this.ShowMessageAsync("警告", "请选择一个常用语进行修改\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace);
-            }
-        }
-        //删除常用语
-        private async void buttonDeleteCommlang_Click(object sender, RoutedEventArgs e)
-        {
-            try
-            {
-                var target = (DataRowView)this.dataGridCommlang.SelectedItem;
-                if (target == null)
-                {
-                    await this.ShowMessageAsync("提示", "请选择一个常用语进行删除");
-                    return;
-                }
-                MessageDialogResult clickresult = await this.ShowMessageAsync("提示", "确认删除该常用语吗?", MessageDialogStyle.AffirmativeAndNegative);
-                if (clickresult == MessageDialogResult.Affirmative)//确认
-                {
-                    int status = SQLite.SQLiteModel.DeleteCommonWordsItem(target["id"].ToString());
-                    if (status > 0)
-                    {
-                        await this.ShowMessageAsync("提示", "删除成功!");
-                    }
-                    else
-                    {
-                        await this.ShowMessageAsync("警告", "目标已被删除");
-                    }
-                }
-                else//取消
-                {
-                    return;
-                }
-            }
-            catch (Exception err)
-            {
-                await this.ShowMessageAsync("警告", "请选择一个常用语进行删除!\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace);
-            }
-
-
-            LoadCommlangDataGrid();
-        }
-        //双击表格触发修改常用语的功能
-        private void dataGridCommlang_MouseDoubleClick(object sender, MouseButtonEventArgs e)
-        {
-            buttonChangeCommlang_Click(sender, e);
-        }
-        //*/
-        #endregion
-
-        #region 软件激活管理
-        //重新激活程序
+        /// <summary>
+        /// 更换医疗机构名称
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
         private void buttonModifyRegisterInfo_Click(object sender, RoutedEventArgs e)
         {
-            SmallDialogs.RegisterCode rc = new SmallDialogs.RegisterCode(this, cfg, false);
-            rc.ShowDialog();
-        }
-
-        //保存其他医生级别的设置,如显示血压的单位
-        private void buttonSaveDocSetting_Click(object sender, RoutedEventArgs e)
-        {
-            string bp_unit_temp = "1";
-            if (radioButtonBP_kpa.IsChecked == true)
-            {
-                bp_unit_temp = "2";
-            }
             try
             {
-                SQLite.SQLiteModel.UpdateDocSetting(bp_unit_temp);
+                SQLiteModel.UpdateOrganizationName(Toolkits.FilterDangerousCharacter.filter(textBoxOrganizationName.Text));
             }
-            catch (Exception err)
+            catch (Exception)
             {
-                this.ShowMessageAsync("错误", "数据库读写失败,调试信息:\r\n" + err.StackTrace);
+                MessageBox.Show("更新失败!", "错误");
             }
-
-            cfg.refresh();
-            this.ShowMessageAsync("提示", "修改成功");
+            MessageBox.Show("更新成功", "提示");
+            
         }
 
         /// <summary>
@@ -743,19 +1289,20 @@ namespace WpfTest1
             try
             {
                 //获取标记为删除的病人记录
-                List<string> ids_to_be_deleted = SQLite.SQLiteModel.getDeletedPatients();
+                List<int> ids_to_be_deleted = SQLite.SQLiteModel.getDeletedPatients();
                 //确实删除这些病人记录
                 SQLite.SQLiteModel.realDeleteRecords();
                 //确实删除这些病人所含有的检查记录
-                foreach(string each_line in ids_to_be_deleted)
+                foreach(int each_line in ids_to_be_deleted)
                 {
-                    //SQLite.SQLiteModel.DeleteRecordItem(each_line);
+                    SQLite.SQLiteModel.deleteRecordByPid(each_line);
                 }
+                //SQLiteModel.optmizeDatabase();
                 MessageBox.Show("操作完成", "信息");
             }
-            catch (Exception)
+            catch (Exception err)
             {
-                MessageBox.Show("数据库异常", "错误");
+                MessageBox.Show("数据库异常\r\b"+err.Message+"\r\b"+err.StackTrace, "错误");
             }
         }
 
@@ -770,9 +1317,6 @@ namespace WpfTest1
             if (((Button)sender).Equals(buttonDeleteAllPdfReport))
             {
                 target_path = Constants.reportPath;
-            }else if (((Button)sender).Equals(buttonDeleteAllCSVWave))
-            {
-                target_path = Constants.exportWavePath;
             }
             try
             {
@@ -797,18 +1341,8 @@ namespace WpfTest1
                 MessageBox.Show("文件系统异常", "错误");
             }
         }
-
-
-
-
-
-
         #endregion
 
         #endregion
-
-        
     }
-
-
 }

+ 0 - 57
WpfTest1/PatientInfo.xaml

@@ -1,57 +0,0 @@
-<UserControl x:Class="WpfTest1.PatientInfo"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             xmlns:local="clr-namespace:WpfTest1"
-             xmlns:my="clr-namespace:WpfTest1"
-             mc:Ignorable="d" Height="116" Width="1330"
-             >
-    <!--d:DesignHeight="300" d:DesignWidth="300"-->
-    <Grid>
-        <Grid Margin="0,0,0,0">
-            <GroupBox x:Name="groupBox" Header="病例基本信息及输入参数" HorizontalAlignment="Left" Margin="0,0,0,-116" VerticalAlignment="Top" Height="116" Width="1330">
-                <Grid Margin="0,0,84,0">
-                    <Label x:Name="label2_Copy" Content="身份证号:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy1" Content="病例号:" HorizontalAlignment="Left" Margin="215,9,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy2" Content="姓名:" HorizontalAlignment="Left" Margin="400,9,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy3" Content="孕次:" HorizontalAlignment="Left" Margin="532,10,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy4" Content="产次:" HorizontalAlignment="Left" Margin="603,10,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy5" Content="年龄:" HorizontalAlignment="Left" Margin="675,10,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy6" Content="身高:" HorizontalAlignment="Left" Margin="759,10,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy7" Content="cm   体重:" HorizontalAlignment="Left" Margin="844,10,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <TextBox x:Name="textBoxIDNum" HorizontalAlignment="Left" Height="25" Margin="80,9,0,0" TextWrapping="Wrap" Text="123123123123123139" VerticalAlignment="Top" Width="130" IsEnabled="False"/>
-                    <TextBox x:Name="textBoxPaID" HorizontalAlignment="Left" Height="17" Margin="264,10,0,0" TextWrapping="Wrap" Text="123123123123123139" VerticalAlignment="Top" Width="131" IsEnabled="False"/>
-                    <TextBox x:Name="textBoxName" HorizontalAlignment="Left" Height="17" Margin="440,10,0,0" TextWrapping="Wrap" Text="李二狗" VerticalAlignment="Top" Width="87" IsEnabled="False"/>
-                    <TextBox x:Name="textBoxPerg_time" HorizontalAlignment="Left" Height="24" Margin="573,10,0,0" TextWrapping="Wrap" Text="12" VerticalAlignment="Top" Width="25" IsEnabled="False"/>
-                    <TextBox x:Name="textBoxProd_time" HorizontalAlignment="Left" Height="25" Margin="645,10,0,0" TextWrapping="Wrap" Text="23" VerticalAlignment="Top" Width="25" IsEnabled="False"/>
-                    <TextBox x:Name="textBoxAge" HorizontalAlignment="Left" Height="25" Margin="721,10,0,0" TextWrapping="Wrap" Text="100" VerticalAlignment="Top" Width="33" IsEnabled="False"/>
-                    <TextBox x:Name="textBoxHeight" HorizontalAlignment="Left" Height="17" Margin="805,10,0,0" TextWrapping="Wrap" Text="299" VerticalAlignment="Top" Width="34" IsEnabled="False"/>
-                    <TextBox x:Name="textBoxDescription" HorizontalAlignment="Left" Height="17" Margin="1030,10,0,0" TextWrapping="Wrap" Text="(无)" VerticalAlignment="Top" Width="160" IsEnabled="False"/>
-                    <Label x:Name="label2_Copy11" Content="收缩压:" HorizontalAlignment="Left" Margin="10,48,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="bp_unit1" Content="mmHg" HorizontalAlignment="Left" Margin="108,48,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy12" Content="舒张压:" HorizontalAlignment="Left" Margin="157,48,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="bp_unit2" Content="mmHg" HorizontalAlignment="Left" Margin="252,49,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy22" Content="平均动脉压:" HorizontalAlignment="Left" Margin="313,49,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="bp_unit3" Content="mmHg" HorizontalAlignment="Left" Margin="426,49,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy33" Content="体重指数:" HorizontalAlignment="Left" Margin="484,49,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy44" Content="kg   备注:" HorizontalAlignment="Left" Margin="963,11,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy55" Content="孕周:" HorizontalAlignment="Left" Margin="619,48,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy66" Content="周" HorizontalAlignment="Left" Margin="709,48,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy77" Content="天" HorizontalAlignment="Left" Margin="783,48,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <TextBox x:Name="textBoxHighBP" HorizontalAlignment="Left" Height="22" Margin="68,48,0,0" TextWrapping="Wrap"  VerticalAlignment="Top" Width="33" IsEnabled="False" TextChanged="textBoxHighBP_TextChanged"/>
-                    <TextBox x:Name="textBoxLowBP" HorizontalAlignment="Left" Height="25" Margin="215,48,0,0" TextWrapping="Wrap"  VerticalAlignment="Top" Width="32" IsEnabled="False" TextChanged="textBoxLowBP_TextChanged"/>
-                    <TextBox x:Name="textBoxMeanBP" HorizontalAlignment="Left" Height="25" Margin="389,48,0,0" TextWrapping="Wrap"  VerticalAlignment="Top" Width="32" IsEnabled="False"/>
-                    <TextBox x:Name="textBoxWeight" HorizontalAlignment="Left" Height="25" Margin="923,9,0,0" TextWrapping="Wrap" Text="999" VerticalAlignment="Top" Width="35" IsEnabled="False"/>
-                    <TextBox x:Name="textBoxBMI" HorizontalAlignment="Left" Height="25" Margin="544,47,0,0" TextWrapping="Wrap" Text="23.1235" VerticalAlignment="Top" Width="54" IsEnabled="False"/>
-                    <TextBox x:Name="textBoxWeek" HorizontalAlignment="Left" Height="25" Margin="665,48,0,0" TextWrapping="Wrap" Text="100" VerticalAlignment="Top" Width="33" IsEnabled="False"/>
-                    <TextBox x:Name="textBoxDay" HorizontalAlignment="Left" Height="17" Margin="741,47,0,0" TextWrapping="Wrap" Text="299" VerticalAlignment="Top" Width="34" IsEnabled="False"/>
-                    
-
-                </Grid>
-
-            </GroupBox>
-
-        </Grid>
-    </Grid>
-</UserControl>

+ 0 - 130
WpfTest1/PatientInfo.xaml.cs

@@ -1,130 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-using WpfTest1.SQLite;
-
-namespace WpfTest1
-{
-    /// <summary>
-    /// PatientInfo.xaml 的交互逻辑
-    /// PatientInfo是显示在各个界面的病例信息组件
-    /// </summary>
-    public partial class PatientInfo : UserControl
-    {
-        public PatientInfo()
-        {
-            InitializeComponent();
-            textBoxHighBP.IsEnabled = false;
-            textBoxLowBP.IsEnabled = false;
-        }
-        public void setPatientInfo(Patient onePerson, bool bpReadOnly = false)
-        {
-            
-            fillBlanks(onePerson);
-            if (bpReadOnly)
-            {
-                textBoxHighBP.IsEnabled = false;
-                textBoxLowBP.IsEnabled = false;
-            }
-            else
-            {
-                textBoxHighBP.IsEnabled = true;
-                textBoxLowBP.IsEnabled = true;
-            }
-        }
-
-        public void setPatientInfo(Patient onePerson, double highBp, double lowBp, Toolkits.Config cfg, bool bpReadOnly = true)
-        {
-            fillBlanks(onePerson);
-            if (cfg.bp_unit_hhmg == 1)
-            {
-                textBoxHighBP.Text = highBp.ToString();
-                textBoxLowBP.Text = lowBp.ToString();
-                textBoxMeanBP.Text = ((highBp + lowBp) / 2).ToString();
-                bp_unit1.Content = "mmHg";
-                bp_unit2.Content = "mmHg";
-                bp_unit3.Content = "mmHg";
-            }
-            else
-            {
-                textBoxHighBP.Text = (highBp*4/3).ToString();
-                textBoxLowBP.Text = (lowBp*4/3).ToString();
-                textBoxMeanBP.Text = (((highBp * 4 / 3) + (lowBp * 4 / 3)) / 2).ToString();
-                bp_unit1.Content = "kPa";
-                bp_unit2.Content = "kPa";
-                bp_unit3.Content = "kPa";
-            }
-            
-            if (bpReadOnly)
-            {
-                textBoxHighBP.IsEnabled = false;
-                textBoxLowBP.IsEnabled = false;
-            }
-            else
-            {
-                textBoxHighBP.IsEnabled = true;
-                textBoxLowBP.IsEnabled = true;
-            }
-        }
-
-        private void fillBlanks(Patient onePerson)
-        {/*
-            textBoxIDNum.Text = onePerson.idNum;
-            textBoxPaID.Text = onePerson.record_id;
-            textBoxName.Text = onePerson.name;
-            textBoxPerg_time.Text = onePerson.pregnancy_times.ToString();
-            textBoxProd_time.Text = onePerson.birth_times.ToString();
-            textBoxHeight.Text = onePerson.height.ToString();
-            textBoxDescription.Text = onePerson.description == "" ? "(无)" : onePerson.description;
-            textBoxWeight.Text = onePerson.weight.ToString();
-            textBoxBMI.Text = (onePerson.weight / ((onePerson.height / 100.0) * (onePerson.height / 100.0))).ToString(); //体重(kg)/身高(m)^2
-            textBoxWeek.Text = ((DateTime.Now - onePerson.pregnancy_date).Days / 7 + 1).ToString();
-            textBoxDay.Text = ((DateTime.Now - onePerson.pregnancy_date).Days % 7).ToString();
-
-            if (onePerson.idNum.Length >= 13)
-            {
-                //假设身份证号合法
-                string birthday = onePerson.idNum.Substring(6, 8);
-                //MessageBox.Show(birthday);
-                DateTime birthdayDate = new DateTime(Convert.ToInt32(birthday.Substring(0, 4)), Convert.ToInt32(birthday.Substring(4, 2)), Convert.ToInt32(birthday.Substring(6, 2)));
-                int age = Toolkits.OtherSmallFunction.getAgeByBirthDay(birthdayDate);
-                textBoxAge.Text = age.ToString();
-            }
-            else
-            {
-                textBoxAge.Text = "--";
-            }*/
-        }
-
-        private void textBoxHighBP_TextChanged(object sender, TextChangedEventArgs e)
-        {
-            calculateAverageBP();
-        }
-        private void textBoxLowBP_TextChanged(object sender, TextChangedEventArgs e)
-        {
-            calculateAverageBP();
-        }
-        private void calculateAverageBP()
-        {
-            try
-            {
-                textBoxMeanBP.Text = ((Convert.ToDouble(textBoxHighBP.Text) + Convert.ToDouble(textBoxLowBP.Text)) / 2).ToString();
-            }
-            catch
-            {
-                ;
-            }
-        }
-    }
-}

+ 0 - 32
WpfTest1/PatientInfoShort.xaml

@@ -1,32 +0,0 @@
-<UserControl x:Class="WpfTest1.PatientInfoShort"
-            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             xmlns:local="clr-namespace:WpfTest1"
-             xmlns:my="clr-namespace:WpfTest1"
-             mc:Ignorable="d" Height="86" Width="410"
-             >
-    <!--d:DesignHeight="300" d:DesignWidth="300"-->
-    <Grid>
-        <Grid Margin="0,0,0,0">
-            <GroupBox x:Name="groupBox" Header="病例信息" HorizontalAlignment="Left" Margin="0,0,0,-116" VerticalAlignment="Top" Height="86" Width="410">
-                <Grid Margin="0,0,-5,0">
-                    <Label x:Name="label2_Copy1" Content="病例号:" HorizontalAlignment="Left" Margin="10,23,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="labelName" Content="[name]" HorizontalAlignment="Left" Margin="10,-5,0,0" VerticalAlignment="Top" FontSize="20" FontWeight="Bold"/>
-                    <Label x:Name="label2_Copy3" Content="孕次:" HorizontalAlignment="Left" Margin="297,0,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy4" Content="产次:" HorizontalAlignment="Left" Margin="300,23,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="labelPregTime" Content="[time]" HorizontalAlignment="Left" Margin="339,0,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="labelHeight" Content="[Height]" HorizontalAlignment="Left" Margin="235,0,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="labelPaId" Content="[patinet_id]" HorizontalAlignment="Left" Margin="68,23,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy33" Content="性别:女    身高:" HorizontalAlignment="Left" Margin="130,0,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="label2_Copy44" Content="体重:" HorizontalAlignment="Left" Margin="189,23,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="labelProdTime" Content="[time]" HorizontalAlignment="Left" Margin="339,23,0,0" VerticalAlignment="Top" FontSize="12"/>
-                    <Label x:Name="labelWeight" Content="[wright]" HorizontalAlignment="Left" Margin="240,23,0,0" VerticalAlignment="Top" FontSize="12"/>
-                </Grid>
-
-            </GroupBox>
-
-        </Grid>
-    </Grid>
-</UserControl>

+ 0 - 38
WpfTest1/PatientInfoShort.xaml.cs

@@ -1,38 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-
-namespace WpfTest1
-{
-    /// <summary>
-    /// PatientInfoShort.xaml 的交互逻辑
-    /// </summary>
-    public partial class PatientInfoShort : UserControl
-    {
-        public PatientInfoShort()
-        {
-            InitializeComponent();
-        }
-
-        public void fillBlanks(SQLite.Patient pa)
-        {/*
-            labelName.Content = pa.name;
-            labelPaId.Content = pa.record_id;
-            labelHeight.Content = pa.height;
-            labelWeight.Content = pa.weight;
-            labelPregTime.Content = pa.pregnancy_times;
-            labelProdTime.Content = pa.birth_times;*/
-        }
-    }
-}

BIN
WpfTest1/Resources/homepage - 副本.jpg


+ 1 - 1
WpfTest1/SQLite/Answer.cs

@@ -10,7 +10,7 @@ namespace WpfTest1.SQLite
         public int a_id { get; set; }
         public int q_id { get; set; } //1->filter; 2->evaluation
         public int a_value { get; set; }
-        public int evaluation_q_id { get; set; }
+        public int next_q_id { get; set; }
         public string a_content { get; set; }
         public string a_description_text { get; set; }
         public string a_description_img { get; set; }

+ 2 - 1
WpfTest1/SQLite/Question.cs

@@ -10,7 +10,8 @@ namespace WpfTest1.SQLite
         public int q_id { get; set; }
         public int q_type { get; set; } //1->filter; 2->evaluation
         public int q_number { get; set; }
+        public string q_title { get; set; }
         public string q_content { get; set; }
-        public int filter_a_id { get; set; }
+        public int prior_a_id { get; set; }
     }
 }

+ 9 - 14
WpfTest1/SQLite/Record.cs

@@ -8,19 +8,14 @@ namespace WpfTest1.SQLite
 {
     public class Record
     {
-        public int id { get; set; }
-        public int patientId { get; set; }
-        public int doctorId { get; set; }
-        public DateTime recordTime { get; set; }
-        public byte[] dataLeft { get; set; }
-        public byte[] dataRight { get; set; }
-        public byte[] dataWrist { get; set; }
-        public double topBP { get; set; }
-        public double bottomBP { get; set; }
-        public double heartRate { get; set; }
-        public string waveTpye { get; set; }
-        public int eigenValueSaved { get; set; }
-        public string  comments { get; set; }
-        public string hand { get; set; }
+        public int r_id { get; set; }
+        public int r_type { get; set; }
+        public int p_id { get; set; }
+        public int d_id { get; set; }
+        public int filter_id { get; set; }
+        public DateTime r_time { get; set; }
+        public int r_count { get; set; }
+        public string r_selection { get; set; }
+        public string r_type_d { get; set; }
     }
 }

+ 167 - 122
WpfTest1/SQLite/SQLiteModel.cs

@@ -230,17 +230,17 @@ namespace WpfTest1.SQLite
         /// <summary>
         /// getDeletedPatients:从Patient表中获取所有已被标记为删除的数据的id
         /// </summary>
-        public static List<string> getDeletedPatients()
+        public static List<int> getDeletedPatients()
         {
             string sql = "SELECT p_id FROM Patient WHERE p_delete_flag = 1";
             SQLiteHelper db = new SQLiteHelper(dbPath);
             SQLiteParameter[] parameters = new SQLiteParameter[] { };
-            List<string> result = new List<string>();
+            List<int> result = new List<int>();
             using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
             {
                 while (reader.Read())
                 {
-                    string id = reader.IsDBNull(0) ? "" : reader.GetString(0);
+                    int id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                     result.Add(id);
                 }
             }
@@ -334,15 +334,16 @@ namespace WpfTest1.SQLite
                     temp.q_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                     temp.q_type = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                     temp.q_number = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
-                    temp.q_content = reader.IsDBNull(3) ? "" : reader.GetString(3);
-                    temp.filter_a_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.q_title = reader.IsDBNull(3) ? "" : reader.GetString(3);
+                    temp.q_content = reader.IsDBNull(4) ? "" : reader.GetString(4);
+                    temp.prior_a_id = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);
                     questions.Add(temp);
                 }
             }
             return questions;
         }
 
-        public static Question getQuestionById(string qid)
+        public static Question getQuestionById(int qid)
         { 
             string sql = "SELECT * FROM Question_template WHERE q_id=@qid LIMIT 1";
             SQLiteHelper db = new SQLiteHelper(dbPath);
@@ -357,8 +358,9 @@ namespace WpfTest1.SQLite
                     temp.q_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                     temp.q_type = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                     temp.q_number = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
-                    temp.q_content = reader.IsDBNull(3) ? "" : reader.GetString(3);
-                    temp.filter_a_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.q_title = reader.IsDBNull(3) ? "" : reader.GetString(3);
+                    temp.q_content = reader.IsDBNull(4) ? "" : reader.GetString(4);
+                    temp.prior_a_id = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);
                     return temp;
                 }
             }
@@ -368,7 +370,7 @@ namespace WpfTest1.SQLite
         #endregion
 
         #region Answer_template表相关操作
-        public static List<Answer> getAnswersByQid(string qid)
+        public static List<Answer> getAnswersByQid(int qid)
         {
             List<Answer> questions = new List<Answer>();
             string sql = "SELECT * FROM Answer_template WHERE q_id=@qid order by a_id asc";
@@ -385,7 +387,7 @@ namespace WpfTest1.SQLite
                     temp.q_id = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                     temp.a_content = reader.IsDBNull(2) ? "" : reader.GetString(2);
                     temp.a_value = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
-                    temp.evaluation_q_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.next_q_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                     temp.a_description_text = reader.IsDBNull(5) ? "" : reader.GetString(5);
                     temp.a_description_img = reader.IsDBNull(6) ? "" : reader.GetString(6);
                     temp.a_suggestion_text = reader.IsDBNull(7) ? "" : reader.GetString(7);
@@ -396,7 +398,7 @@ namespace WpfTest1.SQLite
             return questions;
         }
 
-        public static Answer getAnswerById(string aid)
+        public static Answer getAnswerById(int aid)
         {
             string sql = "SELECT * FROM Answer_template WHERE a_id=@aid LIMIT 1";
             SQLiteHelper db = new SQLiteHelper(dbPath);
@@ -412,7 +414,7 @@ namespace WpfTest1.SQLite
                     temp.q_id = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                     temp.a_content = reader.IsDBNull(2) ? "" : reader.GetString(2);
                     temp.a_value = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
-                    temp.evaluation_q_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.next_q_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                     temp.a_description_text = reader.IsDBNull(5) ? "" : reader.GetString(5);
                     temp.a_description_img = reader.IsDBNull(6) ? "" : reader.GetString(6);
                     temp.a_suggestion_text = reader.IsDBNull(7) ? "" : reader.GetString(7);
@@ -426,7 +428,17 @@ namespace WpfTest1.SQLite
 
         #region Record表相关操作
 
-        public static void insertRecord(int r_type, int p_id, int d_id, int filter_id, DateTime r_time, int r_count, string r_selection)
+        /// <summary>
+        /// 插入报告一份,并返回报告的ID
+        /// </summary>
+        /// <param name="r_type">1-筛查,2-评估</param>
+        /// <param name="p_id">病例ID</param>
+        /// <param name="d_id">医生ID</param>
+        /// <param name="filter_id">如是评估报告,那么其遵顼的筛查记录ID</param>
+        /// <param name="r_time">报告时间</param>
+        /// <param name="r_count">报告计数</param>
+        /// <param name="r_selection">报告内容</param>
+        public static int insertRecord(int r_type, int p_id, int d_id, int filter_id, DateTime r_time, int r_count, string r_selection)
         {
             string sql = "INSERT INTO Record(r_type,p_id,d_id,filter_id,r_time,r_count,r_selection)" +
                             "values(@r_type,@p_id,@d_id,@filter_id,@r_time,@r_count,@r_selection)";
@@ -441,6 +453,146 @@ namespace WpfTest1.SQLite
                                                                new SQLiteParameter("@r_selection",r_selection)
                                                                };
             db.ExecuteNonQuery(sql, parameters);
+
+            //返回所插入的r_id
+            sql = "SELECT MAX(r_id) FROM Record;";
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    int max_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    return max_id;
+                }
+            }
+            return 0;
+        }
+
+        /// <summary>
+        /// 根据ID返回一份报告记录
+        /// </summary>
+        /// <param name="r_id">记录ID</param>
+        public static Record getRecordByID(int r_id)
+        {
+            string sql = "SELECT * FROM Record WHERE r_id=@r_id LIMIT 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@r_id",r_id),
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    Record temp = new Record();
+                    temp.r_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.r_type = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
+                    temp.p_id = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
+                    temp.d_id = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
+                    temp.filter_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.r_time = reader.IsDBNull(5) ? DateTime.MinValue : reader.GetDateTime(5);
+                    temp.r_count = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
+                    temp.r_selection = reader.IsDBNull(7) ? "" : reader.GetString(7);
+                    return temp;
+                }
+            }
+            return null;
+        }
+
+        /// <summary>
+        /// 根据ID返回一份报告记录
+        /// </summary>
+        /// <param name="r_id">记录ID</param>
+        public static List<Record> getRecordsByPid(int p_id)
+        {
+            string sql = "SELECT * FROM Record WHERE p_id=@p_id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@p_id",p_id),
+                                                               };
+            List<Record> results = new List<Record>();
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    Record temp = new Record();
+                    temp.r_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.r_type = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
+                    if (temp.r_type == 2)
+                        temp.r_type_d = "评估报告";
+                    else
+                        temp.r_type_d = "筛查报告";
+                    temp.p_id = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
+                    temp.d_id = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
+                    temp.filter_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.r_time = reader.IsDBNull(5) ? DateTime.MinValue : reader.GetDateTime(5);
+                    temp.r_count = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
+                    temp.r_selection = reader.IsDBNull(7) ? "" : reader.GetString(7);
+                    results.Add(temp);
+                }
+            }
+            return results;
+        }
+
+        /// <summary>
+        /// 选取近days里某一病例的type类报告一份
+        /// </summary>
+        /// <param name="p_id">病例ID</param>
+        /// <param name="r_type">1-筛查,2-评估</param>
+        /// <param name="days">前多少天内有效</param>
+        public static Record getLatestXTypeRecordInYDays(int p_id, int r_type, int days)
+        {
+            DateTime dt = DateTime.Now;
+            string sql = "SELECT * FROM Record WHERE p_id=@p_id and r_time >=@r_time and r_type=@r_type LIMIT 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@p_id",p_id),
+                                                               new SQLiteParameter("@r_type",r_type),
+                                                               new SQLiteParameter("@r_time",dt.AddDays(-days)),
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    Record temp = new Record();
+                    temp.r_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.r_type = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
+                    temp.p_id = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
+                    temp.d_id = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
+                    temp.filter_id = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.r_time =reader.IsDBNull(5) ? DateTime.MinValue : reader.GetDateTime(5);
+                    temp.r_count = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
+                    temp.r_selection = reader.IsDBNull(7) ? "" : reader.GetString(7);
+                    return temp;
+                }
+            }
+            return null;
+        }
+
+        /// <summary>
+        /// 将r_id对应的记录生成计数+1
+        /// </summary>
+        /// <param name="r_id">记录ID</param>
+        public static int plusOneCountOnRecordByRid(int r_id)
+        {
+            string sql = "UPDATE Record SET r_count=r_count+1 WHERE r_id=@r_id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@r_id",r_id)
+                                                               };
+            return db.ExecuteNonQuery(sql, parameters);
+        }
+
+        /// <summary>
+        /// 删除病例pid对应的所有记录
+        /// </summary>
+        /// <param name="r_id">记录ID</param>
+        public static int deleteRecordByPid(int p_id)
+        {
+            string sql = "DELETE FROM Record WHERE p_id=@p_id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@p_id",p_id)
+                                                               };
+            return db.ExecuteNonQuery(sql, parameters);
         }
 
         #endregion
@@ -649,7 +801,7 @@ namespace WpfTest1.SQLite
             }
         }
         //更新激活码信息
-        public static void UpdateRegisterCode(string name, string pw, string code)
+        public static void UpdateOrganizationName(string name)
         {
             //Boolean a = false;
             string sql = "UPDATE Config SET value=@name WHERE key='organization_name'";
@@ -658,115 +810,8 @@ namespace WpfTest1.SQLite
                                                                new SQLiteParameter("@name",name)
                                                                };
             db.ExecuteNonQuery(sql, parameters);
-            sql = "UPDATE Config SET value=@pw WHERE key='organization_pw'";
-            db = new SQLiteHelper(dbPath);
-            parameters = new SQLiteParameter[]{
-                                                               new SQLiteParameter("@pw",pw)
-                                                               };
-            db.ExecuteNonQuery(sql, parameters);
-            sql = "UPDATE Config SET value=@code WHERE key='organization_active_code'";
-            db = new SQLiteHelper(dbPath);
-            parameters = new SQLiteParameter[]{
-                                                               new SQLiteParameter("@code",code)
-                                                               };
-            db.ExecuteNonQuery(sql, parameters);
-        }
-        //更新血压单位显示hhmg或者kpa,如果为1则是hhmg
-        public static void UpdateDocSetting(string value)
-        {
-            //Boolean a = false;
-            string sql = "UPDATE Config SET value=@value WHERE key='bp_unit_mmhg'";
-            SQLiteHelper db = new SQLiteHelper(dbPath);
-            SQLiteParameter[] parameters = new SQLiteParameter[]{
-                                                               new SQLiteParameter("@value",value)
-                                                               };
-            db.ExecuteNonQuery(sql, parameters);
-        }
-        //更新平滑参数
-        public static void UpdateSmoothPara(int ori_pts, int ori_times, int dri_pts, int dri_times, int filter_when_saving)
-        {
-            //Boolean a = false;
-            string sql = "UPDATE Config SET value=@ori_pts WHERE key='original_smooth_points'";
-            SQLiteHelper db = new SQLiteHelper(dbPath);
-            SQLiteParameter[] parameters = new SQLiteParameter[]{
-                                                               new SQLiteParameter("@ori_pts",ori_pts)
-                                                               };
-            db.ExecuteNonQuery(sql, parameters);
-            sql = "UPDATE Config SET value=@ori_times WHERE key='original_smooth_times'";
-            db = new SQLiteHelper(dbPath);
-            parameters = new SQLiteParameter[]{
-                                                               new SQLiteParameter("@ori_times",ori_times)
-                                                               };
-            db.ExecuteNonQuery(sql, parameters);
-            sql = "UPDATE Config SET value=@dri_pts WHERE key='derive_smooth_points'";
-            db = new SQLiteHelper(dbPath);
-            parameters = new SQLiteParameter[]{
-                                                               new SQLiteParameter("@dri_pts",dri_pts)
-                                                               };
-            db.ExecuteNonQuery(sql, parameters);
-            sql = "UPDATE Config SET value=@dri_times WHERE key='derive_smooth_times'";
-            db = new SQLiteHelper(dbPath);
-            parameters = new SQLiteParameter[]{
-                                                               new SQLiteParameter("@dri_times",dri_times)
-                                                               };
-            db.ExecuteNonQuery(sql, parameters);
-            sql = "UPDATE Config SET value=@filter_when_saving WHERE key='filter_when_saving'";
-            db = new SQLiteHelper(dbPath);
-            parameters = new SQLiteParameter[]{
-                                                               new SQLiteParameter("@filter_when_saving",filter_when_saving)
-                                                               };
-            db.ExecuteNonQuery(sql, parameters);
-        }
-        //只更新特征值数列的平滑参数
-        public static void UpdateEigenSmoothPara(int egi_pts, int egi_times)
-        {
-            //Boolean a = false;
-            string sql = "UPDATE Config SET value=@egi_pts WHERE key='eigen_smooth_points'";
-            SQLiteHelper db = new SQLiteHelper(dbPath);
-            SQLiteParameter[] parameters = new SQLiteParameter[]{
-                                                               new SQLiteParameter("@egi_pts",egi_pts)
-                                                               };
-            db.ExecuteNonQuery(sql, parameters);
-            sql = "UPDATE Config SET value=@egi_times WHERE key='eigen_smooth_times'";
-            db = new SQLiteHelper(dbPath);
-            parameters = new SQLiteParameter[]{
-                                                               new SQLiteParameter("@egi_times",egi_times)
-                                                               };
-            db.ExecuteNonQuery(sql, parameters);
-        }
-
-        //更新报告中report_figure_name
-        public static void UpdateReportFigureName(string new_name)
-        {
-            string sql = "UPDATE Config SET value=@new_name WHERE key='report_figure_name'";
-            SQLiteHelper db = new SQLiteHelper(dbPath);
-            SQLiteParameter[] parameters = new SQLiteParameter[]{
-                                                               new SQLiteParameter("@new_name",new_name)
-                                                               };
-            db.ExecuteNonQuery(sql, parameters);
-        }
-        //更新主公式等参数
-        public static void UpdateGeneralExpression(string new_segment_name, string segement_threhold, string new_expression)
-        {
-            string sql = "UPDATE Config SET value=@new_segment_name WHERE key='segement_name'";
-            SQLiteHelper db = new SQLiteHelper(dbPath);
-            SQLiteParameter[] parameters = new SQLiteParameter[]{
-                                                               new SQLiteParameter("@new_segment_name",new_segment_name)
-                                                               };
-            db.ExecuteNonQuery(sql, parameters);
-            sql = "UPDATE Config SET value=@segement_threhold WHERE key='segement_threhold'";
-            db = new SQLiteHelper(dbPath);
-            parameters = new SQLiteParameter[]{
-                                                               new SQLiteParameter("@segement_threhold",segement_threhold)
-                                                               };
-            db.ExecuteNonQuery(sql, parameters);
-            sql = "UPDATE Config SET value=@new_expression WHERE key='general_expression'";
-            db = new SQLiteHelper(dbPath);
-            parameters = new SQLiteParameter[]{
-                                                               new SQLiteParameter("@new_expression",new_expression)
-                                                               };
-            db.ExecuteNonQuery(sql, parameters);
         }
+       
 
         #endregion
 

+ 4 - 0
WpfTest1/SQLite/UserSelection.cs

@@ -19,5 +19,9 @@ namespace WpfTest1.SQLite
             q_id = q;
             a_id = a;
         }
+        public UserSelection()
+        {
+
+        }
     }
 }

+ 22 - 0
WpfTest1/SmallDialogs/AboutBox.xaml

@@ -0,0 +1,22 @@
+<Window x:Class="WpfTest1.SmallDialogs.AboutBox"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:WpfTest1.SmallDialogs"
+        mc:Ignorable="d"
+        Title="关于" Height="300" Width="400">
+    <Grid>
+        <Label x:Name="label" Content="关于系统" FontSize="18" HorizontalAlignment="Left" Margin="156,5,0,0" VerticalAlignment="Top"/>
+        
+        <Label x:Name="label1" Content="北京君德医疗有限公司  版权所有© 2006-2020" HorizontalAlignment="Left" Margin="69,33,0,0" VerticalAlignment="Top"/>
+        <TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="29,63,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="344">
+             &#x0020;&#x0020;&#x0020;&#x0020;君德集团是集医疗器械研发生产、医疗器械销售、康复中心整体解决方案、妇幼关爱解决方案为一体的综合医疗服务商。君德医疗秉承"让科技温暖生命"的理念,提供更具人文关怀的产品及专业的服务。君德医疗联合新加坡南洋理工大学、韩国延世大学、清华大学、北航等知名科研院校分别于新加坡、首尔、北京及深圳成立技术研发平台。目前公司与中国人民解放军总医院、青岛大学附属医院等多家医疗机构打造产学研一体的转化医学平台,为客户提供人性化的专业康复体验。详情请访问:
+            https://jdhealthcare.cn
+        </TextBlock>
+        <Label x:Name="label1_Copy" Content="版本号:" HorizontalAlignment="Left" Margin="243,227,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="labelVersion" Content="XXXXXX" HorizontalAlignment="Left" Margin="301,227,0,0" VerticalAlignment="Top"/>
+        <Button x:Name="buttonClose" Content="关闭窗口" HorizontalAlignment="Left" Margin="156,216,0,0" VerticalAlignment="Top" Width="75" Click="buttonClose_Click"/>
+
+    </Grid>
+</Window>

+ 33 - 0
WpfTest1/SmallDialogs/AboutBox.xaml.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace WpfTest1.SmallDialogs
+{
+    /// <summary>
+    /// AboutBox.xaml 的交互逻辑
+    /// </summary>
+    public partial class AboutBox : Window
+    {
+        public AboutBox()
+        {
+            InitializeComponent();
+            labelVersion.Content = Toolkits.Constants.version;
+        }
+
+        private void buttonClose_Click(object sender, RoutedEventArgs e)
+        {
+            this.Close();
+        }
+    }
+}

+ 0 - 25
WpfTest1/SmallDialogs/RegisterCode.xaml

@@ -1,25 +0,0 @@
-<Window x:Class="WpfTest1.SmallDialogs.RegisterCode"
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:local="clr-namespace:WpfTest1.SmallDialogs"
-        mc:Ignorable="d"
-        Title="激活本系统" Height="500" Width="800">
-    <Grid>
-        <Grid>
-            <Label x:Name="label" Content="请输入本机构名称:" HorizontalAlignment="Left" Height="36" Margin="29,26,0,0" VerticalAlignment="Top" Width="183" FontSize="18"/>
-            <Label x:Name="label1" Content="请输入激活码:" HorizontalAlignment="Left" Height="32" Margin="29,189,0,0" VerticalAlignment="Top" Width="144" FontSize="18"/>
-            <TextBox x:Name="textBox_username" HorizontalAlignment="Left" Height="39" Margin="29,62,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="738" FontSize="18" FontFamily="Microsoft YaHei UI"/>
-            <TextBox x:Name="textBox_password" HorizontalAlignment="Left" Height="31" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="738" Margin="29,140,0,0" FontSize="18" FontFamily="Microsoft YaHei UI"/>
-            <TextBox x:Name="textBox_code" HorizontalAlignment="Left" Height="91" Margin="29,226,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="738" FontFamily="Microsoft YaHei Light"/>
-            <Button x:Name="button_check" Content="验证" HorizontalAlignment="Left" Height="39" Margin="214,394,0,0" VerticalAlignment="Top" Width="100" Click="button_Click" FontSize="18" FontFamily="Microsoft YaHei Light"/>
-            <Label x:Name="label2" Content="请输入激活口令:" HorizontalAlignment="Left" Height="34" Margin="29,106,0,0" VerticalAlignment="Top" Width="171" FontSize="18"/>
-            <Button x:Name="button_Cancel" Content="取消" HorizontalAlignment="Left" Height="39" Margin="488,394,0,0" VerticalAlignment="Top" Width="102"  FontSize="18" FontFamily="Microsoft YaHei Light" Click="button_Cancel_Click"/>
-            <Button x:Name="button_Reset" Content="重置" HorizontalAlignment="Left" Height="39" Margin="350,394,0,0" VerticalAlignment="Top" Width="100" FontSize="18" FontFamily="Microsoft YaHei Light" Click="button_Reset_Click"/>
-            <Label x:Name="label3" Content="激活方法:输入购买本产品时所注册的本机构名称(报告单中的机构名称也以此为准)和由此软件提供商发送给您的激活口令与激活码粘" HorizontalAlignment="Left" Margin="29,322,0,0" VerticalAlignment="Top"/>
-            <Label x:Name="label3_Copy" Content="贴在相应位置,点击“激活”按钮完成激活即可使用本软件全部业务功能。" HorizontalAlignment="Left" Margin="88,347,0,0" VerticalAlignment="Top"/>
-
-        </Grid>
-    </Grid>
-</Window>

+ 0 - 94
WpfTest1/SmallDialogs/RegisterCode.xaml.cs

@@ -1,94 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
-
-namespace WpfTest1.SmallDialogs
-{
-    /// <summary>
-    /// RegisterCode.xaml 的交互逻辑
-    /// </summary>
-    public partial class RegisterCode : Window
-    {
-        MainWindow father;
-        Toolkits.Config cfg;
-        bool forceShutdown;
-        public RegisterCode(MainWindow father,Toolkits.Config cfg,bool forceShutdown)
-        {
-            InitializeComponent();
-            this.father = father;
-            this.cfg = cfg;
-            this.forceShutdown = forceShutdown;
-            textBox_username.Text = cfg.organization_name;
-            textBox_password.Text = cfg.organization_pw;
-            textBox_code.Text = cfg.organization_active_code;
-        }
-
-        private void button_Click(object sender, RoutedEventArgs e)
-        {
-            if(textBox_username.Text == "")
-            {
-                MessageBox.Show("机构名称不能为空", "提示");
-                textBox_username.Focus();
-                return;
-            }
-            if (textBox_password.Text == "")
-            {
-                MessageBox.Show("激活口令不能为空", "提示");
-                textBox_password.Focus();
-                return;
-            }
-            if (textBox_code.Text == "")
-            {
-                MessageBox.Show("激活码不能为空", "提示");
-                textBox_code.Focus();
-                return;
-            }
-
-            if (cfg.CheckRegisterCode(
-                Toolkits.FilterDangerousCharacter.filter(textBox_username.Text),
-                Toolkits.FilterDangerousCharacter.filter(textBox_password.Text),
-                Toolkits.FilterDangerousCharacter.filter(textBox_code.Text)
-                ))
-            {
-                SQLite.SQLiteModel.UpdateRegisterCode(
-                Toolkits.FilterDangerousCharacter.filter(textBox_username.Text),
-                Toolkits.FilterDangerousCharacter.filter(textBox_password.Text),
-                Toolkits.FilterDangerousCharacter.filter(textBox_code.Text));
-                cfg.refresh();
-                this.Close();
-            }
-            else
-            {
-                MessageBox.Show("激活失败,请检查验证码和机构信息是否匹配", "警告");
-                return;
-            }
-
-        }
-
-        private void button_Cancel_Click(object sender, RoutedEventArgs e)
-        {
-            if (forceShutdown)
-            {
-                this.father.Close();
-            }
-            this.Close();
-        }
-
-        private void button_Reset_Click(object sender, RoutedEventArgs e)
-        {
-            textBox_username.Text = cfg.organization_name;
-            textBox_password.Text = cfg.organization_pw;
-            textBox_code.Text = cfg.organization_active_code;
-        }
-    }
-}

+ 0 - 54
WpfTest1/Toolkits/CSVWriter.cs

@@ -1,54 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace WpfTest1.Toolkits
-{
-    public class CSVWriter
-    {
-        public static void generateWaveToCSV(List<double> leftRed, List<double> leftInfrared, List<double> rightRed, List<double> rightInfrared, SQLite.Patient pa, SQLite.Record re)
-        {
-            FileStream fs = new FileStream(Constants.exportWavePath + "\\" + re.recordTime.ToString("yyyyMMddHHmmss") + "_" + pa.p_name +  ".csv", FileMode.Create);
-            StreamWriter sw = new StreamWriter(fs);
-            //开始写入
-            sw.Write("leftRed,leftInfrared,rightRed,rightInfrared\n");
-
-            int counter = new int[] { leftRed.Count, rightRed.Count, leftInfrared.Count, rightInfrared.Count }.Max();
-            for(int i = 0; i < counter; ++i)
-            {
-                string[] thisLine = new string[] { "","","",""};
-                if((re.hand == "b" || re.hand=="l"))
-                {
-                    if(i < leftRed.Count)
-                    {
-                        thisLine[0] = leftRed[i].ToString();
-                    }
-                    if(i < leftInfrared.Count)
-                    {
-                        thisLine[1] = leftInfrared[i].ToString();
-                    }
-                }
-                if ((re.hand == "b" || re.hand == "r" ))
-                {
-                    if (i < rightRed.Count)
-                    {
-                        thisLine[2] = rightRed[i].ToString();
-                    }
-                    if (i < rightInfrared.Count)
-                    {
-                        thisLine[3] = rightInfrared[i].ToString();
-                    }
-                }
-                sw.Write(thisLine[0]+","+ thisLine[1] + "," + thisLine[2] + "," + thisLine[3] + "\n");
-            }
-            //清空缓冲区
-            sw.Flush();
-            //关闭流
-            sw.Close();
-            fs.Close();
-        }
-    }
-}

+ 0 - 49
WpfTest1/Toolkits/Config.cs

@@ -10,23 +10,10 @@ namespace WpfTest1.Toolkits
 {
     public class Config
     {
-        public int original_smooth_points = 3;
-        public int drive_smooth_points = 11;
-        public int eigen_smooth_points = 1;
-        public int original_smooth_times = 2;
-        public int drive_smooth_times = 1;
-        public int eigen_smooth_times = 1;
-        
         public string organization_name = "";
         public string organization_pw = "";
         public string organization_active_code = "";
-        public string segement_name = ""; //总指标段名称,用$分隔
-        public string segement_threhold = ""; //总指标段阈值,用$分隔
-        public string report_figure_name = "";//报告单中波形图名称
-        public string general_expression = "";//自动诊断所使用公式
-        public int filter_when_saving = 1;
 
-        public int bp_unit_hhmg = 1;
         Dictionary<string, string> middle = new Dictionary<string, string>();
         public Config()
         {
@@ -40,24 +27,6 @@ namespace WpfTest1.Toolkits
             {
                 switch (key)
                 {
-                    case "original_smooth_points":
-                        original_smooth_points = Convert.ToInt32(middle[key]);
-                        break;
-                    case "derive_smooth_points":
-                        drive_smooth_points = Convert.ToInt32(middle[key]);
-                        break;
-                    case "eigen_smooth_points":
-                        eigen_smooth_points = Convert.ToInt32(middle[key]);
-                        break;
-                    case "original_smooth_times":
-                        original_smooth_times = Convert.ToInt32(middle[key]);
-                        break;
-                    case "derive_smooth_times":
-                        drive_smooth_times = Convert.ToInt32(middle[key]);
-                        break;
-                    case "eigen_smooth_times":
-                        eigen_smooth_times = Convert.ToInt32(middle[key]);
-                        break;
                     case "organization_name":
                         organization_name = middle[key];
                         break;
@@ -67,24 +36,6 @@ namespace WpfTest1.Toolkits
                     case "organization_active_code":
                         organization_active_code = middle[key];
                         break;
-                    case "segement_name":
-                        segement_name = middle[key];
-                        break;
-                    case "segement_threhold":
-                        segement_threhold = middle[key];
-                        break;
-                    case "report_figure_name":
-                        report_figure_name = middle[key];
-                        break;
-                    case "general_expression":
-                        general_expression = middle[key];
-                        break;
-                    case "filter_when_saving":
-                        filter_when_saving = Convert.ToInt32(middle[key]);
-                        break;
-                    case "bp_unit_mmhg":
-                        bp_unit_hhmg = Convert.ToInt32(middle[key]);
-                        break;
                     default:
                         break;
                 }

+ 17 - 29
WpfTest1/Toolkits/Constants.cs

@@ -9,12 +9,14 @@ namespace WpfTest1.Toolkits
     //各种系统需要使用的常值
     public class Constants
     {
+        //编译版本
+        public static string version = "0.1.0.0";
+        //编译日期
+        public static string compileDate = "20200301";
         //数据库物理地址
         public static string dbPath = System.Environment.CurrentDirectory + "\\Junde.db3";
         //数据库连接直接实用的连接字符串
         public static string Connstr = @"Data Source=" + System.Environment.CurrentDirectory + "\\Junde.db3";
-        //采样间隔(秒)
-        public static double sampleInterval = 0.002;
         //默认的公钥位置
         public static string pubkeyPath = System.Environment.CurrentDirectory + "\\pubkey.xml";
         //报告存放目录
@@ -25,35 +27,21 @@ namespace WpfTest1.Toolkits
         public static string imgPath = System.Environment.CurrentDirectory + "\\image";
         //报告页眉的医院图标
         public static string reportHeadPicPath = Constants.imgPath + "\\reportHeadPic.png";
-        //报告页RP图文件名
-        public static string tmpRPWave = tmpPath + "\\raodongmai.png";
-        //报告页PPG文件名
-        public static string tmpPPGLeftRedWave = tmpPath + "\\ppgLeftRed.png";
-        public static string tmpPPGLeftInfraredWave = tmpPath + "\\ppgLeftInf.png";
-        public static string tmpPPGRightRedWave = tmpPath + "\\ppgRightRed.png";
-        public static string tmpPPGRightInfraredWave = tmpPath + "\\ppgLeftInf.png";
-        //上位机的IP地址
-        public static string UptterIp = "192.168.10.31";
-        //上位机端口
-        public static int UpperPort = 9000;
+        public static readonly Dictionary<string, int> keyboardToDigit = new Dictionary<string, int>
+        {
+            { "D1", 1 },
+            { "D2", 2 },
+            { "D3", 3 },
+            { "D4", 4 },
+            { "D5", 5 },
+            { "D6", 6 },
+            { "D7", 7 },
+            { "D8", 8 },
+            { "D9", 9 },
+        };
         //厂家管理员的ID
         public static string adminUsername = "superman";
-        //波形存储放大话或者缩小的倍数
-        public static int zoomTimes = 1000000;
-        //滤波器一阶低通
-        public static string filter_1_PathLow = System.Environment.CurrentDirectory + "\\filter1l.dat";
-        //滤波器一阶高通
-        public static string filter_1_PathHigh = System.Environment.CurrentDirectory + "\\filter1h.dat";
-        //滤波器二阶低通
-        public static string filter_2_PathLow = System.Environment.CurrentDirectory + "\\filter2l.dat";
-        //滤波器二阶高通
-        public static string filter_2_PathHigh = System.Environment.CurrentDirectory + "\\filter2h.dat";
-        //导出文件存放目录
-        public static string exportWavePath = System.Environment.CurrentDirectory + "\\exportWave";
-        //判断波谷范围的阈值
-        //public static int searchPoints = 2000;
-        //public static double redTroughThreShold = 6600;
-        //public static double infraredTroughThreshold = 22000;
+
 
     }
 }

+ 0 - 51
WpfTest1/Toolkits/FilterFile.cs

@@ -1,51 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace WpfTest1.Toolkits
-{
-    class FilterFile
-    {
-        public static int ReadFilterFiles(List<double>[] filter)
-        {
-            //滤波器加载
-            string[] files = { Toolkits.Constants.filter_1_PathLow, Toolkits.Constants.filter_1_PathHigh, Toolkits.Constants.filter_2_PathLow, Toolkits.Constants.filter_1_PathHigh };
-            for(int i = 0;i< files.Length; ++i)
-            {
-                try
-                {
-                    StreamReader filterReader = new StreamReader(files[i]);
-                    string sLine = "";
-                    while (sLine != null)
-                    {
-                        try
-                        {
-                            sLine = filterReader.ReadLine();
-                            //Console.WriteLine(sLine);
-                            if (sLine != null && !sLine.Equals(""))
-                                filter[i].Add(Convert.ToDouble(sLine));
-                        }
-                        catch (Exception err)
-                        {
-                            Console.WriteLine("滤波器文件内容已损坏,错误文件编号:" + i);
-                            Console.WriteLine(err.StackTrace);
-                            return -1;
-                        }
-
-                    }
-                    filterReader.Close();
-                }
-                catch (Exception)
-                {
-                    Console.WriteLine("滤波器文件不存在或文件内容已损坏,错误文件编号:" + i);
-                    return -2;
-                }
-            }
-            return 0;
-            
-        }
-    }
-}

+ 0 - 50
WpfTest1/Toolkits/MeasureHandle.cs

@@ -1,50 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace WpfTest1.Toolkits
-{
-    class MeasureHandle
-    {
-        public static double Code2Vol(byte hex1,byte hex2, byte hex3)
-        {
-            int data;
-            if(hex1>>7 == 0x01)
-            {
-                //是负数,补0xff
-                data = (0xff << 24) | (hex1 << 16) | (hex2 << 8) | hex3;
-            }
-            else
-            {
-                //是正数,补0x00
-                data = (0x00 << 24) | (hex1 << 16) | (hex2 << 8) | hex3;
-            }
-            double result = (1.25 + 1.21 * data / 8388607.0);
-            return 2.47 - result;//波形需要拿最大值翻转一下
-            //return (int)((result_temp - (int)result_temp) * 1000000);
-        }
-
-        //4404组件使用的22位数字信号转数值方法
-        public static double Code2Vol_22(byte hex1, byte hex2, byte hex3)
-        {
-            int data;
-            byte masked_hex1 = (byte)(hex1 & 0x3f);
-            if ((masked_hex1) >> 5 > 0x01)
-            {
-                //是负数,补0xff
-                data = (0xff << 24) | ((masked_hex1 | 0xc0 ) << 16) | (hex2 << 8) | hex3;
-            }
-            else
-            {
-                //是正数,补0x00
-                data = (0x00 << 24) | (masked_hex1 << 16) | (hex2 << 8) | hex3;
-            }
-            double result = (1.2 * data / 2097151.0);
-            return -result;//波形需要拿最大值翻转一下
-            //return (int)((result_temp - (int)result_temp) * 1000000);
-        }
-    }
-}

+ 0 - 220
WpfTest1/Toolkits/RPCalculate.cs

@@ -1,220 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace WpfTest1.Toolkits
-{
-    public class RPCalculate
-    {
-        ///*
-        //[DllImport("rgz.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
-        [DllImport("rgz.dll")]
-        public static extern int rgz_fx(ref int val_sg, ref int val_yc, ref int val_cc, ref int val_nl, ref int val_jzs, ref int val_ssy,
-           ref int val_szy, ref int val_pjy, ref int val_xl, ref int val_yz, ref int val_yt, ref int val_bxlx, ref int val_tz, ref double val_bxxs,
-            ref double val_wzzl, ref double val_xscl, ref double val_mbl, ref double val_xzzs, ref double val_xbzs, ref double val_tbmj,
-           ref double val_zxrl, ref double val_syx, ref double val_yac, ref double val_tzzs, ref double val_bltz, ref double val_zxxll,
-            ref double val_xyzs, ref double val_xynd, ref double val_pjzlsj, ref double val_pl, ref double zl,
-             ref string val_ckjg, ref double val_ckzs, ref int val_len, ref string[] val_mbbx);
-
-        //输入源
-        public int shengao;
-        public int yunci;
-        public int chanci;
-        public int nianling;
-        public int jiazushi;
-        public int shousuoya;
-        public int shuzhangya;
-        public int pingjundongmaiya;
-        public int mailv;
-        public int yunzhou;
-        public int yuntian;
-        public int tizhong;
-        public string[] maixinbo = new string[500]; //具体多少需要进一步调整
-        public int boxinleixin;
-        public int mbbxlen;
-        //输出源
-        public double boxinxishu = 0;
-        public double waizhouzuli = 0;
-        public double xinshuchuliang = 0;
-        public double meiboliang = 0;
-        public double xinzangzhishu = 0;
-        public double xinbozhishu = 0;
-        public double tibiaomianji = 0;
-        public double zongxuerongliang = 0;
-        public double shunyinxing = 0;
-        public double maiya = 0;
-        public double tizhongzhishu = 0;
-        public double bianliangtizhong = 0;
-        public double zhongxinxueliuliang = 0;
-        public double xueyazhishu = 0;
-        public double xueyeniandu = 0;
-        public double pingjunzhiliushijian = 0;
-        public string cankaojieguo = "            ";
-        public double cankaozhishu = 0;
-        public double xpl = 0;  //排量
-        public double wzzl = 0; //阻力
-
-        public RPCalculate(int sg, int yc, int cc, int nl, int jzs, int ssy, int szy, int pjdmy, int ml, int yz, int yt, int tz, string[] mxb, int bxlx)
-        {
-            shengao = sg;
-            yunci = yc;
-            chanci = cc;
-            nianling = nl;
-            jiazushi = jzs;
-            shousuoya = ssy;
-            shuzhangya = szy;
-            pingjundongmaiya = pjdmy;
-            mailv = ml;
-            yunzhou = yz;
-            yuntian = yt;
-            tizhong = tz;
-            maixinbo = mxb;
-            boxinleixin = bxlx;
-            mbbxlen = mxb.Count();
-        }
-
-        public void calculateRP()
-        {
-            //测试用例
-            maixinbo[0] = "1";
-            maixinbo[1] = "2";
-            maixinbo[2] = "3";
-            mbbxlen = 3;
-            int status = rgz_fx(
-                     ref shengao, ref yunci, ref chanci, ref nianling, ref jiazushi, ref shousuoya, ref shuzhangya, ref pingjundongmaiya,
-                     ref mailv, ref yunzhou, ref yuntian, ref boxinleixin, ref tizhong, ref boxinxishu, ref waizhouzuli, ref xinshuchuliang,
-                     ref meiboliang, ref xinzangzhishu, ref xinbozhishu, ref tibiaomianji, ref zongxuerongliang, ref shunyinxing,
-                     ref maiya, ref tizhongzhishu, ref bianliangtizhong, ref zhongxinxueliuliang, ref xueyazhishu, ref xueyeniandu,
-                     ref pingjunzhiliushijian, ref xpl, ref wzzl, ref cankaojieguo, ref cankaozhishu, ref mbbxlen, ref maixinbo);
-
-            if (status == 1)
-            {
-                Console.WriteLine("rp calculate done.");
-            }
-            else
-            {
-                Console.WriteLine("rp calculate failed.");
-            }
-        }
-        //*/
-            /*
-            [DllImport("rgz.dll", CallingConvention = CallingConvention.StdCall)]
-            public static extern IntPtr rgz_fx(IntPtr val_sg, IntPtr val_yc, IntPtr val_cc, IntPtr val_nl, IntPtr val_jzs, IntPtr val_ssy, IntPtr val_szy
-                , IntPtr val_pjy, IntPtr val_xl, IntPtr val_yz, IntPtr val_yt, IntPtr val_bxlx, IntPtr val_tz , IntPtr val_bxxs, IntPtr val_wzzl,
-                IntPtr val_xscl, IntPtr val_mbl, IntPtr val_xzzs, IntPtr val_xbzs, IntPtr val_tbmj, IntPtr val_zxrl, IntPtr val_syx,
-                IntPtr val_yac, IntPtr val_tzzs, IntPtr val_bltz, IntPtr val_zxxll, IntPtr val_xyzs, IntPtr val_xynd, IntPtr val_pjzlsj,
-                IntPtr val_mbbx, IntPtr val_ckjg, IntPtr val_ckzs);
-            //输入源
-            public int shengao;
-            public int yunci;
-            public int chanci;
-            public int nianling;
-            public int jiazushi;
-            public int shousuoya;
-            public int shuzhangya;
-            public int pingjundongmaiya;
-            public int mailv;
-            public int yunzhou;
-            public int yuntian;
-            public int tizhong;
-            public int[] maixinbo;
-            public int boxinleixin;
-            //输出源
-            float boxinxishu = 0;
-            float waizhouzuli = 0;
-            float xinshuchuliang = 0;
-            float meiboliang = 0;
-            float xinzangzhishu = 0;
-            float xinbozhishu = 0;
-            float tibiaomianji = 0;
-            float zongxuerongliang = 0;
-            float shunyinxing = 0;
-            float maiya = 0;
-            float tizhongzhishu = 0;
-            float bianliangtizhong = 0;
-            float zhongxinxueliuliang = 0;
-            float xueyazhishu = 0;
-            float xueyeniandu = 0;
-            float pingjunzhiliushijian = 0;
-            char[] cankaojieguo = new char[1000];
-            float cankaozhishu = 0;
-
-            public RPCalculate(int sg,int yc, int cc,int nl, int jzs, int ssy, int szy, int pjdmy, int ml, int yz, int yt, int tz, int[] mxb,int bxlx)
-            {
-                shengao = sg;
-                yunci = yc;
-                chanci = cc;
-                nianling = nl;
-                jiazushi = jzs;
-                shousuoya = ssy;
-                shuzhangya = szy;
-                pingjundongmaiya = pjdmy;
-                mailv = ml;
-                yunzhou = yz;
-                yuntian = yt;
-                tizhong = tz;
-                maixinbo = mxb;
-                boxinleixin = bxlx;
-            }
-
-            public void calculateRP()
-            {
-                IntPtr shengaoPTR = Marshal.AllocHGlobal(Marshal.SizeOf(shengao));
-                IntPtr yunciPTR = Marshal.AllocHGlobal(Marshal.SizeOf(yunci));
-                IntPtr chanciPTR = Marshal.AllocHGlobal(Marshal.SizeOf(chanci));
-                IntPtr nianlingPTR = Marshal.AllocHGlobal(Marshal.SizeOf(nianling));
-                IntPtr jiazushiPTR = Marshal.AllocHGlobal(Marshal.SizeOf(jiazushi));
-                IntPtr shousuoyaPTR = Marshal.AllocHGlobal(Marshal.SizeOf(shousuoya));
-                IntPtr shuzhangyaPTR = Marshal.AllocHGlobal(Marshal.SizeOf(shuzhangya));
-                IntPtr pingjundongmaiyaPTR = Marshal.AllocHGlobal(Marshal.SizeOf(pingjundongmaiya));
-                IntPtr mailvPTR = Marshal.AllocHGlobal(Marshal.SizeOf(mailv));
-                IntPtr yunzhouPTR = Marshal.AllocHGlobal(Marshal.SizeOf(yunzhou));
-                IntPtr yuntianPTR = Marshal.AllocHGlobal(Marshal.SizeOf(yuntian));
-                IntPtr boxinleixinPTR = Marshal.AllocHGlobal(Marshal.SizeOf(boxinleixin));
-                IntPtr tizhongPTR = Marshal.AllocHGlobal(Marshal.SizeOf(tizhong));
-                IntPtr boxinxishuPTR = Marshal.AllocHGlobal(Marshal.SizeOf(boxinxishu));
-                IntPtr waizhouzuliPTR = Marshal.AllocHGlobal(Marshal.SizeOf(waizhouzuli));
-                IntPtr xinshuchuliangPTR = Marshal.AllocHGlobal(Marshal.SizeOf(xinshuchuliang));
-                IntPtr meiboliangPTR = Marshal.AllocHGlobal(Marshal.SizeOf(meiboliang));
-                IntPtr xinzangzhishuPTR = Marshal.AllocHGlobal(Marshal.SizeOf(xinzangzhishu));
-                IntPtr xinbozhishuPTR = Marshal.AllocHGlobal(Marshal.SizeOf(xinbozhishu));
-                IntPtr tibiaomianjiPTR = Marshal.AllocHGlobal(Marshal.SizeOf(tibiaomianji));
-                IntPtr zongxuerongliangPTR = Marshal.AllocHGlobal(Marshal.SizeOf(zongxuerongliang));
-                IntPtr shunyinxingPTR = Marshal.AllocHGlobal(Marshal.SizeOf(shunyinxing));
-                IntPtr maiyaPTR = Marshal.AllocHGlobal(Marshal.SizeOf(maiya));
-                IntPtr tizhongzhishuPTR = Marshal.AllocHGlobal(Marshal.SizeOf(tizhongzhishu));
-                IntPtr bianliangtizhongPTR = Marshal.AllocHGlobal(Marshal.SizeOf(bianliangtizhong));
-                IntPtr zhongxinxueliuliangPTR = Marshal.AllocHGlobal(Marshal.SizeOf(zhongxinxueliuliang));
-                IntPtr xueyazhishuPTR = Marshal.AllocHGlobal(Marshal.SizeOf(xueyazhishu));
-                IntPtr xueyenianduPTR = Marshal.AllocHGlobal(Marshal.SizeOf(xueyeniandu));
-                IntPtr pingjunzhiliushijianPTR = Marshal.AllocHGlobal(Marshal.SizeOf(pingjunzhiliushijian));
-                IntPtr maixinboPTR = Marshal.AllocHGlobal(sizeof(int)*2000);
-                Marshal.Copy(maixinbo, 0, maixinboPTR, 2000);
-                IntPtr cankaojieguoPTR = Marshal.AllocHGlobal(sizeof(char) * 1000);
-                Marshal.Copy(cankaojieguo, 0, cankaojieguoPTR, 1000);
-                IntPtr cankaozhishuPTR = Marshal.AllocHGlobal(Marshal.SizeOf(cankaozhishu));
-                IntPtr statusPTR = Marshal.AllocHGlobal(Marshal.SizeOf(1));
-                statusPTR = rgz_fx(
-                    shengaoPTR, yunciPTR, chanciPTR, nianlingPTR, jiazushiPTR, shousuoyaPTR, shuzhangyaPTR, pingjundongmaiyaPTR
-                    , mailvPTR, yunzhouPTR, yuntianPTR, boxinleixinPTR, tizhongPTR, boxinxishuPTR, waizhouzuliPTR, xinshuchuliangPTR,
-                    meiboliangPTR, xinzangzhishuPTR, xinbozhishuPTR, tibiaomianjiPTR, zongxuerongliangPTR, shunyinxingPTR,
-                    maiyaPTR, tizhongzhishuPTR, bianliangtizhongPTR, zhongxinxueliuliangPTR, xueyazhishuPTR, xueyenianduPTR,
-                    pingjunzhiliushijianPTR, maixinboPTR,
-                    cankaojieguoPTR, cankaozhishuPTR);
-                int status = Marshal.ReadInt32(statusPTR);
-                if (status == 1)
-                {
-                    Console.WriteLine("done.");
-                }
-                else
-                {
-                    Console.WriteLine("failed.");
-                }
-            }
-            //*/
-
-        }
-}

+ 137 - 0
WpfTest1/Toolkits/ReportGenerater.cs

@@ -0,0 +1,137 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using iTextSharp.text;
+using iTextSharp.text.pdf;
+using System.IO;
+using LitJson;
+
+namespace WpfTest1.Toolkits
+{
+    class ReportGenerater
+    {
+        public static void generateReport(int type, SQLite.Patient onePatient, SQLite.doctor oneDoctor, SQLite.Record oneRecord, string organization_name)
+        {
+            string fileName = Constants.reportPath + "\\" + oneRecord.r_id.ToString() + ".pdf";
+            Document document = new Document(PageSize.A4);
+            //中文字体
+            string chinese = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "STSONG.TTF");
+            //System.Console.WriteLine(chinese);
+            BaseFont baseFont = BaseFont.CreateFont(chinese, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
+            //文字大小12,文字样式
+            Font cn = new Font(baseFont, 12, Font.NORMAL);
+            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create));
+            document.Open();
+
+            //首先是标题
+            var title = new Paragraph(String.Format("\n {0}检测报告", organization_name), new Font(baseFont, 16, Font.BOLD, BaseColor.BLACK));
+            //居中
+            title.Alignment = Element.ALIGN_CENTER;
+            document.Add(title);
+            //加一个空段预防遮挡
+            document.Add(new iTextSharp.text.Paragraph(" "));
+            var border = new Paragraph("------------------------------------------------------------------------------------------------------", new Font(baseFont, 16, Font.BOLD, BaseColor.BLACK));
+            border.Alignment = Element.ALIGN_CENTER;
+            document.Add(border);
+
+            //然后是病例信息表格
+            //添加表格
+            PdfPTable table = new PdfPTable(6);
+            
+
+            DateTime now = DateTime.Today;
+            int age = now.Year - onePatient.p_birthdate.Year;
+            if (onePatient.p_birthdate > now.AddYears(-age))
+                age--;
+
+            string[] dataToBeFilled = new string[] 
+            {
+                "病案号:",
+                onePatient.p_record_id,
+                "姓名:",
+                onePatient.p_name,
+                "性别:",
+                onePatient.p_gender,
+                "年龄:",
+                age.ToString(),
+                "身高:",
+                onePatient.p_height.ToString() + "cm",
+                "体重:",
+                onePatient.p_weight.ToString() + "kg",
+                "操作医师:",
+                oneDoctor.name,
+                "操作时间:",
+                oneRecord.r_time.ToString("g"),
+                " ",
+                " "
+            };
+            foreach(string oneSentance in dataToBeFilled)
+            {
+                Paragraph p = new Paragraph(oneSentance, new Font(baseFont));
+                PdfPCell cell = new PdfPCell(p);
+                
+                cell.Border = Rectangle.NO_BORDER;
+                table.AddCell(cell);
+            }
+            table.HorizontalAlignment = Element.ALIGN_CENTER;
+            //table.
+            table.TotalWidth = 500;
+            table.LockedWidth = true;
+            float[] widths = new float[] { 100, 100, 100, 100, 50, 50 };//三列列宽不同若果是浮点数需要加f
+            table.SetWidths(widths);
+            document.Add(table);
+
+            document.Add(border);
+            
+            //最后是文档
+
+            
+            var jsonUserSelections = oneRecord.r_selection;
+            List<SQLite.UserSelection> uss = JsonMapper.ToObject<List<SQLite.UserSelection>>(jsonUserSelections);
+            foreach(SQLite.UserSelection us in uss)
+            {
+                SQLite.Question qTemp = SQLite.SQLiteModel.getQuestionById(us.q_id);
+                SQLite.Answer aTemp = SQLite.SQLiteModel.getAnswerById(us.a_id);
+                //System.Console.WriteLine(String.Format("a_id:{0},next_qid:{1}", aTemp.a_id, aTemp.next_q_id));
+                if(type == 2 && aTemp.next_q_id != 0)
+                {
+                    //evaluation
+                    continue;
+                }
+                else
+                {
+                    var questionTitle = new Paragraph(String.Format("{0}:{1}", qTemp.q_title, aTemp.a_content), new Font(baseFont, 13, Font.NORMAL, BaseColor.BLACK));
+                    document.Add(questionTitle);
+                    if (aTemp.a_description_img != "")
+                    {
+                        Image image = Image.GetInstance(Constants.imgPath + "\\" + aTemp.a_description_img);
+                        image.ScaleAbsoluteWidth(500);
+                        document.Add(image);
+                    }
+                    if (aTemp.a_description_text != "")
+                    {
+                        var description = new Paragraph(String.Format("问题说明:\n    {0}", aTemp.a_description_text), new Font(baseFont, 13, Font.NORMAL, BaseColor.BLACK));
+                        document.Add(description);
+                    }
+                    if (aTemp.a_suggestion_img != "")
+                    {
+                        Image image = Image.GetInstance(Constants.imgPath + "\\" + aTemp.a_suggestion_img);
+                        image.ScaleAbsoluteWidth(500);
+                        document.Add(image);
+                    }
+                    if (aTemp.a_suggestion_text != "")
+                    {
+                        var suggestion = new Paragraph(String.Format("建议:\n    {0}", aTemp.a_suggestion_text), new Font(baseFont, 13, Font.NORMAL, BaseColor.BLACK));
+                        document.Add(suggestion);
+                    }
+                }
+            }
+            document.Close();
+
+            //打开文件
+            System.Diagnostics.Process.Start(fileName);
+        }
+    }
+}

+ 0 - 1013
WpfTest1/Toolkits/ReportGenerator.cs

@@ -1,1013 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using MSWord = Microsoft.Office.Interop.Word;
-using System.IO;
-using System.Reflection;
-
-namespace WpfTest1.Toolkits
-{
-    class ReportGenerator
-    {
-        /*
-         * generateReport:生成报告的方法
-         * 参数:
-         * patiment:病人对象
-         * rcd: 报告对象
-         * cfg 系统Config类
-         * handFlag:0均没有,1左手,2右手,3双手
-         * mw: 主界面引用
-         * expressions:各参数值结果
-         * rpRecord: RP环节的结果
-         * generalExpressionResult: 用于自动评价风险的总表达式结果,double
-         * */
-        //
-        public void generateReport(SQLite.Patient patient, SQLite.Record rcd, Config cfg, int handFlag,MainWindow mw, Dictionary<string,double> expressions, SQLite.doctor doct,RPCalculate rpRecord, string generalExpressionResult)
-        {
-            String path = Constants.reportPath;
-            //String now = System.DateTime.Now.ToString("yyyyMMddHHmmss");
-            /* String picName0 = path + "\\" + "0.jpg";
-             String picName1 = path + "\\" + "1.jpg";
-             String picName2 = path + "\\" + "2.jpg";
-             String picName3 = path + "\\" + "3.jpg";
-             String picName4 = path + "\\" + "4.jpg";
-             */
-            String fileName = path + "\\" + patient.p_record_id + "_" + patient.p_name + "_" + rcd.recordTime.ToString("yyyyMMddHHmmss") + ".doc";
-            String pdfFileName = path + "\\" + patient.p_record_id + "_" + patient.p_name + "_" + rcd.recordTime.ToString("yyyyMMddHHmmss") + ".pdf";
-            if (File.Exists(fileName))
-            {
-                try
-                {
-                    File.Delete(fileName);
-                }
-                catch (Exception)
-                {
-                    ;
-                }
-                
-            }
-            FileStream fs = new FileStream(fileName, FileMode.CreateNew);
-            fs.Close();
-            int space = 12;
-
-            Object oMissing = System.Reflection.Missing.Value;
-            Microsoft.Office.Interop.Word._Application WordApp = new Microsoft.Office.Interop.Word.Application();
-            object filename = fileName;
-            Microsoft.Office.Interop.Word._Document WordDoc = null;
-
-            try
-            {
-                
-                WordDoc = WordApp.Documents.Open(ref filename, ref oMissing,
-                        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
-                        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
-                WordApp.Visible = false;
-
-                //页面设置
-                WordDoc.PageSetup.PaperSize = MSWord.WdPaperSize.wdPaperA4;//设置纸张样式为A4纸
-                WordDoc.PageSetup.Orientation = MSWord.WdOrientation.wdOrientPortrait;//排列方式为垂直方向
-                WordDoc.PageSetup.TopMargin = 57.0f;
-                WordDoc.PageSetup.BottomMargin = 10.0f;
-                WordDoc.PageSetup.LeftMargin = 57.0f;
-                WordDoc.PageSetup.RightMargin = 57.0f;
-                WordDoc.PageSetup.HeaderDistance = 30.0f;//页眉位置
-                WordDoc.PageSetup.FooterDistance = 15.0f;
-
-                //设置页眉
-                WordApp.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdOutlineView;//视图样式
-                WordApp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekPrimaryHeader;//进入页眉设置,其中页眉边距在页面设置中已完成
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
-
-                //插入页眉图片(测试结果图片未插入成功)
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
-                string headerfile = Constants.reportHeadPicPath;
-                Console.WriteLine(headerfile);
-                Microsoft.Office.Interop.Word.InlineShape shape1 = WordApp.ActiveWindow.ActivePane.Selection.InlineShapes.AddPicture(headerfile, ref oMissing, ref oMissing, ref oMissing);
-                shape1.Height = 25;
-                shape1.Width = 25;
-
-                //页眉修改Test
-                object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
-                object count = WordDoc.Paragraphs.Count;
-                object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdParagraph;
-                string eyeContent = cfg.organization_name;
-                //第一行
-                WordApp.Selection.Font.Name = "黑体";
-                WordApp.Selection.Font.Bold = 1;
-                WordApp.Selection.Font.Color = MSWord.WdColor.wdColorRed;
-                WordApp.Selection.Font.Size = 30;
-                WordApp.Selection.Font.Spacing = 10;
-
-
-                WordApp.ActiveWindow.ActivePane.Selection.InsertAfter(" " + eyeContent + "\n");
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);
-                //第二行
-                WordApp.Selection.Font.Name = "黑体";
-                WordApp.Selection.Font.Bold = 1;
-                WordApp.Selection.Font.Color = MSWord.WdColor.wdColorGray30;
-                WordApp.Selection.Font.Size = 20;
-                WordApp.Selection.Font.Spacing = 0;
-                WordApp.ActiveWindow.ActivePane.Selection.InsertAfter("PIH检测报告单" + "\n");
-                //第一行
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);
-                WordApp.Selection.Font.Name = "黑体";
-                WordApp.Selection.Font.Bold = 1;
-                WordApp.Selection.Font.Color = MSWord.WdColor.wdColorGray30;
-                WordApp.Selection.Font.Size = 10;
-                string currentData = DateTime.Now.ToString("yy/MM/dd");
-                WordApp.ActiveWindow.ActivePane.Selection.InsertAfter("病案编号:" + rcd.id + "      " + "检查日期:" + currentData);
-
-                //去掉页眉的横线
-                //WordApp.ActiveWindow.ActivePane.Selection.ParagraphFormat.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;
-                //WordApp.ActiveWindow.ActivePane.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].Visible = false;
-                WordApp.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;//退出页眉设置
-
-                //页脚
-                WordApp.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdOutlineView;
-                WordApp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekPrimaryFooter;
-                //移动光标文档末尾
-                //  object count = WordDoc.Paragraphs.Count;
-                // object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdParagraph;
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
-                // 去掉页脚的横线
-                WordApp.ActiveWindow.ActivePane.Selection.ParagraphFormat.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
-                WordApp.ActiveWindow.ActivePane.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].Visible = true;
-
-                //为当前页添加页码
-                Microsoft.Office.Interop.Word.PageNumbers pns = WordApp.Selection.Sections[1].Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers;//获取当前页的号码
-                pns.NumberStyle = Microsoft.Office.Interop.Word.WdPageNumberStyle.wdPageNumberStyleNumberInDash;
-                pns.HeadingLevelForChapter = 0;
-                pns.IncludeChapterNumber = false;
-                pns.RestartNumberingAtSection = false;
-                pns.StartingNumber = 0;
-                object pagenmbetal = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberCenter;//将号码设置在中间
-                object first = true;
-                WordApp.Selection.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers.Add(ref pagenmbetal, ref first);
-
-
-                WordApp.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;//退出页眉设置
-                //插入表格
-                // WordApp.Selection.EndKey(ref WdLine, ref oMissing);
-                //WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
-                int tableRow = 6;
-                int tableColumn = 6;
-                //定义一个word中的表格对象
-                MSWord.Table table = WordDoc.Tables.Add(WordApp.Selection.Range, tableRow, tableColumn, ref oMissing, ref oMissing);
-                table.Range.Font.Size = 10;
-                table.Range.Font.Bold = 0;
-                table.Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
-                //内线
-                //table.Borders.InsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;
-                table.Columns[1].Width = 70;
-                table.Columns[2].Width = 120;
-                table.Columns[3].Width = 60;
-                table.Columns[4].Width = 70;
-                table.Columns[5].Width = 80;
-                //table.Columns[6].Width = 40;
-                for (int i = 1; i <= 6; i = i + 2)
-                {
-                    for (int j = 1; j <= 6; j++)
-                    {
-                        table.Cell(j, i).Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphLeft;
-                    }
-                }
-
-                table.Cell(1, 1).Range.Text = "身份证号:";
-                table.Cell(1, 2).Range.Text = patient.p_record_id;
-                table.Cell(1, 3).Range.Text = "性别:";
-                table.Cell(1, 4).Range.Text = "女";
-                table.Cell(1, 5).Range.Text = "病例号:";
-                table.Cell(1, 6).Range.Text = patient.p_record_id.ToString();
-                table.Cell(2, 1).Range.Text = "姓名:";
-                table.Cell(2, 2).Range.Text = patient.p_name;
-                table.Cell(2, 3).Range.Text = "年龄:";
-                if (patient.p_record_id.Length == 18)
-                {
-                    //假设身份证号合法
-                    string birthday = patient.p_record_id.Substring(6, 8);
-                    //MessageBox.Show(birthday);
-                    if (birthday.Substring(0, 2) == "19" || birthday.Substring(0, 2) == "20")
-                    {
-                        DateTime birthdayDate = new DateTime(Convert.ToInt32(birthday.Substring(0, 4)), Convert.ToInt32(birthday.Substring(4, 2)), Convert.ToInt32(birthday.Substring(6, 2)));
-                        int age = Toolkits.OtherSmallFunction.getAgeByBirthDay(birthdayDate);
-                        table.Cell(2, 4).Range.Text = age.ToString();
-                    }
-                    else
-                    {
-                        table.Cell(2, 4).Range.Text = "--";
-                    }
-                }
-                else
-                {
-                    table.Cell(2, 4).Range.Text = "--";
-                }
-                table.Cell(2, 5).Range.Text = "床号:";
-                table.Cell(2, 6).Range.Text = "--";
-                table.Cell(3, 1).Range.Text = "身高:";
-                table.Cell(3, 2).Range.Text = patient.p_height.ToString();
-                table.Cell(3, 3).Range.Text = "科别:";
-                table.Cell(3, 4).Range.Text = "产科";
-                table.Cell(3, 5).Range.Text = "检查部位:";
-                switch (handFlag)
-                {
-                    case 0:
-                        table.Cell(3, 6).Range.Text = "□左手 □右手";
-                        break;
-                    case 1:
-                        table.Cell(3, 6).Range.Text = "√左手 □右手";
-                        break;
-                    case 2:
-                        table.Cell(3, 6).Range.Text = "□左手 √右手";
-                        break;
-                    default:
-                        table.Cell(3, 6).Range.Text = "√左手 √右手";
-                        break;
-                }
-                table.Cell(4, 1).Range.Text = "体重:";
-                table.Cell(4, 2).Range.Text = patient.p_weight.ToString();
-                table.Cell(4, 3).Range.Text = "孕周:";
-                //table.Cell(4, 4).Range.Text = ((DateTime.Now - patient.pregnancy_date).Days / 7 + 1).ToString(); ;
-                table.Cell(4, 5).Range.Text = "孕次:";
-                //table.Cell(4, 6).Range.Text = patient.pregnancy_times.ToString();
-                table.Cell(5, 1).Range.Text = "科室:";
-                table.Cell(5, 2).Range.Text = "--";
-                table.Cell(5, 3).Range.Text = "病床号:";
-                table.Cell(5, 4).Range.Text = "----";
-                table.Cell(5, 5).Range.Text = "单胎/多胎:";
-                table.Cell(5, 6).Range.Text = "--";
-                table.Cell(6, 1).Range.Text = "病区:";
-                table.Cell(6, 2).Range.Text = "--";
-                table.Cell(6, 3).Range.Text = "住院号:";
-                table.Cell(6, 4).Range.Text = "--";
-                table.Cell(6, 5).Range.Text = "设备型号:";
-                table.Cell(6, 6).Range.Text = "HC2180-D";
-
-                Microsoft.Office.Interop.Word.Paragraph oPara1 = WordDoc.Content.Paragraphs.Add(ref oMissing);
-                oPara1.Range.Text = "____________________________________________________________________________________________";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.InsertParagraphAfter();
-
-                //分栏测试
-
-
-                //参数检测部分
-                /*
-                oPara1.Range.Text = "血液动力学参数检测";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Format.SpaceAfter = space;
-                oPara1.Range.InsertParagraphAfter();
-                */
-                //插入表格
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                //WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
-                //WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);
-                int tableRow2 = 43;
-                int tableColumn2 = 5;
-                //定义一个word中的表格对象
-                MSWord.Table table2 = WordDoc.Tables.Add(WordApp.Selection.Range, tableRow2, tableColumn2, ref oMissing, ref oMissing);
-                table2.Range.Font.Size = 8;
-                table2.Range.Font.Bold = 0;
-                table2.Range.Rows.Height = 13;
-                table2.Rows.HeightRule = MSWord.WdRowHeightRule.wdRowHeightExactly;
-                table2.Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphLeft;
-                //内线
-                //table2.Borders.InsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;
-                table2.Columns[1].Width = 95;
-                table2.Columns[2].Width = 40;
-                table2.Columns[3].Width = 15;
-                table2.Columns[4].Width = 95;
-                table2.Columns[5].Width = 250;
-                //table2.Columns[6].Width = 40;
-                //table2.Columns[7].Width = 15;
-                //table2.Columns[8].Width = 95;
-                /*for(int i=1;i<=22;i++)
-                {
-                    table2.Rows[i].Height = 60;
-                }*/
-                //合并表格
-                table2.Cell(1, 1).Merge(table2.Cell(1, 4));
-                table2.Cell(2, 5).Merge(table2.Cell(43, 5));
-
-                //表格文字
-                table2.Cell(1, 1).Range.Text = "血液动力学参数检测结果";
-                table2.Cell(2, 1).Range.Text = "收缩压SPB:";
-                table2.Cell(2, 2).Range.Text = rpRecord.shousuoya.ToString();
-                try
-                {
-                    double hbp = rpRecord.shousuoya;
-                    if (hbp > 130)
-                    {
-                        table2.Cell(2, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 90)
-                    {
-                        table2.Cell(2, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-
-                }
-                table2.Cell(2, 4).Range.Text = "90-130mmHg";
-
-                table2.Cell(3, 1).Range.Text = "舒张压DPB:";
-                table2.Cell(3, 2).Range.Text = rpRecord.shuzhangya.ToString();
-                try
-                {
-                    double hbp = rpRecord.shuzhangya;
-                    if (hbp > 100)
-                    {
-                        table2.Cell(3, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 60)
-                    {
-                        table2.Cell(3, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-
-                }
-                table2.Cell(3, 4).Range.Text = "60-100mmHg";
-
-                table2.Cell(4, 1).Range.Text = "脉压PP:";
-                table2.Cell(4, 2).Range.Text = rpRecord.maiya.ToString();
-                if(rpRecord.maiya > 50)
-                {
-                    table2.Cell(4, 3).Range.Text = "↑";
-                }
-                else if(rpRecord.maiya < 35)
-                {
-                    table2.Cell(4, 3).Range.Text = "↓";
-                }
-                table2.Cell(4, 4).Range.Text = "35-50mmHg";
-
-                table2.Cell(5, 1).Range.Text = "平均动脉压MAP:";
-                table2.Cell(5, 2).Range.Text = rpRecord.pingjundongmaiya.ToString();
-                try
-                {
-                    double hbp = rpRecord.pingjundongmaiya;
-                    if (hbp > 95)
-                    {
-                        table2.Cell(5, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 85)
-                    {
-                        table2.Cell(5, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-
-                }
-                table2.Cell(5, 4).Range.Text = "85-95mmHg";
-
-                table2.Cell(6, 1).Range.Text = "血压指数BPI:";
-                table2.Cell(6, 2).Range.Text = rpRecord.xueyazhishu.ToString();
-                try
-                {
-                    double hbp = rpRecord.xueyazhishu;
-                    if (hbp > 150)
-                    {
-                        table2.Cell(6, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(6, 4).Range.Text = "<150";
-
-                table2.Cell(7, 1).Range.Text = "体表面积TBA:";
-                table2.Cell(7, 2).Range.Text = rpRecord.tibiaomianji.ToString();
-                table2.Cell(7, 4).Range.Text = "m*m";
-
-                table2.Cell(8, 1).Range.Text = "血总容量BV:"; //textBoxRPzongxuerongliangHistory
-                table2.Cell(8, 2).Range.Text = rpRecord.zongxuerongliang.ToString();
-                table2.Cell(8, 4).Range.Text = "(参考范围)";
-
-                table2.Cell(9, 1).Range.Text = "波形系数K:";
-                table2.Cell(9, 2).Range.Text = rpRecord.boxinxishu.ToString();
-                try
-                {
-                    double hbp = rpRecord.boxinxishu;
-                    if (hbp > 0.4)
-                    {
-                        table2.Cell(9, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 0.33)
-                    {
-                        table2.Cell(9, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-
-                }
-                table2.Cell(9, 4).Range.Text = "0.33-0.4";
-
-                table2.Cell(10, 1).Range.Text = "体重指数WI:";
-                table2.Cell(10, 2).Range.Text = rpRecord.tizhongzhishu.ToString();
-                try
-                {
-                    double hbp = rpRecord.tizhongzhishu;
-                    if (hbp > 0.24)
-                    {
-                        table2.Cell(10, 3).Range.Text = "↑";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(10, 4).Range.Text = "<0.24";
-
-                table2.Cell(11, 1).Range.Text = "心输出量CO:";
-                table2.Cell(11, 2).Range.Text = rpRecord.xinshuchuliang.ToString();
-                try
-                {
-                    double hbp = rpRecord.xinshuchuliang;
-                    if (hbp > 7)
-                    {
-                        table2.Cell(11, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 3)
-                    {
-                        table2.Cell(11, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(11, 4).Range.Text = "3-7L/min";
-
-                table2.Cell(12, 1).Range.Text = "外周阻力TPR:";
-                table2.Cell(12, 2).Range.Text = rpRecord.waizhouzuli.ToString();
-                try
-                {
-                    double hbp = rpRecord.waizhouzuli;
-                    if (hbp > 1.4)
-                    {
-                        table2.Cell(12, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 0.9)
-                    {
-                        table2.Cell(12, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(12, 4).Range.Text = "0.9-1.4PRU";
-
-                table2.Cell(13, 1).Range.Text = "每搏量SV:";
-                table2.Cell(13, 2).Range.Text = rpRecord.meiboliang.ToString();
-                try
-                {
-                    double hbp = rpRecord.meiboliang;
-                    if (hbp > 100)
-                    {
-                        table2.Cell(13, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 60)
-                    {
-                        table2.Cell(13, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(13, 4).Range.Text = "60-100ml";
-
-                table2.Cell(14, 1).Range.Text = "心脏指数CI:";
-                table2.Cell(14, 2).Range.Text = rpRecord.xinzangzhishu.ToString();
-                try
-                {
-                    double hbp = rpRecord.xinzangzhishu;
-                    if (hbp > 4)
-                    {
-                        table2.Cell(14, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 2.5)
-                    {
-                        table2.Cell(14, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(14, 4).Range.Text = "2.5-4";
-
-                table2.Cell(15, 1).Range.Text = "心搏指数SI:";
-                table2.Cell(15, 2).Range.Text = rpRecord.xinbozhishu.ToString();
-                try
-                {
-                    double hbp = rpRecord.xinbozhishu;
-                    if (hbp > 60)
-                    {
-                        table2.Cell(15, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 40)
-                    {
-                        table2.Cell(15, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(15, 4).Range.Text = "40-60ml/m*m";
-
-                table2.Cell(16, 1).Range.Text = "顺应性AC:";
-                table2.Cell(16, 2).Range.Text = rpRecord.shunyinxing.ToString();
-                try
-                {
-                    double hbp = rpRecord.shunyinxing;
-                    if (hbp > 2)
-                    {
-                        table2.Cell(16, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 1.2)
-                    {
-                        table2.Cell(16, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(16, 4).Range.Text = "1.2-2ml/mmHg";
-
-                table2.Cell(17, 1).Range.Text = "心率HR:";
-                table2.Cell(17, 2).Range.Text = rcd.heartRate.ToString();
-                table2.Cell(17, 4).Range.Text = "bpm";
-
-                table2.Cell(18, 1).Range.Text = "中心血流量CBF:";
-                table2.Cell(18, 2).Range.Text = rpRecord.zhongxinxueliuliang.ToString();
-
-                table2.Cell(19, 1).Range.Text = "血液黏度V:";
-                table2.Cell(19, 2).Range.Text = rpRecord.xueyeniandu.ToString();
-                try
-                {
-                    double hbp = rpRecord.xueyeniandu;
-                    if (hbp > 4.5)
-                    {
-                        table2.Cell(19, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 3.8)
-                    {
-                        table2.Cell(16, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(19, 4).Range.Text = "3.8-4.5CP";
-
-                table2.Cell(20, 1).Range.Text = "平均滞留时间T:";
-                table2.Cell(20, 2).Range.Text = rpRecord.pingjunzhiliushijian.ToString();
-                try
-                {
-                    double hbp = rpRecord.pingjunzhiliushijian;
-                    if (hbp > 33)
-                    {
-                        table2.Cell(20, 3).Range.Text = "↑";
-                    }
-                    else if (hbp < 20)
-                    {
-                        table2.Cell(20, 3).Range.Text = "↓";
-                    }
-                    else
-                    {
-                    }
-                }
-                catch (Exception)
-                {
-                }
-                table2.Cell(20, 4).Range.Text = "20-33s";
-                //21项开始自动生成
-                int startIdx = 21;
-                /*
-                for (int i = 0; i < expressions.Count && i + startIdx < 41; ++i)
-                {
-                    SQLite.Expression oneExpression = SQLite.SQLiteModel.getExpressionByContent(expressions.ElementAt(i).Key);
-                    table2.Cell(i + startIdx, 1).Range.Text = oneExpression.expression_description;
-                    if (expressions.ElementAt(i).Value == Double.MinValue)
-                    {
-                        table2.Cell(i + startIdx, 2).Range.Text = "--";
-                        continue;
-                    }
-                    table2.Cell(i + startIdx, 2).Range.Text = expressions.ElementAt(i).Value.ToString();
-
-                    if (expressions.ElementAt(i).Value > oneExpression.upBound)
-                    {
-                        table2.Cell(i + startIdx, 3).Range.Text = "↑";
-                    }
-                    else if (expressions.ElementAt(i).Value < (oneExpression.upBound))
-                    {
-                        table2.Cell(i + startIdx, 3).Range.Text = "↓";
-                    }
-                    table2.Cell(i + startIdx, 4).Range.Text = oneExpression.downBound.ToString() + "-" + oneExpression.upBound.ToString();
-                }*/
-
-                //诊断部分
-                string pailiangRemark = "";
-                string zuliRemark = "";
-                if (rpRecord.xpl < 4)
-                {
-                    pailiangRemark = "低排";
-                }
-                else if(rpRecord.xpl > 5)
-                {
-                    pailiangRemark = "高排";
-                }
-                else
-                {
-                    pailiangRemark = "中排";
-                }
-                if (rpRecord.wzzl < 4)
-                {
-                    zuliRemark = "低阻";
-                }
-                else if (rpRecord.wzzl > 5)
-                {
-                    zuliRemark = "高阻";
-                }
-                else
-                {
-                    zuliRemark = "中阻";
-                }
-                table2.Cell(2, 5).Range.Text = "自动分析结果:\n"
-                    + "一、参考结果\n"
-                    + rpRecord.cankaojieguo + "\n"
-                    + "二、参考指数\n"
-                    + "排量:" + rpRecord.xpl.ToString() + "(" + pailiangRemark + ")\n阻力:" + rpRecord.wzzl.ToString() + "(" + zuliRemark + ")\n"
-                    + "三、脉搏波形\n" + rcd.waveTpye + "\n"
-                    + "四、医师建议" + "\n风险等级:" + generalExpressionResult + "\n";// + mw.textBoxDiagnosis.Text;
-                table2.Cell(2, 5).Range.Font.Size = 15;
-
-                //自动分析结果
-                /*
-                oPara1.Range.Text = "______________________________________________________________________________________________________________";
-                oPara1.Range.Font.Bold = fontBold;
-                oPara1.Range.InsertParagraphAfter();
-                */
-
-                //插入分页符
-                object oPageBreak = Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
-
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordDoc.ActiveWindow.Selection.InsertBreak(ref oPageBreak);
-
-                //图片页
-                //图片1
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 80;
-                oPara1.Range.Text = "\n桡动脉波形图:";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 15;
-                oPara1.Format.SpaceAfter = space;
-                oPara1.Range.InsertParagraphAfter();
-
-
-                //插图
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-                string picture1 = Constants.tmpRPWave;
-                //定义要向文档中插入图片的位置
-                object range = WordDoc.Paragraphs.Last.Range;
-                //定义该图片是否为外部链接
-                object linkToFile = false;//默认
-                //定义插入的图片是否随word一起保存
-                object saveWithDocument = true;
-                //向word中写入图片
-                try
-                {
-                    WordDoc.InlineShapes.AddPicture(picture1, ref oMissing, ref oMissing, ref oMissing);
-                }
-                catch (Exception)
-                {
-                    Console.WriteLine("fail to load raodongmai.");
-                }
-
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                WordDoc.InlineShapes[1].Height = 130;
-                WordDoc.InlineShapes[1].Width = 490;
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("右侧桡动脉\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                oPara1.Range.Text = "____________________________________________________________________________________________";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 10;
-                oPara1.Range.InsertParagraphAfter();
-
-
-                //图片2.3
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 80;
-                oPara1.Range.Text = cfg.report_figure_name + ":";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 15;
-                oPara1.Format.SpaceAfter = space;
-                oPara1.Format.SpaceBefore = 0;
-                oPara1.Range.InsertParagraphAfter();
-
-
-                //插图
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-                string picture2 = Constants.tmpPPGLeftInfraredWave;
-                string picture3 = Constants.tmpPPGLeftRedWave;
-                string picture4 = Constants.tmpPPGRightRedWave;
-                string picture5 = Constants.tmpPPGRightInfraredWave;
-                //向word中写入图片
-                try
-                {
-                    WordDoc.InlineShapes.AddPicture(picture2, ref oMissing, ref oMissing, ref oMissing);
-                    WordDoc.InlineShapes.AddPicture(picture3, ref oMissing, ref oMissing, ref oMissing);
-                    WordDoc.InlineShapes.AddPicture(picture4, ref oMissing, ref oMissing, ref oMissing);
-                    WordDoc.InlineShapes.AddPicture(picture5, ref oMissing, ref oMissing, ref oMissing);
-
-                }
-                catch (Exception)
-                {
-                    Console.WriteLine("fail to load a image.");
-                }
-
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                for(int i = 2; i < 6; ++i)
-                {
-                    WordDoc.InlineShapes[i].Height = 80;
-                    WordDoc.InlineShapes[i].Width = 200;
-                }
-                
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("左手手指 红外光\n");
-                //左手红光
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-                /*
-                try
-                {
-                    WordDoc.InlineShapes.AddPicture(picture3, ref oMissing, ref oMissing, ref oMissing);
-
-                }
-                catch (Exception)
-                {
-                    Console.WriteLine("fail to load ppg Left2.");
-                }
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                WordDoc.InlineShapes[3].Height = 100;
-                WordDoc.InlineShapes[3].Width = 245;
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("左手手指 红光\n");
-                //右手红外光
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-               
-                //向word中写入图片
-                try
-                {
-                    WordDoc.InlineShapes.AddPicture(picture4, ref oMissing, ref oMissing, ref oMissing);
-
-                }
-                catch (Exception)
-                {
-                    Console.WriteLine("fail to load ppg right1.");
-                }
-
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                WordDoc.InlineShapes[4].Height = 130;
-                WordDoc.InlineShapes[4].Width = 490;
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("右手手指 红外光\n");
-                //右手红外光
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-                
-                //向word中写入图片
-                try
-                {
-                    WordDoc.InlineShapes.AddPicture(picture5, ref oMissing, ref oMissing, ref oMissing);
-
-                }
-                catch (Exception)
-                {
-                    Console.WriteLine("fail to load ppg right1.");
-                }
-
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                WordDoc.InlineShapes[5].Height = 130;
-                WordDoc.InlineShapes[5].Width = 490;
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("右手手指 红光\n");
-                */
-                //插入分页符
-                //object oPageBreak = Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
-                //WordApp.Selection.EndKey(ref unite, ref oMissing);
-                // WordDoc.ActiveWindow.Selection.InsertBreak(ref oPageBreak);
-
-
-                //第三页
-                /*
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 80;
-                oPara1.Range.Text = "趋势图:";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 15;
-                oPara1.Format.SpaceBefore = space;
-                oPara1.Format.SpaceAfter = space;
-                oPara1.Range.InsertParagraphAfter();
-
-
-                //插图
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-                string picture4 = "c:\\picture\\raodongmai.png";
-                //定义要向文档中插入图片的位置
-                //向word中写入图片
-                WordDoc.InlineShapes.AddPicture(picture4, ref oMissing, ref oMissing, ref oMissing);
-
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                WordDoc.InlineShapes[4].Height = 130;
-                WordDoc.InlineShapes[4].Width = 490;
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("IPR 右侧桡动脉\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                oPara1.Range.Text = "________________________________________________________________________________________________________________";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 10;
-                oPara1.Format.SpaceAfter = 0;
-                oPara1.Range.InsertParagraphAfter();
-
-
-                //图片2.3
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 80;
-                oPara1.Range.Text = "趋势图:";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 15;
-                oPara1.Format.SpaceAfter = space;
-                oPara1.Range.InsertParagraphAfter();
-
-
-                //插图
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-                string picture5 = "c:\\picture\\2.png";
-                //向word中写入图片
-                WordDoc.InlineShapes.AddPicture(picture5, ref oMissing, ref oMissing, ref oMissing);
-
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                WordDoc.InlineShapes[5].Height = 130;
-                WordDoc.InlineShapes[5].Width = 490;
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("RI 左手手指 红外光\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 0;
-                string picture6 = "c:\\picture\\3.png";
-                //向word中写入图片
-                WordDoc.InlineShapes.AddPicture(picture6, ref oMissing, ref oMissing, ref oMissing);
-
-                WordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
-                WordDoc.InlineShapes[6].Height = 130;
-                WordDoc.InlineShapes[6].Width = 490;
-                //WordDoc.Content.InsertAfter("\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
-                WordApp.Selection.Font.Size = 10;//字体大小
-                WordApp.Selection.TypeText("RI 右手手指 红外光\n");
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                //*/
-                oPara1.Range.Text = "____________________________________________________________________________________________";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 10;
-                oPara1.Format.SpaceBefore = 0;
-                oPara1.Format.SpaceAfter = 0;
-                oPara1.Range.InsertParagraphAfter();
-                //医师签名
-                WordApp.Selection.EndKey(ref unite, ref oMissing);
-                WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
-                WordApp.Selection.ParagraphFormat.FirstLineIndent = 150;
-                oPara1.Range.Text = "检查医师:" + doct.name + "   医师签名:";
-                oPara1.Range.Font.Bold = 0;
-                oPara1.Range.Font.Size = 15;
-                oPara1.Format.SpaceAfter = 0;
-                oPara1.Format.SpaceBefore = 0;
-                oPara1.Range.InsertParagraphAfter();
-
-
-                //   object LinkToFile = false;
-                object SaveWithDocument = true;
-                //   object Anchor = WordDoc.Application.Selection.Range;
-                /*
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
-                WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picName4, ref LinkToFile, ref SaveWithDocument, ref Anchor);
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
-                WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picName3, ref LinkToFile, ref SaveWithDocument, ref Anchor);
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
-                WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picName2, ref LinkToFile, ref SaveWithDocument, ref Anchor);
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
-                WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picName1, ref LinkToFile, ref SaveWithDocument, ref Anchor);
-                WordApp.Selection.MoveDown(ref WdLine, ref count, ref oMissing);//移动焦点
-                WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(picName0, ref LinkToFile, ref SaveWithDocument, ref Anchor);
-                */
-                //保存
-                WordDoc.Save();
-                WordDoc.ExportAsFixedFormat(pdfFileName, Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF, true);
-                
-
-            }
-            catch (Exception e)
-            {
-                Console.WriteLine(e.Message);
-                Console.WriteLine(e.StackTrace);
-                
-            }
-            finally
-            {
-                //try
-                //{
-                    WordDoc.Close(ref oMissing, ref oMissing, ref oMissing);
-                    WordApp.Quit(ref oMissing, ref oMissing, ref oMissing);
-                //}
-                //catch (Exception)
-                //{
-
-                //}
-               
-                try
-                {
-                    File.Delete(fileName);
-                }
-                catch (Exception)
-                {
-                    ;
-                }
-            }
-
-
-        }
-    }
-}

+ 0 - 247
WpfTest1/Toolkits/SocketListener.cs

@@ -1,247 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Net;
-using System.Net.Sockets;
-
-
-namespace WpfTest1.Toolkits
-{
-    class SocketListener
-    {
-        private static string ip = Constants.UptterIp;
-        private static int myPort = Constants.UpperPort;
-
-        static void test()
-        {
-            List<int> leftList1 = new List<int>();
-            List<int> leftList2 = new List<int>();
-            List<int> rightList1 = new List<int>();
-            List<int> rightList2 = new List<int>();
-            Console.WriteLine(getTcpData(leftList1, leftList2, rightList1, rightList2, 0.01));
-            Console.Write("1\n");
-            foreach (int i in leftList1)
-            {
-                Console.Write(i);
-                Console.Write(" ");
-            }
-            Console.Write("2\n");
-            foreach (int i in leftList2)
-            {
-                Console.Write(i);
-                Console.Write(" ");
-            }
-            Console.Write("3\n");
-            foreach (int i in rightList1)
-            {
-                Console.Write(i);
-                Console.Write(" ");
-            }
-            Console.Write("4\n");
-            foreach (int i in rightList2)
-            {
-                Console.Write(i);
-                Console.Write(" ");
-            }
-            Console.Write("5\n");
-        }
-
-        /// <summary>
-        /// 服务器端获取下位机数据包的方法
-        /// </summary>
-        /// 
-        static bool getTcpData(List<int> leftList1, List<int> leftList2, List<int> rightList1, List<int> rightList2, double minutes)
-        {
-            try
-            {
-                //1.监听端口
-                TcpListener server = new TcpListener(IPAddress.Parse(ip), myPort);
-                server.Start();
-                Console.WriteLine("{0:HH:mm:ss}->监听端口{1}...", DateTime.Now, myPort);
-
-                //2.等待请求
-                try
-                {
-                    Console.WriteLine("开始数据的传输!");
-                    //2.1 收到请求
-                    TcpClient client = server.AcceptTcpClient(); //停在这等待连接请求
-                    IPEndPoint ipendpoint = client.Client.RemoteEndPoint as IPEndPoint;
-                    NetworkStream stream = client.GetStream();
-
-                    int iterNo = 0;
-                    DateTime startTime = new DateTime();
-                    DateTime nowTime = new DateTime();
-                    bool checkedFlag = false;
-
-                    while (true)
-                    {
-                        if (iterNo == 0)
-                        {
-                            startTime = DateTime.Now;
-                        }
-                        nowTime = DateTime.Now;
-                        //Console.Write((nowTime - startTime).TotalMinutes);
-                        //Console.Write("\n");
-                        if ((nowTime - startTime).TotalMinutes > minutes)
-                        {
-                            break;
-                        }
-
-                        //2.2 解析数据,长度<1024字节
-                        string data = string.Empty;
-                        byte[] bytes = new byte[1024];
-                        int length = 0;
-                        int exceptionCount = 0;
-                        bool trueFlag = false;
-                        while (true)
-                        {
-                            if (trueFlag)
-                            {
-                                break;
-                            }
-                            if (exceptionCount == 3)
-                            {
-                                return false;
-                            }
-                            try
-                            {
-                                length = stream.Read(bytes, 0, bytes.Length);
-                                trueFlag = true;
-                            }
-                            catch (Exception ex)
-                            {
-                                Console.WriteLine("{0:HH:mm:ss}->{1}", DateTime.Now, ex.Message);
-                                exceptionCount += 1;
-                            }
-                        }
-                        //int length = stream.Read(bytes, 0, bytes.Length);
-                        //Console.Write(length);
-                        //Console.Write("\n");
-                        //Console.Write(bytes.Length);
-                        //Console.Write("\n");
-                        for (int i = 0; i < bytes.Length; i++)
-                        {
-                            Console.Write(bytes[i]);
-                            Console.Write(" ");
-                        }
-                        // 签到报文、如果刚开始没有签到报文,则返回false
-                        if (bytes[0] == 2 && bytes[1] == 0 && bytes[2] == 0 && bytes[3] == 0 && bytes[4] == 0 && bytes[5] == 200 && checkedFlag)
-                        {
-                            continue;
-                        }
-                        if (checkedFlag == false)
-                        {
-                            if (bytes[0] == 2 && bytes[1] == 0 && bytes[2] == 0 && bytes[3] == 0 && bytes[4] == 0 && bytes[5] == 200)
-                            {
-                                checkedFlag = true;
-                            }
-                            else
-                            {
-                                break;
-                                //return false;
-                            }
-                        }
-
-                        // 数据报文
-                        if (bytes[0] == 2 && bytes[1] == 0 && bytes[2] == 0 && bytes[3] == 0 && bytes[4] == 0 && bytes[5] == 23)
-                        {
-                            // 校检
-                            int sum = 0;
-                            for (int i = 0; i < length - 2; i++)
-                            {
-                                sum += bytes[i];
-                            }
-                            String sum_ = Convert.ToString(sum, 16);
-                            int sumLength = sum_.Length;
-                            //Console.Write(sumLength);
-                            sum_ = sum_.Substring(sumLength - 2, 2);
-                            String checkString = Convert.ToString(bytes[length - 1], 16);
-                            if (checkString.Length == 1)
-                            {
-                                checkString = "0" + checkString;
-                            }
-                            if (sum_ != checkString)
-                            {
-                                Console.Write("校检失败!");
-                                continue;
-                            }
-                            String c1 = Convert.ToString(bytes[10], 16);
-                            String c2 = Convert.ToString(bytes[11], 16);
-                            int dataLength = Convert.ToInt32(c1 + c2, 16);
-                            byte[] data_ = bytes.Skip(12).Take(dataLength).ToArray();
-                            if (bytes[9] == 1)
-                            {
-                                //表示右手
-                                for (int i = 0; i < data_.Length / 16; i++)
-                                {
-                                    String d1 = ""; //红光
-                                    foreach (byte b in data_.Skip(i * 16 + 2).Take(3).ToArray())
-                                    {
-                                        d1 += Convert.ToString(b, 16);
-                                    }
-                                    String d2 = "";//红外光
-                                    foreach (byte b in data_.Skip(i * 16 + 9).Take(3).ToArray())
-                                    {
-                                        d2 += Convert.ToString(b, 16);
-                                    }
-                                    rightList1.Add(Convert.ToInt32(d1, 16));
-                                    rightList2.Add(Convert.ToInt32(d2, 16));
-                                }
-                            }
-                            if (bytes[9] == 0)
-                            {
-                                //表示左手
-                                for (int i = 0; i < data_.Length / 16; i++)
-                                {
-                                    String d1 = ""; //红光
-                                    foreach (byte b in data_.Skip(i * 16 + 2).Take(3).ToArray())
-                                    {
-                                        d1 += Convert.ToString(b, 16);
-                                    }
-                                    String d2 = "";//红外光
-                                    foreach (byte b in data_.Skip(i * 16 + 9).Take(3).ToArray())
-                                    {
-                                        d2 += Convert.ToString(b, 16);
-                                    }
-                                    leftList1.Add(Convert.ToInt32(d1, 16));
-                                    leftList2.Add(Convert.ToInt32(d2, 16));
-                                }
-                            }
-                        }
-
-                        Console.WriteLine();
-                        Console.WriteLine(length);
-                        iterNo += 1;
-                    }
-
-                    stream.Close();
-                    client.Close();
-                }
-                catch (Exception ex)
-                {
-                    Console.WriteLine(ex);
-                    Console.WriteLine("传输出现问题1!");
-                    Console.WriteLine("{0:HH:mm:ss}->{1}", DateTime.Now, ex.Message);
-                }
-
-            }
-            catch (SocketException socketEx)
-            {
-                Console.WriteLine("传输出现问题2!");
-                //10013 The requested address is a broadcast address, but flag is not set.
-                if (socketEx.ErrorCode == 10013)
-                    Console.WriteLine("{0:HH:mm:ss}->启动失败,请检查{1}端口有无其他程序占用.", DateTime.Now, myPort);
-                else
-                    Console.WriteLine("{0:HH:mm:ss}->{1}", DateTime.Now, socketEx.Message);
-            }
-            catch (Exception ex)
-            {
-                Console.WriteLine("传输出现问题3!");
-                Console.WriteLine("{0:HH:mm:ss}->{1}", DateTime.Now, ex.Message);
-            }
-            return true;
-        }
-    }
-}

+ 0 - 238
WpfTest1/Toolkits/WaveHandle.cs

@@ -1,238 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using ZedGraph;
-
-namespace WpfTest1.Toolkits
-{
-    //本类是处理波的相关工具方法集
-    public class WaveHandle
-    {
-        //由原始字节流转换为数字数组的方法
-        public static int generateWaveData(byte[] orginalData,List<double> red , List<double> infrared)
-        {
-            red.Clear();
-            infrared.Clear();
-            if (orginalData == null)
-            {
-                return 0;
-            }
-            ///*
-            for (int i = 0; i < orginalData.Length; i += 6)
-            {
-                int v1 = (orginalData[i] << 16) | orginalData[i + 1] << 8 | orginalData[i + 2];
-                int v2 = (orginalData[i + 3] << 16) | orginalData[i + 4] << 8 | orginalData[i + 5];
-                red.Add((double)v1);
-                infrared.Add((double)v2);
-            }
-            //*/
-            /*
-            for (int i = 0; i < orginalData.Length; i += 4)
-            {
-                int v1 = (orginalData[i] << 8) | orginalData[i + 1];
-                int v2 = (orginalData[i + 2] << 8) | orginalData[i + 3];
-                red.Add((double)v1);
-                infrared.Add((double)v2);
-            }
-            */
-            return orginalData.Length;
-        }
-        //由数字数组转换为原始字节流的方法
-        public static int zipToWaveByte(byte[] orginalData, List<double> red, List<double> infrared, int measureStartIndex)
-        {
-            int count = red.Count <= infrared.Count ? red.Count : infrared.Count;
-            int j = 0;
-            for (int i = measureStartIndex; i < count; ++i)
-            {
-                Int32 tempIntRed = Convert.ToInt32(red[i] * Toolkits.Constants.zoomTimes);
-                byte[] tempBytesRed = BitConverter.GetBytes(tempIntRed);
-                Int32 tempIntInfrared = Convert.ToInt32(infrared[i] * Toolkits.Constants.zoomTimes);
-                byte[] tempBytesInfrared = BitConverter.GetBytes(tempIntInfrared);
-                orginalData[j * 6] = tempBytesRed[2];
-                orginalData[j * 6 + 1] = tempBytesRed[1];
-                orginalData[j * 6 + 2] = tempBytesRed[0];
-                orginalData[j * 6 + 3] = tempBytesInfrared[2];
-                orginalData[j * 6 + 4] = tempBytesInfrared[1];
-                orginalData[j * 6 + 5] = tempBytesInfrared[0];
-                ++j;
-            }
-            return orginalData.Length;
-        }
-
-        //由原始字节流转换为RP数字数组的方法
-        public static int generateRPWaveData(byte[] orginalData, List<int> target)
-        {
-            target.Clear();
-            if (orginalData == null)
-            {
-                return 0;
-            }
-            for (int i = 0; i < orginalData.Length; i += 4)
-            {
-                double v1 = (orginalData[i] << 8) | orginalData[i + 1];
-                target.Add(Convert.ToInt32(v1));
-            }
-            return orginalData.Length;
-        }
-
-        //平滑数据方法,平滑点数smoothpoints从配置中选取,smoothTimes是平滑次数
-        public static void smoothList(List<double> points,int smoothpoints,int smoothTimes = 1)
-        {
-            if(smoothpoints > points.Count)
-            {
-                return;
-            }
-            
-            ///*
-            for (int i = 0; i < smoothTimes; ++i)
-            {
-                //此处算法应为,取前n/2的点和后n/2的点进行平滑
-                int smooth_radius = smoothpoints / 2;
-                for (int j = smooth_radius; j < points.Count - smooth_radius; ++j)
-                {
-                    double temp = 0;
-                    for (int k = -smooth_radius; k <= smooth_radius; ++k)
-                    {
-                        temp += points[j + k];
-                    }
-                    points[j] = temp / smoothpoints;
-                }
-                //之后平滑最初和最后的几个点(如果不平滑那么显示会很丑)
-                double tempFinal = 0;
-                for (int j = 0; j< smooth_radius;++j)
-                {
-                    tempFinal += points[j];
-                }
-                for (int j = 0; j < smooth_radius; ++j)
-                {
-                    points[j] = points[smooth_radius];
-                }
-                tempFinal = 0;
-                for (int j = points.Count - smooth_radius; j < points.Count; ++j)
-                {
-                    tempFinal += points[j];
-                }
-                for (int j = points.Count - smooth_radius; j < points.Count; ++j)
-                {
-                    points[j] = points[points.Count - smooth_radius - 1];
-                }
-            }
-            //*/
-        }
-
-        //计算滤波的方法
-        public static void filterList(List<double> source)
-        {
-            if (source.Count <= 0)
-            {
-                return;
-            }
-            //先读滤波数
-            List<double>[] filter = new List<double>[4];
-            for(int i = 0; i < filter.Length; ++i)
-            {
-                filter[i] = new List<double>();
-            }
-            int status = Toolkits.FilterFile.ReadFilterFiles(filter);
-            if (status < 0)
-            {
-                System.Console.WriteLine("滤波器文件文件内容已损坏");
-                return;
-            }
-            //然后开始滤波
-            for(int p=0;p< filter.Length; ++p)
-            {
-                for (int i = 0; i <= source.Count - filter[p].Count; ++i)
-                {
-                    double temp = 0;
-                    for (int j = 0; j < filter[p].Count; ++j)
-                    {
-                        temp += (filter[p][j] * source[i + j]);
-                    }
-                    source[i] = temp;
-                }
-                source.RemoveRange(source.Count - filter[p].Count + 1, filter[p].Count - 1);    //记得删除之后不要的点
-            }
-        }
-
-        //计算List导数方法,即后项减前项计算梯度
-        public static void deriveList(List<double> points,List<double> target)
-        {
-            target.Clear();
-            for(int i = 0; i < points.Count - 1; ++i)
-            {
-                //target.Add(points[i + 1] - points[i]);
-                target.Add((points[i + 1] - points[i])/Toolkits.Constants.sampleInterval);
-                //为保证数组长度一致最后补一个点
-                if(i == points.Count - 2)
-                {
-                    target.Add((points[i + 1] - points[i]) / Toolkits.Constants.sampleInterval);
-                    //target.Add(points[i + 1] - points[i]);
-                }
-            }
-        }
-
-        //给一个波,计算某一点之前或者之后的波谷的x坐标,如不存在则返回-1
-        //注意,rightFlag为true时向右找,否则向左找
-        public static int FindTrough(List<double> data, List<double> driveData, int x, bool rightFlag)
-        {
-            double waveMean = data.Average();
-            for (int i = x; i > 1 && i < driveData.Count - 1;)
-            {
-                if (driveData[i] * driveData[i + 1] <= 0 && driveData[i + 1] >= 0 && data[i] < 1 * waveMean)
-                {
-                    return i;
-                }
-                else
-                {
-                    if (rightFlag)//向右走
-                    {
-                        ++i;
-                    }
-                    else
-                    {
-                        --i;
-                    }
-
-                }
-            }
-            return -1;
-        }
-
-        //将一个波形规范化
-        public static PointPairList NormalizeWave(PointPairList target)
-        {
-            PointPairList result = new PointPairList();
-            int count = target.Count;
-            double max = double.MinValue;
-            for (int i = 0; i < count; i++)
-            {
-                if (target[i].Y > max)
-                {
-                    max = target[i].Y;
-                }
-                //target[i].Y -= target[0].Y;
-            }
-            for (int i = 0; i < count; i++)
-            {
-                double x = (double)i / ((double)count - 1);
-                double y = (target[i].Y - target[0].Y - ((target[count - 1].Y - target[0].Y) / (count - 1)) * i) / (max - target[0].Y);
-                //Console.WriteLine(x+";;;"+y);
-                //double y = target[0].Y + ((target[count - 1].Y - target[0].Y) / (count - 1)) * i;
-                //double result = (y);
-                result.Add(x, y);
-                //target[i].X = x;
-                //target[i].Y = y;
-            }
-            for (int i = 0; i < count; ++i)
-            {
-                target[i].X = result[i].X;
-                target[i].Y = result[i].Y;
-            }
-            return target;
-        }
-    }
-}

+ 0 - 81
WpfTest1/Toolkits/WaveSimulator.cs

@@ -1,81 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace WpfTest1.Toolkits
-{
-    class WaveSimulator
-    {
-        //产生模拟波形的方法
-        //generate a signal combining from 0-5 hz
-        //take amplitude and phase shift into account
-        public static List<double> getSimulatedWave()
-        {
-            double Fs = 100;           //Sampling frequency
-            double T = 1.0 / Fs;      //Sample time
-            int L = 1500;            //Length of signal
-            List<double> t = new List<double>();    //Time vector
-            for (int i = 0; i < L; ++i)
-            {
-                t.Add(i * T);
-                //System.Console.WriteLine("t[i]:" + t[i].ToString());
-            }
-            List<double> f = new List<double>();    //frequency
-            for (int i = 1; i < 6; ++i)
-            {
-                f.Add(i);
-            }
-
-            //phase
-            //int pstep = 0;
-            int count = f.Count();
-            //phase = 0:pstep:count * pstep;
-            List<double> phase = new List<double>();
-            for(int i = 0; i < count; ++i)
-            {
-                phase.Add(0);
-            }
-            //phase(2) = 0 / 180;
-            //phase(3) = 00 / 180;
-            //phase(4) = 0 / 180;
-            //phase(5) = 0 / 180;
-
-            //amplitude
-            List<double> amplitude = new List<double>();
-            for (int i = 0; i < count; ++i)
-            {
-                amplitude.Add(1);
-            }
-            for(int i = 2 - 1; i <= count - 1; ++i)
-            {
-                amplitude[i] = 0.9 * amplitude[i - 1];
-            }
-            amplitude[2-1] = 0.8;
-            amplitude[3-1] = 0.1;
-            amplitude[4-1] = 0.1;
-            amplitude[5-1] = 0.2;
-
-            List<double> y = new List<double>();
-            for (int i = 0; i < t.Count; ++i)
-            {
-                y.Add(0);
-            }
-
-            for(int j = 1 - 1; j <= t.Count - 1; ++j)
-            {
-                for(int i = 1 - 1; i <= count - 1; ++i)
-                {
-                    y[j] = y[j] + amplitude[i] * Math.Sin(2 * Math.PI * f[i] * t[j] + phase[i]);
-                    //System.Console.WriteLine("y[i]:"+ y[i].ToString());
-                }
-            }
-            for(int i = 0; i < y.Count; ++i)
-            {
-                y[i] = 1000 * y[i] + 2000;
-            }
-            return y;
-        }
-    }
-}

+ 6 - 27
WpfTest1/WpTest.csproj

@@ -46,8 +46,8 @@
       <HintPath>..\packages\ControlzEx.3.0.2.4\lib\net45\ControlzEx.dll</HintPath>
       <Private>True</Private>
     </Reference>
-    <Reference Include="ExpressionEvaluator, Version=2.0.4.0, Culture=neutral, PublicKeyToken=90d9f15d622e2348, processorArchitecture=MSIL">
-      <HintPath>..\packages\ExpressionEvaluator.2.0.4.0\lib\net40\ExpressionEvaluator.dll</HintPath>
+    <Reference Include="itextsharp, Version=5.5.13.1, Culture=neutral, PublicKeyToken=8354ae6d2174ddca, processorArchitecture=MSIL">
+      <HintPath>..\packages\iTextSharp.5.5.13.1\lib\itextsharp.dll</HintPath>
       <Private>True</Private>
     </Reference>
     <Reference Include="LitJSON, Version=0.16.0.0, Culture=neutral, processorArchitecture=MSIL">
@@ -186,15 +186,12 @@
       <SubType>Designer</SubType>
     </ApplicationDefinition>
     <Compile Include="Exceptions\SplitException.cs" />
-    <Compile Include="PatientInfoShort.xaml.cs">
-      <DependentUpon>PatientInfoShort.xaml</DependentUpon>
+    <Compile Include="SmallDialogs\AboutBox.xaml.cs">
+      <DependentUpon>AboutBox.xaml</DependentUpon>
     </Compile>
     <Compile Include="SmallDialogs\LoginWindow.xaml.cs">
       <DependentUpon>LoginWindow.xaml</DependentUpon>
     </Compile>
-    <Compile Include="SmallDialogs\RegisterCode.xaml.cs">
-      <DependentUpon>RegisterCode.xaml</DependentUpon>
-    </Compile>
     <Compile Include="SQLite\Bar1.cs" />
     <Compile Include="SQLite\Answer.cs" />
     <Compile Include="SQLite\UserSelection.cs" />
@@ -202,17 +199,10 @@
     <Compile Include="SQLite\Question.cs" />
     <Compile Include="SQLite\Run.cs" />
     <Compile Include="Toolkits\Config.cs" />
-    <Compile Include="Toolkits\CSVWriter.cs" />
     <Compile Include="Exceptions\ExpressionCalculateExpression.cs" />
     <Compile Include="Exceptions\ExpressionFindFailedException.cs" />
     <Compile Include="Exceptions\ExpressionUnformattedException.cs" />
-    <Compile Include="Toolkits\FilterFile.cs" />
-    <Compile Include="Toolkits\MeasureHandle.cs" />
-    <Compile Include="Toolkits\ReportGenerator.cs" />
-    <Compile Include="Toolkits\RPCalculate.cs" />
-    <Compile Include="Toolkits\SocketListener.cs" />
-    <Compile Include="Toolkits\WaveHandle.cs" />
-    <Compile Include="Toolkits\WaveSimulator.cs" />
+    <Compile Include="Toolkits\ReportGenerater.cs" />
     <Compile Include="SmallDialogs\AddDoctor.xaml.cs">
       <DependentUpon>AddDoctor.xaml</DependentUpon>
     </Compile>
@@ -228,9 +218,6 @@
     <Compile Include="SmallDialogs\ModifyUser.xaml.cs">
       <DependentUpon>ModifyUser.xaml</DependentUpon>
     </Compile>
-    <Compile Include="PatientInfo.xaml.cs">
-      <DependentUpon>PatientInfo.xaml</DependentUpon>
-    </Compile>
     <Compile Include="selectUser.xaml.cs">
       <DependentUpon>selectUser.xaml</DependentUpon>
     </Compile>
@@ -247,7 +234,7 @@
     <Compile Include="Toolkits\FilterDangerousCharacter.cs" />
     <Compile Include="Toolkits\OtherSmallFunction.cs" />
     <Compile Include="Toolkits\StringToPY.cs" />
-    <Page Include="PatientInfoShort.xaml">
+    <Page Include="SmallDialogs\AboutBox.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
@@ -255,10 +242,6 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="SmallDialogs\RegisterCode.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
     <Page Include="SmallDialogs\AddDoctor.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -291,10 +274,6 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="PatientInfo.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
     <Page Include="Resources\Icons.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>

+ 1 - 1
WpfTest1/packages.config

@@ -2,7 +2,7 @@
 <packages>
   <package id="Antlr" version="3.5.0.2" targetFramework="net452" />
   <package id="ControlzEx" version="3.0.2.4" targetFramework="net452" />
-  <package id="ExpressionEvaluator" version="2.0.4.0" targetFramework="net452" />
+  <package id="iTextSharp" version="5.5.13.1" targetFramework="net452" />
   <package id="LitJson" version="0.16.0" targetFramework="net452" />
   <package id="MahApps.Metro" version="1.5.0" targetFramework="net452" />
   <package id="MahApps.Metro.IconPacks" version="3.2.0" targetFramework="net452" />

+ 1 - 1
WpfTest1/selectUser.xaml

@@ -22,7 +22,7 @@
                 <DataGridTextColumn Header="最近评估时间" Binding="{Binding Path=p_last_evaluation_time}" Width="110"/>
                 <DataGridTextColumn Header="病史" Binding="{Binding Path=p_history}" Width="75"/>
                 <DataGridTextColumn Header="诊断" Binding="{Binding Path=p_diagnosis}" Width="75"/>
-                <DataGridTextColumn Header=" " Binding="{Binding Path=p_delete_flag}" Width="75"/>
+                <!--<DataGridTextColumn Header=" " Binding="{Binding Path=p_delete_flag}" Width="75"/>-->
             </DataGrid.Columns>
         </DataGrid>
         <Label x:Name="label" Content="姓名:" HorizontalAlignment="Left" Margin="23,18,0,0" VerticalAlignment="Top"/>

+ 5 - 4
WpfTest1/selectUser.xaml.cs

@@ -257,12 +257,13 @@ namespace WpfTest1
                 {
                     father.buttonModifyPatient_Click(this.father, e);
                 }
+                if (this.Name == "selectUserevaluation")
+                {
+                    father.buttonEvaluationSelectPatient_Click(this.father, e);
+                }
                 if (this.Name == "selectUserHistory")
                 {
-                    //father.buttonSelectPaitentHistory_Click(this.father, e);
-                    //father.bugFixHostory = true;
-                    //father.selectUserHistory.LoadDataGrid();
-                    //MessageBox.Show(this.father.tabControlHistory.SelectedIndex.ToString());
+                    father.buttonHistorySelectPatient_Click(this.father, e);
                 }
             }
         }