ZhuYifan 5 rokov pred
commit
4cc4137490
76 zmenil súbory, kde vykonal 8750 pridanie a 0 odobranie
  1. 63 0
      .gitattributes
  2. 242 0
      .gitignore
  3. 22 0
      WpTest.sln
  4. 6 0
      WpfTest1/App.config
  5. 22 0
      WpfTest1/App.xaml
  6. 24 0
      WpfTest1/App.xaml.cs
  7. 20 0
      WpfTest1/Exceptions/ExpressionCalculateExpression.cs
  8. 19 0
      WpfTest1/Exceptions/ExpressionFindFailedException.cs
  9. 19 0
      WpfTest1/Exceptions/ExpressionUnformattedException.cs
  10. 20 0
      WpfTest1/Exceptions/SplitException.cs
  11. 311 0
      WpfTest1/MainWindow.xaml
  12. 796 0
      WpfTest1/MainWindow.xaml.cs
  13. 57 0
      WpfTest1/PatientInfo.xaml
  14. 130 0
      WpfTest1/PatientInfo.xaml.cs
  15. 32 0
      WpfTest1/PatientInfoShort.xaml
  16. 38 0
      WpfTest1/PatientInfoShort.xaml.cs
  17. 55 0
      WpfTest1/Properties/AssemblyInfo.cs
  18. 71 0
      WpfTest1/Properties/Resources.Designer.cs
  19. 117 0
      WpfTest1/Properties/Resources.resx
  20. 30 0
      WpfTest1/Properties/Settings.Designer.cs
  21. 7 0
      WpfTest1/Properties/Settings.settings
  22. BIN
      WpfTest1/RPStandard.jpg
  23. 3 0
      WpfTest1/Resources/Entypo-license.txt
  24. BIN
      WpfTest1/Resources/Entypo.ttf
  25. 195 0
      WpfTest1/Resources/Icons.xaml
  26. 195 0
      WpfTest1/Resources/IconsNonShared.xaml
  27. BIN
      WpfTest1/Resources/RPStandard.jpg
  28. 62 0
      WpfTest1/Resources/WindowsIcons-license.txt
  29. BIN
      WpfTest1/Resources/homepage.jpg
  30. BIN
      WpfTest1/Resources/load.jpg
  31. BIN
      WpfTest1/Resources/loginpage.jpg
  32. 4 0
      WpfTest1/Resources/pubkey.xml
  33. 20 0
      WpfTest1/SQLite/Bar1.cs
  34. 15 0
      WpfTest1/SQLite/CommonWords.cs
  35. 21 0
      WpfTest1/SQLite/Expression.cs
  36. 30 0
      WpfTest1/SQLite/Patient.cs
  37. 26 0
      WpfTest1/SQLite/Record.cs
  38. 31 0
      WpfTest1/SQLite/Run.cs
  39. 191 0
      WpfTest1/SQLite/SQLiteHelper.cs
  40. 52 0
      WpfTest1/SQLite/SQLiteLogic.cs
  41. 1233 0
      WpfTest1/SQLite/SQLiteModel.cs
  42. BIN
      WpfTest1/SQLite/System.Data.SQLite.dll
  43. 18 0
      WpfTest1/SQLite/doctor.cs
  44. 35 0
      WpfTest1/SmallDialogs/AddDoctor.xaml
  45. 130 0
      WpfTest1/SmallDialogs/AddDoctor.xaml.cs
  46. 61 0
      WpfTest1/SmallDialogs/AddPatient.xaml
  47. 247 0
      WpfTest1/SmallDialogs/AddPatient.xaml.cs
  48. 31 0
      WpfTest1/SmallDialogs/LoginWindow.xaml
  49. 66 0
      WpfTest1/SmallDialogs/LoginWindow.xaml.cs
  50. 34 0
      WpfTest1/SmallDialogs/ModifyDoctor.xaml
  51. 175 0
      WpfTest1/SmallDialogs/ModifyDoctor.xaml.cs
  52. 21 0
      WpfTest1/SmallDialogs/ModifyDoctorPWD.xaml
  53. 95 0
      WpfTest1/SmallDialogs/ModifyDoctorPWD.xaml.cs
  54. 65 0
      WpfTest1/SmallDialogs/ModifyUser.xaml
  55. 282 0
      WpfTest1/SmallDialogs/ModifyUser.xaml.cs
  56. 25 0
      WpfTest1/SmallDialogs/RegisterCode.xaml
  57. 94 0
      WpfTest1/SmallDialogs/RegisterCode.xaml.cs
  58. 54 0
      WpfTest1/Toolkits/CSVWriter.cs
  59. 27 0
      WpfTest1/Toolkits/ComputeHash.cs
  60. 142 0
      WpfTest1/Toolkits/Config.cs
  61. 59 0
      WpfTest1/Toolkits/Constants.cs
  62. 18 0
      WpfTest1/Toolkits/FilterDangerousCharacter.cs
  63. 51 0
      WpfTest1/Toolkits/FilterFile.cs
  64. 50 0
      WpfTest1/Toolkits/MeasureHandle.cs
  65. 19 0
      WpfTest1/Toolkits/OtherSmallFunction.cs
  66. 220 0
      WpfTest1/Toolkits/RPCalculate.cs
  67. 1012 0
      WpfTest1/Toolkits/ReportGenerator.cs
  68. 247 0
      WpfTest1/Toolkits/SocketListener.cs
  69. 161 0
      WpfTest1/Toolkits/StringToPY.cs
  70. 238 0
      WpfTest1/Toolkits/WaveHandle.cs
  71. 81 0
      WpfTest1/Toolkits/WaveSimulator.cs
  72. 359 0
      WpfTest1/WpTest.csproj
  73. 9 0
      WpfTest1/packages.config
  74. 74 0
      WpfTest1/selectUser.xaml
  75. 368 0
      WpfTest1/selectUser.xaml.cs
  76. 3 0
      WpfTest1/测试用激活码_生产环境务必删除.txt

+ 63 - 0
.gitattributes

@@ -0,0 +1,63 @@
+###############################################################################
+# Set default behavior to automatically normalize line endings.
+###############################################################################
+* text=auto
+
+###############################################################################
+# Set default behavior for command prompt diff.
+#
+# This is need for earlier builds of msysgit that does not have it on by
+# default for csharp files.
+# Note: This is only used by command line
+###############################################################################
+#*.cs     diff=csharp
+
+###############################################################################
+# Set the merge driver for project and solution files
+#
+# Merging from the command prompt will add diff markers to the files if there
+# are conflicts (Merging from VS is not affected by the settings below, in VS
+# the diff markers are never inserted). Diff markers may cause the following 
+# file extensions to fail to load in VS. An alternative would be to treat
+# these files as binary and thus will always conflict and require user
+# intervention with every merge. To do so, just uncomment the entries below
+###############################################################################
+#*.sln       merge=binary
+#*.csproj    merge=binary
+#*.vbproj    merge=binary
+#*.vcxproj   merge=binary
+#*.vcproj    merge=binary
+#*.dbproj    merge=binary
+#*.fsproj    merge=binary
+#*.lsproj    merge=binary
+#*.wixproj   merge=binary
+#*.modelproj merge=binary
+#*.sqlproj   merge=binary
+#*.wwaproj   merge=binary
+
+###############################################################################
+# behavior for image files
+#
+# image files are treated as binary by default.
+###############################################################################
+#*.jpg   binary
+#*.png   binary
+#*.gif   binary
+
+###############################################################################
+# diff behavior for common document formats
+# 
+# Convert binary document formats to text before diffing them. This feature
+# is only available from the command line. Turn it on by uncommenting the 
+# entries below.
+###############################################################################
+#*.doc   diff=astextplain
+#*.DOC   diff=astextplain
+#*.docx  diff=astextplain
+#*.DOCX  diff=astextplain
+#*.dot   diff=astextplain
+#*.DOT   diff=astextplain
+#*.pdf   diff=astextplain
+#*.PDF   diff=astextplain
+#*.rtf   diff=astextplain
+#*.RTF   diff=astextplain

+ 242 - 0
.gitignore

@@ -0,0 +1,242 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+[Xx]64/
+[Xx]86/
+[Bb]uild/
+bld/
+[Bb]in/
+[Oo]bj/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# DNX
+project.lock.json
+artifacts/
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+
+# TODO: Un-comment the next line if you do not want to checkin
+# your web deploy settings because they may include unencrypted
+# passwords
+#*.pubxml
+*.publishproj
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignoreable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directory
+AppPackages/
+BundleArtifacts/
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# LightSwitch generated files
+GeneratedArtifacts/
+ModelManifest.xml
+
+# Paket dependency manager
+.paket/paket.exe
+
+# FAKE - F# Make
+.fake/

+ 22 - 0
WpTest.sln

@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpTest", "WpfTest1\WpTest.csproj", "{FFCACC68-37D0-4628-9B0C-A6FCA5DCCF58}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{FFCACC68-37D0-4628-9B0C-A6FCA5DCCF58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{FFCACC68-37D0-4628-9B0C-A6FCA5DCCF58}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{FFCACC68-37D0-4628-9B0C-A6FCA5DCCF58}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{FFCACC68-37D0-4628-9B0C-A6FCA5DCCF58}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

+ 6 - 0
WpfTest1/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
+    </startup>
+</configuration>

+ 22 - 0
WpfTest1/App.xaml

@@ -0,0 +1,22 @@
+<Application x:Class="WpfTest1.App"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:local="clr-namespace:WpfTest1"
+             StartupUri="MainWindow.xaml">
+    <Application.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
+                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
+                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
+                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
+                <ResourceDictionary Source="/Resources/Icons.xaml" />
+                <!-- Accent and AppTheme setting -->
+                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Steel.xaml" />
+                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
+                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedTabControl.xaml" />
+                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </Application.Resources>
+</Application>

+ 24 - 0
WpfTest1/App.xaml.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace WpfTest1
+{
+    /// <summary>
+    /// App.xaml 的交互逻辑
+    /// </summary>
+    public partial class App : Application
+    {
+        protected override void OnStartup(StartupEventArgs e)
+        {
+            SplashScreen s = new SplashScreen("Resources/load.jpg");
+            s.Show(false);
+            s.Close(new TimeSpan(0, 0, 1));
+            base.OnStartup(e);
+        }
+    }
+}

+ 20 - 0
WpfTest1/Exceptions/ExpressionCalculateExpression.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfTest1.Toolkits
+{
+    class ExpressionCalculateExpression : ApplicationException
+    {
+        public ExpressionCalculateExpression(string message) : base(message)
+        {
+        }
+
+        public ExpressionCalculateExpression(string message, Exception innerException) : base(message,innerException)
+        {
+        }
+    }
+
+}

+ 19 - 0
WpfTest1/Exceptions/ExpressionFindFailedException.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfTest1.Toolkits
+{
+    public class ExpressionFindFailedException : ApplicationException
+    {
+        public ExpressionFindFailedException(string message) : base(message)
+        {
+        }
+
+        public ExpressionFindFailedException(string message, Exception innerException) : base(message, innerException)
+        {
+        }
+    }
+}

+ 19 - 0
WpfTest1/Exceptions/ExpressionUnformattedException.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfTest1.Toolkits
+{
+    public class ExpressionUnformattedException:ApplicationException
+    {
+        public ExpressionUnformattedException(string message) : base(message)
+        {
+        }
+
+        public ExpressionUnformattedException(string message, Exception innerException) : base(message,innerException)
+        {
+        }
+    }
+}

+ 20 - 0
WpfTest1/Exceptions/SplitException.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfTest1.Exceptions
+{
+    class SplitException : ApplicationException
+    {
+        public SplitException(string message) : base(message)
+        {
+        }
+
+        public SplitException(string message, Exception innerException) : base(message,innerException)
+        {
+        }
+    }
+
+}

+ 311 - 0
WpfTest1/MainWindow.xaml

@@ -0,0 +1,311 @@
+<Controls:MetroWindow
+        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"
+        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
+        xmlns:my="clr-namespace:WpfTest1"
+        xmlns:System="clr-namespace:System;assembly=mscorlib" x:Class="WpfTest1.MainWindow"
+        mc:Ignorable="d"
+        Title="君德医疗上位机软件" Height="725" Width="1366"
+        ShowTitleBar="True"
+        ShowIconOnTitleBar="True"
+
+        WindowStartupLocation="CenterScreen"
+        WindowState = "Normal" Loaded="MetroWindow_Loaded"
+        >
+    <Controls:MetroWindow.Resources>
+
+        <!--<Style BasedOn="{StaticResource MetroTabControlItem}" TargetType="{x:Type TabItem}" x:Key="smallerHeader" >
+            <Setter Property="Controls:ControlsHelper.HeaderFontSize" Value="18"></Setter>
+            BasedOn="{StaticResource MetroTabItem}"
+        </Style>-->
+        <Style BasedOn="{StaticResource MetroTabItem}" TargetType="{x:Type TabItem}" x:Key="smallHeader" >
+            <Setter Property="Controls:ControlsHelper.HeaderFontSize" Value="20"/>
+            <!--BasedOn="{StaticResource MetroTabItem}"-->
+        </Style>
+        <Style BasedOn="{StaticResource MetroTabItem}" TargetType="{x:Type TabItem}" x:Key="smallerHeader" >
+            <Setter Property="Controls:ControlsHelper.HeaderFontSize" Value="18"/>
+            <!--BasedOn="{StaticResource MetroTabItem}"-->
+        </Style>
+        <Style BasedOn="{StaticResource MetroTabItem}" TargetType="{x:Type TabItem}" x:Key="smallestHeader" >
+            <Setter Property="Controls:ControlsHelper.HeaderFontSize" Value="13"/>
+            <!--BasedOn="{StaticResource MetroTabItem}"-->
+        </Style>
+        <Style BasedOn="{StaticResource MetroTabControl}" TargetType="{x:Type TabControl}" x:Key="whtietab" >
+            <!--<Setter Property="Background" Value="#FFFFFF"></Setter>
+            //change the "Value" to your required size-->
+        </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>
+        <Controls:WindowCommands>
+            <Button x:Name="loginedDoctorName" Content="欢迎您," />
+            <Button Click="Fast_Add_Patient_Button_Click">
+                <StackPanel Orientation="Horizontal">
+                    <Rectangle Width="20"
+                   Height="20"
+                   Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}">
+                        <Rectangle.OpacityMask>
+                            <VisualBrush Stretch="Fill" Visual="{StaticResource appbar_user_add}" />
+                        </Rectangle.OpacityMask>
+                    </Rectangle>
+                    <TextBlock Margin="4 0 0 0"
+                   VerticalAlignment="Center"
+                   Text="快速添加用户" />
+                </StackPanel>
+            </Button>
+        </Controls:WindowCommands>
+    </Controls:MetroWindow.RightWindowCommands>
+    <Grid x:Name="mainWndGrid" Background="#FFFFFF" >
+        <!-- #333945 -->
+        <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" >
+            <TabItem Header="首页" Style="{StaticResource smallHeader}" x:Uid="1000">
+                <!--Style="{StaticResource darkItem}"
+                <TabItem.Header>
+                    <Label Style="{StaticResource whiteLabel}">首页</Label>
+                </TabItem.Header>-->
+                <Grid  Margin="-1,-1,-1,-1">
+
+                    <Grid.Background>
+                        <ImageBrush ImageSource="/WpfTest1;component/Resources/homepage.jpg" />
+                    </Grid.Background>
+                   <Button x:Name="buttonHomePageAddPatient" Content="Button" HorizontalAlignment="Left" Margin="315,178,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#FFA07A" Click="buttonHomePageAddPatient_Click">
+                        <Button.ContentTemplate>
+                            <DataTemplate>
+                                <StackPanel>
+                                    <Rectangle Fill="#ffffff" Width="80" Height="80">
+                                        <Rectangle.OpacityMask>
+                                            <VisualBrush Visual="{StaticResource appbar_user_add}" Stretch="Fill" />
+                                        </Rectangle.OpacityMask>
+                                    </Rectangle>
+                                    <TextBlock Text="新建用户"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
+                                </StackPanel>
+                            </DataTemplate>
+                        </Button.ContentTemplate>
+                    </Button>
+                    <Button x:Name="buttonHomePagePatientManagent" Content="Button" HorizontalAlignment="Left" Margin="509,178,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#66CDAA" Click="buttonHomePagePatientManagent_Click">
+                        <Button.ContentTemplate>
+                            <DataTemplate>
+                                <StackPanel>
+                                    <Rectangle Fill="#ffffff" Width="80" Height="80">
+                                        <Rectangle.OpacityMask>
+                                            <VisualBrush Visual="{StaticResource appbar_folder_people}" Stretch="Fill" />
+                                        </Rectangle.OpacityMask>
+                                    </Rectangle>
+                                    <TextBlock Text="用户管理"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
+                                </StackPanel>
+                            </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.ContentTemplate>
+                            <DataTemplate>
+                                <StackPanel>
+                                    <Rectangle Fill="#ffffff" Width="80" Height="80">
+                                        <Rectangle.OpacityMask>
+                                            <VisualBrush Visual="{StaticResource appbar_medical_pulse}" Stretch="Fill" />
+                                        </Rectangle.OpacityMask>
+                                    </Rectangle>
+                                    <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.ContentTemplate>
+                            <DataTemplate>
+                                <StackPanel>
+                                    <Rectangle Fill="#ffffff" Width="80" Height="80">
+                                        <Rectangle.OpacityMask>
+                                            <VisualBrush Visual="{StaticResource appbar_journal}" Stretch="Fill" />
+                                        </Rectangle.OpacityMask>
+                                    </Rectangle>
+                                    <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.ContentTemplate>
+                            <DataTemplate>
+                                <StackPanel>
+                                    <Rectangle Fill="#ffffff" Width="80" Height="80">
+                                        <Rectangle.OpacityMask>
+                                            <VisualBrush Visual="{StaticResource appbar_newspaper}" Stretch="Fill" />
+                                        </Rectangle.OpacityMask>
+                                    </Rectangle>
+                                    <TextBlock Text="检测报告"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
+                                </StackPanel>
+                            </DataTemplate>
+                        </Button.ContentTemplate>
+                    </Button>
+                    <Button x:Name="buttonHomePageSystemSettings" Content="Button" HorizontalAlignment="Left" Margin="509,359,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#008080" Click="buttonHomePageSystemSettings_Click">
+                        <Button.ContentTemplate>
+                            <DataTemplate>
+                                <StackPanel>
+                                    <Rectangle Fill="#ffffff" Width="80" Height="80">
+                                        <Rectangle.OpacityMask>
+                                            <VisualBrush Visual="{StaticResource appbar_settings}" Stretch="Fill" />
+                                        </Rectangle.OpacityMask>
+                                    </Rectangle>
+                                    <TextBlock Text="系统设置"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
+                                </StackPanel>
+                            </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.ContentTemplate>
+                            <DataTemplate>
+                                <StackPanel>
+                                    <Rectangle Fill="#ffffff" Width="80" Height="80">
+                                        <Rectangle.OpacityMask>
+                                            <VisualBrush Visual="{StaticResource appbar_share}" Stretch="Fill" />
+                                        </Rectangle.OpacityMask>
+                                    </Rectangle>
+                                    <TextBlock Text="数据传输"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
+                                </StackPanel>
+                            </DataTemplate>
+                        </Button.ContentTemplate>
+                    </Button>
+                    <Button x:Name="buttonHomePageHelp" Content="Button" HorizontalAlignment="Left" Margin="886,359,0,0" VerticalAlignment="Top" Width="160" Height="150" Background="#008080" Click="buttonHomePageHelp_Click">
+                        <Button.ContentTemplate>
+                            <DataTemplate>
+                                <StackPanel>
+                                    <Rectangle Fill="#ffffff" Width="80" Height="80">
+                                        <Rectangle.OpacityMask>
+                                            <VisualBrush Visual="{StaticResource appbar_home_question}" Stretch="Fill" />
+                                        </Rectangle.OpacityMask>
+                                    </Rectangle>
+                                    <TextBlock Text="操作帮助"  Margin="5 10 4 4" VerticalAlignment="Center" FontSize="20" Foreground="White" />
+                                </StackPanel>
+                            </DataTemplate>
+                        </Button.ContentTemplate>
+                    </Button>
+                    <Label x:Name="labelHomepageCversion" Content="编译日期:20190726" HorizontalAlignment="Left" Margin="594,109,0,0" VerticalAlignment="Top" Foreground="White"/>
+                </Grid>
+            </TabItem>
+            <TabItem Header="用户管理" Style="{StaticResource smallHeader}" >
+                <!--<TabItem.Header>
+                    <Label Style="{StaticResource whiteLabel}">病例管理</Label>
+                </TabItem.Header>-->
+                <TabControl x:Name="tabPatientManagent" 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">
+                            <!--<Button x:Name="buttonSelectPaitent" Content="开始测量" HorizontalAlignment="Left" Margin="24,404,0,0" VerticalAlignment="Top" Width="236" Click="buttonSelectPaitent_Click" Height="38" Background="#FF3C9BB8" FontSize="18"/>-->
+                            <!--<my:selectUser Margin="-1,0,29,29"></my:selectUser>-->
+                            <my:selectUser x:Name="selectUserPatientManagent" Margin="0,0,0,0"/>
+                            <Button x:Name="buttonAddPatient" Content="添加用户" HorizontalAlignment="Left" Margin="41,531,0,0" VerticalAlignment="Top" Width="71" Height="36" FontSize="15" Click="buttonAddPatient_Click"/>
+                            <Button x:Name="buttonModifyPatient" Content="修改用户" HorizontalAlignment="Left" Margin="117,531,0,0" VerticalAlignment="Top" Width="76" Height="36" FontSize="15" Click="buttonModifyPatient_Click"/>
+                            <Button x:Name="buttonDeletePatient" Content="删除用户" HorizontalAlignment="Left" Margin="198,531,0,0" VerticalAlignment="Top" Width="80" Height="36" FontSize="15" Click="buttonDeletePatient_Click"/>
+                        </Grid>
+                    </TabItem>
+                </TabControl>
+
+            </TabItem>
+
+        <TabItem Header="系统设置" x:Name="tabitemDoctorSetting" Style="{StaticResource smallHeader}">
+                <!--<TabItem.Header>
+                    <Label Style="{StaticResource whiteLabel}">系统设置</Label>
+                </TabItem.Header>-->
+
+                <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}" >
+                        <Grid x:Name="Seeting_ExpressionManagent" Background="White" Margin="0,0,0,0"  >
+                            <DataGrid x:Name="dataGridDoctor" AutoGenerateColumns="False" IsReadOnly="True"  HorizontalAlignment="Left" Margin="299,10,0,0" VerticalAlignment="Top" Height="603" Width="1039" Loaded="LoadDoctorDataGrid" MouseDoubleClick="dataGridDoctor_MouseDoubleClick">
+                                <DataGrid.Columns>
+                                    <DataGridTextColumn Header="医生编号" Binding="{Binding id}" Width="180"/>
+                                    <DataGridTextColumn Header="登录名" Binding="{Binding name}" Width="150"/>
+                                    <DataGridTextColumn Header="联系电话" Binding="{Binding phone_number}" Width="180"/>
+                                    <DataGridTextColumn Header="是否为主任账户" Binding="{Binding director_flag}" Width="120"/>
+                                </DataGrid.Columns>
+                            </DataGrid>
+                            <Button x:Name="buttonAddDoctor" FontSize="18" Content="新增医师" HorizontalAlignment="Left" Margin="26,40,0,0" VerticalAlignment="Top" Width="236" Height="38" Click="buttonAddDoctor_Click"/>
+                            <Button x:Name="buttonChangeDoctor" FontSize="18" Content="修改医师信息" HorizontalAlignment="Left" Margin="26,98,0,0" VerticalAlignment="Top" Width="236" Height="38" Click="buttonChangeDoctor_Click"/>
+                            <Button x:Name="buttonDeleteDoctor" FontSize="18" Content="删除医师" HorizontalAlignment="Left" Margin="26,210,0,0" VerticalAlignment="Top" Width="236" Height="38" Click="buttonDeleteDoctor_Click"/>
+                            <Button x:Name="buttonFindDoctor" Content="查找" FontSize="18" HorizontalAlignment="Left" Margin="170,328,0,0" VerticalAlignment="Top" Width="92" Height="36" Click="buttonFindDoctor_Click"/>
+                            <TextBox x:Name="textBoxFindDoctor" HorizontalAlignment="Left"  FontSize="18" Height="36" Margin="126,287,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="136"/>
+                            <Label x:Name="label5" Content="登陆名:" HorizontalAlignment="Left" Margin="26,287,0,0" VerticalAlignment="Top" Height="36" Width="95" FontSize="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}" >
+                        <Grid>
+                            <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"/>
+                                </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"/>
+                                    <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"/>
+                                    <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>
+                    </TabItem>
+                </TabControl>
+            </TabItem>
+
+
+        </TabControl>
+
+
+    </Grid>
+</Controls:MetroWindow>

+ 796 - 0
WpfTest1/MainWindow.xaml.cs

