private void btApply_Click(object sender, EventArgs e) { try { if(cbMode.SelectedIndex == 0) { comPort.DisplayData("("+DateTime.Now+")Sensor chuyen sang che do thuc ngu!", tbShow); comPort.WriteData(confixcmd); MessageBox.Show("Sent successful!", "Infomations"); } if(cbMode.SelectedIndex == 1) { if (cbPeriod.SelectedIndex != -1) { comPort.DisplayData("(" + DateTime.Now + ")Dieu chinh thoi gian gui du lieu dinh ky!", tbShow); comPort.WriteData(confixcmd); MessageBox.Show("Sent successful!", "Infomations"); } else { MessageBox.Show("Not enough imformation","Error"); } } if (cbMode.SelectedIndex == 2) { if (cbtimecontrol.SelectedIndex != -1) { Database myDatabase = new Database(); int value = cbtimecontrol.SelectedIndex + 1; int a = myDatabase.setTimeActor(value); if(a == 1) MessageBox.Show("Save successful!", "Infomations"); comPort.Time_control = myDatabase.getTimeActor(); } else { MessageBox.Show("Not enough imformation", "Error"); } } if (cbMode.SelectedIndex == 3) { if (cbSmokeThresh.SelectedIndex != -1) { comPort.WriteData(confixcmd); comPort.DisplayData("(" + DateTime.Now + ")Thiet lap nong do nguong khoi", tbShow); MessageBox.Show("Sent successful", "Imformation"); } else { MessageBox.Show("Not enough imformation", "Error"); } } if (cbMode.SelectedIndex == 4) { if (cbalarm.SelectedIndex != -1) { Database myDatabase = new Database(); int value = (cbalarm.SelectedIndex + 1)*5; int a = myDatabase.setTimeAlarm(value); if (a == 1) MessageBox.Show("Save successful!", "Infomations"); comPort.Time_alarm = myDatabase.getTimeAlarm(); } else { MessageBox.Show("Not enough imformation", "Error"); } } } catch { } }