Browse Source

读写逻辑修改

master
sc 2 months ago
parent
commit
c32e34df73
  1. 11
      UserClass/AsyncTcpClient.cs
  2. 18
      UserClass/SqliteHelper.cs
  3. 2
      ViewModel/MainWindowViewModel.cs

11
UserClass/AsyncTcpClient.cs

@ -198,6 +198,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
Product_.Add("Amount", newRow.Field<object>("Amount"));
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
{
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

18
UserClass/SqliteHelper.cs

@ -680,6 +680,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
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
}

2
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)
{

Loading…
Cancel
Save