@@ -0,0 +1,796 @@
+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.IO;
+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 MahApps.Metro.Controls;
+using System.Windows.Threading;
+using MahApps.Metro.Controls.Dialogs;
+using System.Data;
+using WpfTest1.SQLite;
+using WpfTest1.Toolkits;
+using Ciloci.Flee;
+using System.Threading;
+using System.Timers;
+using System.ComponentModel;
+using System.IO.Ports;
+using System.Collections.Concurrent;
+using Microsoft.Win32;
+using System.Data.SQLite;
+using System.Collections;
+
+namespace WpfTest1
+{
+    /// <summary>
+    /// MainWindow.xaml 的交互逻辑
+    /// </summary>
+    public partial class MainWindow : MetroWindow
+    {
+        #region 系统基本参数
+        System.Data.SQLite.SQLiteDataAdapter daHistoryRecord;   //选择记录页面查询记录条目的数据集容器
+        public doctor loginDoctor = null;                       //所登陆的医师
+        DataSet ds;                                             //其他界面的DataSet
+        System.Data.SQLite.SQLiteDataAdapter da;                //其他界面的DataAdapter
+        //double highBp;                                        //BP界面高压
+        //double lowBp;                                         //BP界面低压
+        DateTime lastSettingLogin;                              //上一次在系统设置界面登陆的时间
+        public Dictionary<string, double> expressions = new Dictionary<string, double>();//全部的表达式暂存器
+        public Dictionary<string, string> expressions_position = new Dictionary<string, string>();//全部的表达式所属类别暂存器
+        public List<Dictionary<string, double>> expressionList = new List<Dictionary<string, double>>();//全表达式对应所有波的特征值计算(相当耗时请勿乱用)
+        public List<double> generalExpressionResults = new List<double>(); //总表达式的计算结果
+        public double generalExpressionTemp;//总表达式的计算结果临时存储变量
+        //public Toolkits.EigenValueCalculator evc;  //计算特征值的类
+        public Toolkits.Config cfg;                //从数据库取配置的类
+        RPCalculate rpReport;         //RP单元计算模块,开始不要初始化,用的时候再初始化
+        System.Timers.Timer timerUpdateWave = new System.Timers.Timer(5);   //一个每个2ms更新一个数据波形点的计时器
+                                                                            //List<double> dataSource = Toolkits.WaveSimulator.getSimulatedWave();  //20180224数据模拟生成
+        int measure_time_limit = 0; //PPG模块自动计时停止的阈值
+        ConcurrentQueue<string> measureMessage = new ConcurrentQueue<string>();       //采集时控制自动停止的消息队列
+        ConcurrentQueue<string> measureTimeLeft = new ConcurrentQueue<string>();       //采集时倒计时的消息队列
+        SerialPort serialPortUSBPPG;
+        SerialPort serialPortUSBPPGBackup;
+        SerialPort serialPortUSBPPGTest;
+        ConcurrentQueue<double> dataSourceLeftRed = new ConcurrentQueue<double>();
+        ConcurrentQueue<double> dataSourceLeftInfrared = new ConcurrentQueue<double>();
+        ConcurrentQueue<double> dataSourceRightRed = new ConcurrentQueue<double>();
+        ConcurrentQueue<double> dataSourceRightInfrared = new ConcurrentQueue<double>();
+        int measureStartIndex = 0;
+        //BackgroundWorker aWorkerPlusOne = new BackgroundWorker();
+        BackgroundWorker aWorkerInUSBMeasure = new BackgroundWorker();
+        BackgroundWorker bg_calculate_eigen_value = new BackgroundWorker();
+        BackgroundWorker bg_final_report_calculate = new BackgroundWorker();
+        ///SmallDialogs.EigenValueList evl;
+        //SmallDialogs.WaitNotify wn;
+        ConcurrentQueue<string> canditate_searial_port = new ConcurrentQueue<string>(); //判断一个串口是否为本软件使用的端口
+        #endregion
+
+        #region 优化系统效率参数
+        //首先是PPG部分的历史记录部分
+        //左手红光
+        List<double> historyLeftRed0Q = new List<double>();
+        List<double> historyLeftRed1D = new List<double>();
+        List<double> historyLeftRed2D = new List<double>();
+        List<double> historyLeftRed3D = new List<double>();
+        List<double> historyLeftRed4D = new List<double>();
+        //左手红外光
+        List<double> historyLeftInfrared0Q = new List<double>();
+        List<double> historyLeftInfrared1D = new List<double>();
+        List<double> historyLeftInfrared2D = new List<double>();
+        List<double> historyLeftInfrared3D = new List<double>();
+        List<double> historyLeftInfrared4D = new List<double>();
+        //右手红光
+        List<double> historyRightRed0Q = new List<double>();
+        List<double> historyRightRed1D = new List<double>();
+        List<double> historyRightRed2D = new List<double>();
+        List<double> historyRightRed3D = new List<double>();
+        List<double> historyRightRed4D = new List<double>();
+        //右手红外光
+        List<double> historyRightInfrared0Q = new List<double>();
+        List<double> historyRightInfrared1D = new List<double>();
+        List<double> historyRightInfrared2D = new List<double>();
+        List<double> historyRightInfrared3D = new List<double>();
+        List<double> historyRightInfrared4D = new List<double>();
+        //RP波形部分
+        List<int> historyRP = new List<int>();
+        //然后是PPG部分的测量时部分
+        //滤波器的参数,分别是一阶低通一阶高通,二阶低通和二阶高通
+        List<double>[] filter = new List<double>[4];
+        //左手红光,注意:0Q中0是原始波形,每+1层就用一个过滤器过一下,最终那个用于显示
+        List<double>[] measureLeftRed0Q = new List<double>[4 + 1];
+        List<double> measureLeftRed1D = new List<double>();
+        List<double> measureLeftRed2D = new List<double>();
+        List<double> measureLeftRed3D = new List<double>();
+        List<double> measureLeftRed4D = new List<double>();
+        //左手红外光
+        List<double>[] measureLeftInfrared0Q = new List<double>[4 + 1];
+        List<double> measureLeftInfrared1D = new List<double>();
+        List<double> measureLeftInfrared2D = new List<double>();
+        List<double> measureLeftInfrared3D = new List<double>();
+        List<double> measureLeftInfrared4D = new List<double>();
+        //右手红光
+        List<double>[] measureRightRed0Q = new List<double>[4 + 1];
+        List<double> measureRightRed1D = new List<double>();
+        List<double> measureRightRed2D = new List<double>();
+        List<double> measureRightRed3D = new List<double>();
+        List<double> measureRightRed4D = new List<double>();
+        //右手红外光
+        List<double>[] measureRightInfrared0Q = new List<double>[4 + 1];
+        List<double> measureRightInfrared1D = new List<double>();
+        List<double> measureRightInfrared2D = new List<double>();
+        List<double> measureRightInfrared3D = new List<double>();
+        List<double> measureRightInfrared4D = new List<double>();
+
+        //RP波形部分
+        List<int> measure = new List<int>();
+        //画线的颜色设定
+        System.Drawing.Color lineColorRed = System.Drawing.Color.Wheat;
+        System.Drawing.Color lineColorInfrared = System.Drawing.Color.White;
+        System.Drawing.Color lineColorBlack = System.Drawing.Color.Black;
+
+        //临时补丁
+        //1.针对历史记录大类双击两个dataGrid会导致TabItem回弹一页的问题,加一个标签
+        public bool bugFixHostory = false;
+        #endregion
+
+        public MainWindow()
+        {
+            InitializeComponent();
+            //加载配置
+            cfg = new Toolkits.Config();
+            //绑定三个selectUser的父类
+            //selectUserMeasure.setMainWindow(this);
+            selectUserPatientManagent.setMainWindow(this);
+            //selectUserHistory.setMainWindow(this);
+
+        }
+
+        #region 初始化与系统调用部分
+
+        //加载表达式到内存
+        public void LoadExpressionToMemory()
+        {
+            expressions.Clear();
+            expressions_position.Clear();
+            SQLite.SQLiteModel.GetAllExpressionContent(expressions, expressions_position, loginDoctor.privilege_flag);
+        }
+
+        //初始化全部组件后需要先输入医生密码才能进入
+        //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();
+            if(loginDoctor == null)
+            {
+                this.Close();
+            }
+            /*
+            //之后填充程序高级设置的信息
+            //平滑点设置
+            labelOrganizationName.Content = cfg.organization_name;
+            textBoxOriginalSmoothPoints.Text = cfg.original_smooth_points.ToString();
+            textBoxOriginalSmoothTimes.Text = cfg.original_smooth_times.ToString();
+            textBoxDeriveSmoothPoints.Text = cfg.drive_smooth_points.ToString();
+            textBoxDeriveSmoothTimes.Text = cfg.drive_smooth_times.ToString();
+            buttonModifySmoothPoints.IsEnabled = false;
+            if(cfg.filter_when_saving == 1)
+            {
+                checkBoxFilterWhenSaving.IsChecked = true;
+            }
+            //填充医师界面的设置信息
+            if(cfg.bp_unit_hhmg == 1)
+            {
+                radioButtonBP_mmhg.IsChecked = true;
+            }
+            else
+            {
+                radioButtonBP_kpa.IsChecked = true;
+            }
+            //自动诊断公式
+            textBoxgeneralExpression.Text = cfg.general_expression;
+            textBoxgeneralExpressionSegementName0.Text = cfg.segement_name.Split('$').ElementAt(0);
+            textBoxgeneralExpressionSegementName1.Text = cfg.segement_name.Split('$').ElementAt(1);
+            textBoxgeneralExpressionSegementName2.Text = cfg.segement_name.Split('$').ElementAt(2);
+            textBoxgeneralExpressionSegementName3.Text = cfg.segement_name.Split('$').ElementAt(3);
+            textBoxgeneralExpressionSegementName4.Text = cfg.segement_name.Split('$').ElementAt(4);
+            textBoxgeneralExpressionSegementThrehold0.Text = cfg.segement_threhold.Split('$').ElementAt(0);
+            textBoxgeneralExpressionSegementThrehold1.Text = cfg.segement_threhold.Split('$').ElementAt(1);
+            textBoxgeneralExpressionSegementThrehold2.Text = cfg.segement_threhold.Split('$').ElementAt(2);
+            textBoxgeneralExpressionSegementThrehold3.Text = cfg.segement_threhold.Split('$').ElementAt(3);
+            //诊断报告参数设置
+            textboxReportFigureName.Text = cfg.report_figure_name;
+
+            //为PPG波形采集进行注册
+            timerUpdateWave.Elapsed += new System.Timers.ElapsedEventHandler(updateWavePoints);
+            aWorkerInUSBMeasure.WorkerSupportsCancellation = true;
+            aWorkerInUSBMeasure.DoWork += new DoWorkEventHandler(this.startMeasure_RunWorkerDowork);
+            //为后台计算波形结果及公式进行注册
+            bg_calculate_eigen_value.WorkerReportsProgress = false;
+            bg_calculate_eigen_value.RunWorkerCompleted += new RunWorkerCompletedEventHandler(eigenvalue_calculation_process);
+            bg_final_report_calculate.WorkerReportsProgress = false;
+            bg_final_report_calculate.RunWorkerCompleted += new RunWorkerCompletedEventHandler(do_work_bg_final_report_calculate);
+            //aWorkerPlusOne.WorkerSupportsCancellation = true;
+            //aWorkerPlusOne.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.bwPlusOne_RunWorkerCompleted);
+            for (int i = 0; i < measureLeftRed0Q.Length; ++i)
+            {
+                measureLeftRed0Q[i] = new List<double>();
+            }
+            for (int i = 0; i < measureLeftInfrared0Q.Length; ++i)
+            {
+                measureLeftInfrared0Q[i] = new List<double>();
+            }
+            for (int i = 0; i < measureRightRed0Q.Length; ++i)
+            {
+                measureRightRed0Q[i] = new List<double>();
+            }
+            for (int i = 0; i < measureRightInfrared0Q.Length; ++i)
+            {
+                measureRightInfrared0Q[i] = new List<double>();
+            }
+
+            //为测量界面的滚动条设置波形图
+            //measureWaveLeftOriginal.SetScrollBar(scrollBarMeasureLeftRed);
+            //measureWaveRightOriginal.SetScrollBar(scrollBarMeasureRightRed);
+            //measureWaveLeftInfraredOriginal.SetScrollBar(scrollBarMeasureLeftInfrared);
+            //measureWaveRightInfraredOriginal.SetScrollBar(scrollBarMeasureRightInfrared);
+            //*/
+            //显示医生姓名
+            if (loginDoctor != null)
+            {
+                loginedDoctorName.Content = "欢迎您, " + loginDoctor.name;
+                return;
+            }
+        }
+        #endregion
+
+        #region 首页功能
+
+        //标题栏快速添加病例的接口
+        private void Fast_Add_Patient_Button_Click(object sender, RoutedEventArgs e)
+        {
+            buttonAddPatient_Click(this, e);
+        }
+
+        //首页--新建用户
+        private void buttonHomePageAddPatient_Click(object sender, RoutedEventArgs e)
+        {
+            buttonAddPatient_Click(this, e);
+        }
+
+        //首页--用户管理
+        private void buttonHomePagePatientManagent_Click(object sender, RoutedEventArgs e)
+        {
+            tabControlGeneral.SelectedIndex = 2;
+        }
+
+        //首页--检测操作
+        private void buttonHomePageMeasureFunction_Click(object sender, RoutedEventArgs e)
+        {
+            tabControlGeneral.SelectedIndex = 1;
+        }
+
+        //首页--历史记录
+        private void buttonHomePageHistoryRecord_Click(object sender, RoutedEventArgs e)
+        {
+            tabControlGeneral.SelectedIndex = 3;
+        }
+
+        //首页--检测报告
+        private void buttonHomePageReport_Click(object sender, RoutedEventArgs e)
+        {
+            //buttonResultOpenDirHistory_Click(this, e);
+        }
+
+        //首页--系统设置
+        private void buttonHomePageSystemSettings_Click(object sender, RoutedEventArgs e)
+        {
+            tabControlGeneral.SelectedIndex = 4;
+        }
+       
+        //首页--操作帮助
+        private void buttonHomePageHelp_Click(object sender, RoutedEventArgs e)
+        {
+            System.Diagnostics.Process.Start("https://www.baidu.com");
+        }
+
+
+        #endregion
+
+        #region 病例管理
+        //病例管理
+        //病例管理--病例管理
+
+        #region 病例管理--添加病例
+        //添加病例
+        private void buttonAddPatient_Click(object sender, RoutedEventArgs e)
+        {
+            AddPatient a_new_one = new AddPatient(this);
+            a_new_one.Show();
+            //selectUserPatientManagent.LoadDataGrid();
+        }
+        #endregion  
+
+        #region 病例管理--修改病例
+        //修改病例
+        public void buttonModifyPatient_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                var target = (DataRowView)this.selectUserPatientManagent.dataGrid.SelectedItem;
+                //MessageBox.Show(target["id"].ToString());
+                ModifyUser modify_one = new ModifyUser(this, target["id"].ToString());
+                modify_one.Show();
+            }
+            catch(Exception err)
+            {
+                this.ShowMessageAsync("警告","请选择一个病例进行修改\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace );
+                //MessageBox.Show("请选择一个病例进行修改\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace,"警告");
+            }
+            
+        }
+        #endregion
+
+        #region 病例管理--删除病例
+        //删除病例
+        private async void buttonDeletePatient_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                var target = (DataRowView)this.selectUserPatientManagent.dataGrid.SelectedItem;
+                if(target == null)
+                {
+                    await this.ShowMessageAsync("提示", "请选择一个病例进行删除");
+                    return;
+                }
+                MessageDialogResult clickresult = await this.ShowMessageAsync("提示", "确认删除该病例?", MessageDialogStyle.AffirmativeAndNegative);
+                if (clickresult == MessageDialogResult.Affirmative)//确认
+                {
+                    int status = SQLite.SQLiteModel.DeletePatientItem(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);
+            }
+            
+
+            selectUserPatientManagent.LoadDataGrid();
+            
+        }
+        #endregion
+        #endregion
+
+        #region 系统设置
+        //系统设置
+        //进入系统设置前主任级别用户的身份验证
+        async private void tabControlGeneral_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            //System.Console.WriteLine(Convert.ToString(tabControlGeneral.SelectedIndex));
+            if (e.Source is TabControl)
+            {
+                //系统设置页验证
+                if (tabitemDoctorSetting.IsSelected)
+                {
+                    DateTime now = DateTime.Now;
+                    if (lastSettingLogin != null && (now - lastSettingLogin).Minutes <= 10)
+                    {
+                        //如果上次有登陆而且登陆时间在10分钟以内,则免登陆
+                        return;
+                    }
+
+                    bool dialogLoop = true;
+                    bool wrongPassword = false;
+                    string description;
+                    int x = 1;
+                    while (dialogLoop)
+                    {
+                        x++;
+                        if (wrongPassword)
+                        {
+                            description = "用户名或密码不正确,请重新输入账号和密码进入系统设置";
+                        }
+                        else
+                        {
+                            description = "请输入账号和密码进入系统设置";
+                        }
+                        LoginDialogData loginDialogData;
+                        loginDialogData = await this.ShowLoginAsync
+                            (
+                                "输入科室主任级别账号密码以继续..." + Convert.ToString(x),
+                                description,
+                                new LoginDialogSettings
+                                {
+                                    ColorScheme = MetroDialogColorScheme.Accented,
+                                    UsernameWatermark = "用户名",
+                                    PasswordWatermark = "密码",
+                                    NegativeButtonVisibility = Visibility.Visible
+                                }
+                            );
+                        if (loginDialogData == null)
+                        {
+                            dialogLoop = false;
+                            tabControlGeneral.SelectedIndex = 0;
+                            return;
+                            //break;
+
+                        }
+                        //调用数据库验证
+                        string doctorName = loginDialogData.Username;
+                        string doctorPassword = loginDialogData.Password;
+                        string doctorPWD = Toolkits.ComputeHash.GetMD5(doctorPassword);
+                        doctor loginDirector = SQLiteModel.directorLogin(doctorName, doctorPWD);
+                        if (loginDirector == null)
+                        {
+                            //MessageBox.Show("admin");
+                            wrongPassword = true;
+                            dialogLoop = true;
+                        }
+                        else
+                        {
+                            lastSettingLogin = DateTime.Now;
+                            dialogLoop = false;
+                            return;
+                            //break;
+                        }
+                    }
+                }
+                //高级系统设置验证页
+                //if (tabitemOEMSetting.IsSelected)
+            }
+        }
+
+        private void tabControlSystemSetting_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            lastSettingLogin = DateTime.Now;
+        }
+
+        #region 医师管理
+        //系统设置--医师管理
+        private void LoadDoctorDataGrid(object sender, RoutedEventArgs e)
+        {
+            LoadDoctorDataGrid();
+        }
+        public void LoadDoctorDataGrid()
+        {
+            //连接字符串
+            string Connstr = Toolkits.Constants.Connstr;
+            //连接对象
+            System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection(Connstr);
+            //Sql语句
+            string selectCmd = "SELECT * FROM Doctor WHERE delete_flag=0 AND name != '" + Constants.adminUsername + "' LIMIT 100";
+            con.Open();
+            da = new System.Data.SQLite.SQLiteDataAdapter(selectCmd, con);
+            ds = new DataSet();
+            da.Fill(ds);
+
+            dataGridDoctor.ItemsSource = ds.Tables[0].DefaultView;
+            con.Close();
+        }
+
+        //新增医师
+        private void buttonAddDoctor_Click(object sender, RoutedEventArgs e)
+        {
+            AddDoctor a_new_doctor = new AddDoctor(this);
+            a_new_doctor.Show();
+        }
+        //修改医师
+        private void buttonChangeDoctor_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                var target = (DataRowView)this.dataGridDoctor.SelectedItem;
+                //MessageBox.Show(target["id"].ToString());
+                ModifyDoctor modify_one = new ModifyDoctor(this, target["id"].ToString());
+                modify_one.Show();
+            }
+            catch (Exception err)
+            {
+                this.ShowMessageAsync("警告", "请选择一个医生进行修改\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace);
+            }
+        }
+        //双击表格触发修改医师的方法
+        private void dataGridDoctor_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            buttonChangeDoctor_Click(this, e);
+        }
+        //修改医师密码
+        private void buttonChangeDoctorPWD_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                var target = (DataRowView)this.dataGridDoctor.SelectedItem;
+                //MessageBox.Show(target["id"].ToString());
+                ModifyDoctorPWD modify_one = new ModifyDoctorPWD(this, target["id"].ToString());
+                modify_one.Show();
+            }
+            catch (Exception err)
+            {
+                this.ShowMessageAsync("警告", "请选择一个医生进行修改\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace);
+            }
+        }
+        //删除医师
+        private async void buttonDeleteDoctor_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                var target = (DataRowView)this.dataGridDoctor.SelectedItem;
+                if (target == null)
+                {
+                    await this.ShowMessageAsync("提示", "请选择一个医生进行删除");
+                    return;
+                }
+                MessageDialogResult clickresult = await this.ShowMessageAsync("提示", "确认删除该医生信息吗?", MessageDialogStyle.AffirmativeAndNegative);
+                if (clickresult == MessageDialogResult.Affirmative)//确认
+                {
+                    int status = SQLite.SQLiteModel.DeleteDoctorItem(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);
+            }
+            LoadDoctorDataGrid();
+        }
+        //筛选医师
+        private void buttonFindDoctor_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                //连接字符串
+                string Connstr = "Data Source=" + System.Environment.CurrentDirectory + "\\Junde.db3"; ;
+                //连接对象
+                System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection(Connstr);
+                string namelike = textBoxFindDoctor.Text;
+                //MessageBox.Show(namelike);
+                //Sql语句
+                string selectCmd = "SELECT * FROM Doctor WHERE NAME LIKE \'%" + namelike + "%\' AND delete_flag=0  LIMIT 100";
+                con.Open();
+                System.Data.SQLite.SQLiteDataAdapter da_1 = new System.Data.SQLite.SQLiteDataAdapter(selectCmd, con);
+                DataSet ds_1 = new DataSet();
+                da_1.Fill(ds_1);
+
+                dataGridDoctor.ItemsSource = ds_1.Tables[0].DefaultView;
+                con.Close();
+            }
+            catch (Exception err)
+            {
+                MessageBox.Show("数据库错误.\r\n调试信息:" + err.Message, "错误");
+            }
+        }
+        #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);
+
+            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 软件激活管理
+        //重新激活程序
+        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);
+            }
+            catch (Exception err)
+            {
+                this.ShowMessageAsync("错误", "数据库读写失败,调试信息:\r\n" + err.StackTrace);
+            }
+
+            cfg.refresh();
+            this.ShowMessageAsync("提示", "修改成功");
+        }
+
+        /// <summary>
+        /// buttonOptmizeDatabase_Click:点击优化数据库的方法,把已经被删除的数据进行彻底清除
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonOptmizeDatabase_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                //获取标记为删除的病人记录
+                List<string> ids_to_be_deleted = SQLite.SQLiteModel.getDeletedPatients();
+                //确实删除这些病人记录
+                SQLite.SQLiteModel.realDeleteRecords();
+                //确实删除这些病人所含有的检查记录
+                foreach(string each_line in ids_to_be_deleted)
+                {
+                    SQLite.SQLiteModel.DeleteRecordItem(each_line);
+                }
+                MessageBox.Show("操作完成", "信息");
+            }
+            catch (Exception)
+            {
+                MessageBox.Show("数据库异常", "错误");
+            }
+        }
+
+        /// <summary>
+        /// buttonDeleteAllPdfReport_Click:点击删除某一目录下所有文件的方法
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void buttonDeleteFiles_Click(object sender, RoutedEventArgs e)
+        {
+            string target_path = "";
+            if (((Button)sender).Equals(buttonDeleteAllPdfReport))
+            {
+                target_path = Constants.reportPath;
+            }else if (((Button)sender).Equals(buttonDeleteAllCSVWave))
+            {
+                target_path = Constants.exportWavePath;
+            }
+            try
+            {
+                DirectoryInfo dir = new DirectoryInfo(target_path);
+                FileSystemInfo[] fileinfo = dir.GetFileSystemInfos();  //返回目录中所有文件和子目录
+                foreach (FileSystemInfo i in fileinfo)
+                {
+                    if (i is DirectoryInfo)            //判断是否文件夹
+                    {
+                        DirectoryInfo subdir = new DirectoryInfo(i.FullName);
+                        subdir.Delete(true);          //删除子目录和文件
+                    }
+                    else
+                    {
+                        File.Delete(i.FullName);      //删除指定文件
+                    }
+                }
+                MessageBox.Show("操作完成", "信息");
+            }
+            catch (Exception)
+            {
+                MessageBox.Show("文件系统异常", "错误");
+            }
+        }
+
+        #endregion
+
+        #endregion
+
+    }
+
+
+}

+ 57 - 0
WpfTest1/PatientInfo.xaml

@@ -0,0 +1,57 @@
+<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>

+ 130 - 0
WpfTest1/PatientInfo.xaml.cs

