Browse Source

第一次修改selectUser.xaml.cs,修改无效

xcbosa 3 years ago
parent
commit
baa5b432a9
2 changed files with 50 additions and 12 deletions
  1. 36 0
      WpfTest1/SQLite/SQLiteModel.cs
  2. 14 12
      WpfTest1/selectUser.xaml.cs

+ 36 - 0
WpfTest1/SQLite/SQLiteModel.cs

@@ -334,6 +334,42 @@ namespace WpfTest1.SQLite
             return false;
         }
 
+        //查找所有p_delete_flag为0的Patient
+        public static List<Patient> getAllNotLogicDeletePatient(string orderCondition)
+        {
+            string sql = "SELECT * FROM Patient WHERE p_delete_flag = 0 ORDER BY " + orderCondition + " LIMIT 100";
+            SQLiteHelper db = new SQLiteHelper(dbPath);
+            SQLiteParameter[] parameters = new SQLiteParameter[]{};
+
+            List<Patient> result = new List<Patient>();
+            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
+            {
+                while (reader.Read())
+                {
+                    Patient temp = new Patient();
+                    temp.p_id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
+                    temp.p_name = reader.IsDBNull(1) ? "" : reader.GetString(1);
+                    temp.p_name_py = reader.IsDBNull(2) ? "" : reader.GetString(2);
+                    temp.p_record_id = reader.IsDBNull(3) ? "" : reader.GetString(3);
+                    temp.p_gender = reader.IsDBNull(4) ? "" : reader.GetString(4);
+                    temp.p_birthdate = reader.IsDBNull(5) ? DateTime.MinValue : reader.GetDateTime(5);
+                    temp.p_height = reader.IsDBNull(6) ? 0 : reader.GetDouble(6);
+                    temp.p_weight = reader.IsDBNull(7) ? 0 : reader.GetDouble(7);
+                    temp.p_pregnancy_time = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
+                    temp.p_phone = reader.IsDBNull(9) ? "" : reader.GetString(9);
+                    temp.p_address = reader.IsDBNull(10) ? "" : reader.GetString(10);
+                    temp.p_history = reader.IsDBNull(11) ? "" : reader.GetString(11);
+                    temp.p_diagnosis = reader.IsDBNull(12) ? "" : reader.GetString(12);
+                    temp.doc_id = reader.IsDBNull(13) ? 0 : reader.GetInt32(13);
+                    temp.p_last_filter_time = reader.IsDBNull(14) ? DateTime.MinValue : reader.GetDateTime(14);
+                    temp.p_last_evaluation_time = reader.IsDBNull(15) ? DateTime.MinValue : reader.GetDateTime(15);
+                    temp.p_delete_flag = reader.IsDBNull(16) ? false : reader.GetBoolean(16); ;
+                    result.Add(temp);
+                }
+            }
+            return null;
+        }
+
         //通过id主键查找Patient
         public static Patient getPatientById(string id)
         {

+ 14 - 12
WpfTest1/selectUser.xaml.cs

@@ -60,11 +60,11 @@ namespace WpfTest1
         }
         public void LoadDataGrid()
         {
-            //连接字符串
-            string Connstr = "Data Source=" + System.Environment.CurrentDirectory + "\\Junde.db3"; ;
-            //连接对象
-            SQLiteConnection con = new SQLiteConnection(Connstr);
-            //Sql语句
+            ////连接字符串
+            //string Connstr = "Data Source=" + System.Environment.CurrentDirectory + "\\Junde.db3"; ;
+            ////连接对象
+            //SQLiteConnection con = new SQLiteConnection(Connstr);
+            ////Sql语句
             string orderCondition = "p_last_filter_time desc";
             if (this.Name == "selectUserPatientManagent")
             {
@@ -75,13 +75,15 @@ namespace WpfTest1
                 orderCondition = "p_last_filter_time desc";
             }
 
-            string selectCmd = "SELECT * FROM Patient WHERE p_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;
-            con.Close();
+            List<Patient> patientList = SQLiteModel.getAllNotLogicDeletePatient(orderCondition);
+            //string selectCmd = "SELECT * FROM Patient WHERE p_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;
+            dataGrid.ItemsSource = patientList;
+            //con.Close();
         }
 
         //点击重置的效果