读写逻辑修改

This commit is contained in:
sc committed 2025-08-24 13:46:51 +08:00
commit c32e34df73
3 files changed
+29 -2

No files matched your search

+10 -1
View File
@@ -198,6 +198,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
Product_.Add("Amount", newRow.Field<object>("Amount")); Product_.Add("Amount", newRow.Field<object>("Amount"));
Product_.Add("DispenseEndTime", newRow.Field<object>("DispenseEndTime")); Product_.Add("DispenseEndTime", newRow.Field<object>("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 MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = Convert.ToInt16(MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, 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++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
}//呼叫领料单 }//获取呼叫领料单
else if (SYSAPI == "SC830") else if (SYSAPI == "SC830")
{ {
try try
+18
View File
@@ -680,6 +680,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
return result; return result;
} }
/// <summary>
/// 将DataRow转换为Dictionary&lt;string, object&gt;
/// </summary>
/// <param name="row">DataRow实例</param>
/// <returns>键为列名、值为对应数据的字典</returns>
public Dictionary<string, object> ToDictionary(DataRow row)
{
var dictionary = new Dictionary<string, object>(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 #endregion
} }
+1 -1
View File
@@ -145,7 +145,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
conn_SC = new SqlConnection("server=" + SQLIP + ";database=" + SQLNAME + ";User ID=" + SQLUSER + ";Password=" + SQLPASWORD); conn_SC = new SqlConnection("server=" + SQLIP + ";database=" + SQLNAME + ";User ID=" + SQLUSER + ";Password=" + SQLPASWORD);
} }
await conn_SC.OpenAsync(); //连接数据库 await conn_SC.OpenAsync(); //连接数据库
//conn_SC.Close(); conn_SC.Close();
} }
catch (Exception ex) catch (Exception ex)
{ {