@@ -0,0 +1,130 @@
+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
+            {
+                ;
+            }
+        }
+    }
+}

+ 32 - 0
WpfTest1/PatientInfoShort.xaml

@@ -0,0 +1,32 @@
+<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>

+ 38 - 0
WpfTest1/PatientInfoShort.xaml.cs

@@ -0,0 +1,38 @@
+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;
+        }
+    }
+}

+ 55 - 0
WpfTest1/Properties/AssemblyInfo.cs

@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("WpfTest1")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("WpfTest1")]
+[assembly: AssemblyCopyright("Copyright ©  2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+//将 ComVisible 设置为 false 将使此程序集中的类型
+//对 COM 组件不可见。  如果需要从 COM 访问此程序集中的类型,
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+//若要开始生成可本地化的应用程序,请
+//<PropertyGroup> 中的 .csproj 文件中
+//例如,如果您在源文件中使用的是美国英语,
+//使用的是美国英语,请将 <UICulture> 设置为 en-US。  然后取消
+//对以下 NeutralResourceLanguage 特性的注释。  更新
+//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+    ResourceDictionaryLocation.None, //主题特定资源词典所处位置
+                                     //(当资源未在页面
+                                     //或应用程序资源字典中找到时使用)
+    ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
+                                              //(当资源未在页面
+                                              //、应用程序或任何主题专用资源字典中找到时使用)
+)]
+
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 71 - 0
WpfTest1/Properties/Resources.Designer.cs

@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本: 4.0.30319.42000
+//
+//     对此文件的更改可能导致不正确的行为,如果
+//     重新生成代码,则所做更改将丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace WpfTest1.Properties
+{
+
+
+    /// <summary>
+    ///   强类型资源类,用于查找本地化字符串等。
+    /// </summary>
+    // 此类是由 StronglyTypedResourceBuilder
+    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+    // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // (以 /str 作为命令选项),或重新生成 VS 项目。
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resources
+    {
+
+        private static global::System.Resources.ResourceManager resourceMan;
+
+        private static global::System.Globalization.CultureInfo resourceCulture;
+
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resources()
+        {
+        }
+
+        /// <summary>
+        ///   返回此类使用的缓存 ResourceManager 实例。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager
+        {
+            get
+            {
+                if ((resourceMan == null))
+                {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WpfTest1.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+
+        /// <summary>
+        ///   覆盖当前线程的 CurrentUICulture 属性
+        ///   使用此强类型的资源类的资源查找。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture
+        {
+            get
+            {
+                return resourceCulture;
+            }
+            set
+            {
+                resourceCulture = value;
+            }
+        }
+    }
+}

+ 117 - 0
WpfTest1/Properties/Resources.resx

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 30 - 0
WpfTest1/Properties/Settings.Designer.cs

@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace WpfTest1.Properties
+{
+
+
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+    {
+
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+        public static Settings Default
+        {
+            get
+            {
+                return defaultInstance;
+            }
+        }
+    }
+}

+ 7 - 0
WpfTest1/Properties/Settings.settings

@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>

BIN
WpfTest1/RPStandard.jpg


+ 3 - 0
WpfTest1/Resources/Entypo-license.txt

@@ -0,0 +1,3 @@
+Entypo (http://www.entypo.com/) is created by Daniel Bruce and released under the Creative Commons, Share Alike/Attribution license.
+
+http://creativecommons.org/licenses/by-sa/3.0/

BIN
WpfTest1/Resources/Entypo.ttf


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 195 - 0
WpfTest1/Resources/Icons.xaml


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 195 - 0
WpfTest1/Resources/IconsNonShared.xaml


BIN
WpfTest1/Resources/RPStandard.jpg


+ 62 - 0
WpfTest1/Resources/WindowsIcons-license.txt

@@ -0,0 +1,62 @@
+# License
+
+Please carefully understand the license and download the latest icons at ModernUIIcons.com.
+
+## Understand Your Rights
+No Attribution and No Derived Works
+http://creativecommons.org/licenses/by-nd/3.0/ *
+
+- If your project is open source include this license file in the source.
+- Nothing is needed in the front facing project (UNLESS you
+  are using any of the icons listed below in the attribution section).
+- Commercial use is not only allowed but encouraged. If it is an icon
+  in the attribution list below, you still need to attribute those!
+- Do not distribute the entire package (I've allowed this dozens of
+  times for open source projects, but email me first).
+
+## Creator
+- Austin Andrews (@templarian)
+
+## Contributor**
+- Jay Zawrotny (@JayZawrotny)
+  - A Bunch
+- Oren Nachman
+  - appbar.chevron.down
+  - appbar.chevron.up
+  - appbar.chevron.left
+  - appbar.chevron.right
+
+## Derived Works
+- Alex Peattie
+  - Social: http://www.alexpeattie.com/projects/justvector_icons/
+
+## Attribution***
+- Kris Vandermotten (@kvandermotten)
+  - appbar.medical.pulse
+- Constantin Kichinsky (@kichinsky)
+  - appbar.currency.rubles
+  - appbar.currency.grivna
+- Massimo Savazzi (@msavazzi)
+  - List of missing exported icons
+- Proletkult Graphik, from The Noun Project
+  - appbar.draw.pen (inspired)
+- Olivier Guin, from The Noun Project
+  - appbar.draw.marker
+- Gibran Bisio, from The Noun Project
+  - appbar.draw.bucket
+Andrew Forrester, from The Noun Project
+  - appbar.fingerprint
+
+* The license is for attribution, but this is not required.
+** Developers and designers that emailed Templarian the source .design icons to be added into the package. PNGs also accepted, but may take longer to be added.
+*** Icons I've copied so closely you want to attribute them and are also under the CC license.
+
+Contact
+- http://templarian.com/
+- admin[@]templarian[.]com
+
+* Does not apply to copyrighted logos
+- Skype
+- Facebook
+- Twitter
+- etc...

BIN
WpfTest1/Resources/homepage.jpg


BIN
WpfTest1/Resources/load.jpg


BIN
WpfTest1/Resources/loginpage.jpg


+ 4 - 0
WpfTest1/Resources/pubkey.xml

@@ -0,0 +1,4 @@
+<RSAKeyValue>
+  <Modulus>xurCz3Zxeb0AqCtkMqlVYdWDlCuVyDp7HoKlSHeyhpsUWAu6hcS8gnaOofe9jQb7C7V1GszlY8QuN8GRUusHuXOOvQq3H6ZRNQ+OEynz/g3caD6aqbbzi0J179EcUiddocuSRxveQVJ8F6SlT1us2+lEumrWej9imgsU3+NVDTE=</Modulus>
+  <Exponent>AQAB</Exponent>
+</RSAKeyValue>

+ 20 - 0
WpfTest1/SQLite/Bar1.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+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 System.Threading;
+
+
+namespace WpfTest1
+{
+    public delegate void SetProgressValueEventHandler(int pos);//设置进度值的委托 定义参数列表
+}

+ 15 - 0
WpfTest1/SQLite/CommonWords.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfTest1.SQLite
+{
+    public class CommonWords
+    {
+        public int id { get; set; }
+        public string content { get; set; }
+        public string describe { get; set; }
+    }
+}

+ 21 - 0
WpfTest1/SQLite/Expression.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfTest1.SQLite
+{
+    public class Expression
+    {
+        public int id { get; set; }
+        public string expression_content { get; set; }
+        public string expression_description { get; set; }
+        public double range { get; set; }
+        public int isRelative { get; set; }
+        public double upBound { get; set; }
+        public double downBound { get; set; }
+        public int isCache { get; set; }
+        public string position { get; set; }
+    }
+}

+ 30 - 0
WpfTest1/SQLite/Patient.cs

@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection.Emit;
+using System.Text;
+namespace WpfTest1.SQLite
+{
+    public class Patient
+    {
+        public int id { get; set; }
+        public string record_id { get; set; } //注意这里的record指的是病例号不是记录的record
+        public string idNum { get; set; }
+        public string name { get; set; }
+        public double height { get; set; }
+        public double weight { get; set; }
+        public int base_heartrate { get; set; }
+        public int pregnancy_times { get; set; }
+        public int birth_times { get; set; }
+        public DateTime pregnancy_date { get; set; }
+        public string mobile { get; set; }
+        public string profession { get; set; }
+        public string address { get; set; }
+        public string category { get; set; }
+        public string group_1 { get; set; }
+        public string firstLetterPY { get; set; }
+        public string description { get; set; }
+        public DateTime lastRecordDate { get; set; }
+        public Boolean delete_flag { get; set; }
+    }
+}

+ 26 - 0
WpfTest1/SQLite/Record.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection.Emit;
+using System.Text;
+
+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; }
+    }
+}

+ 31 - 0
WpfTest1/SQLite/Run.cs

@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace WpfTest1.SQLite
+{
+    class Run
+    {
+        public void RunProgress(int range, SetProgressValueEventHandler setProgressBar)
+        {
+            try
+            {
+                for (int i = 0; i < range; i++)
+                {
+                    Thread.Sleep(100);
+                    //int p = 10 / (i - 10);//此处为了验证程序错误响应处理,当i=10时触发异常
+                    setProgressBar(i * 100 / range);
+                }
+                setProgressBar(100);//耗时任务结束,进度条达到100;
+            }
+            catch (System.Exception ex)
+            {
+                System.Console.WriteLine(ex.Message);
+                setProgressBar(101);//处理任务失败,向进度窗口传递消息传递值大于100或小于0的数
+            }
+        }
+    }
+}

+ 191 - 0
WpfTest1/SQLite/SQLiteHelper.cs

@@ -0,0 +1,191 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection.Emit;
+using System.Text;
+using System.Data.SQLite;
+using System.Data.Common;
+using System.Data;
+
+namespace WpfTest1.SQLite
+{
+    /// <summary> 
+    /// 说明:这是一个针对System.Data.SQLite的数据库常规操作封装的通用类。 
+    /// </summary> 
+    public class SQLiteHelper
+    {
+        private string connectionString = string.Empty;
+        /// <summary> 
+        /// 构造函数 
+        /// </summary> 
+        /// <param name="dbPath">SQLite数据库文件路径</param> 
+        public SQLiteHelper(string dbPath)
+        {
+            this.connectionString = "Data Source=" + dbPath;
+        }
+        /// <summary> 
+        /// 创建SQLite数据库文件 
+        /// </summary> 
+        /// <param name="dbPath">要创建的SQLite数据库文件路径</param> 
+        public static void CreateDB(string dbPath)
+        {
+            using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + dbPath))
+            {
+                connection.Open();
+                using (SQLiteCommand command = new SQLiteCommand(connection))
+                {
+                    //command.CommandText = "CREATE TABLE Demo(id integer NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE)";
+                    //command.ExecuteNonQuery();
+                }
+            }
+        }
+        /// <summary> 
+        /// 对SQLite数据库执行增删改操作,返回受影响的行数。 
+        /// </summary> 
+        /// <param name="sql">要执行的增删改的SQL语句</param> 
+        /// <param name="parameters">执行增删改语句所需要的参数,参数必须以它们在SQL语句中的顺序为准</param> 
+        /// <returns></returns> 
+        public int ExecuteNonQuery(string sql, SQLiteParameter[] parameters)
+        {
+            int affectedRows = 0;
+            //Console.WriteLine(sql);
+            //Console.WriteLine(connectionString);
+            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
+            {
+                connection.Open();
+                using (DbTransaction transaction = connection.BeginTransaction())
+                {
+                    using (SQLiteCommand command = new SQLiteCommand(connection))
+                    {
+                        command.CommandText = sql;
+                        if (parameters != null)
+                        {
+                            command.Parameters.AddRange(parameters);
+                        }
+                        affectedRows = command.ExecuteNonQuery();
+                    }
+                    transaction.Commit();
+                }
+            }
+            return affectedRows;
+        }
+        /// <summary> 
+        /// 执行一个查询语句,返回一个关联的SQLiteDataReader实例 
+        /// </summary> 
+        /// <param name="sql">要执行的查询语句</param> 
+        /// <param name="parameters">执行SQL查询语句所需要的参数,参数必须以它们在SQL语句中的顺序为准</param> 
+        /// <returns></returns> 
+        public SQLiteDataReader ExecuteReader(string sql, SQLiteParameter[] parameters)
+        {
+            SQLiteConnection connection = new SQLiteConnection(connectionString);
+            SQLiteCommand command = new SQLiteCommand(sql, connection);
+            if (parameters != null)
+            {
+                command.Parameters.AddRange(parameters);
+            }
+            connection.Open();
+            return command.ExecuteReader(CommandBehavior.CloseConnection);
+        }
+        /// <summary> 
+        /// 执行一个查询语句,返回一个包含查询结果的DataTable 
+        /// </summary> 
+        /// <param name="sql">要执行的查询语句</param> 
+        /// <param name="parameters">执行SQL查询语句所需要的参数,参数必须以它们在SQL语句中的顺序为准</param> 
+        /// <returns></returns> 
+        public DataTable ExecuteDataTable(string sql, SQLiteParameter[] parameters)
+        {
+            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
+            {
+                using (SQLiteCommand command = new SQLiteCommand(sql, connection))
+                {
+                    if (parameters != null)
+                    {
+                        command.Parameters.AddRange(parameters);
+                    }
+                    SQLiteDataAdapter adapter = new SQLiteDataAdapter(command);
+                    DataTable data = new DataTable();
+                    adapter.Fill(data);
+                    return data;
+                }
+            }
+        }
+        /// <summary> 
+        /// 执行一个查询语句,返回查询结果的第一行第一列 
+        /// </summary> 
+        /// <param name="sql">要执行的查询语句</param> 
+        /// <param name="parameters">执行SQL查询语句所需要的参数,参数必须以它们在SQL语句中的顺序为准</param> 
+        /// <returns></returns> 
+        public Object ExecuteScalar(string sql, SQLiteParameter[] parameters)
+        {
+            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
+            {
+                using (SQLiteCommand command = new SQLiteCommand(sql, connection))
+                {
+                    if (parameters != null)
+                    {
+                        command.Parameters.AddRange(parameters);
+                    }
+                    SQLiteDataAdapter adapter = new SQLiteDataAdapter(command);
+                    DataTable data = new DataTable();
+                    adapter.Fill(data);
+                    Console.WriteLine(data.ToString());
+                    return data;
+                }
+            }
+        }
+        /// <summary> 
+        /// 执行一个查询语句,返回插入结果的id
+        /// </summary> 
+        /// <param name="sql">要执行的查询语句</param> 
+        /// <returns></returns> 
+        public Object ExecuteFindNewID(string sql)
+        {
+            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
+            {
+                using (SQLiteCommand command = new SQLiteCommand(sql, connection))
+                {
+                    connection.Open();
+                    int row_id = Convert.ToInt32(command.ExecuteScalar());
+                    //Console.WriteLine(row_id);
+                    return row_id;
+                }
+            }
+        }
+        //查询数据库中的记录数
+        public Object ExecuteFindCount(string sql, SQLiteParameter[] parameters)
+        {
+            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
+            {
+                using (SQLiteCommand command = new SQLiteCommand(sql, connection))
+                {
+                    if (parameters != null)
+                    {
+                        command.Parameters.AddRange(parameters);
+                    }
+                    connection.Open();
+                    int count = Convert.ToInt32(command.ExecuteScalar());
+                    //Console.WriteLine(row_id);
+                    return count;
+                }
+            }
+        }
+        /// <summary> 
+        /// 查询数据库中的所有数据类型信息 
+        /// </summary> 
+        /// <returns></returns> 
+        public DataTable GetSchema()
+        {
+            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
+            {
+                connection.Open();
+                DataTable data = connection.GetSchema("TABLES");
+                connection.Close();
+                //foreach (DataColumn column in data.Columns) 
+                //{ 
+                //  Console.WriteLine(column.ColumnName); 
+                //} 
+                return data;
+            }
+        }
+    }
+}

+ 52 - 0
WpfTest1/SQLite/SQLiteLogic.cs

@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection.Emit;
+using System.Text;
+using WpfTest1.SQLite;
+
+namespace WpfTest1.SQLite
+{
+    public class SQLiteLogic
+    {
+        static void Main_1(string[] args)
+        {   /*
+            
+            //CreateTable(); 
+            //InsertData();
+            Console.WriteLine("开始创建数据表!");
+            SQLiteModel.CreatePatientTable();
+            Console.WriteLine("插入数据!");
+            SQLiteModel.InsertPatientData("620523199509051700", "张三", 175.1, 68.5, 144, 2, 3, DateTime.Now.Date,"13718141455", "护士", "北京市海淀区", "1", "1", "ZS", "状态良好", new DateTime(111111), false);
+            SQLiteModel.InsertPatientData("620523199509051720", "李四", 145.1, 58.5, 134, 1, 3,DateTime.Now.Date, "12718141455", "教授", "西安市海淀区", "4", "1", "LS", "状态一般", new DateTime(111111), false);
+            SQLiteModel.InsertPatientData("620523199509051702", "古丽 ", 165.1, 88.5, 154, 1, 3, DateTime.Now.Date,"15718141455", "司机", "上海市海淀区", "3", "1", "GL", "差", new DateTime(111111), false);
+            Console.WriteLine("更新数据!");
+            SQLiteModel.UpdatePatientData("620523199509051702", "张丽 ", 195.1, 98.5, 154, 1, 3, DateTime.Now.Date,"25718141455", "学生", "上海市海淀区", "3", "1", "ZL", "差", new DateTime(111111), false);
+            Console.WriteLine("删除数据!");
+            Console.WriteLine(SQLiteModel.DeletePatientItem("620523199509051702")); 
+            Console.WriteLine("获取数据!");
+            //查询的一个问题是怎么返回值
+            //根据姓名或者简写模糊查询
+            SQLiteModel.getPatientByPY("G");
+            SQLiteModel.getPatientByName("张");
+            //根据条件进行查询 每个条件前面加AND
+            //姓名name 身份证号  病例编号 孕次pregnancy_times 产次birth_times 身高height 体重weight 心率base_heartrate
+            SQLiteModel.getPatientByCondition("AND name like\'%张丽%\'");
+            Console.WriteLine("操作完毕!");
+            Console.ReadLine();
+            */
+        }
+        public SQLiteLogic(){}
+        public static void createDBAndTables() {
+            if (!System.IO.File.Exists(System.Environment.CurrentDirectory + "\\Junde.db3"))
+            {
+                SQLiteModel.CreatePatientTable();
+                SQLiteModel.CreateRecordTable();
+                SQLiteModel.CreateDoctorTable();
+                SQLiteModel.CreateExpressionTable();
+                SQLiteModel.CreateCommonWordsTable();
+            }
+ 
+        }
+    }
+}

+ 1233 - 0
WpfTest1/SQLite/SQLiteModel.cs

