|
|
@ -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]; //读取表写入缓存
|
|
|
|
SQLiteHelpers.Close(); |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
{ |
|
|
|