diff --git a/UserClass/AsyncTcpClient.cs b/UserClass/AsyncTcpClient.cs index c1502a5..69db75e 100644 --- a/UserClass/AsyncTcpClient.cs +++ b/UserClass/AsyncTcpClient.cs @@ -198,6 +198,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass Product_.Add("Amount", newRow.Field("Amount")); Product_.Add("DispenseEndTime", newRow.Field("DispenseEndTime")); + newRow.BeginEdit(); + newRow["State"] = 202; + newRow.EndEdit(); + + SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径 + SQLiteHelpers.Open(); //打开数据库 + SQLiteHelpers.InsertData("DyelotHistory", SQLiteHelpers.ToDictionary(newRow));// 执行插入 + SQLiteHelpers.Close(); + MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString { ID = Convert.ToInt16(MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, @@ -208,7 +217,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass } } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } - }//呼叫领料单 + }//获取呼叫领料单 else if (SYSAPI == "SC830") { try diff --git a/UserClass/SqliteHelper.cs b/UserClass/SqliteHelper.cs index 94b9f75..9ec6cfd 100644 --- a/UserClass/SqliteHelper.cs +++ b/UserClass/SqliteHelper.cs @@ -680,6 +680,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass return result; } + /// + /// 将DataRow转换为Dictionary<string, object> + /// + /// DataRow实例 + /// 键为列名、值为对应数据的字典 + public Dictionary ToDictionary(DataRow row) + { + var dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); + if (row == null) return dictionary; + + foreach (DataColumn column in row.Table.Columns) + { + object value = row[column] == DBNull.Value ? null : row[column]; + dictionary[column.ColumnName] = value; + } + return dictionary; + } + } #endregion } diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs index c7bc9f8..6ebcd1e 100644 --- a/ViewModel/MainWindowViewModel.cs +++ b/ViewModel/MainWindowViewModel.cs @@ -145,7 +145,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel conn_SC = new SqlConnection("server=" + SQLIP + ";database=" + SQLNAME + ";User ID=" + SQLUSER + ";Password=" + SQLPASWORD); } await conn_SC.OpenAsync(); //连接数据库 - //conn_SC.Close(); + conn_SC.Close(); } catch (Exception ex) {