@@ -0,0 +1,1233 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Data;
+using System.Data.Common;
+using System.Data.SQLite;
+namespace WpfTest1.SQLite
+{
+    public class SQLiteModel
+    {
+        public static string dbPath = Toolkits.Constants.dbPath;
+        #region 各类建表操作
+        //Patient表的创建
+        //Patient表的创建
+        public static void CreatePatientTable()
+        {
+            //如果不存在改数据库文件,则创建该数据库文件 
+            if (!System.IO.File.Exists(dbPath))
+            {
+                SQLiteHelper.CreateDB(dbPath);
+                //Console.WriteLine("OK");
+            }
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            string sql = @"CREATE TABLE Patient(
+                                     id integer primary key autoincrement not null,
+                                     record_id varchar(100),
+                                     idNum varchar(20),
+                                     name varchar(20),
+                                     height float,
+                                     weight float,
+                                     base_heartrate integer,
+                                     pregnancy_times integer,
+                                     birth_times integer,
+                                     pregnancy_date Date,
+                                     mobile varchar(20),
+                                     profession varchar(40),
+                                     address varchar(140),
+                                     category varchar(40),
+                                     group_1 varchar(40),
+                                     firstLetterPY varchar(10),
+                                     description varchar(200),
+                                     lastRecordDate datetime,
+                                     delete_flag boolean
+                                 )";
+            db.ExecuteNonQuery(sql, null);
+            string sql_1 = "CREATE INDEX Patient_idNum on Patient(idNum)";
+            db.ExecuteNonQuery(sql_1, null);
+        }
+        //创建记录表
+        public static void CreateRecordTable()
+        {
+            //如果不存在改数据库文件,则创建该数据库文件 
+            if (!System.IO.File.Exists(dbPath))
+            {
+                SQLiteHelper.CreateDB(dbPath);
+            }
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            string sql = @"CREATE TABLE Record(
+                                        id integer primary key autoincrement not null ,
+                                        patientId integer,
+                                        recordTime datetime ,
+                                        dataLeft blob,
+                                        dataRight blob,
+                                        dataWrist blob,
+                                        topBP integer,
+                                        bottomBP integer,
+                                        heartRate integer,
+                                        eigenValueSaved integer ,
+                                        comments varchar(200)
+                                        )";
+            db.ExecuteNonQuery(sql, null);
+        }
+        //创建医生表
+        public static void CreateDoctorTable()
+        {
+            //如果不存在改数据库文件,则创建该数据库文件 
+            if (!System.IO.File.Exists(dbPath))
+            {
+                SQLiteHelper.CreateDB(dbPath);
+            }
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            string sql = @"CREATE TABLE Doctor(
+                                        id integer primary key autoincrement not null ,
+                                        name varchar(20),
+                                        pwd_hash varchar(32),
+                                        phone_number varchar(20),
+                                        director_flag boolean,
+                                        delete_flag boolean)";
+            db.ExecuteNonQuery(sql, null);
+        }
+
+        //创建CommonWords表
+        public static void CreateCommonWordsTable()
+        {
+            //如果不存在改数据库文件,则创建该数据库文件 
+            if (!System.IO.File.Exists(dbPath))
+            {
+                SQLiteHelper.CreateDB(dbPath);
+            }
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            string sql = @"CREATE TABLE CommonWords(
+                                        id integer primary key autoincrement not null ,
+                                        content varchar(200),
+                                        describe varchar(20))";
+            db.ExecuteNonQuery(sql, null);
+        }
+
+        //创建表达式表
+        public static void CreateExpressionTable()
+        {
+            //如果不存在改数据库文件,则创建该数据库文件 
+            if (!System.IO.File.Exists(dbPath))
+            {
+                SQLiteHelper.CreateDB(dbPath);
+            }
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            string sql = @"CREATE TABLE Expression(
+                                        id integer primary key autoincrement not null ,
+                                        expression_content varchar(500),
+                                        expression_description varchar(500) 
+                                        )";
+            db.ExecuteNonQuery(sql, null);
+        }
+
+        //创建配置表
+        public static void CreateConfigTable()
+        {
+            //如果不存在改数据库文件,则创建该数据库文件 
+            if (!System.IO.File.Exists(dbPath))
+            {
+                SQLiteHelper.CreateDB(dbPath);
+            }
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            string sql = @"CREATE TABLE Config(
+                                        key varchar(100) primary key not null ,
+                                        value varchar(500)
+                                        )";
+            db.ExecuteNonQuery(sql, null);
+        }
+
+        #endregion
+
+        #region 数据库整体操作
+        /// <summary>
+        /// optmizeDatabase:从数据库中清空空闲列表
+        /// </summary>
+        public static int optmizeDatabase()
+        {
+            string sql = "vacuum";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[] { };
+            return db.ExecuteNonQuery(sql, parameters);
+        }
+        #endregion
+
+        #region Patient表各类操作
+        //Patient表的插入
+        public static void InsertPatientData(string record_id,string idNum,string name, double height, double weight,int base_heartrate,int pregnancy_times,int birth_times,DateTime pregnancy_date,string mobile,string profession,string address,string category,string group_1, string firstLetterPY,string description,DateTime lastRecordDate,Boolean delete_flag, DateTime birth_date)
+        {
+            string sql = "INSERT INTO Patient(record_id,idNum,name,height,weight,base_heartrate,pregnancy_times,birth_times,pregnancy_date,mobile,profession,address,category,group_1,firstLetterPY,description,lastRecordDate,delete_flag,birth_date)values(@record_id,@idNum,@name,@height,@weight,@base_heartrate,@pregnancy_times,@birth_times,@pregnancy_date,@mobile,@profession,@address,@category,@group_1,@firstLetterPY,@description,@lastRecordDate,@delete_flag,@birth_date)";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@record_id",record_id),
+                                                               new SQLiteParameter("@idNum",idNum),
+                                                               new SQLiteParameter("@name",name),
+                                                               new SQLiteParameter("@height",height),
+                                                               new SQLiteParameter("@weight",weight),
+                                                               new SQLiteParameter("@base_heartrate",base_heartrate),
+                                                               new SQLiteParameter("@pregnancy_times",pregnancy_times),
+                                                               new SQLiteParameter("@birth_times",birth_times),
+                                                               new SQLiteParameter("@pregnancy_date",pregnancy_date),
+                                                               new SQLiteParameter("@mobile",mobile),
+                                                               new SQLiteParameter("@profession",profession),
+                                                               new SQLiteParameter("@address",address),
+                                                               new SQLiteParameter("@category",category),
+                                                               new SQLiteParameter("@group_1",group_1),
+                                                               new SQLiteParameter("@firstLetterPY",firstLetterPY),
+                                                               new SQLiteParameter("@description",description),
+                                                               new SQLiteParameter("@lastRecordDate",lastRecordDate),
+                                                               new SQLiteParameter("@delete_flag",delete_flag),
+                                                               new SQLiteParameter("@birth_date",birth_date)
+                                                               };
+            db.ExecuteNonQuery(sql, parameters);
+        }
+        //Patient表的插入 返回自增主键
+        public static int InsertPatientAndReturnID(string record_id, string idNum, string name, double height, double weight, int base_heartrate, int pregnancy_times, int birth_times, DateTime pregnancy_date, string mobile, string profession, string address, string category, string group_1, string firstLetterPY, string description, DateTime lastRecordDate, Boolean delete_flag, DateTime birth_date)
+        {
+            string sql = "INSERT INTO Patient(record_id,idNum,name,height,weight,base_heartrate,pregnancy_times,birth_times,pregnancy_date,mobile,profession,address,category,group_1,firstLetterPY,description,lastRecordDate,delete_flag,birth_date)values(@record_id,@idNum,@name,@height,@weight,@base_heartrate,@pregnancy_times,@birth_times,@pregnancy_date,@mobile,@profession,@address,@category,@group_1,@firstLetterPY,@description,@lastRecordDate,@delete_flag,@birth_date);";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@record_id",record_id),
+                                                               new SQLiteParameter("@idNum",idNum),
+                                                               new SQLiteParameter("@name",name),
+                                                               new SQLiteParameter("@height",height),
+                                                               new SQLiteParameter("@weight",weight),
+                                                               new SQLiteParameter("@base_heartrate",base_heartrate),
+                                                               new SQLiteParameter("@pregnancy_times",pregnancy_times),
+                                                               new SQLiteParameter("@birth_times",birth_times),
+                                                               new SQLiteParameter("@pregnancy_date",pregnancy_date),
+                                                               new SQLiteParameter("@mobile",mobile),
+                                                               new SQLiteParameter("@profession",profession),
+                                                               new SQLiteParameter("@address",address),
+                                                               new SQLiteParameter("@category",category),
+                                                               new SQLiteParameter("@group_1",group_1),
+                                                               new SQLiteParameter("@firstLetterPY",firstLetterPY),
+                                                               new SQLiteParameter("@description",description),
+                                                               new SQLiteParameter("@lastRecordDate",lastRecordDate),
+                                                               new SQLiteParameter("@delete_flag",delete_flag),
+                                                               new SQLiteParameter("@birth_date",birth_date)
+                                                               };
+            db.ExecuteNonQuery(sql, parameters);
+            //Console.WriteLine(db.ExecuteScalar("select last_insert_rowid() from Patient",null).ToString());
+            //int new_id = Int32.Parse(db.ExecuteScalar("select id from Patient order by id desc", parameters).ToString());
+            int new_id = Convert.ToInt32(db.ExecuteFindNewID("select max(id) from Patient;"));
+            //int new_id = Convert.ToInt32(db.ExecuteFindNewID("select last_insert_rowid(id) from Patient;"));
+            //Console.WriteLine(new_id);
+            //return (Int32)db.ExecuteScalar("select last_insert_rowid();", new SQLiteParameter[] { });
+
+            return new_id;
+            
+        }
+
+        //Patient表的更新 不更新生日
+        public static void UpdatePatientData2(string id, string record_id, string idNum, string name, double height, double weight, int base_heartrate, int pregnancy_times, int birth_times, DateTime pregnancy_date, string mobile, string profession, string address, string category, string group_1, string firstLetterPY, string description, Boolean delete_flag)
+        {
+            //Boolean a = false;
+            string sql = "UPDATE Patient SET record_id=@record_id,idNum=@idNum,name=@name,height=@height,weight=@weight,base_heartrate=@base_heartrate,pregnancy_times=@pregnancy_times,birth_times = @birth_times,pregnancy_date= @pregnancy_date, mobile = @mobile,profession=@profession,address=@address,category=@category,group_1=@group_1,firstLetterPY=@firstLetterPY,description=@description,delete_flag=@delete_flag WHERE id=@id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@record_id",record_id),
+                                                               new SQLiteParameter("@idNum",idNum),
+                                                               new SQLiteParameter("@name",name),
+                                                               new SQLiteParameter("@height",height),
+                                                               new SQLiteParameter("@weight",weight),
+                                                               new SQLiteParameter("@base_heartrate",base_heartrate),
+                                                               new SQLiteParameter("@pregnancy_times",pregnancy_times),
+                                                               new SQLiteParameter("@birth_times",birth_times),
+                                                               new SQLiteParameter("@pregnancy_date",pregnancy_date),
+                                                               new SQLiteParameter("@mobile",mobile),
+                                                               new SQLiteParameter("@profession",profession),
+                                                               new SQLiteParameter("@address",address),
+                                                               new SQLiteParameter("@category",category),
+                                                               new SQLiteParameter("@group_1",group_1),
+                                                               new SQLiteParameter("@firstLetterPY",firstLetterPY),
+                                                               new SQLiteParameter("@description",description),
+                                                               new SQLiteParameter("@delete_flag",delete_flag),
+                                                               new SQLiteParameter("@id",id)
+                                                               };
+            db.ExecuteNonQuery(sql, parameters);
+        }
+        //Patient表的更新
+        public static void UpdatePatientData(string id,string record_id ,string idNum, string name, double height, double weight, int base_heartrate, int pregnancy_times, int birth_times,DateTime pregnancy_date, string mobile, string profession, string address, string category, string group_1, string firstLetterPY, string description, Boolean delete_flag, DateTime birth_date)
+        {
+            //Boolean a = false;
+            string sql = "UPDATE Patient SET record_id=@record_id,idNum=@idNum,name=@name,height=@height,weight=@weight,base_heartrate=@base_heartrate,pregnancy_times=@pregnancy_times,birth_times = @birth_times,pregnancy_date= @pregnancy_date, mobile = @mobile,profession=@profession,address=@address,category=@category,group_1=@group_1,firstLetterPY=@firstLetterPY,description=@description,delete_flag=@delete_flag,birth_date=@birth_date WHERE id=@id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@record_id",record_id),
+                                                               new SQLiteParameter("@idNum",idNum),
+                                                               new SQLiteParameter("@name",name),
+                                                               new SQLiteParameter("@height",height),
+                                                               new SQLiteParameter("@weight",weight),
+                                                               new SQLiteParameter("@base_heartrate",base_heartrate),
+                                                               new SQLiteParameter("@pregnancy_times",pregnancy_times),
+                                                               new SQLiteParameter("@birth_times",birth_times),
+                                                               new SQLiteParameter("@pregnancy_date",pregnancy_date),
+                                                               new SQLiteParameter("@mobile",mobile),
+                                                               new SQLiteParameter("@profession",profession),
+                                                               new SQLiteParameter("@address",address),
+                                                               new SQLiteParameter("@category",category),
+                                                               new SQLiteParameter("@group_1",group_1),
+                                                               new SQLiteParameter("@firstLetterPY",firstLetterPY),
+                                                               new SQLiteParameter("@description",description),
+                                                               new SQLiteParameter("@delete_flag",delete_flag),
+                                                               new SQLiteParameter("@birth_date",birth_date),
+                                                               new SQLiteParameter("@id",id)
+                                                               };
+            db.ExecuteNonQuery(sql, parameters);
+        }
+        //Patient表的仅更新最后测量时间的方法
+        public static void UpdatePatientDataWithLastMeasureDate(string id, DateTime lastRecordDate)
+        {
+            string sql = "UPDATE Patient SET lastRecordDate=@lastRecordDate WHERE id=@id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@lastRecordDate",lastRecordDate),
+                                                               new SQLiteParameter("@id",id)
+                                                               };
+            db.ExecuteNonQuery(sql, parameters);
+        }
+
+        //Patient表记录的删除
+        public static int DeletePatientItem(string id)
+        {
+            string sql = "UPDATE Patient SET delete_flag=1 WHERE id=@id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@id",id)
+                                                               };
+            return db.ExecuteNonQuery(sql, parameters);
+        }
+        /// <summary>
+        /// getDeletedPatients:从Patient表中获取所有已被标记为删除的数据的id
+        /// </summary>
+        public static List<string> getDeletedPatients()
+        {
+            string sql = "SELECT id FROM Patient WHERE delete_flag = 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[] { };
+            List<string> result = new List<string>();
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    string id = reader.IsDBNull(0) ? "" : reader.GetString(0);
+                    result.Add(id);
+                }
+            }
+            return result;
+        }
+        /// <summary>
+        /// realDeleteRecords:从Patient表中真实删除记录
+        /// </summary>
+        public static int realDeleteRecords()
+        {
+            string sql = "DELETE from Patient WHERE delete_flag=1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{ };
+            return db.ExecuteNonQuery(sql, parameters);
+        }
+
+        //检查Patient表是否重复,条件提供身份号和病例号(至少一个)重复返回true,否则返回false
+        public static bool checkRepeatPatient(string idnum,string record_id)
+        {
+            string sql = "SELECT * FROM Patient WHERE (record_id = @record_id OR idNum = @idnum) AND delete_flag = 0";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@record_id",record_id),
+                                                               new SQLiteParameter("@idnum",idnum)
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    reader.Close();
+                    return true;
+                }
+            }
+            return false;
+        }
+        //通过身份证号、孕次、产次查找Patient
+        public static Patient getPatientByIdNum_pregnancy_brith(string idNum,int pregnancy_times, int birth_times)
+        {
+            string sql = "SELECT * FROM Patient WHERE idNUm = @idNum AND pregnancy_times = @pregnancy_times AND birth_times = @birth_times AND delete_flag = 0 LIMIT 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@idNum",idNum),
+                                                               new SQLiteParameter("@pregnancy_times",pregnancy_times),
+                                                               new SQLiteParameter("@birth_times",birth_times),
+
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    Patient temp = new Patient();
+                    temp.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.record_id = reader.IsDBNull(1) ? "" : reader.GetString(1);
+                    temp.idNum = reader.IsDBNull(2) ? "" : reader.GetString(2);
+                    temp.name = reader.IsDBNull(3) ? "" : reader.GetString(3);
+                    temp.height = reader.IsDBNull(4) ? 0 : reader.GetDouble(4);
+                    temp.weight = reader.IsDBNull(5) ? 0 : reader.GetDouble(5);
+                    temp.base_heartrate = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
+                    temp.pregnancy_times = reader.IsDBNull(7) ? 0 :reader.GetInt32(7);
+                    temp.birth_times = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
+                    temp.pregnancy_date = reader.IsDBNull(9) ? DateTime.MinValue : reader.GetDateTime(9);
+                    temp.mobile = reader.IsDBNull(10)? "" : reader.GetString(10);
+                    temp.profession = reader.IsDBNull(11) ? "" : reader.GetString(11);
+                    temp.address = reader.IsDBNull(12) ? "" : reader.GetString(12);
+                    temp.category = reader.IsDBNull(13) ? "" : reader.GetString(13);
+                    temp.group_1 = reader.IsDBNull(14) ? "" : reader.GetString(14);
+                    temp.firstLetterPY = reader.IsDBNull(15) ? "" : reader.GetString(15);
+                    temp.description = reader.IsDBNull(16) ? "" : reader.GetString(16);
+                    return temp;
+                }
+            }
+            return null;
+        }
+
+        //通过id主键查找Patient
+        public static Patient getPatientById(string id)
+        {
+            string sql = "SELECT * FROM Patient WHERE id = @id AND delete_flag = 0 LIMIT 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@id",id),
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    Patient temp = new Patient();
+                    temp.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.record_id = reader.IsDBNull(1) ? "" : reader.GetString(1);
+                    temp.idNum = reader.IsDBNull(2) ? "" : reader.GetString(2);
+                    temp.name = reader.IsDBNull(3) ? "" : reader.GetString(3);
+                    temp.height = reader.IsDBNull(4) ? 0 : reader.GetDouble(4);
+                    temp.weight = reader.IsDBNull(5) ? 0 : reader.GetDouble(5);
+                    temp.base_heartrate = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
+                    temp.pregnancy_times = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
+                    temp.birth_times = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
+                    temp.pregnancy_date = reader.IsDBNull(9) ? DateTime.MinValue : reader.GetDateTime(9);
+                    temp.mobile = reader.IsDBNull(10) ? "" : reader.GetString(10);
+                    temp.profession = reader.IsDBNull(11) ? "" : reader.GetString(11);
+                    temp.address = reader.IsDBNull(12) ? "" : reader.GetString(12);
+                    temp.category = reader.IsDBNull(13) ? "" : reader.GetString(13);
+                    temp.group_1 = reader.IsDBNull(14) ? "" : reader.GetString(14);
+                    temp.firstLetterPY = reader.IsDBNull(15) ? "" : reader.GetString(15);
+                    temp.description = reader.IsDBNull(16) ? "" : reader.GetString(16);
+                    return temp;
+                }
+            }
+            return null;
+        }
+        //根据拼音获取patient记录
+        public static void getPatientByPY(string py)
+        {
+            //查询从20条起的50条记录 
+            string sql = "SELECT * FROM Patient WHERE firstLetterPY like\'%" + py + "%\' AND delete_flag=0";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, null))
+            {
+                while (reader.Read())
+                {
+                    Console.WriteLine("姓名:{0},职业:{1}", reader.GetString(2), reader.GetString(9));
+                }
+            }
+        }
+        //根据姓名获取patient记录
+        public static void getPatientByName(string name)
+        {
+            string sql = "SELECT * FROM Patient WHERE name like\'%" + name+ "%\' AND delete_flag=0";
+            Console.WriteLine(sql);
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, null))
+            {
+                while (reader.Read())
+                {
+                    //Console.WriteLine("DDDDDDDDDDDDDDDDDDDD");
+                    Console.WriteLine("姓名:{0},职业:{1}", reader.GetString(2), reader.GetString(9));
+                }
+            }
+        }
+        //根据condition获取patient记录
+        public static DataView getPatientByCondition(string condition)
+        {
+            /*
+             * 
+             
+            string sql = "SELECT * FROM Patient WHERE delete_flag=0 " + condition;
+            Console.WriteLine(sql);
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, null))
+            {
+                return reader;
+                while (reader.Read())
+                {
+                    //Console.WriteLine("DDDDDDDDDDDDDDDDDDDD");
+                    Console.WriteLine("姓名:{0},职业:{1}", reader.GetString(2), reader.GetString(9));
+                }
+            }
+             */
+            //var path1 = "d:\\temp\\temp.db";
+            string sql = "SELECT * FROM Patient WHERE delete_flag=0 " + condition;
+            System.Data.SQLite.SQLiteConnectionStringBuilder connstr = new System.Data.SQLite.SQLiteConnectionStringBuilder();
+            connstr.DataSource = dbPath;
+            System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection();
+            conn.ConnectionString = connstr.ToString();
+            conn.Open();
+            SQLiteDataAdapter adapter = new SQLiteDataAdapter(sql, conn);
+            DataSet ds = new DataSet();
+            adapter.Fill(ds);
+            DataView dv = ds.Tables[0].DefaultView;
+
+            conn.Close();
+            conn.Dispose();
+            return dv;
+
+
+        }
+
+        //获取Patient表的用户所有分类和所有用户组
+        public static List<string> getCategory(string taskType="category")
+        {
+            string sql = "SELECT " + taskType + " FROM Patient WHERE delete_flag = 0 group by " + taskType;
+            List<string> result = new List<string>();
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{ };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    if (reader.IsDBNull(0))
+                        continue;
+                    result.Add(reader.GetString(0));
+                }
+                reader.Close();
+            }
+            return result;
+        }
+        #endregion
+
+        #region doctor表相关的操作
+        //医生登录操作
+        public static doctor doctorLogin(string name,string passwordHash)
+        {
+            string sql = "SELECT * FROM Doctor WHERE name = @name and pwd_hash=@passwordHash and delete_flag =0 LIMIT 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@name",name),
+                                                               new SQLiteParameter("@passwordHash",passwordHash),
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    doctor oneDoctor = new doctor();
+                    oneDoctor.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    oneDoctor.name = name;
+                    oneDoctor.phone_number = reader.IsDBNull(3) ? "" : reader.GetString(3);
+                    oneDoctor.director_flag = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    oneDoctor.privilege_flag = reader.IsDBNull(6) ? -1 : reader.GetInt32(6);
+                    return oneDoctor;
+                }
+            }
+            return null;
+        }
+
+        //主任登录操作
+        public static doctor directorLogin(string name, string passwordHash)
+        {
+            string sql = "SELECT * FROM Doctor WHERE name = @name and pwd_hash=@passwordHash and delete_flag = 0 and director_flag = 1 LIMIT 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@name",name),
+                                                               new SQLiteParameter("@passwordHash",passwordHash),
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    doctor oneDoctor = new doctor();
+                    oneDoctor.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    oneDoctor.name = name;
+                    oneDoctor.phone_number = reader.IsDBNull(3) ? "" : reader.GetString(3);
+                    oneDoctor.director_flag = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    return oneDoctor;
+                }
+            }
+            return null;
+        }
+
+        //厂商登录操作
+        public static doctor OEMLogin(string name, string passwordHash)
+        {
+            string sql = "SELECT * FROM Doctor WHERE name = @name and pwd_hash=@passwordHash and delete_flag = 0 and privilege_flag = 1 LIMIT 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@name",name),
+                                                               new SQLiteParameter("@passwordHash",passwordHash),
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    doctor oneDoctor = new doctor();
+                    oneDoctor.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    oneDoctor.name = name;
+                    oneDoctor.phone_number = reader.IsDBNull(3) ? "" : reader.GetString(3);
+                    oneDoctor.director_flag = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    return oneDoctor;
+                }
+            }
+            return null;
+        }
+
+        //查询医生用户名是否存在 存在返回true
+        public static bool checkRepeatDoctor(string name)
+        {
+            string sql = "SELECT * FROM Doctor WHERE name = @name AND delete_flag = 0";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@name",name)
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    reader.Close();
+                    return true;
+                }
+            }
+            return false;
+        }
+        //通过id主键查找Doctor
+        public static doctor getDoctorById(string id)
+        {
+            string sql = "SELECT * FROM Doctor WHERE id = @id AND delete_flag = 0 LIMIT 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@id",id),
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    doctor temp = new doctor();
+                    temp.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.name = reader.IsDBNull(1) ? "" : reader.GetString(1);
+                    temp.pwd_hash = reader.IsDBNull(2) ? "" : reader.GetString(2);
+                    temp.phone_number = reader.IsDBNull(3) ? "" : reader.GetString(3);
+                    temp.director_flag = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    return temp;
+                }
+            }
+            return null;
+        }
+        //查找Doctor 返回目前还使用的医生id
+        public static int getDoctorIdByNoDelete()
+        {
+            string sql = "SELECT * FROM Doctor WHERE delete_flag = 0 LIMIT 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{};
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    doctor temp = new doctor();
+                    temp.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.name = reader.IsDBNull(1) ? "" : reader.GetString(1);
+                    temp.pwd_hash = reader.IsDBNull(2) ? "" : reader.GetString(2);
+                    temp.phone_number = reader.IsDBNull(3) ? "" : reader.GetString(3);
+                    temp.director_flag = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    return temp.id;
+                }
+            }
+            return -1;
+        }
+        //Doctort表的插入
+        public static void InsertDoctorData(string name, string pwd_hash, string phone_number, Boolean director_flag = false, Boolean delete_flag = false)
+        {
+            string sql = "INSERT INTO Doctor(name,pwd_hash,phone_number,director_flag,delete_flag)values(@name,@pwd_hash,@phone_number,@director_flag,@delete_flag)";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@name",name),
+                                                               new SQLiteParameter("@pwd_hash",pwd_hash),
+                                                               new SQLiteParameter("@phone_number",phone_number),
+                                                               new SQLiteParameter("@director_flag",director_flag),
+                                                               new SQLiteParameter("@delete_flag",delete_flag)
+                                                               };
+            db.ExecuteNonQuery(sql, parameters);
+        }
+        //Doctor表的更新
+        public static void UpdateDoctorData(string id, string name, string pwd_hash, string phone_number, Boolean director_flag = false, Boolean delete_flag = false)
+        {
+            //Boolean a = false;
+            string sql = "UPDATE Doctor SET name=@name,pwd_hash=@pwd_hash,phone_number=@phone_number,director_flag=@director_flag,delete_flag=@delete_flag WHERE id=@id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@name",name),
+                                                               new SQLiteParameter("@pwd_hash",pwd_hash),
+                                                               new SQLiteParameter("@phone_number",phone_number),
+                                                               new SQLiteParameter("@director_flag",director_flag),
+                                                               new SQLiteParameter("@delete_flag",delete_flag),
+                                                               new SQLiteParameter("@id",id)
+                                                               };
+            db.ExecuteNonQuery(sql, parameters);
+        }
+        //Doctor表记录的删除
+        public static int DeleteDoctorItem(string id)
+        {
+            string sql = "UPDATE Doctor SET delete_flag=1 WHERE id=@id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@id",id)
+                                                               };
+            return db.ExecuteNonQuery(sql, parameters);
+        }
+        #endregion
+
+        #region 常用语CommonWords表操作
+        //通过id主键查找CommonWords
+        public static CommonWords getCommonWordsById(string id)
+        {
+            string sql = "SELECT * FROM CommonWords WHERE id = @id LIMIT 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@id",id),
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    CommonWords temp = new CommonWords();
+                    temp.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.content = reader.IsDBNull(1) ? "" : reader.GetString(1);
+                    temp.describe = reader.IsDBNull(2) ? "" : reader.GetString(2);
+                    return temp;
+                }
+            }
+            return null;
+        }
+        //CommonWords表的插入
+        public static void InsertCommonWordsData(string content, string describe)
+        {
+            string sql = "INSERT INTO CommonWords(content,describe)values(@content,@describe)";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@content",content),
+                                                               new SQLiteParameter("@describe",describe)
+                                                               };
+            db.ExecuteNonQuery(sql, parameters);
+        }
+        //CommonWords表的更新
+        public static void UpdateCommonWordsData(string id, string content, string describe)
+        {
+            //Boolean a = false;
+            string sql = "UPDATE CommonWords SET content=@content,describe=@describe WHERE id=@id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@content",content),
+                                                               new SQLiteParameter("@describe",describe),
+                                                               new SQLiteParameter("@id",id)
+                                                               };
+            db.ExecuteNonQuery(sql, parameters);
+        }
+        //CommonWords表记录的删除
+        public static int DeleteCommonWordsItem(string id)
+        {
+            string sql = "DELETE FROM CommonWords WHERE id=@id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@id",id)
+                                                               };
+            return db.ExecuteNonQuery(sql, parameters);
+        }
+        #endregion
+
+        #region Record标的相关操作
+        // //通过id主键查找Record
+        public static Record getRecordById(string id)
+        {
+            string sql = "SELECT * FROM Record WHERE id = @id LIMIT 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@id",id),
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    Record temp = new Record();
+
+                    //long len = reader.GetBytes(reader.GetOrdinal("Data"), 0, null, 0, 0);
+                    //Console.WriteLine("len is :" + len.ToString());
+                    //buffer = new byte[len];
+
+                    //len = reader.GetBytes(reader.GetOrdinal("Data"), 0, buffer, 0, (int)len);
+                    temp.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.patientId = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
+                    temp.doctorId = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
+                    temp.recordTime = reader.IsDBNull(3) ? DateTime.MinValue : reader.GetDateTime(3);
+                    //左手
+                    if(!reader.IsDBNull(4))
+                    {
+                        long len = reader.GetBytes(reader.GetOrdinal("dataLeft"), 0, null, 0, 0);
+                        byte[] buffer = new byte[len];
+                        reader.GetBytes(reader.GetOrdinal("dataLeft"), 0, buffer, 0, (int)len);
+                        temp.dataLeft = buffer;
+                    }
+                    else
+                    {
+                        temp.dataLeft = new byte[] { };
+                    }
+                    //右手
+                    if (!reader.IsDBNull(5))
+                    {
+                        long len = reader.GetBytes(reader.GetOrdinal("dataRight"), 0, null, 0, 0);
+                        byte[] buffer = new byte[len];
+                        reader.GetBytes(reader.GetOrdinal("dataRight"), 0, buffer, 0, (int)len);
+                        temp.dataRight = buffer;
+                    }
+                    else
+                    {
+                        temp.dataRight = new byte[] { };
+                    }
+                    //绕关节
+                    if (!reader.IsDBNull(6))
+                    {
+                        long len = reader.GetBytes(reader.GetOrdinal("dataWrist"), 0, null, 0, 0);
+                        byte[] buffer = new byte[len];
+                        reader.GetBytes(reader.GetOrdinal("dataWrist"), 0, buffer, 0, (int)len);
+                        temp.dataWrist = buffer;
+                    }
+                    else
+                    {
+                        temp.dataWrist = new byte[] { };
+                    }
+                    temp.topBP = reader.IsDBNull(7) ? 0 : reader.GetDouble(7);
+                    temp.bottomBP = reader.IsDBNull(8) ? 0 : reader.GetDouble(8);
+                    temp.heartRate = reader.IsDBNull(9) ? 0 : reader.GetDouble(9);
+                    temp.waveTpye = reader.IsDBNull(10) ? "" : reader.GetString(10);
+                    temp.eigenValueSaved = reader.IsDBNull(11) ? 0: reader.GetInt32(11);
+                    temp.comments = reader.IsDBNull(12) ? "" : reader.GetString(12);
+                    temp.hand = reader.IsDBNull(14) ? "b" : reader.GetString(14);
+                    return temp;
+                }
+            }
+            return null;
+        }
+        //查找Record中病人id和时间相同的记录个数
+        public static int getRecordCountByPatientIdAndTime(int patient_id, DateTime recordTime)
+        {
+            string sql = "SELECT count(*) FROM Record WHERE patientId = @patient_id AND recordTime=@recordTime";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@patient_id",patient_id),
+                                                               new SQLiteParameter("@recordTime",recordTime),
+                                                               };
+            int count = Convert.ToInt32(db.ExecuteFindCount(sql,parameters));
+            return count;
+        }
+        //Record表的插入
+        public static void InsertRecordData(int PatientId, int doctorId, DateTime RecordTime, byte[] DataLeft,byte[] DataRight, byte[] DataWrist, double TopBP, double BottomBP, double HeartRate, int EigenValueSaved, string Comments, string waveType, string hand)
+        {
+            string sql = "INSERT INTO Record(PatientId,doctorId,RecordTime,DataLeft,DataRight,DataWrist,TopBP,BottomBP,HeartRate,waveType,EigenValueSaved,Comments,hand)values(@PatientId,@doctorId,@RecordTime,@DataLeft,@DataRight,@DataWrist,@TopBP,@BottomBP,@HeartRate,@waveType,@EigenValueSaved,@Comments,@hand)";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@PatientId",PatientId),
+                                                               new SQLiteParameter("@doctorId",doctorId),
+                                                               new SQLiteParameter("@RecordTime",RecordTime),
+                                                               new SQLiteParameter("@DataLeft",DbType.Binary),
+                                                               new SQLiteParameter("@DataRight",DbType.Binary),
+                                                               new SQLiteParameter("@DataWrist",DbType.Binary),
+                                                               new SQLiteParameter("@TopBP",TopBP),
+                                                               new SQLiteParameter("@BottomBP",BottomBP),
+                                                               new SQLiteParameter("@HeartRate",HeartRate),
+                                                               new SQLiteParameter("@waveType",waveType),
+                                                               new SQLiteParameter("@EigenValueSaved",EigenValueSaved),
+                                                               new SQLiteParameter("@Comments",Comments),
+                                                               new SQLiteParameter("@hand",hand)
+                                                               };
+            parameters[3].Value = DataLeft;
+            parameters[4].Value = DataRight;
+            parameters[5].Value = DataWrist;
+            db.ExecuteNonQuery(sql, parameters);
+        }
+        ////Record表的更新
+        public static void UpdateRecordData(int id,int PatientId, int doctorId, DateTime RecordTime, byte[] DataLeft, byte[] DataRight, byte[] DataWrist, double TopBP, double BottomBP, double HeartRate, int EigenValueSaved, string Comments, string waveType)
+        {
+            string sql = "UPDATE Record SET PatientId=@PatientId,doctorId=@doctorId,RecordTime=@RecordTime,DataLeft=@DataLeft,DataRight=@DataLeft,DataWrist=@DataWrist,TopBP=@TopBP,BottomBP=@BottomBP,HeartRate=@HeartRate,EigenValueSaved=@EigenValueSaved,comments=@Comments,waveType=@waveType WHERE id=@id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@PatientId",PatientId),
+                                                               new SQLiteParameter("@doctorId",doctorId),
+                                                               new SQLiteParameter("@RecordTime",RecordTime),
+                                                               new SQLiteParameter("@DataLeft",DataLeft),
+                                                               new SQLiteParameter("@DataRight",DataRight),
+                                                               new SQLiteParameter("@DataWrist",DataWrist),
+                                                               new SQLiteParameter("@TopBP",TopBP),
+                                                               new SQLiteParameter("@BottomBP",BottomBP),
+                                                               new SQLiteParameter("@HeartRate",HeartRate),
+                                                               new SQLiteParameter("@EigenValueSaved",EigenValueSaved),
+                                                               new SQLiteParameter("@Comments",Comments),
+                                                               new SQLiteParameter("@id",id),
+                                                               new SQLiteParameter("@waveType",waveType)
+                                                               };
+            db.ExecuteNonQuery(sql, parameters);
+        }
+
+        //Record表更新医生的诊断
+        public static void UpdateDiagnosisData(int id, string Comments)
+        {
+            string sql = "UPDATE Record SET comments=@Comments WHERE id=@id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@Comments",Comments),
+                                                               new SQLiteParameter("@id",id),
+                                                               };
+            db.ExecuteNonQuery(sql, parameters);
+        }
+
+        //Record表删除操作
+        public static int DeleteRecordItem(string id)
+        {
+            string sql = "DELETE FROM Record WHERE id=@id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@id",id)
+                                                               };
+            return db.ExecuteNonQuery(sql, parameters);
+        }
+        #endregion
+
+        #region Expression表的相关操作
+        //查找所有的expression的content和position列,privilege_flag为1时才显示所有的公示,否则只显示isCache=1的公式
+        public static void GetAllExpressionContent(Dictionary<string, double> target, Dictionary<string, string> positions, int privilege_flag)
+        {
+            string sql = "SELECT expression_content,position FROM Expression WHERE ";
+            if(privilege_flag == 1)
+            {
+                sql += "1";
+            }
+            else
+            {
+                sql += "isCache = 1";
+            }
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    string tempKey = reader.IsDBNull(0) ? "" : reader.GetString(0);
+                    string tempPosition = reader.IsDBNull(1) ? "" : reader.GetString(1);
+                    if (tempKey == "")
+                    {
+                        break;
+                    }
+                    //KeyValuePair<string, double> temp = new KeyValuePair<string, double>(tempKey,0);
+                    target.Add(tempKey,0);
+                    positions.Add(tempKey, tempPosition);
+                }
+            }
+        }
+
+        //通过id主键查找Expression
+        public static Expression getExpressionById(string id)
+        {
+            string sql = "SELECT * FROM Expression WHERE id = @id LIMIT 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@id",id),
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    Expression temp = new Expression();
+                    temp.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.expression_content = reader.IsDBNull(1) ? "" : reader.GetString(1);
+                    temp.expression_description = reader.IsDBNull(2) ? "" : reader.GetString(2);
+                    temp.range = reader.IsDBNull(3) ? 0.0 : reader.GetDouble(3);
+                    temp.isRelative = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.isCache = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);
+                    temp.upBound = reader.IsDBNull(6) ? 0 : reader.GetDouble(6);
+                    temp.downBound = reader.IsDBNull(7) ? 0 : reader.GetDouble(7);
+                    temp.position = reader.IsDBNull(8) ? "o" : reader.GetString(8);
+                    return temp;
+                }
+            }
+            return null;
+        }
+        //通过公式值查找Expression
+        public static Expression getExpressionByContent(string content)
+        {
+            string sql = "SELECT * FROM Expression WHERE expression_content = @content LIMIT 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@content",content),
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    Expression temp = new Expression();
+                    temp.id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.expression_content = reader.IsDBNull(1) ? "" : reader.GetString(1);
+                    temp.expression_description = reader.IsDBNull(2) ? "" : reader.GetString(2);
+                    temp.range = reader.IsDBNull(3) ? 0.0 : reader.GetDouble(3);
+                    temp.isRelative = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
+                    temp.isCache = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);
+                    temp.upBound = reader.IsDBNull(6) ? 0 : reader.GetDouble(6);
+                    temp.downBound = reader.IsDBNull(7) ? 0 : reader.GetDouble(7);
+                    temp.position = reader.IsDBNull(8) ? "o" : reader.GetString(8);
+                    return temp;
+                }
+            }
+            return null;
+        }
+        //Expression表的插入
+        public static void InsertExpressionData(string content, string describe,double range, int relative,double upBound, double downBound, int isCache, string position)
+        {
+            string sql = "INSERT INTO Expression(expression_content,expression_description,range,isRelative,upBound,downBound,isCache,position)values(@content,@describe,@range,@relative,@upBound,@downBound,@isCache,@position)";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@content",content),
+                                                               new SQLiteParameter("@describe",describe),
+                                                               new SQLiteParameter("@range",range),
+                                                               new SQLiteParameter("@relative",relative),
+                                                               new SQLiteParameter("@upBound",upBound),
+                                                               new SQLiteParameter("@downBound",downBound),
+                                                               new SQLiteParameter("@isCache",isCache),
+                                                               new SQLiteParameter("@position",position)
+                                                               };
+            db.ExecuteNonQuery(sql, parameters);
+        }
+        //Expression表的更新
+        public static void UpdateExpressionData(string id, string content, string describe, double range, int relative, double upBound, double downBound, int isCache,string position)
+        {
+            //Boolean a = false;
+            string sql = "UPDATE Expression SET expression_content=@content,expression_description=@describe,range=@range,isRelative=@relative,upBound=@upBound,downBound=@downBound,isCache=@isCache,position=@position WHERE id=@id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@content",content),
+                                                               new SQLiteParameter("@describe",describe),
+                                                               new SQLiteParameter("@id",id),
+                                                               new SQLiteParameter("@range",range),
+                                                               new SQLiteParameter("@relative",relative),
+                                                               new SQLiteParameter("@upBound",upBound),
+                                                               new SQLiteParameter("@downBound",downBound),
+                                                               new SQLiteParameter("@isCache",isCache),
+                                                               new SQLiteParameter("@position",position)
+                                                               };
+            db.ExecuteNonQuery(sql, parameters);
+        }
+        //Expression表仅更新取值范围的方法
+        public static void UpdateExpressionDataOnlyWithRange(string content, double range, int relative)
+        {
+            //Boolean a = false;
+            string sql = "UPDATE Expression SET range=@range,isRelative=@relative WHERE expression_content=@content";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@content",content),
+                                                               new SQLiteParameter("@range",range),
+                                                               new SQLiteParameter("@relative",relative)
+                                                               };
+            db.ExecuteNonQuery(sql, parameters);
+        }
+        //Expression表记录的删除
+        public static int DeleteExpressionItem(string id)
+        {
+            string sql = "DELETE FROM Expression WHERE id=@id";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               new SQLiteParameter("@id",id)
+                                                               };
+            return db.ExecuteNonQuery(sql, parameters);
+        }
+        #endregion
+
+        #region 配置表Config的相关操作
+        //查找所有的expression的content列
+        public static void GetAllConfigContent(Dictionary<string, string> target)
+        {
+            target.Clear();
+            string sql = "SELECT key,value FROM Config WHERE 1";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               };
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    string tempKey = reader.IsDBNull(0) ? "" : reader.GetString(0);
+                    string tempValue = reader.IsDBNull(1) ? "" : reader.GetString(1);
+                    if (tempKey == "")
+                    {
+                        break;
+                    }
+                    //KeyValuePair<string, double> temp = new KeyValuePair<string, double>(tempKey,0);
+                    target.Add(tempKey, tempValue);
+                }
+            }
+        }
+        //更新激活码信息
+        public static void UpdateRegisterCode(string name, string pw, string code)
+        {
+            //Boolean a = false;
+            string sql = "UPDATE Config SET value=@name WHERE key='organization_name'";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{
+                                                               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
+
+        #region 以下是测试功能,请在生产环境之前删除这些功能
+        public static byte[] getRecordData()
+        {
+            string dbPathTest = @"D:\\sourceCode\\github\\Junde_New\bin\\Debug\\data\\data.db";
+            string sql = "SELECT Data FROM Record WHERE id = 22";
+            SQLiteHelper db = new SQLiteHelper(dbPathTest);
+            Console.WriteLine("database ok!");
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, null))
+            {
+                byte[] buffer = null;
+                if (reader.HasRows)
+                {
+
+                    reader.Read();
+                    long len = reader.GetBytes(reader.GetOrdinal("Data"), 0, null, 0, 0);
+                    Console.WriteLine("len is :" + len.ToString());
+                    buffer = new byte[len];
+
+                    len = reader.GetBytes(reader.GetOrdinal("Data"), 0, buffer, 0, (int)len);
+                    for(int i =0;i<100;i++)
+                    {
+                        Console.WriteLine(buffer[i]);
+                    }
+                    return buffer;
+                    //System.IO.MemoryStream ms = new System.IO.MemoryStream(buffer);
+                    //System.Drawing.Image iamge = System.Drawing.Image.FromStream(ms);
+                    //pictureBox1.Image = iamge;
+                }
+
+            }
+            return null;
+        }
+        #endregion
+    }
+}

