This commit is contained in:
sc committed 2024-11-25 23:31:55 +08:00
commit 13a2c4ca63
2 files changed
+52 -15

No files matched your search

+20 -11
View File
@@ -65,26 +65,35 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
private void Save_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrEmpty(comboBoxMachine.Text))
{
{
Dictionary<string, object> dr_new = new Dictionary<string, object>();//缓存函数
dr_new.Add("Name", comboBoxMachine.Text);
dr_new.Add("Groups", TextMachineGroup.Text);
dr_new.Add("IP", IP.Text);
dr_new.Add("PORT", PORT.Text);
dr_new.Add("Serial", comboBoxCOM0.Text);
dr_new.Add("Baud", BAUD.Text);
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.InsertData("Machines", dr_new);
MainWindowViewModel.Machines = SQLiteHelpers.ExecuteDataSet("select * from Machines Order by id", null).Tables[0]; //读取表写入缓存
if (SQLiteHelpers.ExecuteDataSet("select * from Machines where name ='" + comboBoxMachine.Text + "'", null).Tables[0].Rows.Count == 0)
{
SQLiteHelpers.InsertData("Machines", dr_new);
}
else
{
SQLiteHelpers.Update("Machines",dr_new,"name='"+comboBoxMachine.Text+"'",null);
}
MainWindowViewModel.Machines = SQLiteHelpers.ExecuteDataSet("select * from Machines Order by id", null).Tables[0]; //读取表写入缓存
SQLiteHelpers.Close();
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
comboBoxMachine.Text = null;
TextMachineGroup.Text = null;
IP.Text = null;
PORT.Text = "7789";
comboBoxCOM0.Text = null;
BAUD.Text = "57600";
}
else
{