BIN
WpfTest1/SQLite/System.Data.SQLite.dll


+ 18 - 0
WpfTest1/SQLite/doctor.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection.Emit;
+using System.Text;
+
+namespace WpfTest1.SQLite
+{
+    public class doctor
+    {
+        public int id { get; set; }
+        public string name { get; set; }
+        public string pwd_hash { get; set; }
+        public string phone_number { get; set; }
+        public int director_flag { get; set; }
+        public int privilege_flag { get; set; }
+    }
+}

+ 35 - 0
WpfTest1/SmallDialogs/AddDoctor.xaml

@@ -0,0 +1,35 @@
+<Window x:Class="WpfTest1.AddDoctor"
+        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"
+        mc:Ignorable="d"
+        Title="添加医生" Height="300" Width="376.762">
+    <Grid Margin="0,0,-0,-0">
+        <Label x:Name="label" Content="登录名:" HorizontalAlignment="Left" Margin="69,43,0,0" VerticalAlignment="Top" RenderTransformOrigin="1.028,0.561"/>
+        <Label x:Name="label1" Content="密码:" HorizontalAlignment="Left" Margin="81,74,0,0" VerticalAlignment="Top" RenderTransformOrigin="1.401,1.055"/>
+        <Label x:Name="label_1" Content="重复密码:" HorizontalAlignment="Left" Margin="57,105,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="label2" Content="联系电话:" HorizontalAlignment="Left" Margin="57,136,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.505,2.015"/>
+        <Label x:Name="label3" Content="是否是主任账户:" HorizontalAlignment="Left" Margin="21,178,0,0" VerticalAlignment="Top"/>
+        <CheckBox x:Name="radioButton" Content="是" HorizontalAlignment="Left" Margin="127,181,0,0" VerticalAlignment="Top"/>
+        <TextBox x:Name="name" HorizontalAlignment="Left" Height="23" Margin="127,42,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="166"/>
+        <PasswordBox x:Name="pwd" HorizontalAlignment="Left" Margin="127,73,0,0" VerticalAlignment="Top" RenderTransformOrigin="-12.438,-0.406" Width="166"/>
+        <PasswordBox x:Name="pwd_1" HorizontalAlignment="Left" Margin="127,104,0,0" VerticalAlignment="Top" RenderTransformOrigin="-12.438,-0.406" Width="166"/>
+        <TextBox x:Name="phone" HorizontalAlignment="Left" Height="23" Margin="127,135,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="166"/>
+        <Button x:Name="button_add" Content="添加" HorizontalAlignment="Left" Margin="47,220,0,0" VerticalAlignment="Top" Width="75" Click="addButtonClick" RenderTransformOrigin="0.544,1.606"/>
+        <Button x:Name="button_reset" Content="重置" HorizontalAlignment="Left" Margin="152,220,0,0" VerticalAlignment="Top" Width="75" Click="resetButtonClick"/>
+        <Button x:Name="button_cancel" Content="取消" HorizontalAlignment="Left" Margin="260,220,0,0" VerticalAlignment="Top" Width="75" Click="cancelButtonClick"/>
+
+
+        <Label x:Name="label_Copy1" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="71,74,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy2" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="47,105,0,0" VerticalAlignment="Top" FontSize="18" RenderTransformOrigin="0.665,0.716"/>
+        <Label x:Name="label_Copy3" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="47,136,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy4" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="57,42,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy" Content="带" HorizontalAlignment="Left" Margin="224,178,0,0" VerticalAlignment="Top" FontSize="12" Height="25" Width="22" RenderTransformOrigin="1.281,0.534"/>
+        <Label x:Name="label_Copy_1" Content="的为必填项" HorizontalAlignment="Left" Margin="251,178,0,0" VerticalAlignment="Top" FontSize="12" Height="25" Width="75" RenderTransformOrigin="1.281,0.534"/>
+        <Label x:Name="label_Copy5" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="241,176,0,0" VerticalAlignment="Top" FontSize="18" RenderTransformOrigin="1.22,0.399"/>
+
+
+    </Grid>
+</Window>

+ 130 - 0
WpfTest1/SmallDialogs/AddDoctor.xaml.cs

@@ -0,0 +1,130 @@
+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;
+using WpfTest1.Toolkits;
+
+namespace WpfTest1
+{
+    /// <summary>
+    /// AddDoctor是添加医师的交互界面
+    /// AddDoctor.xaml 的交互逻辑
+    /// </summary>
+    public partial class AddDoctor : Window
+    {
+        MainWindow father;
+        //int check = 0;
+        public AddDoctor(MainWindow father)
+        {
+            this.father = father;
+            InitializeComponent();
+        }
+        /*
+        private void radioButton_Checked(object sender, RoutedEventArgs e)
+        {
+            check = 1;
+        }
+        */
+        //添加按钮
+        private void addButtonClick(object sender, RoutedEventArgs e)
+        {
+            if (name.Text == "")
+            {
+                MessageBox.Show("请填写用户名!");
+                name.Focus();
+                return;
+            }
+            if (pwd.Password == "")
+            {
+                MessageBox.Show("请填写密码!");
+                pwd.Focus();
+                return;
+            }
+            if (pwd_1.Password == "")
+            {
+                MessageBox.Show("请填写确认密码!");
+                pwd_1.Focus();
+                return;
+            }
+            if (phone.Text == "")
+            {
+                MessageBox.Show("请填写联系电话!");
+                phone.Focus();
+                return;
+            }
+            if (pwd_1.Password != pwd.Password)
+            {
+                MessageBox.Show("两次输入的密码不一致,请重新输入!");
+                pwd.Focus();
+                return;
+            }
+            string doctor_name = FilterDangerousCharacter.filter(name.Text);
+            string doctor_pwd = Toolkits.ComputeHash.GetMD5(FilterDangerousCharacter.filter(pwd.Password));
+            string doctor_phone = FilterDangerousCharacter.filter(phone.Text);
+            int doctor_dir_flag = 0;
+            if ((Boolean)(radioButton.IsChecked)) doctor_dir_flag = 1;
+            int doctor_del_flag = 0;
+
+            bool success_flag = true;
+            try
+            {
+                if (SQLite.SQLiteModel.checkRepeatDoctor(doctor_name))
+                {
+                    MessageBox.Show("用户名选择重复,请选择新的用户名!");
+                    name.Focus();
+                    return;
+                }
+                SQLite.SQLiteModel.InsertDoctorData(doctor_name,
+                                                     doctor_pwd,
+                                                     doctor_phone,
+                                                     Convert.ToBoolean(doctor_dir_flag),
+                                                     Convert.ToBoolean(doctor_del_flag)
+                                                     );
+            }
+            catch (Exception err)
+            {
+                success_flag = false;
+                MessageBox.Show("数据库错误.\r\n调试信息:" + err.Message, "错误");
+            }
+            if (success_flag)
+            {
+                MessageBox.Show("添加医生成功", "提示");
+                father.LoadDoctorDataGrid();
+                this.Close();
+            }
+        }
+        //重置按钮
+        private void resetButtonClick(object sender, RoutedEventArgs e)
+        {
+            name.Text = "";
+            phone.Text = "";
+            pwd.Password = "";
+            pwd_1.Password = "";
+            radioButton.IsChecked = false;
+            name.Focus();
+        }
+        //取消按钮
+        private void cancelButtonClick(object sender, RoutedEventArgs e)
+        {
+            MessageBoxResult dr = MessageBox.Show("是否放弃添加?", "提示", MessageBoxButton.OKCancel);
+            if (dr == MessageBoxResult.OK)
+            {
+                this.Close();
+            }
+            else if (dr == MessageBoxResult.Cancel)
+            {
+                return;
+            }
+            //this.Close();
+        }
+    }
+}

+ 61 - 0
WpfTest1/SmallDialogs/AddPatient.xaml

@@ -0,0 +1,61 @@
+<Window x:Class="WpfTest1.AddPatient"
+        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"
+        mc:Ignorable="d"
+        Title="添加病例" Height="600" Width="800">
+    <Grid Margin="0,0,-0,-0">
+        <Button x:Name="buttonAddPatinetcSubmit" Content="添加" HorizontalAlignment="Left" Margin="160,502,0,0" VerticalAlignment="Top" Width="130" Height="40" FontSize="18" Click="buttonAddPatinetcSubmit_Click"/>
+        <Button x:Name="buttonAddPatinetcReset" Content="重置" HorizontalAlignment="Left" Margin="334,502,0,0" VerticalAlignment="Top" Width="130" Height="40" FontSize="18" Click="buttonAddPatinetcReset_Click"/>
+        <Button x:Name="buttonAddPatinetcCancel" Content="取消" HorizontalAlignment="Left" Margin="511,502,0,0" VerticalAlignment="Top" Width="130" Height="40" FontSize="18" Click="buttonAddPatinetcCancel_Click"/>
+        <Label x:Name="label" Content="病例编号:" HorizontalAlignment="Left" Margin="112,37,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy" Content="身份证号:" HorizontalAlignment="Left" Margin="112,75,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy1" Content="姓名:" HorizontalAlignment="Left" Margin="148,113,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy2" Content="身高:" HorizontalAlignment="Left" Margin="148,189,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy3" Content="体重:" HorizontalAlignment="Left" Margin="148,227,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy4" Content="静息心率:" HorizontalAlignment="Left" Margin="112,265,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy5" Content="孕次:" HorizontalAlignment="Left" Margin="148,303,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy6" Content="产次:" HorizontalAlignment="Left" Margin="148,341,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy7" Content="受孕日期:" HorizontalAlignment="Left" Margin="112,374,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy8" Content="联系方式:" HorizontalAlignment="Left" Margin="450,37,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy9" Content="职业:" HorizontalAlignment="Left" Margin="486,75,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy10" Content="通讯地址:" HorizontalAlignment="Left" Margin="450,113,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy11" Content="分类:" HorizontalAlignment="Left" Margin="486,151,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy12" Content="用户组:" HorizontalAlignment="Left" Margin="468,189,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy13" Content="备注:" HorizontalAlignment="Left" Margin="486,227,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy14" Content="姓名拼音首字母:" HorizontalAlignment="Left" Margin="58,151,0,0" VerticalAlignment="Top" FontSize="18" RenderTransformOrigin="-1.338,0.121"/>
+        <TextBox x:Name="textBoxCaseId" HorizontalAlignment="Left" Height="33" Margin="219,37,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxIdNum" HorizontalAlignment="Left" Height="33" Margin="219,75,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxName" HorizontalAlignment="Left" Height="33" Margin="219,113,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15" TextChanged="textBoxName_TextChanged"/>
+        <TextBox x:Name="textBoxPY" HorizontalAlignment="Left" Height="33" Margin="219,151,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxHeight" HorizontalAlignment="Left" Height="33" Margin="219,189,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxWeight" HorizontalAlignment="Left" Height="33" Margin="219,227,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxBaseHartrate" HorizontalAlignment="Left" Height="33" Margin="219,265,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxPregnancyTimes" HorizontalAlignment="Left" Height="33" Margin="219,303,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxBirthTimes" HorizontalAlignment="Left" Height="33" Margin="219,341,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <DatePicker x:Name="textBoxPregnancyDate" SelectedDateFormat="Short" FirstDayOfWeek="Monday" IsTodayHighlighted="True" Margin="219,379,382,157">
+        </DatePicker>
+        <TextBox x:Name="textBoxMobile" HorizontalAlignment="Left" Height="33" Margin="555,37,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxProfession" HorizontalAlignment="Left" Height="33" Margin="555,75,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxAddress" HorizontalAlignment="Left" Height="33" Margin="555,113,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxCategory" HorizontalAlignment="Left" Height="33" Margin="555,151,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxGroup" HorizontalAlignment="Left" Height="33" Margin="555,189,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxDescription" HorizontalAlignment="Left" Height="33" Margin="555,227,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <Label x:Name="label_Copy15" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="93,37,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy16" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="93,75,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy17" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,113,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy18" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="39,151,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy19" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,189,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy20" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,227,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy21" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="93,265,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy22" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,303,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy23" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,341,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy24" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="88,374,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy25" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="627,303,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy26" Content="带" HorizontalAlignment="Left" Margin="599,303,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy27" Content="的为必填项" HorizontalAlignment="Left" Margin="646,303,0,0" VerticalAlignment="Top" FontSize="18"/>
+
+    </Grid>
+</Window>

+ 247 - 0
WpfTest1/SmallDialogs/AddPatient.xaml.cs

@@ -0,0 +1,247 @@
+using MahApps.Metro.Controls.Dialogs;
+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;
+using WpfTest1.Toolkits;
+
+namespace WpfTest1
+{
+    /// <summary>
+    /// AddPatient.xaml 为病例管理功能中添加病例的界面和逻辑
+    /// </summary>
+    public partial class AddPatient : Window
+    {
+        MainWindow father;
+        public AddPatient(MainWindow father)
+        {
+            this.father = father;
+            InitializeComponent();
+        }
+
+        //每输一个姓名摘取其拼音缩写
+        private void textBoxName_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            string source_text = textBoxName.Text;
+            string result_PY = "";
+            for (int i = 0;i<source_text.Length;i++)
+            {
+                result_PY += Toolkits.StringToPY.GetCharSpellCode(Convert.ToString(source_text[i]));
+            }
+            textBoxPY.Text = result_PY;
+        }
+
+        //取消按钮
+        private void buttonAddPatinetcCancel_Click(object sender, RoutedEventArgs e)
+        {
+            MessageBoxResult dr = MessageBox.Show("是否放弃添加?", "提示", MessageBoxButton.OKCancel);
+            if (dr == MessageBoxResult.OK)
+            {
+                this.Close();
+            }
+            else if (dr == MessageBoxResult.Cancel)
+            {
+                return;
+            }
+            //this.Close();
+        }
+
+        //重置按钮
+        private void buttonAddPatinetcReset_Click(object sender, RoutedEventArgs e)
+        {
+            this.doResetInfo();
+        }
+
+        //重置执行的内容
+        private void doResetInfo()
+        {
+            textBoxCaseId.Text = "";
+            textBoxIdNum.Text = "";
+            textBoxName.Text = "";
+            textBoxPY.Text = "";
+            textBoxHeight.Text = "";
+            textBoxWeight.Text = "";
+            textBoxBaseHartrate.Text = "";
+            textBoxPregnancyTimes.Text = "";
+            textBoxBirthTimes.Text = "";
+            textBoxPregnancyDate.Text = "";
+            textBoxMobile.Text = "";
+            textBoxProfession.Text = "";
+            textBoxAddress.Text = "";
+            textBoxCategory.Text = "";
+            textBoxGroup.Text = "";
+            textBoxDescription.Text = "";
+        }
+
+        //提交按钮
+        private void buttonAddPatinetcSubmit_Click(object sender, RoutedEventArgs e)
+        {
+            if(textBoxCaseId.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxCaseId.Focus();
+                return;
+            }
+            if (textBoxIdNum.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxIdNum.Focus();
+                return;
+            }
+            if (textBoxIdNum.Text.Length != 18 || !(textBoxIdNum.Text.Substring(6, 2) == "19" || textBoxIdNum.Text.Substring(6, 2) == "20"))
+            {
+                MessageBox.Show("身份证信息异常");
+                textBoxIdNum.Focus();
+                return;
+            }
+            if (textBoxName.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxName.Focus();
+                return;
+            }
+            if (textBoxPY.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxPY.Focus();
+                return;
+            }
+            if (textBoxHeight.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxHeight.Focus();
+                return;
+            }
+            if (textBoxWeight.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxWeight.Focus();
+                return;
+            }
+            if (textBoxBaseHartrate.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxBaseHartrate.Focus();
+                return;
+            }
+            if (textBoxPregnancyTimes.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxPregnancyTimes.Focus();
+                return;
+            }
+            if (textBoxBirthTimes.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxBirthTimes.Focus();
+                return;
+            }
+            if (textBoxPregnancyDate.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxPregnancyDate.Focus();
+                return;
+            }
+
+            //筛选通过后调用数据库进行存储
+            string record_id = FilterDangerousCharacter.filter(textBoxCaseId.Text);
+            string idnum = FilterDangerousCharacter.filter(textBoxIdNum.Text);
+            string name = FilterDangerousCharacter.filter(textBoxName.Text);
+            string py = FilterDangerousCharacter.filter(textBoxPY.Text);
+            string height = FilterDangerousCharacter.filter(textBoxHeight.Text);
+            string weight = FilterDangerousCharacter.filter(textBoxWeight.Text);
+            string baseheartrate = FilterDangerousCharacter.filter(textBoxBaseHartrate.Text);
+            string pregnancytimes = FilterDangerousCharacter.filter(textBoxPregnancyTimes.Text);
+            string birthtimes = FilterDangerousCharacter.filter(textBoxBirthTimes.Text);
+            string pregnancydate = FilterDangerousCharacter.filter(textBoxPregnancyDate.Text);
+            DateTime dt;
+            System.Globalization.DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();
+            //MessageBox.Show(pregnancydate);
+            dtFormat.ShortDatePattern = "yyyy/M/d";
+            dt = Convert.ToDateTime(pregnancydate, dtFormat);
+            string mobile = FilterDangerousCharacter.filter(textBoxMobile.Text);
+            string profession = FilterDangerousCharacter.filter(textBoxProfession.Text);
+            string address = FilterDangerousCharacter.filter(textBoxAddress.Text);
+            string category = FilterDangerousCharacter.filter(textBoxCategory.Text);
+            string group = FilterDangerousCharacter.filter(textBoxGroup.Text);
+            string description = FilterDangerousCharacter.filter(textBoxDescription.Text);
+            //通过身份证号计算出生日期
+            string birthday = textBoxIdNum.Text.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)));
+
+            //string record_id = FilterDangerousCharacter.filter(textBoxCaseId.Text);
+
+            bool success_flag = true;
+            try
+            {
+                if(SQLite.SQLiteModel.checkRepeatPatient(idnum, record_id))
+                {
+                    MessageBoxResult dr = MessageBox.Show("发现数据库中存在身份证号或者病例号重复,是否继续储存?", "警告", MessageBoxButton.OKCancel);
+                    if (dr == MessageBoxResult.OK)
+                    {
+                        
+                    }
+                    else if (dr == MessageBoxResult.Cancel)
+                    {
+                        return;
+                    }
+                }
+                SQLite.SQLiteModel.InsertPatientData(record_id, 
+                                                     idnum, 
+                                                     name, 
+                                                     Convert.ToDouble(height), 
+                                                     Convert.ToDouble(weight), 
+                                                     Convert.ToInt32(baseheartrate), 
+                                                     Convert.ToInt32(pregnancytimes), 
+                                                     Convert.ToInt32(birthtimes),
+                                                     dt, 
+                                                     mobile, 
+                                                     profession, 
+                                                     address, 
+                                                     category, 
+                                                     group, 
+                                                     py, 
+                                                     description, 
+                                                     DateTime.MinValue, 
+                                                     false,
+                                                     birthdayDate);
+
+            }catch(Exception err)
+            {
+                success_flag = false;
+                MessageBox.Show("数据库错误.\r\n调试信息:" + err.Message, "错误");
+            }
+            if(success_flag)
+            {
+                //MessageBox.Show("插入成功", "提示");
+                //father.selectUserPatientManagent.LoadDataGrid();
+                //father.selectUserMeasure.LoadDataGrid();
+                //father.selectUserHistory.LoadDataGrid();
+                MessageBoxResult dr = MessageBox.Show("插入成功,是否继续添加?", "提示", MessageBoxButton.OKCancel);
+                if (dr == MessageBoxResult.OK)
+                {
+                    this.doResetInfo();
+                    return;
+                }
+                else if (dr == MessageBoxResult.Cancel)
+                {
+                    this.Close();
+                }
+                
+                
+            }
+            
+            
+        }
+    }
+}

+ 31 - 0
WpfTest1/SmallDialogs/LoginWindow.xaml

@@ -0,0 +1,31 @@
+<Window
+        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"
+        xmlns:Custom="http://metro.mahapps.com/winfx/xaml/controls" x:Class="WpfTest1.SmallDialogs.LoginWindow"
+        mc:Ignorable="d"
+        Title="登陆" Height="725" Width="1366"
+        WindowStartupLocation="CenterScreen"
+        >
+           
+    <!--WindowState = "Maximized"-->
+    <Grid>
+        <Grid.Background>
+            <ImageBrush ImageSource="/WpfTest1;component/Resources/loginpage.jpg" />
+        </Grid.Background>
+        <TextBox x:Name="textBoxUsername" HorizontalAlignment="Left" Height="29" Margin="850,313,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="220" Background="#BDC7D3"/>
+        <PasswordBox x:Name="textBoxPassword" HorizontalAlignment="Left" Height="29" Margin="851,364,0,0" VerticalAlignment="Top" Width="220" Background="#BDC7D3"  KeyDown="textBoxPassword_KeyDown"/>
+        <Button x:Name="buttonLogin" Content="登陆" HorizontalAlignment="Left" Margin="813,420,0,0" VerticalAlignment="Top" Width="261" Height="33" BorderBrush="Black" FontFamily="Microsoft YaHei UI Light" Click="buttonLogin_Click" Foreground="White" Custom:ButtonHelper.CornerRadius="-2" >
+            <Button.Background x:Uid="loginButtonColor">
+                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
+                    <GradientStop Color="Black" Offset="1"/>
+                    <GradientStop Color="#FF3B4147" Offset="0.098"/>
+                </LinearGradientBrush>
+            </Button.Background>
+        </Button>
+        
+        <Label x:Name="labelWrongPw" Content="用户名或密码不正确!" HorizontalAlignment="Left" Margin="881,278,0,0" VerticalAlignment="Top" Foreground="Red" Visibility="Hidden"/>
+    </Grid>
+</Window>

+ 66 - 0
WpfTest1/SmallDialogs/LoginWindow.xaml.cs

@@ -0,0 +1,66 @@
+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>
+    /// LoginWindow.xaml 的交互逻辑
+    /// </summary>
+    public partial class LoginWindow : Window
+    {
+        MainWindow mw;
+        public LoginWindow(MainWindow mw)
+        {
+            InitializeComponent();
+            this.mw = mw;
+        }
+
+        private void buttonLogin_Click(object sender, RoutedEventArgs e)
+        {
+            //调用数据库验证
+            string doctorName = textBoxUsername.Text;
+            string doctorPassword = textBoxPassword.Password;
+            string doctorPWD = Toolkits.ComputeHash.GetMD5(doctorPassword);
+            SQLite.doctor loginDoctor = SQLite.SQLiteModel.doctorLogin(doctorName, doctorPWD);
+            if (loginDoctor == null)
+            {
+                labelWrongPw.Visibility = Visibility.Visible;
+                return;
+            }
+            else
+            {
+                mw.loginDoctor = loginDoctor;
+                mw.LoadExpressionToMemory();
+                if (loginDoctor.privilege_flag != 1)
+                {
+                    //mw.tabitemOEMSetting.Visibility = Visibility.Hidden;
+                }
+                this.Close();
+            }
+        }
+
+        /// <summary>
+        /// textBoxPassword_KeyDown: 判读密码是否输入了回车的函数
+        /// </summary>
+        /// <param name="sender">默认</param>
+        /// <param name="e">默认</param>
+        private void textBoxPassword_KeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.Key == Key.Return)
+            {
+                buttonLogin_Click(sender, e);
+            }
+        }
+    }
+}

+ 34 - 0
WpfTest1/SmallDialogs/ModifyDoctor.xaml

@@ -0,0 +1,34 @@
+<Window x:Class="WpfTest1.ModifyDoctor"
+        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"
+        mc:Ignorable="d"
+       Title="修改医生信息" Height="300" Width="376.762">
+    <Grid>
+        <Label x:Name="label" Content="登录名:" HorizontalAlignment="Left" Margin="69,43,0,0" VerticalAlignment="Top" RenderTransformOrigin="1.028,0.561"/>
+        <!--<Label x:Name="label1" Content="密码:" HorizontalAlignment="Left" Margin="81,74,0,0" VerticalAlignment="Top" RenderTransformOrigin="1.401,1.055"/>
+        <Label x:Name="label_1" Content="重复密码:" HorizontalAlignment="Left" Margin="57,105,0,0" VerticalAlignment="Top"/>-->
+        <Label x:Name="label2" Content="联系电话:" HorizontalAlignment="Left" Margin="57,136,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.505,2.015"/>
+        <Label x:Name="label3" Content="是否是主任账户:" HorizontalAlignment="Left" Margin="21,178,0,0" VerticalAlignment="Top"/>
+        <CheckBox x:Name="radioButton" Content="是" HorizontalAlignment="Left" Margin="127,181,0,0" VerticalAlignment="Top"/>
+        <TextBox x:Name="name" HorizontalAlignment="Left" Height="23" Margin="127,42,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="166"/>
+        <!--<PasswordBox x:Name="pwd" HorizontalAlignment="Left" Margin="127,73,0,0" VerticalAlignment="Top" RenderTransformOrigin="-12.438,-0.406" Width="166"/>
+        <PasswordBox x:Name="pwd_1" HorizontalAlignment="Left" Margin="127,104,0,0" VerticalAlignment="Top" RenderTransformOrigin="-12.438,-0.406" Width="166"/>-->
+        <TextBox x:Name="phone" HorizontalAlignment="Left" Height="23" Margin="127,135,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="166"/>
+        <Button x:Name="button_modify" Content="修改" HorizontalAlignment="Left" Margin="47,220,0,0" VerticalAlignment="Top" Width="75" Click="modifyButtonClick" RenderTransformOrigin="0.544,1.606"/>
+        <Button x:Name="button_reset" Content="重置" HorizontalAlignment="Left" Margin="152,220,0,0" VerticalAlignment="Top" Width="75" Click="resetButtonClick"/>
+        <Button x:Name="button_cancel" Content="取消" HorizontalAlignment="Left" Margin="260,220,0,0" VerticalAlignment="Top" Width="75" Click="cancelButtonClick"/>
+
+
+        <!--<Label x:Name="label_Copy1" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="71,74,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy2" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="47,105,0,0" VerticalAlignment="Top" FontSize="18" RenderTransformOrigin="0.665,0.716"/>-->
+        <Label x:Name="label_Copy3" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="47,136,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy4" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="57,42,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy" Content="带" HorizontalAlignment="Left" Margin="224,178,0,0" VerticalAlignment="Top" FontSize="12" Height="25" Width="22" RenderTransformOrigin="1.281,0.534"/>
+        <Label x:Name="label_Copy_1" Content="的为必填项" HorizontalAlignment="Left" Margin="251,178,0,0" VerticalAlignment="Top" FontSize="12" Height="25" Width="75" RenderTransformOrigin="1.281,0.534"/>
+        <Label x:Name="label_Copy5" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="241,176,0,0" VerticalAlignment="Top" FontSize="18" RenderTransformOrigin="1.22,0.399"/>
+
+    </Grid>
+</Window>

+ 175 - 0
WpfTest1/SmallDialogs/ModifyDoctor.xaml.cs

@@ -0,0 +1,175 @@
+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;
+using WpfTest1.Toolkits;
+
+namespace WpfTest1
+{
+    /// <summary>
+    /// ModifyDoctor.xaml 的交互逻辑
+    /// </summary>
+    public partial class ModifyDoctor : Window
+    {
+        string id;
+        SQLite.doctor target;
+        MainWindow father;
+        //int check = 0;
+        public ModifyDoctor(MainWindow father, string id)
+        {
+            this.father = father;
+            InitializeComponent();
+            this.id = id;
+            if (id == "")
+            {
+                MessageBox.Show("未查找到该医生记录", "错误");
+                this.Close();
+            }
+            this.id = id;
+            try
+            {
+                target = SQLite.SQLiteModel.getDoctorById(id);
+                if (target == null)
+                {
+                    MessageBox.Show("未查找到该医生记录", "错误");
+                    this.Close();
+                }
+                else
+                {
+                    //查找完毕开始填充
+                    fillBlanks();
+                }
+            }
+            catch (Exception err)
+            {
+                MessageBox.Show("数据库错误\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误");
+                this.Close();
+            }
+
+
+        }
+        //填充数据
+        private void fillBlanks()
+        {
+            name.Text = target.name;
+            //pwd.Password = target.pwd_hash;
+            //pwd_1.Password = target.pwd_hash;
+            phone.Text = target.phone_number;
+            if (target.director_flag == 1)
+            {
+                radioButton.IsChecked = true;
+            }
+        }
+        /*
+        private void radioButton_Checked(object sender, RoutedEventArgs e)
+        {
+            check = 1;
+        }
+        */
+        //修改按钮
+        private void modifyButtonClick(object sender, RoutedEventArgs e)
+        {
+            if (name.Text == "")
+            {
+                MessageBox.Show("请填写用户名!");
+                name.Focus();
+                return;
+            }
+            /*
+            if (pwd.Password == "")
+            {
+                MessageBox.Show("请填写密码!");
+                pwd.Focus();
+                return;
+            }
+            if (pwd_1.Password == "")
+            {
+                MessageBox.Show("请填写确认密码!");
+                pwd_1.Focus();
+                return;
+            }
+            */
+            if (phone.Text == "")
+            {
+                MessageBox.Show("请填写联系电话!");
+                phone.Focus();
+                return;
+            }
+            /*
+            if (pwd_1.Password != pwd.Password)
+            {
+                MessageBox.Show("两次输入的密码不一致,请重新输入!");
+                pwd.Focus();
+                return;
+            }
+            */
+            string doctor_name = FilterDangerousCharacter.filter(name.Text);
+            //string doctor_pwd = Toolkits.ComputeHash.GetMD5(FilterDangerousCharacter.filter(pwd.Password));
+            string doctor_phone = FilterDangerousCharacter.filter(phone.Text);
+            int doctor_dir_flag = 0;
+            if ((Boolean)(radioButton.IsChecked)) doctor_dir_flag = 1;
+            int doctor_del_flag = 0;
+
+            bool success_flag = true;
+            try
+            {//防止修改之后和其他数据的name重复
+                if (doctor_name != target.name)
+                {
+                    if (SQLite.SQLiteModel.checkRepeatDoctor(doctor_name))
+                    {
+                        MessageBox.Show("用户名选择重复,请选择新的用户名!");
+                        name.Focus();
+                        return;
+                    }
+                }
+
+                SQLite.SQLiteModel.UpdateDoctorData(id,
+                                                     doctor_name,
+                                                     target.pwd_hash,
+                                                     doctor_phone,
+                                                     Convert.ToBoolean(doctor_dir_flag),
+                                                     Convert.ToBoolean(doctor_del_flag)
+                                                     );
+            }
+            catch (Exception err)
+            {
+                success_flag = false;
+                MessageBox.Show("数据库错误.\r\n调试信息:" + err.Message, "错误");
+            }
+            if (success_flag)
+            {
+                MessageBox.Show("修改医生信息成功", "提示");
+                father.LoadDoctorDataGrid();
+                this.Close();
+            }
+        }
+        //重置按钮
+        private void resetButtonClick(object sender, RoutedEventArgs e)
+        {
+            fillBlanks();
+        }
+        //取消按钮
+        private void cancelButtonClick(object sender, RoutedEventArgs e)
+        {
+            MessageBoxResult dr = MessageBox.Show("是否放弃添加?", "提示", MessageBoxButton.OKCancel);
+            if (dr == MessageBoxResult.OK)
+            {
+                this.Close();
+            }
+            else if (dr == MessageBoxResult.Cancel)
+            {
+                return;
+            }
+            //this.Close();
+        }
+    }
+}

+ 21 - 0
WpfTest1/SmallDialogs/ModifyDoctorPWD.xaml

@@ -0,0 +1,21 @@
+<Window x:Class="WpfTest1.ModifyDoctorPWD"
+        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"
+        mc:Ignorable="d"
+        Title="修改医师密码" Height="300" Width="500">
+    <Grid>
+        <Label x:Name="label" Content="新密码:" FontSize="18" HorizontalAlignment="Left" Margin="10,42,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="label2" Content="重复新密码:" FontSize="18" HorizontalAlignment="Left" Margin="10,80,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="label2_Copy" Content="密码支持大小写字母和不含单引号、双引号的符号" FontSize="13" HorizontalAlignment="Left" Margin="161,144,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="label2_Copy1" Foreground="Blue" Content="*" FontSize="18" HorizontalAlignment="Left" Margin="143,144,0,0" VerticalAlignment="Top"/>
+        <PasswordBox x:Name="passwordBoxNewPWD" HorizontalAlignment="Left" Height="33" Margin="143,42,0,0" FontSize="18" VerticalAlignment="Top" Width="314"/>
+        <PasswordBox x:Name="passwordBoxRepeatBox" HorizontalAlignment="Left" Margin="143,81,0,0" VerticalAlignment="Top"  FontSize="18" Width="314"/>
+        <Button x:Name="buttonSubmit" Content="修改" FontSize="18" HorizontalAlignment="Left" Margin="143,222,0,0" VerticalAlignment="Top" Width="93" Height="37" Click="buttonSubmit_Click"/>
+        <Button x:Name="buttonCancel" Content="取消" FontSize="18" HorizontalAlignment="Left" Margin="258,222,0,0" VerticalAlignment="Top" Width="96" Click="buttonCancel_Click"/>
+
+
+    </Grid>
+</Window>

+ 95 - 0
WpfTest1/SmallDialogs/ModifyDoctorPWD.xaml.cs

@@ -0,0 +1,95 @@
+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;
+using WpfTest1.SQLite;
+
+namespace WpfTest1
+{
+    /// <summary>
+    /// ModifyDoctorPWD.xaml 的交互逻辑
+    /// </summary>
+    public partial class ModifyDoctorPWD : Window
+    {
+        string id;
+        MainWindow father;
+        doctor target;
+        public ModifyDoctorPWD(MainWindow father,string id)
+        {
+            InitializeComponent();
+            this.father = father;
+            if (id == "")
+            {
+                MessageBox.Show("未查找到该记录", "错误");
+                this.Close();
+            }
+            this.id = id;
+            try
+            {
+                target = SQLite.SQLiteModel.getDoctorById(id);
+                if (target == null)
+                {
+                    MessageBox.Show("未查找到该记录", "错误");
+                    this.Close();
+                }
+            }
+            catch (Exception err)
+            {
+                MessageBox.Show("数据库错误\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误");
+                this.Close();
+            }
+        }
+
+        private void buttonSubmit_Click(object sender, RoutedEventArgs e)
+        {
+            if(passwordBoxNewPWD.Password != passwordBoxRepeatBox.Password)
+            {
+                MessageBox.Show("两次输入密码不一致","提示");
+                return;
+            }
+            else
+            {
+                bool success_flag = true;
+                try
+                {
+                    string pwdHash = Toolkits.ComputeHash.GetMD5(Toolkits.FilterDangerousCharacter.filter(passwordBoxNewPWD.Password));
+                    bool director_flag = target.director_flag == 1 ? true : false;
+                    SQLiteModel.UpdateDoctorData(target.id.ToString(), target.name, pwdHash, target.phone_number, director_flag, false);
+                }
+                catch(Exception err)
+                {
+                    success_flag = false;
+                    MessageBox.Show("数据库故障\r\n调试信息:"+err.StackTrace,"错误");
+                }
+                if (success_flag)
+                {
+                    MessageBox.Show("修改成功","提示");
+                    this.Close();
+                }
+                
+            }
+        }
+
+        private void buttonCancel_Click(object sender, RoutedEventArgs e)
+        {
+            MessageBoxResult dr = MessageBox.Show("是否放弃添加?", "提示", MessageBoxButton.OKCancel);
+            if (dr == MessageBoxResult.OK)
+            {
+                this.Close();
+            }
+            else if (dr == MessageBoxResult.Cancel)
+            {
+                return;
+            }
+        }
+    }
+}

+ 65 - 0
WpfTest1/SmallDialogs/ModifyUser.xaml

@@ -0,0 +1,65 @@
+<Window x:Class="WpfTest1.ModifyUser"
+        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"
+        mc:Ignorable="d"
+        Title="修改病例" Height="600" Width="800">
+    <Grid Margin="0,0,-0,-0">
+        <Button x:Name="buttonAddPatinetcSubmit" Content="修改" HorizontalAlignment="Left" Margin="160,502,0,0" VerticalAlignment="Top" Width="130" Height="40" FontSize="18" Click="buttonAddPatinetcSubmit_Click"/>
+        <Button x:Name="buttonAddPatinetcReset" Content="重置" HorizontalAlignment="Left" Margin="334,502,0,0" VerticalAlignment="Top" Width="130" Height="40" FontSize="18" Click="buttonAddPatinetcReset_Click"/>
+        <Button x:Name="buttonAddPatinetcCancel" Content="取消" HorizontalAlignment="Left" Margin="511,502,0,0" VerticalAlignment="Top" Width="130" Height="40" FontSize="18" Click="buttonAddPatinetcCancel_Click"/>
+        <Label x:Name="label" Content="病例编号:" HorizontalAlignment="Left" Margin="112,37,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy" Content="身份证号:" HorizontalAlignment="Left" Margin="112,75,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy1" Content="姓名:" HorizontalAlignment="Left" Margin="148,113,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy2" Content="身高:" HorizontalAlignment="Left" Margin="148,189,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy3" Content="体重:" HorizontalAlignment="Left" Margin="148,227,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy4" Content="静息心率:" HorizontalAlignment="Left" Margin="112,265,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy5" Content="孕次:" HorizontalAlignment="Left" Margin="148,303,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy6" Content="产次:" HorizontalAlignment="Left" Margin="148,341,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy7" Content="受孕日期:" HorizontalAlignment="Left" Margin="112,374,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy8" Content="联系方式:" HorizontalAlignment="Left" Margin="450,37,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy9" Content="职业:" HorizontalAlignment="Left" Margin="486,75,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy10" Content="通讯地址:" HorizontalAlignment="Left" Margin="450,113,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy11" Content="分类:" HorizontalAlignment="Left" Margin="486,151,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy12" Content="用户组:" HorizontalAlignment="Left" Margin="468,189,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy13" Content="备注:" HorizontalAlignment="Left" Margin="486,227,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy14" Content="姓名拼音首字母:" HorizontalAlignment="Left" Margin="58,151,0,0" VerticalAlignment="Top" FontSize="18" RenderTransformOrigin="-1.338,0.121"/>
+        <TextBox x:Name="textBoxCaseId" HorizontalAlignment="Left" Height="33" Margin="219,37,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxIdNum" HorizontalAlignment="Left" Height="33" Margin="219,75,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxName" HorizontalAlignment="Left" Height="33" Margin="219,113,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15" TextChanged="textBoxName_TextChanged"/>
+        <TextBox x:Name="textBoxPY" HorizontalAlignment="Left" Height="33" Margin="219,151,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxHeight" HorizontalAlignment="Left" Height="33" Margin="219,189,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxWeight" HorizontalAlignment="Left" Height="33" Margin="219,227,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxBaseHartrate" HorizontalAlignment="Left" Height="33" Margin="219,265,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxPregnancyTimes" HorizontalAlignment="Left" Height="33" Margin="219,303,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxBirthTimes" HorizontalAlignment="Left" Height="33" Margin="219,341,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <DatePicker x:Name="textBoxPregnancyDate" SelectedDateFormat="Short" FirstDayOfWeek="Monday" IsTodayHighlighted="True" Margin="219,379,382,157">
+        </DatePicker>
+        <TextBox x:Name="textBoxMobile" HorizontalAlignment="Left" Height="33" Margin="555,37,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxProfession" HorizontalAlignment="Left" Height="33" Margin="555,75,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxAddress" HorizontalAlignment="Left" Height="33" Margin="555,113,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxCategory" HorizontalAlignment="Left" Height="33" Margin="555,151,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxGroup" HorizontalAlignment="Left" Height="33" Margin="555,189,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <TextBox x:Name="textBoxDescription" HorizontalAlignment="Left" Height="33" Margin="555,227,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="191" FontSize="15"/>
+        <Label x:Name="label_Copy15" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="93,37,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy16" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="93,75,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy17" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,113,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy18" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="39,151,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy19" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,189,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy20" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,227,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy21" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="93,265,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy22" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,303,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy23" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="129,341,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy24" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="93,374,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy25" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="627,303,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy26" Content="带" HorizontalAlignment="Left" Margin="599,303,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy27" Content="的为必填项" HorizontalAlignment="Left" Margin="646,303,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <RadioButton x:Name="radioButtonModify" Content="勘误(这样会修改原来病例的信息)" GroupName="updateOption" IsChecked="True" HorizontalAlignment="Left" Margin="234,439,0,0" VerticalAlignment="Top"/>
+        <RadioButton x:Name="radioButtonAdd" Content="病例因流产等原因需要重建(这样会新增一个有着相同身份信息的新病例)" GroupName="updateOption" HorizontalAlignment="Left" Margin="234,462,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="label_Copy28" Content="修改原因:" HorizontalAlignment="Left" Margin="112,439,0,0" VerticalAlignment="Top" FontSize="18"/>
+        <Label x:Name="label_Copy29" Content="*" HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Margin="88,439,0,0" VerticalAlignment="Top" FontSize="18"/>
+
+    </Grid>
+</Window>

+ 282 - 0
WpfTest1/SmallDialogs/ModifyUser.xaml.cs

@@ -0,0 +1,282 @@
+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;
+using WpfTest1.Toolkits;
+
+namespace WpfTest1
+{
+    /// <summary>
+    /// ModifyUser.xaml 的交互逻辑
+    /// </summary>
+    public partial class ModifyUser : Window
+    {
+        string id;
+        MainWindow father;
+        SQLite.Patient target;
+        //构造函数,首先查找所需要修改的记录并填充,之后修改
+        public ModifyUser(MainWindow father,string id)
+        {
+            InitializeComponent();
+            this.father = father;
+            if (id == "")
+            {
+                MessageBox.Show("未查找到该记录", "错误");
+                this.Close();
+            }
+            this.id = id;
+            try
+            {
+                target = SQLite.SQLiteModel.getPatientById(id);
+                if(target == null)
+                {
+                    MessageBox.Show("未查找到该记录", "错误");
+                    this.Close();
+                }
+            }catch(Exception err)
+            {
+                MessageBox.Show("数据库错误\r\n调试信息:"+err.Message+"\r\n"+err.StackTrace, "错误");
+                this.Close();
+            }
+
+            //查找完毕开始填充
+            fillBlanks();
+            
+        }
+
+        //用系统中的Patient target 填充所有空格
+        private void fillBlanks()
+        {
+            textBoxCaseId.Text = target.record_id;
+            textBoxIdNum.Text = target.idNum;
+            textBoxName.Text = target.name;
+            textBoxPY.Text = target.firstLetterPY;
+            textBoxHeight.Text = target.height.ToString();
+            textBoxWeight.Text = target.weight.ToString();
+            textBoxBaseHartrate.Text = target.base_heartrate.ToString();
+            textBoxPregnancyTimes.Text = target.pregnancy_times.ToString();
+            textBoxBirthTimes.Text = target.birth_times.ToString();
+            textBoxPregnancyDate.Text = target.pregnancy_date.ToString("yyyy/M/d");
+            textBoxMobile.Text = target.mobile;
+            textBoxProfession.Text = target.profession;
+            textBoxAddress.Text = target.address;
+            textBoxCategory.Text = target.category;
+            textBoxGroup.Text = target.group_1;
+            textBoxDescription.Text = target.description;
+        }
+
+        //每输一个姓名摘取其拼音缩写
+        private void textBoxName_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            string source_text = textBoxName.Text;
+            string result_PY = "";
+            for (int i = 0; i < source_text.Length; i++)
+            {
+                result_PY += Toolkits.StringToPY.GetCharSpellCode(Convert.ToString(source_text[i]));
+            }
+            textBoxPY.Text = result_PY;
+        }
+
+        private void buttonAddPatinetcSubmit_Click(object sender, RoutedEventArgs e)
+        {
+            if (textBoxCaseId.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxCaseId.Focus();
+                return;
+            }
+            if (textBoxIdNum.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxIdNum.Focus();
+                return;
+            }
+            if (textBoxIdNum.Text.Length != 18 || !(textBoxIdNum.Text.Substring(6, 2) == "19" || textBoxIdNum.Text.Substring(6, 2) == "20"))
+            {
+                MessageBox.Show("身份证信息异常");
+                textBoxIdNum.Focus();
+                return;
+            }
+            if (textBoxName.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxName.Focus();
+                return;
+            }
+            if (textBoxPY.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxPY.Focus();
+                return;
+            }
+            if (textBoxHeight.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxHeight.Focus();
+                return;
+            }
+            if (textBoxWeight.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxWeight.Focus();
+                return;
+            }
+            if (textBoxBaseHartrate.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxBaseHartrate.Focus();
+                return;
+            }
+            if (textBoxPregnancyTimes.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxPregnancyTimes.Focus();
+                return;
+            }
+            if (textBoxBirthTimes.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxBirthTimes.Focus();
+                return;
+            }
+            if (textBoxPregnancyDate.Text == "")
+            {
+                MessageBox.Show("必要信息未填写");
+                textBoxPregnancyDate.Focus();
+                return;
+            }
+
+            //筛选通过后调用数据库进行存储
+            string record_id = FilterDangerousCharacter.filter(textBoxCaseId.Text);
+            string idnum = FilterDangerousCharacter.filter(textBoxIdNum.Text);
+            string name = FilterDangerousCharacter.filter(textBoxName.Text);
+            string py = FilterDangerousCharacter.filter(textBoxPY.Text);
+            string height = FilterDangerousCharacter.filter(textBoxHeight.Text);
+            string weight = FilterDangerousCharacter.filter(textBoxWeight.Text);
+            string baseheartrate = FilterDangerousCharacter.filter(textBoxBaseHartrate.Text);
+            string pregnancytimes = FilterDangerousCharacter.filter(textBoxPregnancyTimes.Text);
+            string birthtimes = FilterDangerousCharacter.filter(textBoxBirthTimes.Text);
+            string pregnancydate = FilterDangerousCharacter.filter(textBoxPregnancyDate.Text);
+            DateTime dt;
+            System.Globalization.DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();
+            //MessageBox.Show(pregnancydate);
+            dtFormat.ShortDatePattern = "yyyy/M/d";
+            dt = Convert.ToDateTime(pregnancydate, dtFormat);
+            string mobile = FilterDangerousCharacter.filter(textBoxMobile.Text);
+            string profession = FilterDangerousCharacter.filter(textBoxProfession.Text);
+            string address = FilterDangerousCharacter.filter(textBoxAddress.Text);
+            string category = FilterDangerousCharacter.filter(textBoxCategory.Text);
+            string group = FilterDangerousCharacter.filter(textBoxGroup.Text);
+            string description = FilterDangerousCharacter.filter(textBoxDescription.Text);
+            //string record_id = FilterDangerousCharacter.filter(textBoxCaseId.Text);
+            //通过身份证号计算出生日期
+            string birthday = textBoxIdNum.Text.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)));
+
+            bool success_flag = true;
+            try
+            {
+                //首先检查修改原因再决定执行更新还是插入
+                if(radioButtonModify.IsChecked == true)
+                {
+                    SQLite.SQLiteModel.UpdatePatientData(id,
+                                                     record_id,
+                                                     idnum,
+                                                     name,
+                                                     Convert.ToDouble(height),
+                                                     Convert.ToDouble(weight),
+                                                     Convert.ToInt32(baseheartrate),
+                                                     Convert.ToInt32(pregnancytimes),
+                                                     Convert.ToInt32(birthtimes),
+                                                     dt,
+                                                     mobile,
+                                                     profession,
+                                                     address,
+                                                     category,
+                                                     group,
+                                                     py,
+                                                     description,
+                                                     false, 
+                                                     birthdayDate);
+
+                }
+                else if(radioButtonAdd.IsChecked == true)
+                {
+                    if (SQLite.SQLiteModel.checkRepeatPatient(idnum, record_id))
+                    {
+                        MessageBoxResult dr = MessageBox.Show("发现数据库中存在身份证号或者病例号重复,是否继续储存?", "警告", MessageBoxButton.OKCancel);
+                        if (dr == MessageBoxResult.OK)
+                        {
+
+                        }
+                        else if (dr == MessageBoxResult.Cancel)
+                        {
+                            return;
+                        }
+                    }
+                    SQLite.SQLiteModel.InsertPatientData(record_id,
+                                                         idnum,
+                                                         name,
+                                                         Convert.ToDouble(height),
+                                                         Convert.ToDouble(weight),
+                                                         Convert.ToInt32(baseheartrate),
+                                                         Convert.ToInt32(pregnancytimes),
+                                                         Convert.ToInt32(birthtimes),
+                                                         dt,
+                                                         mobile,
+                                                         profession,
+                                                         address,
+                                                         category,
+                                                         group,
+                                                         py,
+                                                         description,
+                                                         DateTime.MinValue,
+                                                         false,
+                                                         birthdayDate
+                                                         );
+
+                }
+            }
+            catch (Exception err)
+            {
+                success_flag = false;
+                MessageBox.Show("数据库错误.\r\n调试信息:" + err.Message+"\r\n"+err.StackTrace, "错误");
+            }
+            if (success_flag)
+            {
+                MessageBox.Show("修改成功", "提示");
+                father.selectUserPatientManagent.LoadDataGrid();
+                this.Close();
+            }
+        }
+
+        //点击重置按钮的效果
+        private void buttonAddPatinetcReset_Click(object sender, RoutedEventArgs e)
+        {
+            fillBlanks();
+        }
+
+        private void buttonAddPatinetcCancel_Click(object sender, RoutedEventArgs e)
+        {
+            MessageBoxResult dr = MessageBox.Show("是否放弃修改?", "提示", MessageBoxButton.OKCancel);
+            if (dr == MessageBoxResult.OK)
+            {
+                this.Close();
+            }
+            else if (dr == MessageBoxResult.Cancel)
+            {
+                return;
+            }
+        }
+    }
+}

+ 25 - 0
WpfTest1/SmallDialogs/RegisterCode.xaml

@@ -0,0 +1,25 @@
+<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>

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

@@ -0,0 +1,94 @@
+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;
+        }
+    }
+}

+ 54 - 0
WpfTest1/Toolkits/CSVWriter.cs

@@ -0,0 +1,54 @@
+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.idNum + "_" + pa.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();
+        }
+    }
+}

+ 27 - 0
WpfTest1/Toolkits/ComputeHash.cs

@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfTest1.Toolkits
+{
+    class ComputeHash
+    {
+        public static string GetMD5(string sDataIn)
+        {
+            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
+            byte[] bytValue, bytHash;
+            bytValue = System.Text.Encoding.UTF8.GetBytes(sDataIn);
+            bytHash = md5.ComputeHash(bytValue);
+            md5.Clear();
+            string sTemp = "";
+            for (int i = 0; i < bytHash.Length; i++)
+            {
+                sTemp += bytHash[i].ToString("X").PadLeft(2, '0');
+            }
+            return sTemp.ToLower();
+        }
+    }
+}

+ 142 - 0
WpfTest1/Toolkits/Config.cs

@@ -0,0 +1,142 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml;
+
+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()
+        {
+            refresh();
+        }
+
+        public void refresh()
+        {
+            SQLite.SQLiteModel.GetAllConfigContent(middle);
+            foreach (string key in middle.Keys)
+            {
+                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;
+                    case "organization_pw":
+                        organization_pw = middle[key];
+                        break;
+                    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;
+                }
+            }
+        }
+
+        public bool CheckRegisterCode(string o_name, string o_pw,string o_code)
+        {
+            if (o_name == "" || o_pw == "" || o_code == "")
+            {
+                return false;
+            }
+            string pubkey;
+            try
+            {
+                XmlDocument xdoc = new XmlDocument();
+                string file = Toolkits.Constants.pubkeyPath;
+                xdoc.Load(file);
+                pubkey = xdoc.InnerXml;
+            }
+            catch (Exception err)
+            {
+                throw new Exception("pubkey file is error!",err);
+            }
+            
+            string result = o_name + o_pw;
+            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(1024);
+            rsa.FromXmlString(pubkey);
+            RSAPKCS1SignatureDeformatter f = new RSAPKCS1SignatureDeformatter(rsa);
+            f.SetHashAlgorithm("SHA1");
+
+            try
+            {
+                byte[] key = Convert.FromBase64String(o_code);
+
+                SHA1Managed sha = new SHA1Managed();
+                byte[] name = sha.ComputeHash(ASCIIEncoding.ASCII.GetBytes(result));
+                if (f.VerifySignature(name, key))
+                    return true;
+                else
+                    return false;
+            }
+            catch (Exception)
+            {
+                return false;
+            }
+            
+        }
+
+        public bool CheckRegisterCode()
+        {
+            return CheckRegisterCode(organization_name, organization_pw, organization_active_code);
+        }
+    }
+}

+ 59 - 0
WpfTest1/Toolkits/Constants.cs

@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfTest1.Toolkits
+{
+    //各种系统需要使用的常值
+    public class Constants
+    {
+        //数据库物理地址
+        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";
+        //报告存放目录
+        public static string reportPath = System.Environment.CurrentDirectory + "\\reports";
+        //报告生成所需要临时存放素材的目录
+        public static string tmpPath = System.Environment.CurrentDirectory + "\\tmp";
+        //各种静态素材
+        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;
+        //厂家管理员的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;
+
+    }
+}

+ 18 - 0
WpfTest1/Toolkits/FilterDangerousCharacter.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfTest1.Toolkits
+{
+    class FilterDangerousCharacter
+    {
+        public static string filter(string source)
+        {
+            string middle = source.Replace('\'',char.MinValue);
+            middle = source.Replace('\"', char.MinValue);
+            return middle;
+        }
+    }
+}

+ 51 - 0
WpfTest1/Toolkits/FilterFile.cs

@@ -0,0 +1,51 @@
+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;
+            
+        }
+    }
+}

+ 50 - 0
WpfTest1/Toolkits/MeasureHandle.cs

@@ -0,0 +1,50 @@
+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);
+        }
+    }
+}

+ 19 - 0
WpfTest1/Toolkits/OtherSmallFunction.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfTest1.Toolkits
+{
+    class OtherSmallFunction
+    {
+        public static int getAgeByBirthDay(DateTime birthDate)
+        {
+            DateTime now = DateTime.Now;
+            int age = now.Year - birthDate.Year;
+            if (now.Month < birthDate.Month || (now.Month == birthDate.Month && now.Day < birthDate.Day)) age--;
+            return age;
+        }
+    }
+}

+ 220 - 0
WpfTest1/Toolkits/RPCalculate.cs

@@ -0,0 +1,220 @@
+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.");
+                }
+            }
+            //*/
+
+        }
+}

+ 1012 - 0
WpfTest1/Toolkits/ReportGenerator.cs

@@ -0,0 +1,1012 @@
+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.idNum + "_" + patient.name + "_" + rcd.recordTime.ToString("yyyyMMddHHmmss") + ".doc";
+            String pdfFileName = path + "\\" + patient.idNum + "_" + patient.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.idNum;
+                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.id.ToString();
+                table.Cell(2, 1).Range.Text = "姓名:";
+                table.Cell(2, 2).Range.Text = patient.name;
+                table.Cell(2, 3).Range.Text = "年龄:";
+                if (patient.idNum.Length == 18)
+                {
+                    //假设身份证号合法
+                    string birthday = patient.idNum.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.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.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)
+                {
+                    ;
+                }
+            }
+
+
+        }
+    }
+}

+ 247 - 0
WpfTest1/Toolkits/SocketListener.cs

@@ -0,0 +1,247 @@
+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;
+        }
+    }
+}

+ 161 - 0
WpfTest1/Toolkits/StringToPY.cs

@@ -0,0 +1,161 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WpfTest1.Toolkits
+{
+    class StringToPY
+    {
+        ///   <summary> 
+        ///   得到一个汉字的拼音第一个字母,如果是一个英文字母则直接返回大写字母 
+        ///   </summary> 
+        ///   <param   name="CnChar">单个汉字</param> 
+        ///   <returns>单个大写字母</returns> 
+        public static string GetCharSpellCode(string CnChar)
+        {
+            long iCnChar;
+
+            byte[] ZW = System.Text.Encoding.Default.GetBytes(CnChar);
+
+            //如果是字母,则直接返回 
+            if (ZW.Length == 1)
+            {
+                return CnChar.ToUpper();
+            }
+            else
+            {
+                //   get   the     array   of   byte   from   the   single   char    
+                int i1 = (short)(ZW[0]);
+                int i2 = (short)(ZW[1]);
+                iCnChar = i1 * 256 + i2;
+            }
+            #region table   of   the   constant   list
+            //expresstion 
+            //table   of   the   constant   list 
+            // 'A';           //45217..45252 
+            // 'B';           //45253..45760 
+            // 'C';           //45761..46317 
+            // 'D';           //46318..46825 
+            // 'E';           //46826..47009 
+            // 'F';           //47010..47296 
+            // 'G';           //47297..47613 
+
+            // 'H';           //47614..48118 
+            // 'J';           //48119..49061 
+            // 'K';           //49062..49323 
+            // 'L';           //49324..49895 
+            // 'M';           //49896..50370 
+            // 'N';           //50371..50613 
+            // 'O';           //50614..50621 
+            // 'P';           //50622..50905 
+            // 'Q';           //50906..51386 
+
+            // 'R';           //51387..51445 
+            // 'S';           //51446..52217 
+            // 'T';           //52218..52697 
+            //没有U,V 
+            // 'W';           //52698..52979 
+            // 'X';           //52980..53640 
+            // 'Y';           //53689..54480 
+            // 'Z';           //54481..55289 
+            #endregion
+            //   iCnChar match     the   constant 
+            if ((iCnChar >= 45217) && (iCnChar <= 45252))
+            {
+                return "A";
+            }
+            else if ((iCnChar >= 45253) && (iCnChar <= 45760))
+            {
+                return "B";
+            }
+            else if ((iCnChar >= 45761) && (iCnChar <= 46317))
+            {
+                return "C";
+            }
+            else if ((iCnChar >= 46318) && (iCnChar <= 46825))
+            {
+                return "D";
+            }
+            else if ((iCnChar >= 46826) && (iCnChar <= 47009))
+            {
+                return "E";
+            }
+            else if ((iCnChar >= 47010) && (iCnChar <= 47296))
+            {
+                return "F";
+            }
+            else if ((iCnChar >= 47297) && (iCnChar <= 47613))
+            {
+                return "G";
+            }
+            else if ((iCnChar >= 47614) && (iCnChar <= 48118))
+            {
+                return "H";
+            }
+            else if ((iCnChar >= 48119) && (iCnChar <= 49061))
+            {
+                return "J";
+            }
+            else if ((iCnChar >= 49062) && (iCnChar <= 49323))
+            {
+                return "K";
+            }
+            else if ((iCnChar >= 49324) && (iCnChar <= 49895))
+            {
+                return "L";
+            }
+            else if ((iCnChar >= 49896) && (iCnChar <= 50370))
+            {
+                return "M";
+            }
+
+            else if ((iCnChar >= 50371) && (iCnChar <= 50613))
+            {
+                return "N";
+            }
+            else if ((iCnChar >= 50614) && (iCnChar <= 50621))
+            {
+                return "O";
+            }
+            else if ((iCnChar >= 50622) && (iCnChar <= 50905))
+            {
+                return "P";
+            }
+            else if ((iCnChar >= 50906) && (iCnChar <= .51386))
+            {
+                return "Q";
+            }
+            else if ((iCnChar >= 51387) && (iCnChar <= 51445))
+            {
+                return "R";
+            }
+            else if ((iCnChar >= 51446) && (iCnChar <= 52217))
+            {
+                return "S";
+            }
+            else if ((iCnChar >= 52218) && (iCnChar <= 52697))
+            {
+                return "T";
+            }
+            else if ((iCnChar >= 52698) && (iCnChar <= 52979))
+            {
+                return "W";
+            }
+            else if ((iCnChar >= 52980) && (iCnChar <= 53640))
+            {
+                return "X";
+            }
+            else if ((iCnChar >= 53689) && (iCnChar <= 54480))
+            {
+                return "Y";
+            }
+            else if ((iCnChar >= 54481) && (iCnChar <= 55289))
+            {
+                return "Z";
+            }
+            else return ("?");
+        }
+    }
+}

+ 238 - 0
WpfTest1/Toolkits/WaveHandle.cs

@@ -0,0 +1,238 @@
+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;
+        }
+    }
+}

+ 81 - 0
WpfTest1/Toolkits/WaveSimulator.cs

@@ -0,0 +1,81 @@
+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;
+        }
+    }
+}

+ 359 - 0
WpfTest1/WpTest.csproj

@@ -0,0 +1,359 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{FFCACC68-37D0-4628-9B0C-A6FCA5DCCF58}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>WpfTest1</RootNamespace>
+    <AssemblyName>WpfTest1</AssemblyName>
+    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <WarningLevel>4</WarningLevel>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
+      <HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="Ciloci.Flee">
+      <HintPath>..\RPdlls\Ciloci.Flee.dll</HintPath>
+    </Reference>
+    <Reference Include="ControlzEx, Version=3.0.2.4, Culture=neutral, processorArchitecture=MSIL">
+      <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>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro, Version=1.5.0.23, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.BoxIcons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.BoxIcons.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.Core.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.Entypo, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.Entypo.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.EvaIcons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.EvaIcons.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.FeatherIcons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.FeatherIcons.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.FontAwesome, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.FontAwesome.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.Ionicons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.Ionicons.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.JamIcons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.JamIcons.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.Material, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.Material.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.MaterialDesign, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.MaterialDesign.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.MaterialLight, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.MaterialLight.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.Microns, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.Microns.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.Modern, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.Modern.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.Octicons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.Octicons.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.PicolIcons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.PicolIcons.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.RPGAwesome, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.RPGAwesome.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.SimpleIcons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.SimpleIcons.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.Typicons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.Typicons.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.Unicons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.Unicons.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.WeatherIcons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.WeatherIcons.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="MahApps.Metro.IconPacks.Zondicons, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MahApps.Metro.IconPacks.3.2.0\lib\net45\MahApps.Metro.IconPacks.Zondicons.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="Microsoft.Office.Interop.Word, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+      <HintPath>C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Word\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Data.SQLite, Version=1.0.86.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\WpTest\WpfTest1\SQLite\System.Data.SQLite.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\ControlzEx.3.0.2.4\lib\net45\System.Windows.Interactivity.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="System.Xml" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xaml">
+      <RequiredTargetFramework>4.0</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="WindowsBase" />
+    <Reference Include="PresentationCore" />
+    <Reference Include="PresentationFramework" />
+    <Reference Include="WindowsFormsIntegration" />
+    <Reference Include="ZedGraph">
+      <HintPath>..\ZedGraph5.1\source\bin\Debug\ZedGraph.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <ApplicationDefinition Include="App.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </ApplicationDefinition>
+    <Compile Include="Exceptions\SplitException.cs" />
+    <Compile Include="PatientInfoShort.xaml.cs">
+      <DependentUpon>PatientInfoShort.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\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="SmallDialogs\AddDoctor.xaml.cs">
+      <DependentUpon>AddDoctor.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="SmallDialogs\AddPatient.xaml.cs">
+      <DependentUpon>AddPatient.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="SmallDialogs\ModifyDoctor.xaml.cs">
+      <DependentUpon>ModifyDoctor.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="SmallDialogs\ModifyDoctorPWD.xaml.cs">
+      <DependentUpon>ModifyDoctorPWD.xaml</DependentUpon>
+    </Compile>
+    <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>
+    <Compile Include="SQLite\CommonWords.cs" />
+    <Compile Include="SQLite\doctor.cs" />
+    <Compile Include="SQLite\Expression.cs" />
+    <Compile Include="SQLite\Patient.cs" />
+    <Compile Include="SQLite\Record.cs" />
+    <Compile Include="SQLite\SQLiteHelper.cs" />
+    <Compile Include="SQLite\SQLiteLogic.cs" />
+    <Compile Include="SQLite\SQLiteModel.cs" />
+    <Compile Include="Toolkits\ComputeHash.cs" />
+    <Compile Include="Toolkits\Constants.cs" />
+    <Compile Include="Toolkits\FilterDangerousCharacter.cs" />
+    <Compile Include="Toolkits\OtherSmallFunction.cs" />
+    <Compile Include="Toolkits\StringToPY.cs" />
+    <Page Include="PatientInfoShort.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="SmallDialogs\LoginWindow.xaml">
+      <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>
+    </Page>
+    <Page Include="SmallDialogs\AddPatient.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="MainWindow.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
+    <Compile Include="App.xaml.cs">
+      <DependentUpon>App.xaml</DependentUpon>
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="MainWindow.xaml.cs">
+      <DependentUpon>MainWindow.xaml</DependentUpon>
+      <SubType>Code</SubType>
+    </Compile>
+    <Page Include="SmallDialogs\ModifyDoctor.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="SmallDialogs\ModifyDoctorPWD.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="SmallDialogs\ModifyUser.xaml">
+      <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>
+    </Page>
+    <Page Include="Resources\IconsNonShared.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
+    <Page Include="selectUser.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs">
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>Resources.resx</DependentUpon>
+    </Compile>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+    </EmbeddedResource>
+    <None Include="packages.config">
+      <SubType>Designer</SubType>
+    </None>
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+    <AppDesigner Include="Properties\" />
+    <Resource Include="Resources\Entypo.ttf" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Resources\WindowsIcons-license.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Resources\Entypo-license.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Resources\RPStandard.jpg" />
+    <Resource Include="Resources\pubkey.xml" />
+    <Resource Include="Resources\load.jpg" />
+    <Resource Include="Resources\loginpage.jpg" />
+    <Resource Include="Resources\homepage.jpg" />
+    <Content Include="SQLite\System.Data.SQLite.dll" />
+  </ItemGroup>
+  <ItemGroup>
+    <WCFMetadata Include="Service References\" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 9 - 0
WpfTest1/packages.config

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<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="MahApps.Metro" version="1.5.0" targetFramework="net452" />
+  <package id="MahApps.Metro.IconPacks" version="3.2.0" targetFramework="net452" />
+  <package id="MahApps.Metro.Resources" version="0.6.1.0" targetFramework="net452" />
+</packages>

+ 74 - 0
WpfTest1/selectUser.xaml

@@ -0,0 +1,74 @@
+<UserControl x:Class="WpfTest1.selectUser"
+             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"
+             mc:Ignorable="d" Height="600" Width="1300">
+
+    <Grid Background="White" Margin="0,0,0,0">
+        <DataGrid x:Name="dataGrid"  Loaded="dataGrid_Loaded" AutoGenerateColumns="False" HorizontalAlignment="Left" Margin="314,10,0,0" VerticalAlignment="Top" Height="580" Width="976" IsReadOnly="True" MouseDoubleClick="dataGrid_MouseDoubleClick">
+            <DataGrid.Columns>
+                <!---->
+                <DataGridTextColumn Header="病例编号" Binding="{Binding Path=record_id}" Width="90"/>
+                <DataGridTextColumn Header="病例姓名" Binding="{Binding Path=name}" Width="90"/>
+                <DataGridTextColumn Header="病例身份证号" Binding="{Binding Path=idNum}" Width="120"/>
+                <DataGridTextColumn Header="身高" Binding="{Binding Path=height}" Width="50"/>
+                <DataGridTextColumn Header="体重" Binding="{Binding Path=weight}" Width="50"/>
+                <DataGridTextColumn Header="心率" Binding="{Binding Path=base_heartrate}" Width="50"/>
+                <DataGridTextColumn Header="受孕日期" Binding="{Binding Path=pregnancy_date}" Width="80"/>
+                <DataGridTextColumn Header="孕次" Binding="{Binding Path=birth_times}" Width="50"/>
+                <DataGridTextColumn Header="产次" Binding="{Binding Path=pregnancy_times}" Width="50"/>
+                <DataGridTextColumn Header="描述信息" Binding="{Binding Path=description}" Width="70"/>
+                <DataGridTextColumn Header="最近测量时间" Binding="{Binding Path=lastRecordDate}" Width="110"/>
+                <DataGridTextColumn Header="分类" Binding="{Binding Path=category}" Width="75"/>
+                <DataGridTextColumn Header="用户组" Binding="{Binding Path=group_1}" Width="75"/>
+                <!-- -->
+            </DataGrid.Columns>
+        </DataGrid>
+        <Label x:Name="label" Content="姓名:" HorizontalAlignment="Left" Margin="23,18,0,0" VerticalAlignment="Top"/>
+        <TextBox x:Name="textBoxName" HorizontalAlignment="Left" Height="23" Margin="89,18,0,0" TextWrapping="Wrap"  Text="姓名或者拼音首字母" VerticalAlignment="Top" Width="127" GotFocus="textBoxName_GotFocus" PreviewMouseDown="textBoxName_PreviewMouseDown" LostFocus="textBoxName_LostFocus"/>
+        <Label x:Name="label_Copy" Content="身份证号:" HorizontalAlignment="Left" Margin="23,50,0,0" VerticalAlignment="Top"/>
+        <TextBox x:Name="textBoxIDNumber" HorizontalAlignment="Left" Height="23" Margin="89,49,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="173"/>
+        <Label x:Name="label_Copy1" Content="病例编号:" HorizontalAlignment="Left" Margin="23,81,0,0" VerticalAlignment="Top"/>
+        <TextBox x:Name="textBoxCaseID" HorizontalAlignment="Left" Height="23" Margin="89,80,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="173"/>
+        <Label x:Name="label_Copy2" Content="孕次:" HorizontalAlignment="Left" Margin="23,112,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="label_Copy3" Content="产次:" HorizontalAlignment="Left" Margin="23,142,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="label_Copy4" Content="受孕时间:" HorizontalAlignment="Left" Margin="23,180,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="label_Copy5" Content="身高:" HorizontalAlignment="Left" Margin="23,312,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="label_Copy6" Content="体重:" HorizontalAlignment="Left" Margin="23,342,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.471,1.027"/>
+        <Label x:Name="label_Copy7" Content="静息心率:" HorizontalAlignment="Left" Margin="23,372,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="label_Copy8" Content="至" HorizontalAlignment="Left" Margin="166,371,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.732,-0.253"/>
+        <Label x:Name="label_Copy9" Content="至" HorizontalAlignment="Left" Margin="166,341,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.409,0.48"/>
+        <Label x:Name="label_Copy10" Content="至" HorizontalAlignment="Left" Margin="166,312,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.545,0.44"/>
+        <TextBox x:Name="textBoxPregnancyTime" HorizontalAlignment="Left" Height="23" Margin="89,111,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="173"/>
+        <TextBox x:Name="textBoxProductionTime" HorizontalAlignment="Left" Height="23" Margin="89,142,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="173"/>
+        <Label x:Name="label_Copy11" Content="至" HorizontalAlignment="Left" Margin="66,213,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.732,-0.253"/>
+        <TextBox x:Name="textBoxHeightStart" HorizontalAlignment="Left" Height="25" Margin="94,309,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="59"/>
+        <TextBox x:Name="textBoxHeightEnd" HorizontalAlignment="Left" Height="25" Margin="202,309,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="60"/>
+        <TextBox x:Name="textBoxWeightStart" HorizontalAlignment="Left" Height="25" Margin="93,340,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="60"/>
+        <TextBox x:Name="textBoxWeightEnd" HorizontalAlignment="Left" Height="24" Margin="202,340,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="60"/>
+        <TextBox x:Name="textBoxHeartRateStart" HorizontalAlignment="Left" Height="25" Margin="93,371,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="59"/>
+        <TextBox x:Name="textBoxHeartRateEnd" HorizontalAlignment="Left" Height="23" Margin="202,370,0,0" TextWrapping="Wrap"  Text="" VerticalAlignment="Top" Width="60"/>
+        <Button x:Name="buttonQuery" Content="筛选" HorizontalAlignment="Left" Margin="148,469,0,0" VerticalAlignment="Top" Width="114" Height="37" FontSize="18" Background="#FF54BD4A" Click="buttonQuery_Click" RenderTransformOrigin="0.5,0.514"/>
+        <Button x:Name="buttonQueryCopy2" Content="筛选" HorizontalAlignment="Left" Margin="216,17,0,0" VerticalAlignment="Top" Width="46" Height="26" FontSize="10" Click="buttonQuery_Click" RenderTransformOrigin="0.5,0.541"/>
+
+        <Button x:Name="buttonReset" Content="重置" HorizontalAlignment="Left" Margin="23,469,0,0" VerticalAlignment="Top" Width="107" Height="37" FontSize="18" Click="buttonReset_Click"/>
+        <DatePicker x:Name="datePickerTimeStart" SelectedDateFormat="Short" FirstDayOfWeek="Monday" IsTodayHighlighted="True" Margin="93,179,1038,395">
+        </DatePicker>
+        <DatePicker x:Name="datePickerTimeEnd" SelectedDateFormat="Short" FirstDayOfWeek="Monday"  IsTodayHighlighted="True" Margin="93,213,1038,361">
+        </DatePicker>
+        <DatePicker x:Name="datePickerBirthTimeStart" SelectedDateFormat="Short" FirstDayOfWeek="Monday" IsTodayHighlighted="True" Margin="93,244,1038,330">
+        </DatePicker>
+        <DatePicker x:Name="datePickerBirthTimeEnd" SelectedDateFormat="Short" FirstDayOfWeek="Monday"  IsTodayHighlighted="True" Margin="93,275,1038,299">
+        </DatePicker>
+        <Label x:Name="label_Copy12" Content="出生日期:" HorizontalAlignment="Left" Margin="23,245,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="label_Copy13" Content="至" HorizontalAlignment="Left" Margin="66,276,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.732,-0.253"/>
+        <Label x:Name="label_Copy14" Content="分类:" HorizontalAlignment="Left" Margin="23,404,0,0" VerticalAlignment="Top"/>
+        <Label x:Name="label_Copy15" Content="用户组:" HorizontalAlignment="Left" Margin="23,438,0,0" VerticalAlignment="Top"/>
+        <ComboBox x:Name="comboBoxCategory" HorizontalAlignment="Left" Margin="93,403,0,0" VerticalAlignment="Top" Width="169" Height="17"/>
+        <ComboBox x:Name="comboBoxGroup_1" HorizontalAlignment="Left" Margin="93,438,0,0" VerticalAlignment="Top" Width="169" Height="17"/>
+
+    </Grid>
+
+</UserControl>

+ 368 - 0
WpfTest1/selectUser.xaml.cs

@@ -0,0 +1,368 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SQLite;
+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>
+    /// selectUser.xaml 的交互逻辑
+    /// </summary>
+    public partial class selectUser : UserControl
+    {
+        DataSet ds;
+        //SQLiteCommandBuilder cmdb;
+        SQLiteDataAdapter da;
+        //DataRow dr;
+        MainWindow father;
+
+
+        public selectUser()
+        {
+            InitializeComponent();
+            SQLiteLogic.createDBAndTables();
+            //dataGrid.LoadingRow += new EventHandler<DataGridRowEventArgs>(dataGrid_LoadingRow);
+        }
+        public selectUser(MainWindow father)
+        {
+            InitializeComponent();
+            SQLiteLogic.createDBAndTables();
+            this.father = father;
+            //dataGrid.LoadingRow += new EventHandler<DataGridRowEventArgs>(dataGrid_LoadingRow);
+        }
+
+        public void setMainWindow(MainWindow father)
+        {
+            this.father = father;
+        }
+
+        public void dataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
+        {
+            e.Row.Header = e.Row.GetIndex() + 1;
+        }
+        //筛选得到符合条件的用户数据
+        private void dataGrid_Loaded(object sender, RoutedEventArgs e)
+        {
+            LoadDataGrid();
+        }
+        public void LoadDataGrid()
+        {
+            //连接字符串
+            string Connstr = "Data Source=" + System.Environment.CurrentDirectory + "\\Junde.db3"; ;
+            //连接对象
+            SQLiteConnection con = new SQLiteConnection(Connstr);
+            //Sql语句
+            string orderCondition = "lastRecordDate desc";
+            if (this.Name == "selectUserMeasure")
+            {
+                orderCondition = "id desc";
+            }
+            if (this.Name == "selectUserPatientManagent")
+            {
+                orderCondition = "id asc";
+            }
+            string selectCmd = "SELECT * FROM Patient WHERE delete_flag = 0 ORDER BY " + orderCondition + " LIMIT 100";
+            con.Open();
+            da = new SQLiteDataAdapter(selectCmd, con);
+            ds = new DataSet();
+            da.Fill(ds);
+            dataGrid.ItemsSource = ds.Tables[0].DefaultView;
+
+            //之后为筛选用户组和分类进行枚举
+            comboBoxCategory.Items.Clear();
+            comboBoxGroup_1.Items.Clear();
+            List<string> category = SQLiteModel.getCategory("category");
+            foreach(string one_item in category)
+            {
+                comboBoxCategory.Items.Add(one_item);
+            }
+            List<string> group_1 = SQLiteModel.getCategory("group_1");
+            foreach (string one_item in group_1)
+            {
+                comboBoxGroup_1.Items.Add(one_item);
+            }
+            con.Close();
+        }
+
+        //点击重置的效果
+        private void buttonReset_Click(object sender, RoutedEventArgs e)
+        {
+            textBoxName.Text = "姓名或者拼音首字母";
+            textBoxIDNumber.Text = "";
+            textBoxCaseID.Text = "";
+            textBoxPregnancyTime.Text = "";
+            textBoxProductionTime.Text = "";
+            datePickerTimeStart.Text = "";
+            datePickerTimeEnd.Text = "";
+            //textBoxTimeStart.Text = "";
+            //textBoxTimeEnd.Text = "";
+            textBoxHeightStart.Text = "";
+            textBoxHeightEnd.Text = "";
+            textBoxWeightStart.Text = "";
+            textBoxWeightEnd.Text = "";
+            textBoxHeartRateStart.Text = "";
+            textBoxHeartRateEnd.Text = "";
+            comboBoxCategory.SelectedIndex = -1;
+            comboBoxGroup_1.SelectedIndex = -1;
+            LoadDataGrid();
+        }
+
+        private void textBoxName_GotFocus(object sender, RoutedEventArgs e)
+        {
+            if (sender != null)
+            {
+                TextBox tbx = sender as TextBox;
+                tbx.SelectAll();
+                tbx.PreviewMouseDown -= new MouseButtonEventHandler(textBoxName_PreviewMouseDown);
+
+            }
+        }
+
+        private void textBoxName_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+        {
+            TextBox tb = sender as TextBox;
+            if (tb != null)
+            {
+                tb.Focus();
+                e.Handled = true;
+            }
+        }
+
+        private void textBoxName_LostFocus(object sender, RoutedEventArgs e)
+        {
+            TextBox tb = sender as TextBox;
+            if (tb != null)
+            {
+                tb.PreviewMouseDown += new MouseButtonEventHandler(textBoxName_PreviewMouseDown);
+            }
+        }
+
+        //点击筛选用户
+        private void buttonQuery_Click(object sender, RoutedEventArgs e)
+        {
+            List<string> condition_list = new List<string>();
+
+            //姓名或拼音
+            string name_or_py = textBoxName.Text;
+            if (name_or_py != "姓名或者拼音首字母" && name_or_py != "")
+            {
+                condition_list.Add(" and (name LIKE \'%"+ name_or_py +"%\' or firstLetterPY LIKE \'%"+ name_or_py +"%\') ");
+            }
+
+            //身份证号
+            if (textBoxIDNumber.Text != "")
+            {
+                condition_list.Add("  and idNum = '" + textBoxIDNumber.Text + "' ");
+            }
+
+            //病例编号
+            if(textBoxCaseID.Text != "")
+            {
+                condition_list.Add("  and record_id = '" + textBoxCaseID.Text + "' ");
+            }
+
+            //孕次
+            if (textBoxPregnancyTime.Text != "")
+            {
+                string pt_temp = "";
+                try
+                {
+                    pt_temp = Convert.ToString(Convert.ToInt32(textBoxPregnancyTime.Text));
+                }
+                catch(Exception err)
+                {
+                    MessageBox.Show("孕次信息格式不正确,请填写一个整数数字。\r\n调试信息:"+err.Message,"警告");
+                    return;
+                }
+                condition_list.Add("  and pregnancy_times = " + pt_temp + " ");
+            }
+
+            //产次
+            if (textBoxProductionTime.Text != "")
+            {
+                string bt_temp = "";
+                try
+                {
+                    bt_temp = Convert.ToString(Convert.ToInt32(textBoxProductionTime.Text));
+                }
+                catch (Exception err)
+                {
+                    MessageBox.Show("产次信息格式不正确,请填写一个整数数字。\r\n调试信息:" + err.Message, "警告");
+                    return;
+                }
+                condition_list.Add("  and birth_times = " + bt_temp + " ");
+            }
+
+            //怀孕日期
+            if(datePickerTimeStart.Text != "" && datePickerTimeEnd.Text != "")
+            {
+
+
+                DateTime dt;
+                System.Globalization.DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();
+                //MessageBox.Show(pregnancydate);
+                dtFormat.ShortDatePattern = "yyyy/M/d";
+                string dateStart = datePickerTimeStart.Text;
+                string dateEnd = datePickerTimeEnd.Text;
+                try
+                {
+                    dt = Convert.ToDateTime(dateStart, dtFormat);
+                    dateStart = dt.ToString("yyyy-MM-dd");
+                    dt = Convert.ToDateTime(dateEnd, dtFormat);
+                    dateEnd = dt.ToString("yyyy-MM-dd");
+                }
+                catch (Exception err)
+                {
+                    MessageBox.Show("推测怀孕日期格式不正确,请通过栏中日历的按钮选择日期。\r\n调试信息:" + err.Message, "警告");
+                    return;
+                }
+                condition_list.Add("  and (pregnancy_date between '" + dateStart + "' and '" + dateEnd + "') ");
+
+            }
+
+            //出生日期
+            if (datePickerBirthTimeStart.Text != "" && datePickerBirthTimeEnd.Text != "")
+            {
+
+                DateTime dt;
+                System.Globalization.DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();
+                //MessageBox.Show(pregnancydate);
+                dtFormat.ShortDatePattern = "yyyy/M/d";
+                string dateStart = datePickerBirthTimeStart.Text;
+                string dateEnd = datePickerBirthTimeEnd.Text;
+                try
+                {
+                    dt = Convert.ToDateTime(dateStart, dtFormat);
+                    dateStart = dt.ToString("yyyy-MM-dd");
+                    dt = Convert.ToDateTime(dateEnd, dtFormat);
+                    dateEnd = dt.ToString("yyyy-MM-dd");
+                }
+                catch (Exception err)
+                {
+                    MessageBox.Show("孕妇出生日期格式不正确,请通过栏中日历的按钮选择日期。\r\n调试信息:" + err.Message, "警告");
+                    return;
+                }
+                condition_list.Add("  and (birth_date between '" + dateStart + "' and '" + dateEnd + "') ");
+
+            }
+
+            //身高条件
+            if (textBoxHeightStart.Text != "" && textBoxHeightEnd.Text != "")
+            {
+                string hs_temp = "";
+                string he_temp = "";
+                try
+                {
+                    hs_temp = Convert.ToString(Convert.ToDouble(textBoxHeightStart.Text));
+                    he_temp = Convert.ToString(Convert.ToDouble(textBoxHeightEnd.Text));
+                }
+                catch (Exception err)
+                {
+                    MessageBox.Show("身高信息格式不正确,请填写一个整数数字。\r\n调试信息:" + err.Message, "警告");
+                    return;
+                }
+                condition_list.Add("  and (height between " + hs_temp + " and "+ he_temp + ") ");
+            }
+
+            //体重条件
+            if (textBoxWeightStart.Text != "" && textBoxWeightEnd.Text != "")
+            {
+                string ws_temp = "";
+                string we_temp = "";
+                try
+                {
+                    ws_temp = Convert.ToString(Convert.ToInt32(textBoxWeightStart.Text));
+                    we_temp = Convert.ToString(Convert.ToInt32(textBoxWeightEnd.Text));
+                }
+                catch (Exception err)
+                {
+                    MessageBox.Show("体重信息格式不正确,请填写一个整数数字。\r\n调试信息:" + err.Message, "警告");
+                    return;
+                }
+                condition_list.Add("  and (weight between " + ws_temp + " and " + we_temp + ") ");
+            }
+
+            //基础心率条件
+            if (textBoxHeartRateStart.Text != "" && textBoxHeartRateEnd.Text != "")
+            {
+                string bhs_temp = "";
+                string bhe_temp = "";
+                try
+                {
+                    bhs_temp = Convert.ToString(Convert.ToInt32(textBoxHeartRateStart.Text));
+                    bhe_temp = Convert.ToString(Convert.ToInt32(textBoxHeartRateEnd.Text));
+                }
+                catch (Exception err)
+                {
+                    MessageBox.Show("基础心率信息格式不正确,请填写一个整数数字。\r\n调试信息:" + err.Message, "警告");
+                    return;
+                }
+                condition_list.Add("  and (base_heartrate between " + bhs_temp + " and " + bhe_temp + ") ");
+            }
+            //用户分类条件
+            if (comboBoxCategory.SelectedIndex > -1)
+            {
+                condition_list.Add("  and category = '" + comboBoxCategory.SelectedValue + "' ");
+            }
+            //用户组条件
+            if (comboBoxGroup_1.SelectedIndex != -1)
+            {
+                condition_list.Add("  and group_1 = '" + comboBoxGroup_1.SelectedValue + "' ");
+            }
+
+            //连接字符串
+            string Connstr = "Data Source=" + System.Environment.CurrentDirectory + "\\Junde.db3"; ;
+            //连接对象
+            SQLiteConnection con = new SQLiteConnection(Connstr);
+            //Sql语句
+            string selectCmd = "SELECT * FROM Patient WHERE delete_flag = 0";
+            foreach(string one_more_condition in condition_list)
+            {
+                selectCmd += one_more_condition;
+            }
+            selectCmd += " ORDER BY lastRecordDate desc LIMIT 1000;";
+            con.Open();
+            da = new SQLiteDataAdapter(selectCmd, con);
+            ds = new DataSet();
+            da.Fill(ds);
+            dataGrid.ItemsSource = ds.Tables[0].DefaultView;
+            con.Close();
+        }
+
+        //双击某一行触发的事件
+        private void dataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            if (father != null)
+            {
+                if (this.Name == "selectUserMeasure")
+                {
+                    //father.buttonSelectPaitent_Click(this.father, e);
+                }
+                if (this.Name == "selectUserPatientManagent")
+                {
+                    father.buttonModifyPatient_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());
+                }
+            }
+        }
+    }
+}

+ 3 - 0
WpfTest1/测试用激活码_生产环境务必删除.txt

@@ -0,0 +1,3 @@
+测试用医疗机构
+fuckoff
+GlgKCFyKj1iZg7J1/scmKzuyHjK/DQ/Fg3IXJ5HnSuXQqc9zqmGXzH6epASa2XDI1chGvRET6VpC0aLxiafanTN+skSKFFfyM3qAilHqij08uxZxUt9MlQUsLBAJSvz039ORXs6zkZIYDk/8OnKTOGJoFhMsGAMiogskaea+4Dc=

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov